]>
git.r.bdr.sh - rbdr/r.bdr.sh/blob - js/animation.js
6a67699cab06435bf3f74b3356b08e9fa902a5ab
3 var K
= document
.querySelector('canvas'),
4 { random: R
, PI
, cos: C
, sin: S
, floor
, atan2: A
} = Math
,
10 X
= K
.getContext('2d'), F
= X
.fill
.bind(X
), B
= X
.beginPath
.bind(X
),
11 f
= 24, l
= 0, s
= 1, z
= 5 + r(10),
12 k
= R() > 0.5, c
= R() > 0.5,
13 I
= Array(r(10) + 6).fill().map(() => ({
15 a: R() * 2 * PI
, c: r(100)
17 H
= [sqr
, crc
, hrt
, chs
, lch
], P
= [id
, spn(5), spn(15)],
18 draw
= H
[r(H
.length
)], pos
= P
[r(P
.length
)]
26 X
.fillRect(x
, y
, z
, z
)
32 X
.arc(x
, y
, z
/ 2, 0, 2 * PI
)
40 X
.lineTo(x
* 10 * C(i
.a
), y
* 10 * S(i
.a
))
41 X
.lineTo(r(64), r(64))
49 X
.strokeStyle
= `hsl(0,0%,${i.c}%)`
51 X
.lineTo(x
* 10 * C(i
.a
), y
* 10 * S(i
.a
))
57 X
.fillRect(x
, y
, z
, z
)
60 X
.arc(x
+ z
/ 2, y
, z
/ 2, 0, 2 * PI
, false)
65 X
.arc(x
+ z
, y
+ z
/ 2, z
/ 2, 0, 2 * PI
, false)
71 i
.x
= i
.x
+ s
* C(i
.a
)
72 i
.y
= i
.y
+ s
* S(i
.a
)
74 if (i
.x
< 0 || i
.x
> 64) {
75 i
.a
= A(S(i
.a
), -C(i
.a
))
77 if (i
.y
< 0 || i
.y
> 64) {
78 i
.a
= A(-S(i
.a
), C(i
.a
))
87 requestAnimationFrame(frm
)
92 k
&& X
.clearRect(0, 0, 64, 64)
94 X
.fillStyle
= `hsl(0,0%,${i.c}%)`