{"id":574,"date":"2012-11-12T15:39:12","date_gmt":"2012-11-12T15:39:12","guid":{"rendered":"http:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/?p=574"},"modified":"2012-11-12T15:41:08","modified_gmt":"2012-11-12T15:41:08","slug":"spinning-flowers","status":"publish","type":"post","link":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/2012\/11\/12\/spinning-flowers\/","title":{"rendered":"Nature? Spinning Flowers!"},"content":{"rendered":"<p>THIS DOESN&#8217;T SEEM TO DO SQUAT ONLINE. OH DEAR.<br \/>\nClick to make flowers!<\/p>\n<p><script type=\"application\/processing\">\r\n\/\/Info: http:\/\/processingjs.org\/reference\r\nboolean clicking = false;\r\nboolean rclicking = false;\r\nboolean go = false;\r\nFlower[] fs = new Flower[15];\r\nint numF = 0;\r\nint m = 0;\r\n\r\n\r\nvoid setup() {\r\n  size(1000, 800);\r\n}\r\n\r\n\r\nvoid draw() {\r\n  background(40, 60, 80);\r\n  \r\n  \r\n  if (mousePressed && (mouseButton == LEFT)) {\r\n    if (clicking == false && numF < fs.length){\r\n      \r\n      fs[numF] = new Flower(mouseX, mouseY, 370);\r\n      numF = numF + 1;\r\n      \r\n      clicking = true;\r\n    }\r\n  }\r\n  else clicking = false;\r\n\r\n  if (numF > 0) {\r\n    for (int j = 0; j < numF; j++) {\r\n       fs[j].update();\r\n    }\r\n  }\r\n  \r\n  m = millis();\r\n}\r\n\r\n\r\nclass Flower {\r\n  Petal[] ps = new Petal[50];\r\n  int numP = 1;\r\n  float startX = 0;\r\n  float startY = 0;\r\n  int pause;\r\n  int maxnum = 0;\r\n  int mD = 0;\r\n  \r\n  Flower(float newX, float newY, int newPause) {\r\n    startX = newX;\r\n    startY = newY;\r\n    pause = newPause;\r\n    \r\n  }\r\n  \r\n  void update() {\r\n    \r\n    if (ps[0] == null)\r\n    {\r\n      ps[0] = new Petal(startX, startY);\r\n    }\r\n    else {\r\n      mD += millis() - m;\r\n    }\r\n    \r\n    if (mD >= pause && ps[0].r <= 346) \r\n    {\r\n      ps[numP] = new Petal(startX, startY);\r\n      numP = numP + 1;\r\n      mD = 0;\r\n    }\r\n    if (numP > 0) {\r\n      for (int i = 0; i < numP; i++) {\r\n         ps[i].update();\r\n      }\r\n    }\r\n  }\r\n  \r\n}\r\n\r\nclass Petal {\r\n  float x = 0;\r\n  float y = 0;\r\n  int width = 80;\r\n  int height = 200;\r\n  int r = 0;\r\n  color c = color(random(50, 70), random(190, 210), random(120, 140), 70);\r\n  color c2 = c-100;\r\n  \r\n  Petal(float newX, float newY) {\r\n    x = newX;\r\n    y = newY;\r\n    ellipseMode(CORNER);\r\n    \r\n  }\r\n  \r\n  void update() {\r\n    fill(c);\r\n    stroke(c2);\r\n    pushMatrix();\r\n    translate(x-(width\/2),y);\r\n    rotate(radians(r));\r\n    ellipse(0, 0, width, height);\r\n    popMatrix();\r\n    \r\n    r++;\r\n    c2++;\r\n  }\r\n  \r\n}\r\n<\/script><\/p>\n<p>This one uses objects and rotation! Each petal and each flower is an object. This causes a pretty significant amount of lag. This turned out pretty cool though, because the more lag there is, the more petals appear on each flower!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>THIS DOESN&#8217;T SEEM TO DO SQUAT ONLINE. OH DEAR. Click to make flowers! This one uses objects and rotation! Each petal and each flower is an object. This causes a pretty significant amount of lag. This turned out pretty cool &hellip; <a href=\"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/2012\/11\/12\/spinning-flowers\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":11,"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\/574"}],"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\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/comments?post=574"}],"version-history":[{"count":3,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/574\/revisions"}],"predecessor-version":[{"id":577,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/574\/revisions\/577"}],"wp:attachment":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/media?parent=574"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/categories?post=574"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/tags?post=574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}