xxxxxxxxxx
let tileCountX;
let tileCountY;
let tileWidth;
let actStrokeCap;
let actTileCount;
let actAngle;
function setup(){
createCanvas(windowHeight, windowHeight);
colorMode(HSB,360,100,100);
background(100);
actTileCount = 20;
strokeWeight(10);
actStrokeCap = PROJECT;
actAngle = 0;
}
function draw() {
strokeCap(actStrokeCap);
background(100);
tileCount = actTileCount;
tileWidth = width/tileCount;
for(let i = 0; i < tileCount; i++){
for(let k = 0; k < tileCount; k++){
let posX = i*tileWidth;
let posY = k*tileWidth;
let oX = posX + tileWidth/2;
let oY = posY + tileWidth/2;
let angle = atan((mouseY-oY)/(mouseX-oX)) + actAngle;
push();
translate(oX,oY);
rotate(angle);
line(-tileWidth/2,0,tileWidth/2,0);
pop();
}
}
}
function keyReleased() {
if(key == '1') actStrokeCap = ROUND;
if(key == '2') actStrokeCap = SQUARE;
if(key == '3') actStrokeCap = PROJECT;
if(keyCode == UP_ARROW) actAngle += PI/18;
if(keyCode == DOWN_ARROW) actAngle -= PI/18;
}