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