{"id":2973,"date":"2016-09-11T14:32:56","date_gmt":"2016-09-11T13:32:56","guid":{"rendered":"http:\/\/www.lyceelecorbusier.eu\/p5js\/?p=2973"},"modified":"2016-09-11T14:33:46","modified_gmt":"2016-09-11T13:33:46","slug":"p5-re-code-16-2","status":"publish","type":"post","link":"https:\/\/www.lyceelecorbusier.eu\/p5js\/?p=2973","title":{"rendered":"\/ p5 \/ re-code 16"},"content":{"rendered":"\n<!-- iframe plugin v.5.1 wordpress.org\/plugins\/iframe\/ -->\n<iframe src=\"http:\/\/lyceelecorbusier.eu\/p5\/recode\/016-recode\" width=\"780\" height=\"780\" style=\"border: 1px solid #ddd;\" scrolling=\"yes\" class=\"iframe-class\" frameborder=\"0\"><\/iframe>\n\n<pre>function setup() {\r\n createCanvas(780,780); \r\n}\r\n\r\n\/\/ Draws a single cross.\r\nfunction drawCross(left, top, dim, thickness) {\r\n var offset_1 = dim\/2 - thickness\/2;\r\n var offset_2 = offset_1 + thickness;\r\n var offset_3 = dim;\r\n beginShape();\r\n vertex(left + offset_1, top);\r\n vertex(left + offset_2, top);\r\n vertex(left + offset_2, top + offset_1);\r\n vertex(left + offset_3, top + offset_1);\r\n vertex(left + offset_3, top + offset_2);\r\n vertex(left + offset_2, top + offset_2);\r\n vertex(left + offset_2, top + offset_3);\r\n vertex(left + offset_1, top + offset_3);\r\n vertex(left + offset_1, top + offset_2);\r\n vertex(left, top + offset_2);\r\n vertex(left, top + offset_1);\r\n vertex(left + offset_1, top + offset_1);\r\n vertex(left + offset_1, top);\r\n endShape(CLOSE);\r\n}\r\n\r\n\/\/ Draw a stack of crosses.\r\nfunction drawCrossWithDecay(left, top, base_dim, num_decay, dpos, ddim, dthickness) {\r\n var thickness = base_dim\/3;\r\n var dim = base_dim;\r\n var curleft = left;\r\n var curtop = top;\r\n for (var i = 0; i &lt; num_decay; i++) {\r\n drawCross(curleft, curtop, dim, int(thickness));\r\n curleft += dpos.x + ddim\/2;\r\n curtop += dpos.y + ddim\/2;\r\n dim -= ddim;\r\n thickness -= dthickness;\r\n }\r\n}\r\n\r\nfunction drawCrossMatrix(dim, left, top, rows, cols) {\r\n var thickness = dim\/3;\r\n var dp1 = createVector(0,-1);\r\n var dp2 = createVector(1,0);\r\n var dp;\r\n for (var i = 0; i &lt; rows; i++) {\r\n var rleft = left + i * thickness;\r\n var rtop = top + i * 2 * thickness;\r\n for (var j = 0; j &lt; cols; j++) {\r\n dp = i%2==0?dp1:dp2;\r\n dp.mult(-1);\r\n drawCrossWithDecay(rleft + thickness * 2 *j, rtop - thickness * j, dim, 5, dp, 4, 4.5);\r\n } \r\n }\r\n}\r\n\r\nfunction draw() {\r\n background(255);\r\n \r\n drawCrossMatrix(80, 50, 150, 6, 6);\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>function setup() { createCanvas(780,780); } \/\/ Draws a single cross. function drawCross(left, top, dim, thickness) { var offset_1 = dim\/2 &#8211; thickness\/2; var offset_2 = offset_1 + thickness; var offset_3 = dim; beginShape(); vertex(left + offset_1, top); vertex(left&#8230; <a class=\"read-more\" href=\"https:\/\/www.lyceelecorbusier.eu\/p5js\/?p=2973\">Lire la suite&#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":2975,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[9,6],"tags":[],"_links":{"self":[{"href":"https:\/\/www.lyceelecorbusier.eu\/p5js\/index.php?rest_route=\/wp\/v2\/posts\/2973"}],"collection":[{"href":"https:\/\/www.lyceelecorbusier.eu\/p5js\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lyceelecorbusier.eu\/p5js\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lyceelecorbusier.eu\/p5js\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lyceelecorbusier.eu\/p5js\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2973"}],"version-history":[{"count":1,"href":"https:\/\/www.lyceelecorbusier.eu\/p5js\/index.php?rest_route=\/wp\/v2\/posts\/2973\/revisions"}],"predecessor-version":[{"id":2976,"href":"https:\/\/www.lyceelecorbusier.eu\/p5js\/index.php?rest_route=\/wp\/v2\/posts\/2973\/revisions\/2976"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.lyceelecorbusier.eu\/p5js\/index.php?rest_route=\/wp\/v2\/media\/2975"}],"wp:attachment":[{"href":"https:\/\/www.lyceelecorbusier.eu\/p5js\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2973"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lyceelecorbusier.eu\/p5js\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2973"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lyceelecorbusier.eu\/p5js\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2973"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}