HaikuArchives / ArtPaint

ArtPaint is a painting and image processing program.
https://haikuarchives.github.io/ArtPaint/
29 stars 18 forks source link

LayerWindow: added color blend modes: Hue, Saturation, Luminosity, Color #588

Closed dsizzle closed 1 year ago

dsizzle commented 1 year ago

-as a side effect, added hsl2rgb and rgb2hsl functions to ColorUtilities.h

Fixes #555

dsizzle commented 1 year ago

I compared with Krita and except for Color/Luminosity they look correct. (Color and Luminosity are opposites) If I have time I'll try GIMP or another tool. Not sure why the brightness is so different with those two? :confused:

ArtPaint hue: hue

Krita hue(hsl): hue(hsl)_Krita

ArtPaint saturation: sat

Krita saturation(hsl): saturation_Krita

ArtPaint luminosity: lum

Krita luminosity (EDIT: this is the wrong blend, "luminosity" in Krita uses the LCh color model, not HSL): luminosity_Krita

ArtPaint color: col

Krita color (EDIT: this is the wrong blend, "color" in Krita uses the Lch color model so this is actually "Chroma"): color_Krita

humdingerb commented 1 year ago

No idea about the differences to GIMP, unsurprisingly. It does do some blending, so it is working correctly, but may need some algo-twiddling...

dsizzle commented 1 year ago

Ok, I checked and rechecked the math and it's all correct. The problem is a matter of terminology - Lightness, Luminance, and Luminosity are used in different contexts to mean different things. :exploding_head:

So I renamed this to use "Lightness" because it seems to match other tools.

GIMP "Color" blend: gimp-color

ArtPaint "Color": col

Krita "Lightness": krita-light

ArtPaint "Lightness": lum

Krita's "Luminosity" matches GIMP's "Lch Lightness" which uses the LCh color model. The ArtPaint ones in this PR are using the HSL color model (because they're called Hue, Saturation, Lightness and Color).

So this code is correct.

humdingerb commented 1 year ago

Gfx programming is an occult art that demands the correct incantations, it seems. Merge when ready, I say.

dsizzle commented 1 year ago

Merged.