Add static.js

This commit is contained in:
Cube14yt 2025-11-26 19:46:33 +08:00 committed by GitHub
parent f2aaa56da0
commit 2e244f636b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 42 additions and 0 deletions

42
mods/static.js Normal file
View File

@ -0,0 +1,42 @@
// IIFE to prevent this mod from breaking
(() => {
let staticMode = 0
function randomGrayscale() {
const value = Math.floor(Math.random() * 256);
return `rgb(${value}, ${value}, ${value})`;
}
function randomColor() {
const letters = "0123456789ABCDEF";
let color = "#";
for (let i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
function loopScreen(callback) {
for (let x = 0; x <= width; x++) {
for (let y = 0; y <= height; y++) {
callback(x, y)
}
}
}
keybinds["KeyS"] = () => {
staticMode === 0 ? staticMode = 1 : staticMode === 1 ? staticMode = 2 : staticMode = 0
}
renderPostPixel(function (ctx) {
if (!staticMode) return
loopScreen((x, y) => {
if (staticMode === 1) {
drawSquare(ctx, randomGrayscale(), x, y, 1, 0.2)
}
if (staticMode === 2) {
drawSquare(ctx, randomColor(), x, y, 1, 0.3)
}
})
})
})()