{"id":167,"date":"2015-06-18T04:13:56","date_gmt":"2015-06-18T00:13:56","guid":{"rendered":"http:\/\/courses.haigarmen.com\/creativecoding\/?p=167"},"modified":"2015-06-18T05:04:07","modified_gmt":"2015-06-18T01:04:07","slug":"exercise-32","status":"publish","type":"post","link":"https:\/\/courses.haigarmen.com\/creativecoding\/exercise-32\/","title":{"rendered":"Exercise 32"},"content":{"rendered":"<p>Instead of just telling Processing to draw a circle, let\u2019s instead create a circle object. The circle object will encapsulate everything there is to know about itself, which at the moment isn\u2019t much more than the x,y of its center point, and its radius.<\/p>\n<pre><code>\r\nclass Circle {\r\n  float x, y;\r\n  float radius;\r\n  color linecol, fillcol;\r\n  float alph;\r\n  Circle () {\r\n    x = random(width);\r\n    y = random(height);\r\n    radius = random(100) + 10;\r\n    linecol = color(random(255), random(255), random(255));\r\n    fillcol = color(random(255), random(255), random(255));\r\n    alph = random(255);\r\n  }\r\n}\r\n<\/code><\/pre>\n<p>Then we need to change our drawCircles function to this:<\/p>\n<pre><code>\r\nvoid drawCircles() {\r\n  for (int i=0; i<_num; i++) {\r\n    Circle thisCirc = new Circle();\r\n  }\r\n}\r\n<\/code><\/pre>\n<p>Still no circles been draw because we haven't put the draw function into the circle class:<\/p>\n<pre><code>\r\n\r\nclass Circle {\r\n  float x, y;\r\n  float radius;\r\n  color linecol, fillcol;\r\n  float alph;\r\n\r\n  Circle () {\r\n    x = random(width);\r\n    y = random(height);\r\n    radius = random(100) + 10;\r\n    linecol = color(random(255), random(255), random(255));\r\n    fillcol = color(random(255), random(255), random(255));\r\n    alph = random(255);\r\n  }\r\n  void drawMe() {\r\n    noStroke();\r\n    fill(fillcol, alph);\r\n    ellipse(x, y, radius*2, radius*2);\r\n    stroke(linecol, 150);\r\n    noFill();\r\n    ellipse(x, y, 10, 10);\r\n  }\r\n}\r\n<\/code><\/pre>\n<p>And finally we must update the drawCircles() function<\/p>\n<pre><code>\r\nvoid drawCircles() {\r\n  for (int i=0; i<_num; i++) {\r\n    Circle thisCirc = new Circle();\r\n    thisCirc.drawMe();\r\n  }\r\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Instead of just telling Processing to draw a circle, let\u2019s instead create a circle object. The circle object will encapsulate everything there is to know about itself, which at the moment isn\u2019t much more than the x,y of its center point, and its radius. class Circle { float x, y; float radius; color linecol, fillcol; [&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-167","post","type-post","status-publish","format-standard","hentry","category-lessons"],"_links":{"self":[{"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/posts\/167","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=167"}],"version-history":[{"count":7,"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/posts\/167\/revisions"}],"predecessor-version":[{"id":180,"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/posts\/167\/revisions\/180"}],"wp:attachment":[{"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/media?parent=167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/categories?post=167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/tags?post=167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}