xxxxxxxxxx
49
function setup() {
createCanvas(windowWidth, windowHeight);
angleMode(DEGREES);
radius = width/17/sin(60);
bg = 180
}
function draw() {
background(bg);
//translate(width/2, height/2);
//translate(radius*sin(60), radius);
stroke(255);
y = sin(frameCount)*60;
for(j=0;j<=height/radius/2+3;j++) {
for(i=0;i<=width/radius/2+2;i++) {
push();
translate(radius*2*i*sin(60)+(j%2)*radius*sin(60), radius*2*j*sin(48));
rotate(30+(i+j)*60+y*pow(-1, i));
//rotate(y*pow(-1, i));
hax(0, 0, radius);
pop();
}
}
}
function hax(x, y, r) {
fill(255);
//polygon(0, 0, r, 6);
f = 0.8;
fill(bg);
strokeWeight(3);
quad(-r*f/2, -r*f*sin(60), r*f/2, -r*f*sin(60), r*f, 0, -r*f, 0);
strokeWeight(1);
quad(-r*f/2, r*f*sin(60), r*f/2, r*f*sin(60), r*f*sin(59), r*(1-f), -r*f*sin(59), r*(1-f));
}
function polygon(x, y, radius, npoints) {
angleMode(RADIANS);
let angle = TWO_PI / npoints;
beginShape();
for (let a = 0; a < TWO_PI; a += angle) {
let sx = x + cos(a) * radius;
let sy = y + sin(a) * radius;
vertex(sx, sy);
}
endShape(CLOSE);
angleMode(DEGREES);
}