Mischback / colorizer

A simple web-based colorscheme builder which focuses on contrast values.
https://mischback.github.io/colorizer/
MIT License
1 stars 0 forks source link

Use an existing library for handling colors #10

Open Mischback opened 1 year ago

Mischback commented 1 year ago

As of now, color handling is based on (s)RGB internally. All conversion functions are implemented (more or less) following the reference implementations in W3C's Color Module Level 4.

Reasoning

Candidates

Evaluation

color.js aswell as culori add lots of overhead while using the tree-shakable APIs. Both of them are based around Color Spaces / Color Modes, which are - as of now - way out of scope of this application, which is intended to provide different input methods to define colors and then work with them.

Just for now, we're implementing our own interface for colors, which is tightly geared towards the specific needs of this application.

Evaluation - Part II

Ok, I gave culori another try.

culori exposes its conversion functions directly, making it suitable for tree-shaking (color.js has the conversion functions tied to classes/objects, so the resulting bundle would contain more overhead). BUT, culori does not provide a full set of conversion functions!

Everything went smooth to convert from sRGB to CIE XYZ and back, but there are no conversion functions from CIE XYZ to (i.e.) OkLCH. You would have to convert to sRGB and then to OkLCH which is a) overhead and b) might lead to rounding/calculation/precision issues.