Skip to content

Commit 4adba41

Browse files
committed
Fix animate
1 parent afe4180 commit 4adba41

2 files changed

Lines changed: 17 additions & 15 deletions

File tree

src/static/js/animate.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,25 @@ class TerminalBg {
116116
}
117117

118118
initLines () {
119-
const lineCount = Math.max(20, Math.floor(this.width / 80))
119+
const lineCount = Math.max(15, Math.floor(this.width / 120))
120+
const rowCount = Math.max(8, Math.floor(this.height / 100))
120121
const texts = this.texts
121122
this.lines = []
122123
const angle = Math.PI / 6
123-
for (let i = 0; i < lineCount; i++) {
124-
const progress = i / lineCount
125-
const startX = -this.width * 0.5 + progress * (this.width * 1.5)
126-
const startY = -this.height * 0.3 + progress * (this.height * 1.3) - Math.random() * 150
127-
this.lines.push({
128-
x: startX,
129-
y: startY,
130-
angle,
131-
speed: (0.3 + Math.random() * 0.4) * this.speed,
132-
text: texts[Math.floor(Math.random() * texts.length)],
133-
opacity: 0.08 + Math.random() * 0.1,
134-
fontSize: this.fontSize + Math.floor(Math.random() * 6)
135-
})
124+
for (let row = 0; row < rowCount; row++) {
125+
for (let col = 0; col < lineCount; col++) {
126+
const startX = -this.width * 0.3 + col * (this.width * 1.6 / lineCount) + Math.random() * 30
127+
const startY = -this.height * 0.3 + row * (this.height * 1.6 / rowCount) + Math.random() * 30
128+
this.lines.push({
129+
x: startX,
130+
y: startY,
131+
angle,
132+
speed: (0.3 + Math.random() * 0.4) * this.speed,
133+
text: texts[Math.floor(Math.random() * texts.length)],
134+
opacity: 0.08 + Math.random() * 0.1,
135+
fontSize: this.fontSize + Math.floor(Math.random() * 6)
136+
})
137+
}
136138
}
137139
}
138140

src/views/parts/react-footer.pug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//- script(crossorigin, src='//unpkg.zhimg.com/react@18/umd/react.production.min.js')
22
//- script(crossorigin, src='//unpkg.zhimg.com/react-dom@18/umd/react-dom.production.min.js')
33
script(type='module').
4-
import TerminalBg from '/src/static/js/animate.js'
4+
import TerminalBg from '/js/animate.js'
55
window.x = new TerminalBg({
66
className: 'animate',
77
color: '#666666',

0 commit comments

Comments
 (0)