or "Palette (not the ffmpeg thing) Gen"
Simple palette generator using Oklab (or Okhsl, technically). The code is probably ...not the best, but I guess it gets the job done.
- Node.js
- NPM (Node's package manager, included in Node)
- culori
npm install culori
- chalk
npm install chalk
The info at the right should be read like the Kotlin range operator: (minimumValue..maximumValue) : fallbackValue. If the number you inputted is outside of the valid value ranges, it will too use the 'fallbackValue'
- --h: Set the hue (0..360) : 0
- --s: Set the saturation (0..1) : 1
- --mil: Set the minimum lightness (0..1) : 0.05
- --mal: Set the maximum lightness (0..1) : 0.95
- --hshift: Change the hue by n in each subsequent color (-20..20) : 0
- --sshift: Change the saturation by n in each subsequent color (-1..1) : 0
- --steps: Change the lightness by n in each subsequent color, from maxLightness until minLightness (0.01, 1) : 0.05
- Modifying this will result in smaller steps (more colors) or bigger steps (less colors) since it will reach minLightness earlier or later depending on it.
- -H: Hide text
- --width: Set width of color swatch (2..12) : 4
- --height: Set height of color swatch (1..4) : 2
A few example commands:
-
node palettegen.js --h=80 --s=0.75 -H --width=12 --height=2
Set the hue to 80, the saturation to 75%, hide the text and specify swatch width and height in characters (spaces)
-
node palettegen.js --h=170
Set the hue to 170, and just use the default values (fallbackValue) for everything else
-
node palettegen.js --h=70 --mil=0.75
Set the hue to 70 and the minimum lightness to 75% -
node palettegen.js --h=192 --hshift=4 -H --width=12 --height=2
Set the hue to 192, then, for every new color, hue shift 4 steps -
node palettegen.js --h=192 --s=0 --sshift=0.05 --hshift=2
Set the hue to 192, then, for every new color hue shift 2 steps, and increase saturation by 0.05
-
Support custom amount of lightness steps (currently hardcoded to increments of 0.05) - Single color syntax:
node palettegen --ok(192, 1, 0.5)
- Custom type of output:
node palettegen --h=236 --o=rgb | --o=hsl
etc
- Generate images with the palettes directly on them somehow
- Check WCAG contrast and readjust the lightness on the fly to meet the required inputted contrast level (good luck with that future me)
- Presets for h, s, l or any combination, like UI, digital painting etc
- Option to generate complementary colors (specified in amount)
I was going to initially set it as MIT, seeing as both culori and chalk use it, but it's not really right if there's a giant section of code copied from StackOverflow... lol. It's not like licenses matters that much for a small js file anyways, sooo