{"id":247,"date":"2012-11-05T05:01:14","date_gmt":"2012-11-05T05:01:14","guid":{"rendered":"http:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/?p=247"},"modified":"2012-11-05T05:02:57","modified_gmt":"2012-11-05T05:02:57","slug":"box-cat-takes-to-the-skies","status":"publish","type":"post","link":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/2012\/11\/05\/box-cat-takes-to-the-skies\/","title":{"rendered":"Box Cat Takes to the Skies"},"content":{"rendered":"<p>This week I expanded on my last sketch, adding changing background colors based on nyan-cat&#8217;s height in the sky and mouse-based locations that a mini-nyan cat uses to follow the mouse. <\/p>\n<p>I am not very good at all at programming so I needed a little more help on this one. I found the Processing reference to be very useful. The reference can be accessed quickly by typing a keyword in Processing, highlighting it, right-clicking and selecting to look it up in the reference. It explains everything about the highlighted term in question, how it can be used, and it provides explanations of related terms as well. But for questions I did not have the keyword for, like when I was having problems declaring variables, the Processing.org forums provided me with the information I needed. I discovered that variables declared in one method cannot be seen in another, so variables used by both the setup and draw methods needed to be declared outside both methods. I found that information here: http:\/\/forum.processing.org\/topic\/cannot-find-anything-named-token<\/p>\n<p> Thanks to the technical resources Processing provides I was able to create this sketch.<\/p>\n<p><script type=\"application\/processing\">\r\n\/\/Box Cat, by Catherine Waple\r\n\r\n\/\/declare variables\r\n\r\n\/\/void rainbow = rect(mouseX-50,mouseY-20,mouseX,mouseY);\r\n\/\/int centerX = width\/2;\r\n\/\/int centerY = height\/2; \r\nint poptartWidth = 50;\r\nint poptartHeight = 20;\r\n\r\nvoid setup() {\r\n  size(500, 500);\/\/window size\r\n  smooth();\r\n\r\n  \/\/set shape modes\r\n  rectMode(CORNERS);\r\n  ellipseMode(CENTER);\r\n}\r\n\r\nvoid draw() {\r\n  \r\n  \/\/change time of day\r\n    \r\n  if (mouseY > ((height\/3)*2))  \r\n    background(141, 213, 245);\r\n  else if (mouseY < (height\/3))\r\n    background(2,1,49);\r\n  else\r\n    background(2, 21, 185);\r\n\r\n  \/\/draw face\r\n  stroke(0);\r\n  fill(175);\r\n  \/\/rect(125, 150, 375, 350);\r\n\r\n  \/\/draw mini head\r\n  rect(mouseX+50, mouseY, (mouseX+50)+20, (mouseY+20));\r\n  rect(mouseX+50, mouseY, (mouseX+50)+20, (mouseY+20));\r\n\r\n  \/\/draw poptart body\r\n  stroke(247, 202, 130);\r\n  strokeWeight(4);\r\n  fill(247, 130, 130);\r\n  rect(mouseX, mouseY, mouseX+poptartWidth, mouseY+poptartHeight);\r\n\r\n  \/\/draw rainbow\r\n  fill(random(255), random(255), random(255));\r\n  rect(mouseX, mouseY, 0, mouseY+poptartHeight);\r\n  \r\n  stroke(0);\r\n\r\n  \/\/draw eyes\r\n  fill(19, 167, 0);\r\n  ellipse(200, 200, 50, 50);\r\n  ellipse(300, 200, 50, 50);\r\n  fill(0);\r\n  ellipse(195, 200, 20, 40);\r\n  ellipse(295, 200, 20, 40);\r\n\r\n  \/\/draw outer ears\r\n  fill(175);\r\n  triangle(140, 150, 200, 150, 170, 90);\r\n  triangle(300, 150, 360, 150, 330, 90);\r\n\r\n  \/\/draw nose and inner ears\r\n  fill(247, 167, 167);\r\n  triangle(230, 260, 270, 260, 250, 290);\r\n  triangle(150, 150, 190, 150, 170, 110);\r\n  triangle(310, 150, 350, 150, 330, 110);\r\n\r\n  \/\/draw mouth\r\n  \/\/fill(255);\r\n  noFill();\r\n  arc(225, 290, 50, 50, 0, PI);\r\n  arc(275, 290, 50, 50, 0, PI);\r\n\r\n  \/\/draw whiskers\r\n  line(220, 260, 110, 230);\r\n  line(210, 280, 100, 300);\r\n  line(280, 260, 390, 230);\r\n  line(290, 280, 400, 300);\r\n}\r\n\r\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This week I expanded on my last sketch, adding changing background colors based on nyan-cat&#8217;s height in the sky and mouse-based locations that a mini-nyan cat uses to follow the mouse. I am not very good at all at programming &hellip; <a href=\"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/2012\/11\/05\/box-cat-takes-to-the-skies\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":22,"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\/247"}],"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\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/comments?post=247"}],"version-history":[{"count":3,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/247\/revisions"}],"predecessor-version":[{"id":250,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/247\/revisions\/250"}],"wp:attachment":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/media?parent=247"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/categories?post=247"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/tags?post=247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}