{"id":1,"date":"2011-09-19T21:45:58","date_gmt":"2011-09-19T21:45:58","guid":{"rendered":"http:\/\/classes.visitsteve.com\/hacking\/?p=1"},"modified":"2011-09-20T19:35:02","modified_gmt":"2011-09-20T19:35:02","slug":"hello-world","status":"publish","type":"post","link":"https:\/\/classes.visitsteve.com\/hacking\/hello-world\/","title":{"rendered":"Using &#8220;Random&#8221; with Processing"},"content":{"rendered":"<p>Below is my very rough code to create messy, random dots. It&#8217;s bloated, and you could do a lot to &#8220;bum&#8221; this code.<\/p>\n<pre><code>\/\/ The statements in the setup() function \r\n\/\/ execute once when the program begins void setup() { size(600, 600); \r\n\/\/ Size should be the first statement stroke(255); \r\n\/\/ Set stroke color to white noLoop(); }\r\n\r\nfloat y = 300; \/\/ this is the midpoint of the 600px tall sketch\r\n\r\n\/\/ The statements in draw() are run until the \r\n\/\/ program is stopped. Each statement is run in \r\n\/\/ sequence and after the last line is read, the first \r\n\/\/ line is run again. \r\n\r\nvoid draw() { \r\n\/\/ background(125); \/\/ Set the background to black (I commented this out - Steve) \r\nfloat rando = random(-10,10); \/\/ choose a random number from -10 to 10 \r\nfloat randColorR = random(255); \/\/ Pick a value for RED from 0-255 \r\nfloat randColorG = random(255); \/\/ Pick a value for GREEN from 0-255 \r\nfloat randColorB = random(255); \/\/ Pick a value for BLUE from 0-255 \r\n\r\nnoStroke(); \r\nfill(randColorR,randColorG,randColorB,5); \r\n\r\n\/\/ fill in the RGB, and the last value is for opacity! Which I set to 5. \r\n\r\nellipse(width\/2+rando*4,y+30+rando*60,y-rando,y-rando); \r\n\/\/This is just some crazy math to make the ellipse all jittery and weird. Could be much more efficient.\r\n\/\/ and now it repeats \r\n\r\nfill(randColorR+randColorR-50,randColorG+randColorR-125,randColorB*randColorR,5); \r\nellipse(width\/4+rando*4,y+30+rando*60,y-rando,y-rando);\r\n\r\n\/\/ and now it repeats - again, this could MUCH more efficient. \r\nfill(randColorR+randColorR-50,randColorG+randColorR-125,randColorB-200,5); \r\nellipse(width\/1.25+rando*4,y+30+rando*60,y-rando,y-rando); \r\n\/\/ stroke(y,y\/2,y\/3); \r\n\/\/ background(y-100,y*2,Y*3); \r\n\/\/ line(10, y, width\/3, y);<\/code>\r\n\r\n y = y - 1;\r\n if (y &lt; 0) {\r\n y = height;\r\n }\r\n }\r\n\r\nvoid mousePressed()\r\n {\r\n loop();\r\n }<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Below is my very rough code to create messy, random dots. It&#8217;s bloated, and you could do a lot to &#8220;bum&#8221; this code. \/\/ The statements in the setup() function \/\/ execute once when the program begins void setup() { &hellip; <a href=\"https:\/\/classes.visitsteve.com\/hacking\/hello-world\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1","post","type-post","status-publish","format-standard","hentry","category-classnews"],"_links":{"self":[{"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/posts\/1","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"count":0,"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"wp:attachment":[{"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/tags?post=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}