xxxxxxxxxx
function setup() {
createCanvas(w=720, w)
N = 8;
let color_pat = "3ec1d3f6f7d7ff9a00ff165d"
+ "00ead3fff5b7ff449f005f99"
+ "f38181fce38aeaffd095e1d3";
let colors = [];
for(let i=0;i<color_pat.length/6;i++){
colors.push("#"+color_pat.slice(i*6,i*6+6));
}
colors = shuffle(colors);
colorMode(HSB);
background(colors[0]);
fill(255);
for (let i=0;i<N;i++){
for (let j=0;j<N;j++){
colors = shuffle(colors);
let colorset = [colors[0], colors[1], colors[2]]
push();
translate(w/N*(i+0.5), w/N*(j+0.5));
pers_3circle(w/N/(3/sqrt(2)), colorset);
pop();
}
}
}
function pers_3circle(l, col){
let r = l/sqrt(2)
let rp = r*sqrt(3);
let x = l/4*sqrt(3);
let y = l/4*3;
strokeWeight(l/16)
push();
translate(0, -y/2);
fill(col[0]);
ellipse(0, 0, rp, r);
face(l);
pop();
push();
translate(x, y/2);
rotate(-PI/3);
fill(col[1]);
ellipse(0, 0, rp, r);
face(l);
pop();
push();
translate(-x, y/2);
rotate(PI/3);
fill(col[2]);
ellipse(0, 0, rp, r);
face(l);
pop();
}
function face(l){
let size = l*0.8
push();
fill("#000000");
ellipse(size/8*2, -size/10, size/14);
ellipse(-size/8, -size/10, size/14);
fill(0,0);
arc(size/8, size/20, size/10*1.25, size/10, -PI/2*1.25, PI/2*1.25);
arc(size/8*0.6, size/16*3.5, size/4, size/10, 0, PI);
pop();
}
//save PNG
function keyPressed() {
save("img_" + month() + day() + hour() + minute() + second() + ".png");
}