elm-color icon indicating copy to clipboard operation
elm-color copied to clipboard

Color manipulation API proposal

Open avh4 opened this issue 5 years ago • 1 comments

Rough ideas

contrast : Color -> Color -> Float  -- http://gka.github.io/chroma.js/#chroma-contrast
delta : Color -> Color -> Float  -- http://gka.github.io/chroma.js/#chroma-deltae

kuon: I wasn't clear, you can compute lightness with 0.299 * R + 0.587 * G + 0.114 * B (per https://www.w3.org/TR/AERT/#color-contrast) but for accessibility we need more tools, like given a source color, compute a color with enough contrast, taking into account color blindness... The accessibility function might grow quickly depending on user needs. I think this should stay out of the core lib.

I also found a few other ways to compute the lightness with RGB https://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color#596243

darkenBy : Float -> Color -> Color
lightenBy : Float -> Color -> Color  -- "brighten"?
saturateBy : Float -> Color -> Color
desaturateBy : Float -> Color -> Color
shiftHueBy : Float -> Color -> Color

darkenTo : Float -> Color -> Color
lightenTo : Float -> Color -> Color  -- "brighten"?
saturateTo : Float -> Color -> Color
desaturateTo : Float -> Color -> Color
shiftHueTo : Float -> Color -> Color

contrasting : Color -> Color

interpolate : Color -> Color -> Float -> Color -- HSLuv
mix : { color : Color, ... other params } -> { color : Color, ...} -> Color  -- https://stackoverflow.com/questions/1351442/is-there-an-algorithm-for-color-mixing-that-works-like-mixing-real-colors

avh4 avatar Sep 10 '18 05:09 avh4