-
Notifications
You must be signed in to change notification settings - Fork 0
/
digital_rain.js
61 lines (39 loc) · 1021 Bytes
/
digital_rain.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
var clock = 0;
var drops = [];
function setup() {
createCanvas(800, 800);
for (let i = 0; i < 100; i++) {
drops[i] = new Drop();
}
}
function draw() {
background(0, 20);
for (let i = 0; i < 100; i++) {
drops[i].move();
drops[i].display();
}
drops.shift();
drops.push(new Drop());
clock += 1;
}
class Drop {
constructor() {
this.length = 90;
this.x = random(-this.length, width);
this.y = -100;
this.opacity = map(this.length, 25, 55, 55, 255);
this.col = color(0,255,0, this.opacity);
}
move() {
this.speed = map(this.x/5, 25, 55, 2, 10);
this.y += this.speed;
}
display() {
stroke(0,255,0);
noStroke();
fill(0, 255, 0, this.opacity);
this.char = "雨災日淵天気麗以目雨火海先縁傘雨冥黴一三龍".charAt(random(21));
textSize(5+this.x/40);
text(this.char, this.x, this.y, this.x+5+this.x/40, this.y+5+this.x/40 );
}
}