palette
palette copied to clipboard
Add color systems
Which color systems should this package support?
Short answer: CIE-LAB and CIE-LCH.
Long answer: I noticed that your maths functions are not very nice. While looking into algorithms for adding and blending colors, I found out that CIE-LAB is a good system for that(That's the system Photoshop and GIMP are using). There was just one small downside: Calculating the middle of two colors sometimes returns a grayish color. To fix that, CIE-LCH was invented.
For the actual implementation, you can use noahzgordon/elm-color-extra to convert to LAB and then define the following functions:
toCIELCH =
Convert.colorToLab
>> (\{ l, a, b } ->
{ l = l
, c = sqrt (a * a + b * b)
, h = atan2 b a
}
)
fromCIELCH =
Convert.colorFromLab
(\{ l, c, h } ->
{ l = l
, a = c * cos h
, b = c * sin h
}
)
>> Convert.labToColor