Skip to content

Commit 2d3dc41

Browse files
authored
Change vertical lines (#9)
* Make lines with max height become a square on the next iteration * Give higher chance to be a vertical line
1 parent 3f5193f commit 2d3dc41

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

app/Main/components/AnimatedLines.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ export default function AnimatedLines({
235235

236236
// Only dots (length 1) can change orientation, others keep their orientation
237237
if (newLength === 1) {
238-
// Dots can have random orientation with 75% chance of being horizontal
239-
newIsHorizontal = Math.random() < 0.75
238+
// Dots can have random orientation with 50% chance of being horizontal
239+
newIsHorizontal = Math.random() < 0.5
240240
} else {
241241
// Non-dots must keep their original orientation
242242
newIsHorizontal = line.isHorizontal
@@ -266,10 +266,19 @@ export default function AnimatedLines({
266266
}
267267
if (newX < 0) newX = 0
268268
} else {
269-
if (newY + newLength > rowCount) {
270-
newY = Math.max(0, rowCount - newLength)
269+
// If vertical line is currently at max height, shrink it to size 1
270+
if (
271+
line.length >= rowCount ||
272+
(line.y + line.length >= rowCount && line.length > 1)
273+
) {
274+
newLength = 1
275+
newY = Math.floor(Math.random() * rowCount)
276+
} else {
277+
if (newY + newLength > rowCount) {
278+
newY = Math.max(0, rowCount - newLength)
279+
}
280+
if (newY < 0) newY = 0
271281
}
272-
if (newY < 0) newY = 0
273282
}
274283

275284
attempts++

0 commit comments

Comments
 (0)