Benoit Ricaud

Opera

var c; var w = 666; var h = w; var w6 = w / 6; var go; function setup() { var seed = Math.floor(random(0, 254)); randomSeed(seed) c = createCanvas(w, h); noLoop() cols = w / 4 rows = h / 4 colors = [ [86, 140, 228], [201, 36, 42], [57, 87, 49], [235, 201, 6], [183, 68, 137], [90, 75, 156], [230, 119, 14] ] rand_left = Math.floor(Math.random() * colors.length) rand_right = Math.floor(Math.random() * colors.length) // var bar = g.fillFloat32Array("waveform", 1000, "sine"); console.log(seed) } function pattern(x, y) { noStroke() rect((height / 2) - 10, w / 6, ) } function doors(c1, c2, flip) { noStroke(); beginShape(); fill(c1); if (flip) { vertex(0, w / 2.5) vertex(0, 0); vertex(w / 6, 0); vertex(w / 6, w / 6); bezierVertex(w / 6, w / 6, w / 6, w / 2.5, 0, w / 2.5); } else { vertex(0, w / 12) vertex(0, height / 2); vertex(w / 6, w / 2); vertex(w / 6, w / 3); bezierVertex(w / 6, w / 3, w / 6, w / 12, 0, w / 12); } endShape(); // beginShape(); fill(c2); if (flip) { vertex(w / 3, w / 12); vertex(w / 3, w / 2); vertex(w6, w / 2); vertex(w6, w / 2.5); bezierVertex(w6, w / 2.5, w / 6, w / 12, w / 3, w / 12); } else { vertex(w / 3, w / 2.5); vertex(w / 3, 0); vertex(w / 6, 0); vertex(w6, w6); bezierVertex(w6, w6, w6, w / 2.5, w / 3, w / 2.5); } endShape(); } function draw() { go() } function go() { background(colors[Math.floor(Math.random() * colors.length)]) for (i = 0; i <= 3; i++) { rand_left = Math.floor(Math.random() * colors.length) rand_right = Math.floor(Math.random() * colors.length) var flipped = i == 1 ? true : false; push(); translate(w / 3 * i, 0); doors(colors[rand_left], colors[rand_right], flipped) pop(); } for (i = 0; i <= 3; i++) { rand_left = Math.floor(Math.random() * colors.length) rand_right = Math.floor(Math.random() * colors.length) var flipped = i == 1 ? true : false; push(); translate(w / 3 * i, w / 2); doors(colors[rand_left], colors[rand_right], flipped) pop(); } } function mouseClicked() { go(); }

A reinterpretation of Bruno Munari's opera grafica. Click to generate a new pattern.