{"id":583,"date":"2012-11-12T16:45:53","date_gmt":"2012-11-12T16:45:53","guid":{"rendered":"http:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/?p=583"},"modified":"2012-11-13T17:18:46","modified_gmt":"2012-11-13T17:18:46","slug":"nature-vs-machine-1-sunset-reflection","status":"publish","type":"post","link":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/2012\/11\/12\/nature-vs-machine-1-sunset-reflection\/","title":{"rendered":"Nature VS Machine #1 &#8211; Sunset Reflection"},"content":{"rendered":"<p>This processing sketch was designed to replicate a sunset. As the mouse moves downward the sun also moves, changing the sky color as it moves.<br \/>\nThe waves use various implementations of the noise function to animate there jittering and opacity.<br \/>\n<script type=\"application\/processing\">\r\n\/\/Info: http:\/\/processingjs.org\/reference\r\ncolor skyColor;\r\n\r\nfloat bStart = 0.0;\r\nfloat increment = 0.01;\r\nfloat bloomScale;\r\n\r\nReflection[] reflections = new Reflection[80];\r\n\r\nvoid setup() {\r\n  size(500, 500);\r\n  \r\n  for (int i=0;i<reflections.length;i++) {\r\n    reflections[i]=new Reflection();\r\n  }\r\n}\r\n\r\nvoid draw() {\r\n  noStroke();\r\n  rectMode(CORNER);\r\n\r\n  \/\/controls the size of sun bloom\r\n  bloomScale = noise(bStart)*330;\r\n  bStart += increment;\r\n\r\n\r\n  \/\/draws the sky\r\n  skyColor = color(470-mouseY*.9, 550-mouseY*1.5, 520-mouseY*.8);\r\n  background(skyColor);\r\n  \r\n  \r\n  \/\/draws pulsating sun bloom\r\n  fill(255, 255, 255, 40);\r\n  ellipse(width\/2, mouseY, bloomScale, bloomScale);  \r\n\r\n\r\n  \/\/draws the sun\r\n  fill(255, 250, 110, 200);\r\n  ellipse(250, mouseY, 140, 140);\r\n\r\n\r\n  \/\/draws the sea\r\n  \/\/fill((400-mouseY)\/5, (400-mouseY)\/3, 600-mouseY);\r\n  fill(20,45,150);\r\n  rect(0, 250, 500, 250);\r\n  \r\n  \r\n  \/\/draws reflections \r\n  for (int z=0;z<reflections.length;z++) {\r\n    reflections[z].drawReflection();\r\n  }\r\n}\r\n\r\n\/\/creates reflections\r\nclass Reflection {\r\n  float refY;\r\n  float refX;\r\n  float refJitter;\r\n  float refOpac;\r\n  \r\n  float jStart = random(-2, 2);\r\n  float jInc = .02;\r\n  float oStart = random(-2, 2);\r\n  float oInc = -.04;\r\n\r\n  Reflection() {\r\n    refY = random(250, 500);\r\n    refX = random(230-(refY\/10),270+(refY\/10));\r\n  }\r\n\r\n  void drawReflection() {\r\n    rectMode(CENTER);\r\n    \r\n    \/\/controls reflection jitter\r\n    refJitter = noise(jStart);    \r\n    \/\/sets opacity of individual lines\r\n    refOpac = noise(oStart);\r\n    \r\n    \r\n    \/\/draws rectangle\r\n    fill(skyColor, refOpac*(50000\/refY));\r\n    rect(refX, refY + refJitter*(900\/refY), refY\/4 + (refJitter*(refY\/3.5)), refJitter*(refY\/90));\r\n    \r\n    oStart += oInc;\r\n    jStart += jInc;\r\n  }\r\n}\r\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This processing sketch was designed to replicate a sunset. As the mouse moves downward the sun also moves, changing the sky color as it moves. The waves use various implementations of the noise function to animate there jittering and opacity.<\/p>\n","protected":false},"author":16,"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\/583"}],"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\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/comments?post=583"}],"version-history":[{"count":4,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/583\/revisions"}],"predecessor-version":[{"id":586,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/583\/revisions\/586"}],"wp:attachment":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/media?parent=583"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/categories?post=583"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/tags?post=583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}