xxxxxxxxxx
42
class Windmill {
constructor() {
this.x = random(width);
this.y = random(height);
this.size = random(10, 50);
this.deg = 0;
this.vel = 50/this.size;
this.col = color(random(100, 255), random(100, 255), random(100, 255));
}
draw() {
this.deg += this.vel;
push();
fill(this.col);
translate(this.x, this.y);
rotate(this.deg);
square(0, 0, this.size);
pop();
}
}
let wms = [];
const N = 100;
function setup() {
createCanvas(600, 600);
angleMode(DEGREES);
rectMode(CENTER);
noStroke();
for (let i = 0; i < N; i += 1) {
wms.push(new Windmill());
}
}
function draw() {
background(255);
for (const wm of wms) {
wm.draw();
}
}