xxxxxxxxxx
40
let a,b,c,d,currPoint
let numIterations = 10
// AFTER YOU PRESS PLAY, PRESS SPACE TO GENERATE NEW RENDERINGS
function setup() {
createCanvas(800, 500);
background(50);
stroke(255,50)
strokeWeight(1)
a = random(-2,2)
b = random(-2,2)
c = random(-2,2)
d = random(-2,2)
currPoint = new createVector(0,0)
}
function draw() {
translate(width/2, height/2)
for(let i =0 ; i< numIterations; i++){
point(currPoint.x*100, currPoint.y*100)
let newX = sin(a*currPoint.y) - cos(b*currPoint.x)
let newY = sin(c*currPoint.x) - cos(d*currPoint.y)
currPoint = new createVector(newX, newY)
}
}
function keyPressed(){
// SPACE bar is keyCode = 32
if(keyCode === 32 ){
background(0);
a = random(-2,2)
b = random(-2,2)
c = random(-2,2)
d = random(-2,2)
console.log(`a is ${a}`,`b is ${b}`,`c is ${c}`,`d is ${d}`)
}
}