mirror of
https://github.com/Art-Portal/April.git
synced 2024-12-26 11:24:16 +01:00
Show hex instead of hsl in palette gen
This commit is contained in:
parent
6fe05437bb
commit
fd889cd823
@ -27,7 +27,7 @@ async function generateRandomPalette() {
|
||||
const saturation = Math.random() * 40 + 50; // Random saturation between 50% and 90%
|
||||
const brightness = Math.random() * 40 + 50; // Random brightness between 50% and 90%
|
||||
|
||||
const color = `hsl(${hue + i * (360 / numColors)}, ${saturation}%, ${brightness}%)`;
|
||||
const color = hslToHex(hue + i * (360 / numColors) , saturation} , brightness);
|
||||
palette.push(color);
|
||||
}
|
||||
|
||||
@ -46,4 +46,15 @@ async function createPaletteImage(colors) {
|
||||
}
|
||||
|
||||
return canvas.toBuffer(); // Convertit le canvas en un buffer d'image
|
||||
}
|
||||
}
|
||||
|
||||
function hslToHex(h, s, l) {
|
||||
l /= 100;
|
||||
const a = s * Math.min(l, 1 - l) / 100;
|
||||
const f = n => {
|
||||
const k = (n + h / 30) % 12;
|
||||
const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
||||
return Math.round(255 * color).toString(16).padStart(2, '0'); // convert to Hex and prefix "0" if needed
|
||||
};
|
||||
return `#${f(0)}${f(8)}${f(4)}`;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user