Color is a small library that has utilities to work with different color formats on web frontends. The goal will be to make this easy to use for Css stylings. For now it allows converting between some color formats. I also plan to look into color mixing and adding built-in color names.
This is a first step in exploring typed css descriptions in OCaml.
Any feedback is welcome
Would there be a chance to connect with the work on specifying colors and color profiles in @dbuenzli’s basic graphics Gg library (see Gg.Color documentation)? From the interface that you provide, it is not completely clear to me how flexible color computations can be – you provide an HSLA color space, but a linearized sRGB space would be also convenient for example, and Gg provides one.
To work with colors, note there is also Color brewery (not yet in opam) which is compatible with
Gg.color. I concur with @gasche, it is good if all these libraries can work together.
I had started with representing the color internally as the HSLA as that was what I was used to in my limited frontend work. As for the flexibility of the format, I started with modifications on existing colors, like finding complementary, making a color darker/lighter etc, for which HSLA seems pretty easy to begin with.
That said, thanks for pointing out
Gg. I hadn’t seen that before. That was also one more reason for this post so I could find out if I’m missing some existing libraries that work in the similar space. I will definitely spend some time with
Gg this weekend as I too would like this library to work well with the existing libraries and not have something incompatible for no good reason.
Color brewery looks really interesting! That adds more motivation for me to use
Great! Thanks for looking at this. It’s nice to have a unified ecosystem.
I have updated the library with more utilities to work with colors. Some other changes since last time is the use of
Gg.Color.t as the color type. So one can use other methods from the wonderful
gg library to tweak/modify their colors, or use color palettes like the ones from