{"id":615,"date":"2012-11-12T17:13:40","date_gmt":"2012-11-12T17:13:40","guid":{"rendered":"http:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/?p=615"},"modified":"2012-11-12T17:13:40","modified_gmt":"2012-11-12T17:13:40","slug":"abstract-falling-leaves","status":"publish","type":"post","link":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/2012\/11\/12\/abstract-falling-leaves\/","title":{"rendered":"Abstract Falling Leaves"},"content":{"rendered":"<p>click to generate falling leaves (well, okay, circles, not leaves).<br \/>\n<script type=\"application\/processing\">\r\n\/\/Info: http:\/\/processingjs.org\/reference\r\nfloat time = 0;\r\nfloat ticker = .01;\r\nint i;\r\nleaf[] leafBank = new leaf[1];\r\n\r\nvoid setup()\r\n{\r\n  size(600,350);\r\n  background(255);\r\n  i = 0;\r\n}\r\n\r\nvoid draw()\r\n{\r\n  background(255);\r\n  if(i!=0)\r\n  {\r\n  for(int n=0;n<leafBank.length;n++)\r\n  {\r\n  leafBank[n].moveLeaf();\r\n  leafBank[n].drawLeaf();\r\n  }\r\n  }\r\n  time = time + ticker;\r\n}\r\n\r\nvoid mouseReleased()\r\n{\r\n  if (i==0)\r\n  {\r\n    leafBank[0]= new leaf(mouseX,mouseY);\r\n    i++;\r\n  }\r\n  else\r\n  {\r\n    leafBank = (leaf[])append(leafBank, new leaf(mouseX+(random(50)-25),mouseY+(random(50)-25)));\r\n    leafBank = (leaf[])append(leafBank, new leaf(mouseX+(random(50)-25),mouseY+(random(50)-25)));\r\n    leafBank = (leaf[])append(leafBank, new leaf(mouseX+(random(50)-25),mouseY+(random(50)-25)));\r\n    leafBank = (leaf[])append(leafBank, new leaf(mouseX+(random(50)-25),mouseY+(random(50)-25)));\r\n    \r\n  }\r\n}\r\n  \r\n\r\nclass leaf\r\n{\r\n  float x;\r\n  float y;\r\n  float leafSize;\r\n  float falldistance;\r\n  float offset;\r\n  float R;\r\n  float R2;\r\n  float G;\r\n  float B;\r\n  \r\n  leaf(float tx, float ty)\r\n  {\r\n    x = tx;\r\n    y = ty;\r\n    leafSize= 20;\r\n    falldistance = random(5)\/10;\r\n    offset = random(100)\/100;\r\n    R = 140;\r\n    R2 = 140;\r\n    G = 222;\r\n    B = 16;\r\n  }\r\n  \r\n  void moveLeaf()\r\n  {\r\n    x = x+(2-(noise(time+offset)*4));\r\n    y = y+falldistance;\r\n    falldistance = falldistance*1.02;\r\n    \r\n    R2 = R2+1;\r\n    if(R2<225){R=R+1;}\r\n    else\r\n    {\r\n      R= R-0.1;\r\n      G= G-1;\r\n    }\r\n   \r\n  }\r\n  \r\n  void drawLeaf()\r\n  {\r\n    ellipseMode(CENTER);\r\n    fill(R,G,B);\r\n    stroke(R\/2,G\/2,B\/2);\r\n    ellipse(x,y,leafSize,leafSize);\r\n  }\r\n}\/\/end class: Leaf\r\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>click to generate falling leaves (well, okay, circles, not leaves).<\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/615"}],"collection":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/comments?post=615"}],"version-history":[{"count":2,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/615\/revisions"}],"predecessor-version":[{"id":617,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/615\/revisions\/617"}],"wp:attachment":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/media?parent=615"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/categories?post=615"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/tags?post=615"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}