xxxxxxxxxx
56
var font
var drops = []
class Drop {
constructor() {
this.char = random('abcdefghijklmnopqrstuvwxyz'.split(''))
this.charSize = random(20, 24)
this.x = random(width)
this.y = -random(height)
this.yspeed = random([4, 4.5, 5, 5.5, 6])
}
update() {
this.y += this.yspeed
if (this.y >= height) {
this.y = -random(height)
}
}
draw() {
noStroke()
fill(0)
textSize(this.charSize)
text(this.char, this.x, this.y)
}
}
function preload() {
font = loadFont('fonts/NotoSans-Regular.ttf')
}
function setup() {
createCanvas(windowWidth, windowHeight)
textSize(24)
textFont(font)
textAlign(CENTER, CENTER)
//smooth()
angleMode(DEGREES)
for (var i = 0; i < 100; i++) {
drops.push(new Drop())
}
}
function draw() {
background(255)
for (var i = 0; i < drops.length; i++) {
drops[i].update()
drops[i].draw()
}
}