{"id":196,"date":"2015-06-18T06:02:30","date_gmt":"2015-06-18T02:02:30","guid":{"rendered":"http:\/\/courses.haigarmen.com\/creativecoding\/?p=196"},"modified":"2015-06-18T06:02:30","modified_gmt":"2015-06-18T02:02:30","slug":"exercise-39","status":"publish","type":"post","link":"https:\/\/courses.haigarmen.com\/creativecoding\/exercise-39\/","title":{"rendered":"Exercise 39"},"content":{"rendered":"<pre><code>\r\n\r\n\/\/ global vars\r\n\r\nint _num = 10;    \r\nfloat _angnoise, _radiusnoise;\r\nfloat _xnoise, _ynoise;\r\nfloat _angle = -PI\/2;\r\nfloat _radius = 100;\r\nfloat _strokeCol = 254;\r\nint _strokeChange = -1;\r\n\r\nvoid setup() {\r\n  size(500, 300);\r\n  smooth(); \r\n  frameRate(30);\r\n  \r\n  clearBackground();\r\n  \r\n  _angnoise = random(10);\r\n  _radiusnoise = random(10);\r\n  _xnoise = random(10);\r\n  _ynoise = random(10);\r\n}\r\n\r\nvoid clearBackground() {\r\n  background(255);\r\n}\r\n\r\nvoid draw() {\r\n  \r\n  _radiusnoise += 0.005;\r\n  _radius = (noise(_radiusnoise) * 550) +1;\r\n  \r\n  _angnoise += 0.005;\r\n  _angle += (noise(_angnoise) * 6) - 3;\r\n  if (_angle > 360) { _angle -= 360; }\r\n  if (_angle < 0) { _angle += 360; }\r\n  \r\n  \/\/ wobble centre\r\n  _xnoise += 0.01;\r\n  _ynoise += 0.01;\r\n  float centreX = width\/2 + (noise(_xnoise) * 100) - 50;\r\n  float centreY = height\/2 + (noise(_ynoise) * 100) - 50;\r\n  \r\n  float rad = radians(_angle);\r\n  float x1 = centreX + (_radius * cos(rad));\r\n  float y1 = centreY + (_radius * sin(rad));\r\n  \r\n  \/\/ opposite end of line\r\n  float opprad = rad + PI;\r\n  float x2 = centreX + (_radius * cos(opprad));\r\n  float y2 = centreY + (_radius * sin(opprad)); \r\n  \r\n  noFill();\r\n  _strokeCol += _strokeChange;\r\n  if (_strokeCol > 254) { _strokeChange *= -1; }\r\n  if (_strokeCol < 0) { _strokeChange *= -1; }\r\n  stroke(_strokeCol, 60);\r\n  strokeWeight(1);\r\n  line(x1, y1, x2, y2);\r\n}\r\n\r\nvoid keyPressed() {\r\n  if (keyCode == s) {\r\n    saveFrame(\"waveclock-####.tif\");\r\n  }\r\n}\r\n\r\nvoid mousePressed() {\r\n  clearBackground();\r\n}\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/\/ global vars int _num = 10; float _angnoise, _radiusnoise; float _xnoise, _ynoise; float _angle = -PI\/2; float _radius = 100; float _strokeCol = 254; int _strokeChange = -1; void setup() { size(500, 300); smooth(); frameRate(30); clearBackground(); _angnoise = random(10); _radiusnoise = random(10); _xnoise = random(10); _ynoise = random(10); } void clearBackground() { background(255); } [&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-196","post","type-post","status-publish","format-standard","hentry","category-lessons"],"_links":{"self":[{"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/posts\/196","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=196"}],"version-history":[{"count":1,"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/posts\/196\/revisions"}],"predecessor-version":[{"id":197,"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/posts\/196\/revisions\/197"}],"wp:attachment":[{"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/media?parent=196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/categories?post=196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/tags?post=196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}