xxxxxxxxxx
44
//please excuse my naming :/
var rotor;
function setup() {
createCanvas(400, 400);
background(0);
noFill();
stroke(255, 255, 255, 15);
var vs = random(2, 6);
rotor = {
x: random(0, width),
y: random(0, height),
vx: random(vs),
vy: random(vs),
length: random(8, 32),
angle: random(TWO_PI),
speed: (random(1) < 0.5 ? -1 : 1) * random(TWO_PI / 360, TWO_PI / 45)
};
}
function draw() {
//background(220);
rotor.x += rotor.vx;
rotor.y += rotor.vy;
rotor.angle += rotor.speed;
//rotor.x += rotor.vx;
//rotor.y += rotor.vy;
rotor.angle += rotor.speed;
if(rotor.x < 0 || rotor.x > width)
rotor.vx = -rotor.vx;
if(rotor.y < 0 || rotor.y > height)
rotor.vy = -rotor.vy;
var x1 = rotor.x + rotor.length * cos(rotor.angle);
var y1 = rotor.y + rotor.length * sin(rotor.angle);
var x2 = rotor.x - rotor.length * cos(rotor.angle);
var y2 = rotor.y - rotor.length * sin(rotor.angle);
line(x1, y1, x2, y2);
}