xxxxxxxxxx
43
let d, r, r2;
function setup() {
createCanvas(1000, 1000);
d = width * 0.1;
r = d / 2;
r2 = r / 2;
}
function draw() {
background(220);
for (let y = d * 2; y < height - d; y += d) {
for (let x = d * 2; x < width - d; x += d) {
let angle = map(mouseX*mouseY, 0, width*height, 0, TWO_PI);
push();
translate(x, y);
fill(255);
circle(x, y, d);
fill(20);
rotate(angle);
// let angle = atan2(mouseY - y, mouseX - x);
// let newY = y*cos(angle)+x*sin(angle);
// let newX = x*cos(angle)-y*sin(angle);
// circle(newX, newY, r2);
// angle = arctan(y2-y1/x2-x1)
// rotx = Math.atan2( y, z )
// roty = Math.atan2( x * Math.cos(rotx), z )
circle(0,-r, r2);
// rotate(-rotx, -roty)
// translate(-x,-y);
pop();
}
}
}