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
135 stars 3 forks source link

Making Color API color spaces available in CSS #32

Open LeaVerou opened 1 year ago

LeaVerou commented 1 year ago

Perhaps we should have some kind of way to register a ColorSpace object and make it available to CSS. I imagine it may need a worker of some sort, to separate its scope from JS APIs we don't want CSS colors to depend on, and have some kind of registration function that is only exposed in that worker space.

In terms of namespace, I think it's fine if it's the same as colors generated through @color-profile (color(--colorspace ...coords)). E.g. we already have two ways to register custom properties (@property and CSS.registerProperty()), and that's fine. In fact, it could even be used to polyfill @color-profile!

Thoughts, @tabatkins ?

LeaVerou commented 1 year ago

@tabatkins comment from #23 had an interesting idea: using @color-profile for the registration:

We do plan to allow them to be used together, but we're not yet sure how. That said, I'm almost certain it won't be by naively merging the namespaces. Instead, I suspect that either we'll come up with an alternate syntax for referring to a Color API space by name (which would serve the same purpose as the -- requirement in @color-profile, preventing collisions with built-ins); or we'll have some way to plumb a Color API space into @color-profile more directly, like an additional registration function, or perhaps a way to refer to a Color API space in @color-profile/src, either of which would mean they'd obey the -- requirement when you ref them in color().