xxxxxxxxxx
49
class Spot {
constructor(_x, _y, _c, _r) {
this.x = this.x_init = _x;
this.y = this.y_init = _y;
this.c = _c;
this.r = _r;
this.param_noise = random(10000.0);
this.position_noise_x = random(10000.0);
this.position_noise_y = random(10000.0);
this.increment_noise = 0.01;
this.increment_noise_position = 0.001;
}
draw() {
this.param_noise = this.param_noise + this.increment_noise;
this.position_noise_x += this.increment_noise_position;
this.position_noise_y += this.increment_noise_position;
this.x = this.x_init + 100 * noise(this.position_noise_x);
this.y = this.y_init + 100 * noise(this.position_noise_y);
noStroke();
beginShape();
for (var angle = 0.0; angle < 360.0; angle = angle + 1.0) {
var circle_noise = 20 * noise(
this.param_noise + cos(radians(angle)),
this.param_noise + sin(radians(angle))
);
vertex(
this.x + (this.r + circle_noise) * cos(radians(angle)),
this.y + (this.r + circle_noise) * sin(radians(angle)));
}
endShape();
}
}
var spot;
function setup() {
frameRate(60);
createCanvas(800, 400);
spot = new Spot(width / 2, height / 2, 255, 20);
}
function draw() {
background(0);
spot.draw();
}