[csswg-drafts] [css-color-4] Consider adding "extended" and "linear" variants of the predefined RGB-ish color spaces (#6087)

samweinig has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-color-4] Consider adding "extended" and "linear" variants of the predefined RGB-ish color spaces ==
CSS Color 4 currently defines the following "RGB-ish" (meaning, using rgb channels, a transfer function to linear, and linear transform to XYZ) color spaces:  'srgb', 'display-p3', 'a98-rgb', 'prophoto-rgb', 'rec2020'.

In some use cases, it can be useful to have variants of these that are "linear" (meaning, the transfer function is unapplied), "extended" (meaning they are not bounded from 0.0 - 1.0, but rather can extended to Inf in either the positive or negative direction) or "linear and extended" (meaning a combination of the both).

While we certainly could specify the full matrix of all combinations of color spaces with these characteristics, for instance:

srgb
linear-srgb
extended-srgb
linear-extended-srgb

display-p3
linear-display-p3
extended-display-p3
linear-extended-display-p3

(etc, etc...)


An alternate formulation might be to offer CSS functions to transform the color spaces, offering linearize(), extended() functions, so the above could be described as:

srgb -> srgb
linear-srgb -> linearize(srgb) 
extended-srgb -> extended(srgb)
linear-extended-srgb  -> linearize(extended(srgb)) or extended(linearize(srgb))

display-p3 -> display-p3
linear-display-p3 -> linearize(display-p3) 
extended-display-p3 -> extended(display-p3)
linear-extended-display-p3  -> linearize(extended(display-p3)) or extended(linearize(display-p3))

(etc, etc...)


As existing precedent, CoreGraphics, the library used on Apple's platforms for graphics, exposes functions to transform these RGB-ish colorspaces to their "linear", "extended", and "linear and extended" variants via the following functions:


```c
/* Create a linearized copy of the color space if the color space is matrix based.
   Return NULL if otherwise */
CG_EXTERN CGColorSpaceRef  __nullable CGColorSpaceCreateLinearized(CGColorSpaceRef space)
CG_AVAILABLE_STARTING(11.0, 14.0);

/* Create a copy of the color space which uses extended range [-Inf, +Inf] if the color space is
   matrix based. Return NULL if otherwise */
CG_EXTERN CGColorSpaceRef  __nullable CGColorSpaceCreateExtended(CGColorSpaceRef space)
CG_AVAILABLE_STARTING(11.0, 14.0);

/* Create a linearized copy of the color space which uses extended range [-Inf, +Inf]
   if the color space is matrix based. Return NULL if otherwise */
CG_EXTERN CGColorSpaceRef  __nullable CGColorSpaceCreateExtendedLinearized(CGColorSpaceRef space)
CG_AVAILABLE_STARTING(11.0, 14.0);
```



Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6087 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 8 March 2021 19:53:02 UTC