Skip to content

Commit c3de94f

Browse files
committed
[css-color-5] Hue components in RCS also number, w3c#9876
1 parent 3832055 commit c3de94f

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

css-color-5/Overview.bs

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -822,10 +822,13 @@ but they all follow a common structure:
822822
and attempting to do so is an error.
823823

824824
Except as specified for individual color functions,
825-
(for example, hues return an <<angle>>),
825+
(for example, HWB Whiteness and Blackness return <<percentage>>),
826826
the [=channel keywords=] return a <<number>>;
827-
if they were originally specified as a <<percentage>>,
828-
that percentage is resolved to a <<number>>.
827+
if they were originally specified as a <<percentage>> or an <<angle>>,
828+
that <<percentage>> is resolved to a <<number>>
829+
and the <<angle>> is resolved to a <<number>> of degrees
830+
(which is the [=canonical unit=])
831+
in the range [0, 360].
829832

830833
<div class=example>
831834
For example, if a color is specified using <<percentage>>,
@@ -846,6 +849,25 @@ that percentage is resolved to a <<number>>.
846849
oklab(0.457 -0.072 -0.02).
847850
</div>
848851

852+
<div class="example">
853+
For example, if the origin color has a hue <<angle>> specified in degrees,
854+
then RCS in the same colorspace will use the resolved <<number>> form:
855+
856+
<pre highlight=css>
857+
html { --base: <span class="swatch" style="--color: sienna"></span> oklch(52.6% 0.115 44.6deg) }
858+
.summary {
859+
background: <span class="swatch" style="--color: rgb(30.09% 47.36% 18.46%)"></span> oklab(from var(--base) l c calc(h + 90));
860+
}
861+
</pre>
862+
863+
In this example the resulting RCS color is oklch(0.526 0.115 134.6).
864+
865+
Had the origin color hue <<angle>> been specified in another unit,
866+
such as radians or turns,
867+
still the resolved <<number>> would be the number of degrees.
868+
869+
</div>
870+
849871
If the [=origin color=] was originally specified with a different color function,
850872
it's first converted into the chosen color function,
851873
so it has meaningful values for the channels.
@@ -1007,7 +1029,7 @@ the allowed [=channel keywords=] are:
10071029
* <dfn value for="hsl()">h</dfn> is an <<angle>>
10081030
that corresponds to the [=origin color's=] HSL hue
10091031
after its conversion to sRGB,
1010-
normalized to a [0deg, 360deg) range
1032+
normalized to a [0, 360] range
10111033
* <dfn value for="hsl()">s</dfn> and <dfn value for="hsl()">l</dfn>
10121034
are <<percentage>>s that correspond to the [=origin color's=]
10131035
HSL saturation and lightness,
@@ -1044,7 +1066,7 @@ the allowed [=channel keywords=] are:
10441066
* <dfn value for="hwb()">h</dfn> is an <<angle>>
10451067
that corresponds to the [=origin color's=] HWB hue
10461068
after its conversion to sRGB,
1047-
normalized to a [0deg, 360deg) range
1069+
normalized to a [0, 360] range
10481070
* <dfn value for="hwb()">w</dfn> and <dfn value for="hwb()">b</dfn>
10491071
are <<percentage>>s that correspond to the [=origin color's=] HWB whiteness and blackness
10501072
after its conversion to sRGB
@@ -1141,7 +1163,7 @@ the allowed [=channel keywords=] are:
11411163
that corresponds to the [=origin color's=] LCH chroma
11421164
* <dfn value for="lch()">h</dfn> is an <<angle>>
11431165
that corresponds to the [=origin color's=] LCH hue,
1144-
normalized to a [0deg, 360deg) range.
1166+
normalized to a [0, 360] range.
11451167
* <dfn value for="lch()">alpha</dfn> is a <<number>> that corresponds to the [=origin color's=] alpha transparency
11461168

11471169

@@ -1154,7 +1176,7 @@ the allowed [=channel keywords=] are:
11541176
This adds 180 degrees to the hue angle, giving the complementary color.
11551177
<pre>
11561178
--accent: <span class="swatch" style="--color: lightseagreen"></span> lightseagreen;
1157-
--complement: <span class="swatch" style="--color: rgb(88.2814% 51.1047% 58.3039%)"></span> lch(from var(--accent) l c calc(h + 180deg));
1179+
--complement: <span class="swatch" style="--color: rgb(88.2814% 51.1047% 58.3039%)"></span> lch(from var(--accent) l c calc(h + 180));
11581180
</pre>
11591181
lightseagreen is lch(65.4937 39.4484 190.1013), so --complement is <span class="swatch" style="--color: rgb(88.2814% 51.1047% 58.3039%)"></span> lch(65.4937 39.4484 370.1013)
11601182
</div>
@@ -1246,7 +1268,7 @@ However, unlike HSL, manipulations are not guaranteed to be in-gamut.
12461268
we see that, due to the hue rotate in HSL,
12471269
Lightness shot up from 60% to 89%,
12481270
the Chroma has dropped from 90 to 49,
1249-
and the Hue actually changed by 141 degrees not 120.
1271+
and the Hue actually changed by 141 degrees, not 120.
12501272
</div>
12511273

12521274
<h3 id="relative-Oklch">Relative Oklch Colors</h3>
@@ -1271,7 +1293,7 @@ the allowed [=channel keywords=] are:
12711293
that corresponds to the [=origin color's=] Oklch chroma
12721294
* <dfn value for="oklch()">h</dfn> is an <<angle>>
12731295
that corresponds to the [=origin color's=] Oklch hue,
1274-
normalized to a [0deg, 360deg) range.
1296+
normalized to a [0, 360] range.
12751297
* <dfn value for="oklch()">alpha</dfn> is a <<number>> that corresponds to the [=origin color's=] alpha transparency
12761298

12771299
Because Oklch is both perceptually uniform and chroma-preserving,

0 commit comments

Comments
 (0)