{"id":233,"date":"2015-06-22T13:30:47","date_gmt":"2015-06-22T09:30:47","guid":{"rendered":"http:\/\/courses.haigarmen.com\/creativecoding\/?p=233"},"modified":"2015-06-22T15:13:15","modified_gmt":"2015-06-22T11:13:15","slug":"exercise-50","status":"publish","type":"post","link":"https:\/\/courses.haigarmen.com\/creativecoding\/exercise-50\/","title":{"rendered":"Exercise 50"},"content":{"rendered":"<pre><code>\r\n\/*-------- Circle Pattern ----------------*\/\r\n\r\nint margin;\r\nint res = 4;\r\nint padding;\r\n \r\ncolor c [] = {\r\n  #75a665,\r\n  #5c801a,\r\n  #5a7e18,\r\n  #735742,\r\n  #afb837,\r\n  #564311,\r\n  #32320e\r\n};\r\n \r\nvoid setup ()\r\n{\r\n  size (700, 700);\r\n  smooth();\r\n  frameRate (10);\r\n  margin = width\/10;\r\n  padding = width \/30;\r\n}\r\n \r\nvoid draw ()\r\n{\r\n  background (237);\r\n  randomSeed (year() + day() + hour() + minute() + (second ()\/ 20 % 2));\r\n  noStroke();\r\n \r\n  int d = int ((width-2*margin-(res-1)*padding) \/(float) res);\r\n  int D = d;\r\n  for (int x = margin; x < width-margin; x+=d+padding)\r\n  {\r\n \r\n    for (int y = margin; y < width-margin; y+=d+padding)\r\n    {\r\n      D = d;\r\n      int [] cc = new int [3];\r\n      int i = 0;\r\n      while (i < cc.length)\r\n      {\r\n        int index = (int) random (c.length);\r\n        boolean taken = false;\r\n        for (int j = 0; j < i; j++)\r\n        {\r\n          if (cc[j] == index)\r\n          {\r\n            taken = true;\r\n            break;\r\n          }\r\n        }\r\n        if (!taken)\r\n        {\r\n          D = (int) random (D\/2, D);\r\n          fill (c[index]);\r\n          ellipse (x+d\/2, y+d\/2, D, D);\r\n          i++;\r\n        }\r\n      }\r\n    }\r\n  }\r\n}\r\n \r\nvoid mouseDragged ()\r\n{\r\n  if (mouseButton == LEFT)\r\n  {\r\n    margin = (int) map (mouseX, 0, width, 0, width\/3);\r\n    padding = (int) map (mouseY, 0, width, 0, height\/15);\r\n  }\r\n  else res = (int) map (mouseX, 0, width, 1, 50);\r\n}\r\n \r\nvoid keyPressed ()\r\n{\r\n  setup();\r\n}\r\n\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/*&#8212;&#8212;&#8211; Circle Pattern &#8212;&#8212;&#8212;&#8212;&#8212;-*\/ int margin; int res = 4; int padding; color c [] = { #75a665, #5c801a, #5a7e18, #735742, #afb837, #564311, #32320e }; void setup () { size (700, 700); smooth(); frameRate (10); margin = width\/10; padding = width \/30; } void draw () { background (237); randomSeed (year() + day() + hour() [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-233","post","type-post","status-publish","format-standard","hentry","category-lessons"],"_links":{"self":[{"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/posts\/233","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/comments?post=233"}],"version-history":[{"count":1,"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/posts\/233\/revisions"}],"predecessor-version":[{"id":234,"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/posts\/233\/revisions\/234"}],"wp:attachment":[{"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/media?parent=233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/categories?post=233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/tags?post=233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}