]>
git.r.bdr.sh - rbdr/r.bdr.sh/blob - js/animation.js
9c8723f3ba81e4f344be9f67bc052a1495728008
3 var K
= document
.querySelector('canvas'),
4 { random: R
, PI
, cos: C
, sin: S
, floor
, atan2: A
} = Math
,
10 X
= K
.getContext('2d'),
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(() => ({
19 H
= [sqr
, crc
, hrt
, chs
, lch
], P
= [id
, spn(5), spn(15)],
20 draw
= H
[r(H
.length
)], pos
= P
[r(P
.length
)]
29 X
.fillRect(x
, y
, z
, z
)
36 X
.arc(x
, y
, z
/ 2, 0, 2 * PI
)
45 X
.lineTo(x
* 10 * C(i
.a
), y
* 10 * S(i
.a
))
46 X
.lineTo(r(64), r(64))
55 X
.strokeStyle
= `hsl(0,0%,${i.c}%)`
57 X
.lineTo(x
* 10 * C(i
.a
), y
* 10 * S(i
.a
))
64 X
.fillRect(x
, y
, z
, z
)
67 X
.arc(x
+ z
/ 2, y
, z
/ 2, 0, 2 * PI
, false)
72 X
.arc(x
+ z
, y
+ z
/ 2, z
/ 2, 0, 2 * PI
, false)
79 i
.x
= i
.x
+ s
* C(i
.a
)
80 i
.y
= i
.y
+ s
* S(i
.a
)
82 if (i
.x
< 0 || i
.x
> 64) {
83 i
.a
= A(S(i
.a
), -C(i
.a
))
85 if (i
.y
< 0 || i
.y
> 64) {
86 i
.a
= A(-S(i
.a
), C(i
.a
))
96 requestAnimationFrame(frm
)
101 k
&& X
.clearRect(0, 0, 64, 64)
103 X
.fillStyle
= `hsl(0,0%,${i.c}%)`