idk what i did here
This commit is contained in:
+16
-16
@@ -17,7 +17,7 @@ let isAnimating = true
|
||||
let gridVisible = false
|
||||
|
||||
function randomFloat(min, max) {
|
||||
return Math.random() * (max - min) + min;
|
||||
return Math.random() * (max - min) + min
|
||||
}
|
||||
|
||||
|
||||
@@ -38,11 +38,11 @@ function randomBool(probablity) {
|
||||
|
||||
function clampNearest(n, mul) {
|
||||
if(n > 0)
|
||||
return Math.ceil(n / mul) * mul;
|
||||
return Math.ceil(n / mul) * mul
|
||||
else if( n < 0)
|
||||
return Math.floor(n / mul) * mul;
|
||||
return Math.floor(n / mul) * mul
|
||||
else
|
||||
return 0;
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ function debugPrint(title, value) {
|
||||
0 | debugPrint()
|
||||
| ^^^^^^^^^^-- argument #1 of type \`Any\` is missing`
|
||||
)
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
if (value) {
|
||||
@@ -198,35 +198,35 @@ window.addEventListener("pageshow", (event) => {
|
||||
// reload page to clear unwanted cache.
|
||||
// for some reason the loading screen stays
|
||||
// permanently open without this.
|
||||
window.location.reload();
|
||||
window.location.reload()
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
let prevAnimationState = isAnimating
|
||||
|
||||
/*
|
||||
document.addEventListener("visibilitychange", function() {
|
||||
if (document.hidden) {
|
||||
prevAnimationState = isAnimating;
|
||||
isAnimating = false;
|
||||
prevAnimationState = isAnimating
|
||||
isAnimating = false
|
||||
}
|
||||
else {
|
||||
isAnimating = prevAnimationState;
|
||||
isAnimating = prevAnimationState
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
window.addEventListener("blur", function() {
|
||||
if (document.visibilityState === "visible") {
|
||||
prevAnimationState = isAnimating;
|
||||
isAnimating = false;
|
||||
prevAnimationState = isAnimating
|
||||
isAnimating = false
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
window.addEventListener("focus", function() {
|
||||
if (!document.hidden) {
|
||||
isAnimating = prevAnimationState;
|
||||
isAnimating = prevAnimationState
|
||||
}
|
||||
});
|
||||
})
|
||||
*/
|
||||
+18
-18
@@ -37,43 +37,43 @@ class Starfall {
|
||||
|
||||
|
||||
function drawPixelLine(fromX, fromY, toX, toY) {
|
||||
const pxInflate = 0.1;
|
||||
const pxInflate = 0.1
|
||||
|
||||
const dx = Math.abs(toX - fromX);
|
||||
const dy = Math.abs(toY - fromY);
|
||||
const sx = fromX < toX ? 1 : -1;
|
||||
const sy = fromY < toY ? 1 : -1;
|
||||
let err = dx - dy;
|
||||
const dx = Math.abs(toX - fromX)
|
||||
const dy = Math.abs(toY - fromY)
|
||||
const sx = fromX < toX ? 1 : -1
|
||||
const sy = fromY < toY ? 1 : -1
|
||||
let err = dx - dy
|
||||
|
||||
let x = fromX;
|
||||
let y = fromY;
|
||||
let x = fromX
|
||||
let y = fromY
|
||||
|
||||
starfallCtx.beginPath();
|
||||
starfallCtx.beginPath()
|
||||
|
||||
const steps = Math.max(dx, dy);
|
||||
const steps = Math.max(dx, dy)
|
||||
|
||||
for (let i = 0; i <= steps; i++) {
|
||||
const alpha = i == 0 ? 1 : 0.1 * (1 - i / steps)
|
||||
starfallCtx.fillStyle = `rgba(255, 255, 255, ${alpha})`;
|
||||
starfallCtx.fillStyle = `rgba(255, 255, 255, ${alpha})`
|
||||
|
||||
starfallCtx.rect(
|
||||
clampNearest(x * pxDensity, pxDensity) - 0.5,
|
||||
clampNearest(y * pxDensity, pxDensity) - 0.5,
|
||||
pxInflate + pxDensity,
|
||||
pxInflate + pxDensity
|
||||
);
|
||||
)
|
||||
|
||||
const e2 = 2 * err;
|
||||
const e2 = 2 * err
|
||||
if (e2 > -dy) {
|
||||
err -= dy;
|
||||
x += sx;
|
||||
err -= dy
|
||||
x += sx
|
||||
}
|
||||
if (e2 < dx) {
|
||||
err += dx;
|
||||
y += sy;
|
||||
err += dx
|
||||
y += sy
|
||||
}
|
||||
|
||||
starfallCtx.fill();
|
||||
starfallCtx.fill()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user