avh4 / elm-color

Standard representation of colors, encouraging sharing between packages. (This replaces elm-lang/core#Color from Elm 0.18.)
BSD 3-Clause "New" or "Revised" License
23 stars 6 forks source link

Discussion: goals of a standard color package #2

Closed avh4 closed 5 years ago

avh4 commented 5 years ago

Summary (will be updated throughout the discussion)

Questions to answer:

Use-cases

avh4 commented 5 years ago

My thoughts at the moment:

I think the above are important to do quickly and make available and could be an initial release.

Beyond that, I think there are good questions about how best to handle other things like default colors, palettes, color manipulation, and alternate colorspaces. My thoughts at the moment:

2mol commented 5 years ago

I agree with the direction of the discussion.

As per the other thread, a record type of floats for RGBA channels seems great. I'm unsure about making the type opaque or not. The tradeoff: If it's opaque, you can clamp the channels between 0 and 1 when you construct/convert a color value, so you can try to guarantee to never construct invalid colors. Plus you can at any time change the internal representation! I like this. But you lose a little bit of convenience and transparency.

To give my minimal list of what I think belongs into particular package:

  1. Color types for RGBA and HSLA, and (ideally lossless) conversion functions from one into the other.
  2. Conversion to hexadecimal strings.

For me, that already goes a long way.

avh4 commented 5 years ago

There is now an API proposal for further discussion: https://github.com/avh4/elm-color/issues/4

But feel free to comment further on this issue, and I will monitor and incorporate it to the appropriate place.

avh4 commented 5 years ago

I think everything here has been incorporated elsewhere.