xxxxxxxxxx
31
class Oscillator {
constructor(offset) {
this.angle = createVector();
this.velocity = createVector(0.02 + offset, 0.02 - offset);
this.amplitude = createVector(width/3, height/3);
this.t = offset*5;
}
oscillate() {
this.angle.add(this.velocity);
this.t += 0.01;
}
display() {
let x = cos(this.angle.x)*2 * this.amplitude.x/2
let y = sin(this.angle.y)*2 * this.amplitude.y/2
push();
translate(width / 2, height / 2);
//stroke(255);
//strokeWeight(2);
let r = 255 * noise(this.t + 10);
let g = 255 * noise(this.t + 15);
let b = 255 * noise(this.t + 20);
fill(r, g, b);
line(0, 0, x, y);
noStroke();
ellipse(x, y, 32, 32);
pop();
}
}