//chose color palette //grid by two for loop //rotate the rect (need to be in the for loop) let Color = "cb997e-ddbea9-ffe8d6-b7b7a4-a5a58d-6b705c".split("-").map(object=>"#"+object) let cells = 6; let canvasSize, cell_size; function setup() { canvasSize = min(windowWidth, windowHeight); createCanvas(windowWidth, windowHeight); frameRate(6); } function draw() { blendMode(BLEND); background(250,250,220); noStroke(); //nest for loop to create grid for (let i = 0; i < cells; i++) { for (let j = 0; j < cells; j++) { push(); blendMode(MULTIPLY); fill(random(Color)); let x = lerp(canvasSize * 0.15, canvasSize * 0.95, i / cells); let y = lerp(canvasSize * 0.15, canvasSize * 0.95, j / cells); translate(x, y); // low probability that values far from the mean will be returned; rotate(randomGaussian() * PI * 0.1 * i / cells) rotate(randomGaussian() * PI * -0.1 * j / cells); cell_size = random(canvasSize * 15/100); rectMode(CENTER); rect(0, 0, cell_size, cell_size,random(5,20)); pop(); } translate(10,0) rotate(mouseX/5000) rotate(-mouseY/5000) } }
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