update app_modules.js
This commit is contained in:
@@ -43,22 +43,37 @@ const wheelcolors = [
|
|||||||
"#FF1D15",
|
"#FF1D15",
|
||||||
"#FF8600",
|
"#FF8600",
|
||||||
|
|
||||||
// Precomputed 24-step hue colors (15° increments, 70% saturation, 50% lightness)
|
// Precomputed 30° hue-step colors (12 steps, 70% saturation, 50% lightness)
|
||||||
"#bf3f3f", "#bf5f3f", "#bf7f3f", "#bf9f3f", "#bfaf3f", "#bfdf3f",
|
"#bf3f3f", // 0°
|
||||||
"#bfff3f", "#9fff3f", "#7fff3f", "#5fff3f", "#3fff3f", "#3fff5f",
|
"#bf9f3f", // 30°
|
||||||
"#3fff7f", "#3fff9f", "#3fffbf", "#3fdfff", "#3fafff", "#3f7fff",
|
"#bfff3f", // 60°
|
||||||
"#3f5fff", "#3f3fff", "#5f3fff", "#7f3fff", "#9f3fff", "#bf3fff"
|
"#7fff3f", // 90°
|
||||||
|
"#3fff5f", // 120°
|
||||||
|
"#3fffbf", // 150°
|
||||||
|
"#3fafff", // 180°
|
||||||
|
"#3f3fff", // 210°
|
||||||
|
"#9f3fff", // 240°
|
||||||
|
"#ff3fff", // 270°
|
||||||
|
"#ff3f7f", // 300°
|
||||||
|
"#ff3f3f" // 330°
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// String prototype using the precomputed array
|
||||||
String.prototype.toHex = function() {
|
String.prototype.toHex = function() {
|
||||||
let hash = 0;
|
let hash = 0;
|
||||||
for (let i = 0; i < this.length; i++) {
|
for (let i = 0; i < this.length; i++) {
|
||||||
hash = (hash * 31 + this.charCodeAt(i)) >>> 0;
|
hash = (hash * 31 + this.charCodeAt(i)) >>> 0;
|
||||||
}
|
}
|
||||||
return wheelcolors[hash % colors.length];
|
return wheelcolors[hash % wheelcolors.length];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Test
|
||||||
|
console.log("hello".toHex());
|
||||||
|
console.log("world".toHex());
|
||||||
|
console.log("foo".toHex());
|
||||||
|
console.log("bar".toHex());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function stringToColour(str) {
|
function stringToColour(str) {
|
||||||
return str.toHex();
|
return str.toHex();
|
||||||
|
|||||||
Reference in New Issue
Block a user