xxxxxxxxxx
45
let radius = 150;
let radiusOffset = 150;
let sinDepth = 50;
let theta = 0;
let l = [];
class Lissajous {
constructor() {
this.radiusOffset = random(10, width/2);
this.radius = 0;
this.depth = random(10, this.radiusOffset/2);
this.multiplier = int(random(1, 10));
}
show() {
push();
translate(width/2, height/2);
let x = this.radius*cos(theta);
let y = this.radius*sin(theta);
ellipse(x, y, 5);
pop();
}
update() {
this.radius = this.radiusOffset + this.depth*sin(theta*this.multiplier);
}
}
function setup() {
createCanvas(400, 400);
background(220);
noStroke();
fill(0, 0, 0, 100);
for (let i = 0; i < 3; i+=1) {
l.push(new Lissajous());
}
}
function draw() {
l.forEach(lb => {
lb.update();
lb.show();
});
theta -= 0.05;
}