xxxxxxxxxx
function setup() {
createCanvas(w=720, h=w);
colorMode(HSB);
background(100);
push();
strokeWeight(1);
stroke(0, 0.15);
fill(0,0);
translate(w/2, h/2);
//Attractor Parameter
let a0 = PI*random(-1,1);
let b0 = PI*random(-1,1);
let c0 = PI*random(-1,1);
let d0 = PI*random(-1,1);
let a1 = PI*random(-1,1);
let b1 = PI*random(-1,1);
let c1 = PI*random(-1,1);
let d1 = PI*random(-1,1);
let a2 = PI*random(-1,1);
let b2 = PI*random(-1,1);
let c2 = PI*random(-1,1);
let d2 = PI*random(-1,1);
//Draw Parameter
let draw_scale = 60;
let N = 300000;
let x = random(-1,1);
let y = random(-1,1);
for(let i=0;i<N;i++){
let I = random([0, 1, 2]);
let dx, dy;
switch(I){
case 0:
//Peter De Jong Attractor
dx = sin(a0*y) + cos(b0*x);
dy = sin(c0*x) + cos(d0*y);
break;
case 1:
//Clifford Attractor
dx = sin(a1*y) + c1*cos(a1*x);
dy = sin(b1*x) + d1*cos(b1*y);
break;
case 2:
//Jason Rampe 1st Attractor
dx = cos(b2*y) + c2*sin(b2*x);
dy = cos(a2*x) + d2*sin(a2*y);
break;
default: break;
}
x = dx;
y = dy;
point(draw_scale * x, draw_scale * y);
}
pop();
}
//save PNG
function keyPressed() {
let name = "img_" + month() + day() + hour() + minute() + second();
save(name + ".png");
}