{"id":452,"date":"2012-11-12T02:29:44","date_gmt":"2012-11-12T02:29:44","guid":{"rendered":"http:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/?p=452"},"modified":"2012-11-12T02:29:44","modified_gmt":"2012-11-12T02:29:44","slug":"nature-vs-machines-night-light-3-nebulae","status":"publish","type":"post","link":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/2012\/11\/12\/nature-vs-machines-night-light-3-nebulae\/","title":{"rendered":"Nature vs Machines, Night &#038; Light 3: Nebulae"},"content":{"rendered":"<p>The third sketch in &#8220;Night &#038; Light&#8221; is Nebulae, is which creates a different starry sky with each mouse or key press. The color is randomized as well as the star field, so you get a different sky each time!<\/p>\n<p><script type=\"application\/processing\">\r\nint aSize = 500;\r\nint nSize = 200;\r\n\r\nint[] starX = new int[aSize];\r\nint[] starY = new int[aSize];\r\ncolor[] starC = new color[aSize];\r\n\r\nint[] nebX = new int[aSize];\r\nint[] nebY = new int[aSize];\r\ncolor[] nebC = new color[nSize];\r\n\r\nint col = int(random(100,255));\r\nint alph = int(random(255));\r\n\r\nint rcol = int(random(50,255));\r\nint gcol = int(random(100,255));\r\nint bcol = int(random(150,255));\r\nint nAlph = int(random(5,10));\r\n\r\nint rSize = int(random(50,100));\r\n\r\nvoid setup() {\r\n  size(600, 300);\r\n  for (int i = 0; i < aSize; i++) {\r\n    starX[i] = (int)random(width);\r\n    starY[i] = (int)random(height);\r\n    starC[i] = color(col,alph);\r\n  }\r\n  for (int i = 0; i < nSize; i++){\r\n    nebX[i] = (int)random(width);\r\n    nebY[i] = (int)random(height);\r\n    nebC[i] = color(rcol,gcol,bcol,nAlph);\r\n  }\r\n}\r\nvoid draw() {\r\n  background(0);\r\n  noStroke();\r\n  for (int i = 0; i < nSize; i++){\r\n    \r\n\r\n    fill(nebC[i]);\r\n    ellipse(nebX[i],nebY[i],rSize,rSize);\r\n  }\r\n  \r\n\r\n  for (int i = 0; i < aSize; i++) {\r\n   if (random(50) < 1) {\r\n   starC[i] = (int)random(100, 255);\r\n    }\r\n    \r\n    fill(starC[i]);\r\n    ellipse(starX[i], starY[i], 3, 3);\r\n  }\r\n}\r\n\r\nvoid mousePressed() {\r\ncol = int(random(100,255));\r\nalph = int(random(255));\r\n\r\nrcol = int(random(50,255));\r\ngcol = int(random(100,255));\r\nbcol = int(random(150,255));\r\nnAlph = int(random(5,10));\r\n\r\nrSize = int(random(50,100));\r\n\r\nfor (int i = 0; i < aSize; i++) {\r\n    starX[i] = (int)random(width);\r\n    starY[i] = (int)random(height);\r\n    starC[i] = color(col,alph);\r\n  }\r\n  for (int i = 0; i < nSize; i++){\r\n    nebX[i] = (int)random(width);\r\n    nebY[i] = (int)random(height);\r\n    nebC[i] = color(rcol,gcol,bcol,nAlph);\r\n  }\r\n}\r\n\r\nvoid keyPressed() {\r\ncol = int(random(100,255));\r\nalph = int(random(255));\r\n\r\nrcol = int(random(50,255));\r\ngcol = int(random(100,255));\r\nbcol = int(random(150,255));\r\nnAlph = int(random(5,10));\r\n\r\nrSize = int(random(50,100));\r\n\r\nfor (int i = 0; i < aSize; i++) {\r\n    starX[i] = (int)random(width);\r\n    starY[i] = (int)random(height);\r\n    starC[i] = color(col,alph);\r\n  }\r\n  for (int i = 0; i < nSize; i++){\r\n    nebX[i] = (int)random(width);\r\n    nebY[i] = (int)random(height);\r\n    nebC[i] = color(rcol,gcol,bcol,nAlph);\r\n  }\r\n}\r\n\r\n\r\n\r\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The third sketch in &#8220;Night &#038; Light&#8221; is Nebulae, is which creates a different starry sky with each mouse or key press. The color is randomized as well as the star field, so you get a different sky each time!<\/p>\n","protected":false},"author":10,"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\/452"}],"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\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/comments?post=452"}],"version-history":[{"count":1,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/452\/revisions"}],"predecessor-version":[{"id":455,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/452\/revisions\/455"}],"wp:attachment":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/media?parent=452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/categories?post=452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/tags?post=452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}