Styles refactor

This commit is contained in:
Renan LE CARO 2025-03-14 16:13:43 +01:00
parent 2e3ab3011f
commit 7e3750c915
9 changed files with 419 additions and 416 deletions

View file

@ -1,15 +1,5 @@
import {RawLevel} from "./types";
export function hashCode(string: string) {
let hash = 0;
for (let i = 0; i < string.length; i++) {
let code = string.charCodeAt(i);
hash = (hash << 5) - hash + code;
hash = hash & hash; // Convert to 32bit integer
}
return Math.abs(hash);
}
import _backgrounds from "./backgrounds.json";
const backgrounds = _backgrounds as string[];
@ -21,4 +11,15 @@ export function getLevelBackground(level:RawLevel){
svg = backgrounds[hashCode(level.name) % backgrounds.length];
}
return svg
}
}
export function hashCode(string: string) {
let hash = 0;
for (let i = 0; i < string.length; i++) {
let code = string.charCodeAt(i);
hash = (hash << 5) - hash + code;
hash = hash & hash; // Convert to 32bit integer
}
return Math.abs(hash);
}