xxxxxxxxxx
let colors = ['#E10DE5', '#E2E500', '#E80E03', '#80EABE', '##D1DCDC', '#ffffff', '#000000'];
function setup() {
createCanvas(900, 900);
background(255);
shuffle(colors, true);
let seg = 9;
let w = width/seg;
for(let i=-1; i<=seg; i++){
for(let j=-1; j<=seg; j++){
let x = i * w + w / 2;
let y = j * w + w / 2;
let t = random() < 0.5 ? -1 : 1;
if((i+j)%2 == 0)form(x, y, w*sqrt(2), t);
}
}
}
function draw() {
}
function form(x, y, w, rv){
push();
translate(x, y);
rotate(QUARTER_PI);
scale(1, rv);
for(let i=0; i<4; i++){
let col = random(colors);
fill(col);
stroke(col);
strokeWeight(0.5);
beginShape();
vertex(-w/2, -w/2);
for(let a=0; a<=HALF_PI; a+=HALF_PI/90){
vertex(0 + w/2 * cos(a), -w/2 + w/2 * sin(a));
}
for(let a=0; a>=-HALF_PI; a-=HALF_PI/90){
vertex(-w/2 + w/2 * cos(a), 0 + w/2 * sin(a));
}
endShape(CLOSE);
rotate(HALF_PI);
}
pop();
}