{"id":139,"date":"2012-02-21T22:13:06","date_gmt":"2012-02-21T22:13:06","guid":{"rendered":"http:\/\/classes.visitsteve.com\/hacking\/?p=139"},"modified":"2012-02-21T22:13:06","modified_gmt":"2012-02-21T22:13:06","slug":"count-up-count-down","status":"publish","type":"post","link":"https:\/\/classes.visitsteve.com\/hacking\/count-up-count-down\/","title":{"rendered":"Count up, Count down"},"content":{"rendered":"<p>This is a really simple bit of code that counts to 255, and back to 0 over and over again.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nint count; \/\/ how many cycles have gone through\r\nint direction; \/\/direction of the cycle, up or down\r\n\r\nvoid setup() {\r\n  size(200,200);\r\n}\r\n\r\nvoid draw() {\r\n  background(count);\r\n    if (count &gt;= 255) {\r\n    direction = -1;\r\n  } else if (count &lt;= 0) {\r\n    direction = 1;\r\n  }\r\ncount = count + 1*direction;\r\nprintln(&quot;count: &quot; + count); \r\n} \/\/end\r\n<\/pre>\n<p>See it work:<!--more--><\/p>\n<p><script type=\"application\/processing\">\r\n\/\/Info: http:\/\/processingjs.org\/reference\r\nint count; \/\/ how many cycles have gone through\r\nint direction; \/\/direction of the cycle, up or down\r\n\r\nvoid setup() {\r\n  size(200,200);\r\n}\r\n\r\nvoid draw() {\r\n  background(count);\r\n    if (count >= 255) {\r\n    direction = -1;\r\n  } else if (count <= 0) {\r\n    direction = 1;\r\n  }\r\ncount = count + 1*direction;\r\nprintln(\"count: \" + count); \r\n} \/\/end\r\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a really simple bit of code that counts to 255, and back to 0 over and over again. int count; \/\/ how many cycles have gone through int direction; \/\/direction of the cycle, up or down void setup() &hellip; <a href=\"https:\/\/classes.visitsteve.com\/hacking\/count-up-count-down\/\">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-139","post","type-post","status-publish","format-standard","hentry","category-classnews"],"_links":{"self":[{"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/posts\/139","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=139"}],"version-history":[{"count":0,"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/posts\/139\/revisions"}],"wp:attachment":[{"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/media?parent=139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/categories?post=139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/classes.visitsteve.com\/hacking\/wp-json\/wp\/v2\/tags?post=139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}