Peano curve
var c;
var w = 800;
var h = w;
var socket;
function setup() {
frameRate(2)
c = createCanvas(w, h);
cols = width / 4
rows = height / 4
colors = [
[255, 255, 255],
[0, 0, 0],
[38, 166, 154],
[217, 203, 158],
[55, 65, 64],
[42, 44, 43],
[219, 195, 199]
]
}
function pattern(x, y) {
noStroke()
for (a = 0; a < 2; a++) {
for (b = 0; b < 2; b++) {
rand = Math.floor(Math.random() * colors.length)
fill(colors[rand])
rect(x, y, width / 8, width / 8)
}
}
}
function angle(x, y) {
push()
rectMode(CENTER)
rand = Math.floor(Math.random() * colors.length)
noStroke()
fill(colors[rand])
translate(x + (width / 10), y - (width / 24.2424242))
rotate(radians(45))
rect(width / 8 - width / 6, width / 8 - width / 6, width / 16, width / 16)
pop()
}
function draw() {
for (i = 0; i < 10; i++) {
for (j = 0; j < 10; j++) {
pattern((width / 10) * i, (width / 10) * j)
}
}
for (i = 0; i < 5; i++) {
for (j = 1; j < 6; j++) {
angle((width / 5) * i, (width / 5) * j)
}
}
}
An animated reinterpretation of Bruno Munari's "Curva di Peano" (1973)