1
1
xxxxxxxxxx
1
body {
2
background-color: black;
3
overflow: hidden
4
user-select: none
5
margin: 0
6
}
xxxxxxxxxx
1
let doc = $(document), mX, mY, letter = []
2
let letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789!@#$%^&*~`/.,<>?\|]}{[".split("")
3
4
mR = (n, i) => Math.floor(Math.random() * n) + i
5
6
inject = () => {
7
$("body").append("<canvas></canvas>")
8
can = document.querySelector("canvas")
9
con = can.getContext("2d")
10
init()
11
}
12
13
size = () => {
14
can.height = doc.height()
15
can.width = doc.width()
16
}
17
18
$(window).on("resize", () => { size() })
19
20
init = () => {
21
size()
22
think()
23
}
24
25
doc.on("mousemove", (e) => {
26
mX = e.pageX
27
mY = e.pageY
28
letter.push([mX-10+mR(20, 0), mY+mR(20,0), letters[mR(letters.length, 0)], mR(10, 8), 1, mR(6, 1) + Math.random(10)/10, mR(20, 0)])
29
})
30
31
dT = (x, y, t, s, c) => {
32
con.save()
33
con.font = ""+s+"px Lucida Console"
34
con.shadowColor = "rgba(255,0,0,"+c+")"
35
con.shadowBlur = s/2
36
let tW = con.measureText(t).width
37
let gradient = con.createLinearGradient(6,38,6,70)
38
gradient.addColorStop(0, 'rgba(255,255,0,'+c+')')
39
gradient.addColorStop(1, 'rgba(0,255,255,'+c+')')
40
con.fillStyle = gradient
41
con.fillText(t, x-tW/2, y)
42
con.restore()
43
}
44
45
dR = (x, y, w, h, c) => {
46
con.save()
47
con.beginPath()
48
con.rect(x, y, w, h)
49
con.fillStyle = c
50
con.fill()
51
con.restore()
52
}
53
54
think = () => {
55
let sC = mR(2, 1)
56
for (let i = 0; i < letter.length; i++) {
57
sC == 2 ? letter ? letter[i][2] = letters[mR(letters.length, 0)]: null:null
58
letter ? letter[i][1]-= letter[i][5]: null
59
letter[i][4] >= 0 ? letter[i][4]-= 0.01: letter.splice(i, 1)
60
}
61
animate()
62
window.requestAnimationFrame(think)
63
}
64
65
animate = () => {
66
con.clearRect(0, 0, can.width, can.height)
67
for (let i = 0; i < letter.length; i++) {
68
dT(letter[i][0], letter[i][1], letter[i][2], letter[i][3], letter[i][4])
69
let rH = mR(540, 10)
70
let sH = mR(rH, 1)
71
letter[i][6] == 2 ? dR(letter[i][0], letter[i][1]-sH, letter[i][3]/1.5, rH, "rgba(255, 0, 0, 0.05)"): null
72
}
73
dT(can.width/2, can.height/2, "Move your mouse.", 28, 0.5)
74
}
75
76
doc.ready(() => inject())
Console errors: 0