color-js/color.js

New API to normalize color values without NaN.

Opened this issue · 1 comments

My comment was:

Not a blocker, but I think we need something higher level than this, i.e. a function to drop nones either by converting to 0 or taking coords from another color. If that function does not mutate objects but returns new ones, it will also fix the serialization problem. Can you open a new issue for the API design discussion?

I’m envisioning a function that would take a single color as its first argument, and optionally a variable number of other colors which would be used to resolve none values (anything after the first such color would only be used in case the first one also has none values. If no other color is provided, none is just converted to 0.

  • Would such a design work?
  • What should the function be called?
  • Should it mutate the color or return a new color?

We could also then add a allowNone: true | false (or dropNone depending on what we want the default to be) option to serialize() as a shortcut to this.