I am trying to create a 25x25 grid with rotating compasses based on Perlin noise. However, the rotations are affecting subsequent lines even with the use of push/pop. Where have I gone wrong and how can I do it correctly?
var stepSize = 20;
function setup() {
createCanvas(500, 500);
}
function draw() {
background(125);
compassGrid();
}
function compassGrid(){
angleMode(DEGREES);
for(var i = 0; i < 25; ++i){
for(var j = 0; j < 25; ++j){
var change = map(mouseX, 0, width, 50, 200);
var n = noise(i/100, j/100, frameCount/change);
var angle = map(n, 0, 1, 0, 720);
stroke(0);
noFill();
push();
translate(10, 10);
rotate(angle);
line(i * stepSize, j * stepSize,
i * stepSize, j * stepSize - stepSize)
pop();
}
}
}
This is what it looks like currently:
Thanks for any help.