xxxxxxxxxx
45
let n = 4;
let s;
function setup() {
pixelDensity(1);
createCanvas(9000, 9000);
strokeWeight(width/200);
s = width/n;
noFill();
noLoop();
}
function draw() {
clear();
// background(255);
for(let i = 0; i < n; i ++) {
for(let j = 0; j < n; j ++) {
push();
translate(i * s, j * s);
drawCell(i, j);
pop();
}
}
save("geo_gen_light.png");
}
function drawCell(i, j) {
let sides = i + 3;
let rots = j + 1;
push();
const rad = 2/5 * s;
translate(s/2, s/2);
for(let r = 0; r < rots; r ++) {
push();
beginShape();
for(let a = 0; a < TAU; a += TAU/sides) {
vertex(cos(a) * rad, sin(a) * rad);
}
endShape(CLOSE);
pop();
rotate(TAU/(rots * sides));
}
pop();
}