WICG / color-api

A proposal and draft spec for a Color object for the Web Platform, loosely influenced by the Color.js work. Heavily WIP, if you landed here randomly, please move along.
https://wicg.github.io/color-api/
Other
130 stars 3 forks source link

Punt custom serialization to L2 #31

Open LeaVerou opened 1 year ago

LeaVerou commented 1 year ago

Currently, the README includes:

Extensibility: Adding hsv as a transformation of sRGB

ColorSpace.register(new ColorSpace("hsv", {
    base: "srgb",
    coords: ["h", "s", "v"],
    toBase: srgb => {
        ...
        return [h, s, v];
    },
    fromBase: hsv => {
        ...
        return [r, g, b]
    },
    serialize(c) {
        return "hsv("
            + c.coords.join(" ")
            + (c.alpha < 1? "/"
            + c.alpha : "")
            + ")";
    }
}));

It's unclear what the use cases are for outputting custom formats that are not supported by CSS, and it's trivial for author code to emulate this functionality. Also, this is not part of the spec, it's only in the readme. So I'm inclined to just remove it from the readme.