{"id":550,"date":"2012-11-12T15:36:21","date_gmt":"2012-11-12T15:36:21","guid":{"rendered":"http:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/?p=550"},"modified":"2012-11-16T02:15:59","modified_gmt":"2012-11-16T02:15:59","slug":"naturemachine-project-3","status":"publish","type":"post","link":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/2012\/11\/12\/naturemachine-project-3\/","title":{"rendered":"Nature\/Machine Project 3"},"content":{"rendered":"<p>My last project extended the rain idea. I made an interactive raincloud that rains and creates thunderbolts.<br \/>\nThe &#8216;rain&#8217; positions are stored in an array, and it draws lines from those stored positions to make the rain.<br \/>\nI think it&#8217;s a cute animation, and I want to put some finishing touches on it later.<\/p>\n<p>the noise function doesn&#8217;t seem to work on the blog for the way I have it set up, so here is the code.<\/p>\n<p>static int arrMax = 320;<br \/>\nint[] positions1 = new int[arrMax];<br \/>\nint[] positions2 = new int[arrMax];<br \/>\nint index=1;<br \/>\nint trueDex=0;<\/p>\n<p>void setup(){<br \/>\n  size(500,500);<br \/>\n  smooth();<br \/>\n}<\/p>\n<p>void draw(){<br \/>\n  int i=1;<br \/>\n  int x, y;<br \/>\n  background(150,180,250);<br \/>\n  fill(120,120,120);<br \/>\n  ellipseMode(CENTER);<br \/>\n  noStroke();<br \/>\n  triangle(mouseX-25,mouseY+15,mouseX+30,mouseY+15,mouseX,mouseY-10);<br \/>\n  ellipse(mouseX+21,mouseY-5,40,40);<br \/>\n  ellipse(mouseX-18,mouseY,30,30);<br \/>\n  ellipse(mouseX-12,mouseY-23,40,40);<br \/>\n  ellipse(mouseX+6,mouseY-20,35,35);<br \/>\n  ellipse(mouseX+10,mouseY+14,30,5);<br \/>\n  ellipse(mouseX-9,mouseY+14,30,5);<br \/>\n  if(frameCount%1==0){<br \/>\n    x = positions1[index-1] = mouseX + 35 &#8211; int(noise(index)*70);<br \/>\n    y = positions1[index] = mouseY + 16;<br \/>\n    positions2[index-1] = x + 20;<br \/>\n    positions2[index] = y + 30;<br \/>\n    index=(index+2)%arrMax;<br \/>\n    if(trueDex<arrMax-1)\n      trueDex+=2;\n  }\n  if(frameCount%150==0){\n    strokeWeight(4);\n    stroke(200,200,100);\n    line(mouseX+30-random(60),mouseY+10,x = mouseX+20-int(random(40)),y = mouseY+60-int(random(20)));\n    line(x,y,x+10-random(40),y+60-random(20));\n    line(x,y,x = x+30-int(random(20)),y = y+40-int(random(20)));\n    line(x,y,x+30-random(40),y+70-random(30));\n  }\n  for(i=1;i<trueDex;i+=2){\n    strokeWeight(2);\n    stroke(70,70,255,100);\n    line(positions1[i-1],positions1[i],positions2[i-1],positions2[i]);\n    positions1[i-1] += 2;\n    positions1[i] += 3;\n    positions2[i-1] += 2;\n    positions2[i] += 3;\n  }\n  if(frameCount%150==2)\n    background(255,255,255,100);\n}\n\n\n<script type=\"application\/processing\">\r\nstatic int arrMax = 320;\r\nint[] positions1 = new int[arrMax];\r\nint[] positions2 = new int[arrMax];\r\nint index=1;\r\nint trueDex=0;\r\n\r\nvoid setup(){\r\n  size(500,500);\r\n  smooth();\r\n}\r\n\r\nvoid draw(){\r\n  int i=1;\r\n  int x, y;\r\n  background(150,180,250);\r\n  fill(120,120,120);\r\n  ellipseMode(CENTER);\r\n  noStroke();\r\n  triangle(mouseX-25,mouseY+15,mouseX+30,mouseY+15,mouseX,mouseY-10);\r\n  ellipse(mouseX+21,mouseY-5,40,40);\r\n  ellipse(mouseX-18,mouseY,30,30);\r\n  ellipse(mouseX-12,mouseY-23,40,40);\r\n  ellipse(mouseX+6,mouseY-20,35,35);\r\n  ellipse(mouseX+10,mouseY+14,30,5);\r\n  ellipse(mouseX-9,mouseY+14,30,5);\r\n  if(frameCount%1==0){\r\n    x = positions1[index-1] = mouseX + 35 - int(noise(index)*70);\r\n    y = positions1[index] = mouseY + 16;\r\n    positions2[index-1] = x + 20;\r\n    positions2[index] = y + 30;\r\n    index=(index+2)%arrMax;\r\n    if(trueDex<arrMax-1)\r\n      trueDex+=2;\r\n  }\r\n  if(frameCount%150==0){\r\n    strokeWeight(4);\r\n    stroke(200,200,100);\r\n    line(mouseX+30-random(60),mouseY+10,x = mouseX+20-int(random(40)),y = mouseY+60-int(random(20)));\r\n    line(x,y,x+10-random(40),y+60-random(20));\r\n    line(x,y,x = x+30-int(random(20)),y = y+40-int(random(20)));\r\n    line(x,y,x+30-random(40),y+70-random(30));\r\n  }\r\n  for(i=1;i<trueDex;i+=2){\r\n    strokeWeight(2);\r\n    stroke(70,70,255,100);\r\n    line(positions1[i-1],positions1[i],positions2[i-1],positions2[i]);\r\n    positions1[i-1] += 2;\r\n    positions1[i] += 3;\r\n    positions2[i-1] += 2;\r\n    positions2[i] += 3;\r\n  }\r\n  if(frameCount%150==2)\r\n    background(255,255,255,100);\r\n}\r\n\r\n<\/script>\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My last project extended the rain idea. I made an interactive raincloud that rains and creates thunderbolts. The &#8216;rain&#8217; positions are stored in an array, and it draws lines from those stored positions to make the rain. I think it&#8217;s &hellip; <a href=\"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/2012\/11\/12\/naturemachine-project-3\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":9,"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\/550"}],"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\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/comments?post=550"}],"version-history":[{"count":4,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/550\/revisions"}],"predecessor-version":[{"id":695,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/550\/revisions\/695"}],"wp:attachment":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/media?parent=550"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/categories?post=550"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/tags?post=550"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}