{"id":33,"date":"2011-02-15T01:38:56","date_gmt":"2011-02-15T01:38:56","guid":{"rendered":"http:\/\/classes.visitsteve.com\/hacking\/?p=33"},"modified":"2011-02-15T01:38:56","modified_gmt":"2011-02-15T01:38:56","slug":"snowbot","status":"publish","type":"post","link":"https:\/\/classes.visitsteve.com\/hacking\/snowbot\/","title":{"rendered":"Snowbot"},"content":{"rendered":"<p><script type=\"application\/processing\">\r\n\/\/Info: http:\/\/processingjs.org\/reference\r\n\/\/ declare variables\r\n  \/\/colors\r\n  float r; \r\n  float g; \r\n  float b; \r\n  float a;\r\n  \r\n  \/\/construction\r\n  float circW = width\/2;\r\n  float circH = height; \r\n  float x;\r\n  float y;\r\n\r\nvoid setup() {\r\n  rectMode(CENTER);\r\n  size(400,400); \r\n  background(200); \r\n  smooth();\r\n  frameRate(30);\r\n\t}\r\nvoid draw() { \r\n\r\n\/\/ snow    \r\n    for (int i=0; i<400; i++) {\r\n    \r\n    noStroke();\r\n    \/\/ pick a random color\r\n    r = random(240,255);\r\n    g = random(240,255);\r\n    b = random(240,255);\r\n    a = random(20,255);\r\n    \r\n    circW = random(1,3);\r\n    circH = random(1,3);\r\n    x = random(width);\r\n    y = random(height);\r\n\r\n    \/\/ create a random colored line of random dimensions\r\n    fill(r,g,b,a);\r\n    ellipse(x,y,circW,circH);    \r\n    }\r\n    \r\n}\r\n\r\n\/\/ if the mouse is pressed, redraw the background\r\nvoid mousePressed() {\r\n      \/\/ body and arms\r\n  stroke(255);\r\n  fill(150); \/\/ make it grey\r\n  rect(mouseX,mouseY,50,30); \/\/body is 50x30\r\n  ellipse(mouseX-30,mouseY-5,10,10);\r\n  ellipse(mouseX+30,mouseY-5,10,10);\r\n\r\n\/\/ legs\r\n  rect(mouseX-10,mouseY+20,10,10);\r\n  rect(mouseX+10,mouseY+20,10,10);\r\n\r\n\r\n\/\/ head\r\n  rect(mouseX,mouseY-22.5,40,15); \/\/ head is 40x15\r\n\r\n\/\/ eyes\r\n  fill(255); \/\/ make the eyes white\r\n  ellipse(mouseX-9,mouseY-24.5,5,5);\r\n  ellipse(mouseX+9,mouseY-24.5,5,5);\r\n\r\n\/\/ mouth\r\n  rect(mouseX,mouseY-18.5,20,3);\r\n\r\n\r\n}\r\n<\/script><\/p>\n<h2>The Code<\/h2>\n<p><code><br \/>\n\/\/ declare variables<br \/>\n  \/\/colors<br \/>\n  float r;<br \/>\n  float g;<br \/>\n  float b;<br \/>\n  float a;<\/p>\n<p>  \/\/construction<br \/>\n  float circW = width\/2;<br \/>\n  float circH = height;<br \/>\n  float x;<br \/>\n  float y;<\/p>\n<p>void setup() {<br \/>\n  rectMode(CENTER);<br \/>\n  size(400,400);<br \/>\n  background(200);<br \/>\n  smooth();<br \/>\n  frameRate(30);<br \/>\n\t}<br \/>\nvoid draw() { <\/p>\n<p>\/\/ snow<br \/>\n    for (int i=0; i<400; i++) {\n    \n    noStroke();\n    \/\/ pick a random color\n    r = random(240,255);\n    g = random(240,255);\n    b = random(240,255);\n    a = random(20,255);\n    \n    circW = random(1,3);\n    circH = random(1,3);\n    x = random(width);\n    y = random(height);\n\n    \/\/ create a random colored line of random dimensions\n    fill(r,g,b,a);\n    ellipse(x,y,circW,circH);    \n    }\n    \n}\n\n\/\/ if the mouse is pressed, redraw the background\nvoid mousePressed() {\n      \/\/ body and arms\n  stroke(255);\n  fill(150); \/\/ make it grey\n  rect(mouseX,mouseY,50,30); \/\/body is 50x30\n  ellipse(mouseX-30,mouseY-5,10,10);\n  ellipse(mouseX+30,mouseY-5,10,10);\n\n\/\/ legs\n  rect(mouseX-10,mouseY+20,10,10);\n  rect(mouseX+10,mouseY+20,10,10);\n\n\n\/\/ head\n  rect(mouseX,mouseY-22.5,40,15); \/\/ head is 40x15\n\n\/\/ eyes\n  fill(255); \/\/ make the eyes white\n  ellipse(mouseX-9,mouseY-24.5,5,5);\n  ellipse(mouseX+9,mouseY-24.5,5,5);\n\n\/\/ mouth\n  rect(mouseX,mouseY-18.5,20,3);\n\n\n}\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Code \/\/ declare variables \/\/colors float r; float g; float b; float a; \/\/construction float circW = width\/2; float circH = height; float x; float y; void setup() { rectMode(CENTER); size(400,400); background(200); smooth(); frameRate(30); } void draw() { \/\/ &hellip; <a href=\"https:\/\/classes.visitsteve.com\/hacking\/snowbot\/\">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-33","post","type-post","status-publish","format-standard","hentry","category-classnews"],"_links":{"self":[{"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/posts\/33","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=33"}],"version-history":[{"count":0,"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/posts\/33\/revisions"}],"wp:attachment":[{"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/media?parent=33"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/categories?post=33"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/tags?post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}