diff --git a/commands/misc/graphismecommands/palette.mjs b/commands/misc/graphismecommands/palette.mjs index de631c8..4993d44 100644 --- a/commands/misc/graphismecommands/palette.mjs +++ b/commands/misc/graphismecommands/palette.mjs @@ -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 -} \ No newline at end of file +} + +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)}`; +}