/* Inspired by George Nees' Micro-Innovation Series (1966) */ let x; let y; let w; let h; let seed = 500; function setup() { createCanvas(windowWidth, windowHeight); rectMode(CENTER); noFill(); stroke(255); strokeWeight(2); } function draw() { background(0); for (let i = 0; i < 400; i++) { if (random(10) < 8) { w = random(5, 25); h = random(50, 150); } else { w = random(50, 150); h = random(5, 25); } x = random(w, width - w); y = random(h, height - h); rect(x, y, w, h); } noLoop(); } function mousePressed() { seed = random(4000); loop(); } /* ------------↓↓ My comment here ↓↓----------*/ let x; let y; let w; let h; let seed = 500; //seed! must be used in some where function setup() { createCanvas(windowWidth, windowHeight); rectMode(CENTER); noFill(); stroke(255); strokeWeight(2); //rectangle with white stroke } function draw() { background(0); //blackground //for loop, did 400 times for (let i = 0; i < 400; i++) { //if a random number small than 8, //draw a vertical rect //if the random number biger than 8, //draw a horizontal one. //also because there are more numbers smaller than 8, //the vertical rect will appear more than the horizontal one. if (random(10) < 8) { w = random(5, 25); h = random(50, 150); } else { w = random(50, 150); h = random(5, 25); } //control the cernter of these rects //made their edges will not fall outside // (0+w , width-w) x = random(w, width - w); y = random(h, height - h); rect(x, y, w, h); } noLoop(); } function mousePressed() { //can't understand why we need seed here? seed = random(4000); //only the loop can restart the sketch //I test it with comment the let seed in line 10, //and also comment the line 62 //it can also redraw a new version loop(); } //!!!!!!!!!!!!!! Modified Version !!!!!!!!!!!!!// let x; let y; let w; let h; let seed = 500; //seed! must be used in some where function setup() { createCanvas(windowWidth, windowHeight); rectMode(CENTER); stroke(255); strokeWeight(0.2); //rectangle with white stroke } function draw() { frameRate(5+mouseX/100+mouseY/100) background(map(mouseY,100,height-100,0,255),50); //blackground //for loop, did 400 times for (let i = 0; i < 10; i++) { fill(random(255),random(155),random(155),100); //if a random number small than 8, //draw a vertical rect //if the random number biger than 8, //draw a horizontal one. //also because there are more numbers smaller than 8, //the vertical rect will appear more than the horizontal one. if (random(10) < 6) { w = random(25, 50); h = random(150, 250); } else { w = random(250, 350); h = random(50, 80); } //control the cernter of these rects //made their edges will not fall outside // (0+w , width-w) x = random(20+w, width - w-20); y = random(20+h, height - h-20); rect(x, y, w, h); } // noLoop(); } function mousePressed() { //can't understand why we need seed here? seed = random(4000); //only the loop can restart the sketch //I test it with comment the let seed in line 10, //and also comment the line 62 //it can also redraw a new version loop(); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter