This commit is contained in:
Saahil dutta 2025-06-25 22:07:52 -04:00
parent 0675604d1a
commit 816d9dba30
Signed by: neon
GPG key ID: 8A8B64515254CFC6
6 changed files with 79 additions and 19 deletions

View file

@ -20,7 +20,7 @@ class Char {
draw() {
const distToCursor = Math.hypot(
this.x - cursor.value.x,
this.y - cursor.value.y,
this.y - cursor.value.y
);
const highlight = Math.max(0, 0.5 - distToCursor / 250);
@ -66,7 +66,7 @@ const init = () => {
const minColumns = 15; // Ensure at least this many columns on mobile
const columns = Math.max(
minColumns,
Math.floor(window.innerWidth / columnSpacing),
Math.floor(window.innerWidth / columnSpacing)
);
// Adjust rows based on screen height
@ -75,7 +75,7 @@ const init = () => {
const maxRows = 25; // Cap for performance on large screens
const rows = Math.min(
maxRows,
Math.max(minRows, Math.floor(window.innerHeight / rowSpacing)),
Math.max(minRows, Math.floor(window.innerHeight / rowSpacing))
);
chars = [];
@ -84,7 +84,7 @@ const init = () => {
const x = i * (window.innerWidth / columns); // Evenly distribute columns
const y = j * rowSpacing - Math.random() * window.innerHeight;
const char = String.fromCharCode(
0x2729 + Math.floor(Math.random() * 706),
0x2729 + Math.floor(Math.random() * 706)
);
chars.push(new Char(x, y, char));
}
@ -130,6 +130,31 @@ const handleResize = () => {
onMounted(() => {
init();
animate();
// if im holding down shift how can i make it go faster? code it
window.addEventListener("keydown", (e) => {
if (e.key === "Shift") {
chars.forEach((char) => {
char.speed *= 10; // Double the speed when Shift is pressed
});
}
if (e.ctrlKey) {
chars.forEach((char) => {
char.speed *= 1.1; // Halve the speed when Ctrl is pressed
});
}
if (e.altKey) {
chars.forEach((char) => {
char.speed *= 0.9; // Halve the speed when Alt is pressed
});
}
});
window.addEventListener("keyup", (e) => {
if (e.key === "Shift") {
chars.forEach((char) => {
char.speed /= 10; // Reset the speed when Shift is released
});
}
});
window.addEventListener("mousemove", handleMouseMove);
window.addEventListener("resize", handleResize);
});