moudey / Shell

Powerful context menu manager for Windows File Explorer
https://nilesoft.org
MIT License
3.63k stars 122 forks source link

Add more color transformation functions & fix `color.invert` #219

Open SteffanDonal opened 1 year ago

SteffanDonal commented 1 year ago

The color.invert function doesn't modify the colour. In addition, I'd love to see some extra functions for manipulating colours!


color.hue.set(color, hue)

Sets the color's hue with the HSV color model, preserving the saturation and value of the provided color. Hue is a value between 0 and 100.

color.hue.get(color)

Gets the color's hue, between 0 and 100.

color.hue.shift(color, hue)

Offsets the color's hue with the HSV color model. Hue is a value between 0 and 100. Will wrap values that are out of bounds.

color.saturation.set(color, saturation)

Sets the color's saturation with the HSV color model, preserving the hue and value of the provided color. Saturation is a value between 0 and 100.

color.saturation.get(color)

Gets the color's saturation, between 0 and 100.

color.saturation.shift(color, saturation)

Offsets the color's saturation with the HSV color model. Saturation is a value between 0 and 100. Will clamp values that are out of bounds. Note: This is very similar to the color.dark & color.light functions, which I believe should/could be aliased to color.darken & color.lighten as these names are clearer.

color.value.set(color, value)

Sets the color's value with the HSV color model, preserving the hue and saturation of the provided color. Value is a value between 0 and 100.

color.value.get(color)

Gets the color's value, between 0 and 100.

color.value.shift(color, value)

Offsets the color's value with the HSV color model. Value is a value between 0 and 100. Will clamp values that are out of bounds.

color.lerp(a, b, amount)

Mixes the two colors by lerping their RGB components by amount. Amount is a value between 0 and 100.

color.add(a, b)

Combines the two colors by adding their individual components. Opacity is not modified.

color.multiply(a, b)

Combines the two colors by multiplying their individual components. Opacity is not modified.


Also, as an extra ask, something rarely implemented in other tools: CIELAB color functions. This is an extremely useful color model, particularly as it can provide consistent preceived lightness between different hues and chrominance (color intensity).

Here's the sort of thing I have in mind:

See: Color Picker & Code

moudey commented 1 year ago

Thank you @SteffanDonal

https://nilesoft.org/download/shell/debug.zip