xxxxxxxxxx
let flyers;
function setup() {
createCanvas(windowWidth, windowHeight);
flyers = collect(100, createRandomFlyer)
console.log(flyers[0])
angleMode(DEGREES)
}
function draw() {
background("white");
for (let flyer of flyers) {
drawFlyer(flyer)
}
for (let flyer of flyers) {
flyer.pos.x += flyer.speed;
flyer.angle += flyer.rotationSpeed;
}
for (let flyer of flyers) {
if (flyer.pos.x > width + 100) {
flyer.pos.x = -100;
}
}
}
function drawRandomLetter(p, choices) {
const letter = random(choices)
textSize(random(20, 100))
fill(random(colours));
text(letter, p.x, p.y);
}
function mousePressed() {
repeat(2, drawRandomSquares);
}
function keyPressed() {
repeat(10, drawRandomCircle);
}
function createRandomPosition() {
return {
x: random(0, width),
y: random(0, height)
}
}
function createRandomFlyer() {
return {
pos: createRandomPosition(),
angle: random(0, 360),
speed: random(2, 5),
rotationSpeed: random(-2, 2),
colour: random(colours),
size: random(30, 100),
letter: random("LAURA".split(""))
}
}
function drawFlyer(f) {
push();
noStroke()
translate(f.pos.x, f.pos.y);
fill(f.colour)
circle(0, 0, f.size*1.5);
fill(0)
rotate(f.angle);
textSize(f.size)
textAlign(CENTER, CENTER)
text(f.letter, 0, 0);
pop()
}