
{"id":16250,"date":"2015-01-01T13:50:15","date_gmt":"2015-01-01T13:50:15","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=16250"},"modified":"2015-01-01T13:50:15","modified_gmt":"2015-01-01T13:50:15","slug":"example-for-an-array-with-processing-language","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2015\/01\/01\/example-for-an-array-with-processing-language\/","title":{"rendered":"Example for an Array with processing language"},"content":{"rendered":"<pre>\n\/**\n * Array. \n * \n * An array is a list of data. Each piece of data in an array \n * is identified by an index number representing its position in \n * the array. Arrays are zero based, which means that the first \n * element in the array is [0], the second element is [1], and so on. \n * In this example, an array named \"coswav\" is created and\n * filled with the cosine values. This data is displayed three \n * separate ways on the screen.  \n *\/\n\n\nfloat[] coswave; \n\nvoid setup() {\n  size(640, 360);\n  coswave = new float[width];\n  for (int i = 0; i &lt; width; i++) {\n    float amount = map(i, 0, width, 0, PI);\n    coswave[i] = abs(cos(amount));\n  }\n  background(255);\n  noLoop();\n}\n\nvoid draw() {\n\n  int y1 = 0;\n  int y2 = height\/3;\n  for (int i = 0; i &lt; width; i+=2) {\n    stroke(coswave[i]*255);\n    line(i, y1, i, y2);\n  }\n\n  y1 = y2;\n  y2 = y1 + y1;\n  for (int i = 0; i &lt; width; i+=2) {\n    stroke(coswave[i]*255 \/ 4);\n    line(i, y1, i, y2);\n  }\n  \n  y1 = y2;\n  y2 = height;\n  for (int i = 0; i &lt; width; i+=2) {\n    stroke(255 - coswave[i]*255);\n    line(i, y1, i, y2);\n  }\n  \n}\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/** * Array. * * An array is a list of data. Each piece of data in an array * is identified by an index number representing its position in * the array. Arrays are zero based, which means that the first * element in the array is [0], the second element is [1], and &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2015\/01\/01\/example-for-an-array-with-processing-language\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Example for an Array with processing language&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[419,1304],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/16250"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=16250"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/16250\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=16250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=16250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=16250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}