{"id":2530,"date":"2016-02-12T23:42:28","date_gmt":"2016-02-12T22:42:28","guid":{"rendered":"http:\/\/www.lyceelecorbusier.eu\/p5js\/?p=2530"},"modified":"2016-09-09T17:01:26","modified_gmt":"2016-09-09T16:01:26","slug":"p5-js-p_2_1_3_01","status":"publish","type":"post","link":"https:\/\/www.lyceelecorbusier.eu\/p5js\/?p=2530","title":{"rendered":"\/ p5.js \/ P_2_1_3_01"},"content":{"rendered":"<p style=\"text-align: center;\"><!--more-->\n<!-- iframe plugin v.5.1 wordpress.org\/plugins\/iframe\/ -->\n<iframe src=\"http:\/\/lyceelecorbusier.eu\/p5\/generative\/P_2_1_3_01\" width=\"780\" height=\"780\" style=\"border: 1px solid #ddd;\" scrolling=\"yes\" class=\"iframe-class\" frameborder=\"0\"><\/iframe>\n\n<pre style=\"text-align: left;\">\/\/ P_2_1_3_01\r\n\/\/\r\n\/\/ Generative Gestaltung, ISBN: 978-3-87439-759-9\r\n\/\/ First Edition, Hermann Schmidt, Mainz, 2009\r\n\/\/ Hartmut Bohnacker, Benedikt Gross, Julia Laub, Claudius Lazzeroni\r\n\/\/ Copyright 2009 Hartmut Bohnacker, Benedikt Gross, Julia Laub, Claudius Lazzeroni\r\n\/\/\r\n\/\/ http:\/\/www.generative-gestaltung.de\r\n\/\/\r\n\/\/ Licensed under the Apache License, Version 2.0 (the \"License\");\r\n\/\/ you may not use this file except in compliance with the License.\r\n\/\/ You may obtain a copy of the License at http:\/\/www.apache.org\/licenses\/LICENSE-2.0\r\n\/\/ Unless required by applicable law or agreed to in writing, software\r\n\/\/ distributed under the License is distributed on an \"AS IS\" BASIS,\r\n\/\/ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n\/\/ See the License for the specific language governing permissions and\r\n\/\/ limitations under the License.\r\n\r\n\/**\r\n\u00a0* changing circle amount, size and position in a grid\r\n\u00a0* \u00a0\u00a0 \u00a0 \r\n\u00a0* MOUSE\r\n\u00a0* position x\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : circle amount and size\r\n\u00a0* position y\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : circle position\r\n\u00a0* left click\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : random position\r\n\u00a0* \r\n\u00a0* KEYS\r\n\u00a0* s\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : save png\r\n\u00a0*\/\r\n\r\nvar tileCountX = 10;\r\nvar tileCountY = 10;\r\nvar tileWidth, tileHeight;\r\nvar count = 0;\r\nvar colorStep = 15;\r\nvar circleCount;\r\nvar endSize, endOffset;\r\nvar actRandomSeed = 0;\r\n\r\nfunction setup() { \r\n\u00a0 createCanvas(780, 780);\r\n\u00a0 tileWidth = width \/ tileCountX;\r\n\u00a0 tileHeight = height \/ tileCountY;\r\n} \r\n\r\nfunction draw() { \r\n\u00a0 smooth();\r\n\u00a0 noFill();\r\n\u00a0 stroke(0, 128);\r\n\u00a0 background(255); \r\n\u00a0 randomSeed(actRandomSeed);\r\n\u00a0 push();\r\n\u00a0 translate((width\/tileCountX)\/2, (height\/tileCountY)\/2);\r\n\u00a0 circleCount = mouseX\/30 + 1;\r\n\u00a0 endSize = map(mouseX, 0,width, tileWidth\/2.0,0);\r\n\u00a0 endOffset = map(mouseY, 0,height, 0,(tileWidth-endSize)\/2);\r\n\u00a0 pop();\r\n\u00a0 for (var gridY=0; gridY&lt;=tileCountY; gridY++) {\r\n\u00a0\u00a0\u00a0 for (var gridX=0; gridX&lt;=tileCountX; gridX++) { \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 push();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 translate(tileWidth*gridX, tileHeight*gridY);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 scale(1, tileHeight\/tileWidth);\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 var toggle = int(random(0,4));\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 if (toggle == 0) rotate(-HALF_PI); \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 if (toggle == 1) rotate(0); \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 if (toggle == 2) rotate(HALF_PI); \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 if (toggle == 3) rotate(PI); \u00a0\r\n\u00a0\u00a0\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ draw module\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 for(var i=0; i&lt;circleCount; i++) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var diameter = map(i, 0,circleCount-1, tileWidth,endSize);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var offset = map(i, 0,circleCount-1, 0,endOffset);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ellipse(offset, 0, diameter,diameter);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 pop();\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0 }\r\n} \r\n\r\nfunction mousePressed() {\r\n\u00a0 actRandomSeed = int(random(100000));\r\n}\r\n\r\nfunction keyTyped() {\r\n\u00a0 if (key == 's' || key == 'S') save(\"P_2_1_3_01.png\");\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":2531,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[10,6],"tags":[],"_links":{"self":[{"href":"https:\/\/www.lyceelecorbusier.eu\/p5js\/index.php?rest_route=\/wp\/v2\/posts\/2530"}],"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=2530"}],"version-history":[{"count":1,"href":"https:\/\/www.lyceelecorbusier.eu\/p5js\/index.php?rest_route=\/wp\/v2\/posts\/2530\/revisions"}],"predecessor-version":[{"id":2532,"href":"https:\/\/www.lyceelecorbusier.eu\/p5js\/index.php?rest_route=\/wp\/v2\/posts\/2530\/revisions\/2532"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.lyceelecorbusier.eu\/p5js\/index.php?rest_route=\/wp\/v2\/media\/2531"}],"wp:attachment":[{"href":"https:\/\/www.lyceelecorbusier.eu\/p5js\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lyceelecorbusier.eu\/p5js\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lyceelecorbusier.eu\/p5js\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}