@@ -793,11 +793,11 @@ which is rgb(52.446% 45.821% 62.953%)
793
793
-->
794
794
795
795
<h2 id="relative-colors">
796
- Relative Color Syntax
796
+ Relative Colors
797
797
</h2>
798
798
799
799
<h3 id="rcs-intro">
800
- Introduction to Relative Color Syntax
800
+ Processing Model for Relative Colors
801
801
</h3>
802
802
803
803
In previous levels of this specification,
@@ -819,11 +819,81 @@ The origin color and the relative color need not use the same color function.
819
819
820
820
All operations take part in the
821
821
[=color space=] of the [=relative color=] function;
822
- the [=origin color=] is converted to that color space,
822
+ <span id="required-conversion"> if the
823
+ <dfn export>originally specified color space</dfn>
824
+ for the [=origin color=] used a different color function,
825
+ it's first converted into the chosen color function,
826
+ so it has meaningful values for the channels</span>
823
827
and [=channel keywords=]
824
828
refer to the color space of the relative color,
825
829
<em> not</em> the [=origin color=] .
826
830
831
+ If the alpha value of the relative color is omitted,
832
+ it defaults to that of the [=origin color=]
833
+ (rather than defaulting to ''100%'' , as it does in the absolute syntax).
834
+
835
+ When relative color syntax is used,
836
+ <strong> color channel</strong> values,
837
+ whether directly specified
838
+ or arising from color space conversion,
839
+ are <em> not clamped</em> to the reference ranges but are retained as-is.
840
+ This preserves out of gamut values,
841
+ if the destination color space is capable of representing them.
842
+
843
+ However, when relative color syntax is used,
844
+ <strong> alpha channel</strong> values
845
+ whether directly specified
846
+ or arising from color space conversion,
847
+ <em> are</em> clamped to the reference range.
848
+
849
+ Missing components are handled the same way as with
850
+ [[css-color-4#interpolation-missing]] :
851
+ the origin colorspace and the relative function colorspace
852
+ are checked for [=analogous components=]
853
+ which are then [=carried forward=] as missing.
854
+
855
+ While most uses of [=relative color=] syntax
856
+ will use the [=channel keywords=] in their corresponding argument,
857
+ you can use them in any position.
858
+
859
+ Beware when using components outside their normal position;
860
+ when percentages are resolved to numbers,
861
+ there is no "magic scaling"
862
+ to account for the changed position
863
+ if those numbers are used in a different place.
864
+
865
+
866
+ <h3 id="relative-syntax">
867
+ Relative Color Syntax
868
+ </h3>
869
+
870
+ The precise details of each function's syntactic changes
871
+ to accommodate [=relative colors=] are listed below,
872
+ but they all follow a common structure:
873
+
874
+ * An [=origin color=] can be specified with a ''from <<color>>'' value
875
+ at the start of the function.
876
+ This includes the optional alpha channel, if specified.
877
+ * If no origin color is specified, the function is not a relative color.
878
+ * If an [=origin color=] is specified,
879
+ the remaining arguments can either be specified directly, as normal,
880
+ or be specified as a <dfn>channel keyword</dfn>
881
+ referring to one of the channels of the [=origin color=]
882
+ converted to the [=color space=] of the relative color.
883
+ [=Math functions=] can also use these keywords
884
+ to do dynamic modifications of the [=origin color's=] channels.
885
+ * [=Relative color=] syntax doesn't change whether an argument is required or optional.
886
+ * Relative color syntax only applies to the [=modern color syntax=] .
887
+ It <em> cannot</em> be used with <a>legacy color syntax</a>
888
+ and attempting to do so is an error.
889
+ * However, the [=origin color=] can use either modern or legacy syntax.
890
+
891
+ The [=channel keywords=] return a <<number>> ;
892
+ if they were originally specified as a <<percentage>> or an <<angle>> ,
893
+ that <<percentage>> is resolved to a <<number>>
894
+ and the <<angle>> is resolved to a <<number>> of degrees
895
+ (which is the [=canonical unit=] )
896
+ in the range [0, 360] .
827
897
828
898
<wpt>
829
899
relative-currentcolor-a98rgb-01.html
@@ -848,33 +918,6 @@ refer to the color space of the relative color,
848
918
parsing/relative-color-out-of-gamut.html
849
919
</wpt>
850
920
851
- The precise details of each function's changes to accommodate [=relative colors=] are listed below,
852
- but they all follow a common structure:
853
-
854
- * An [=origin color=] can be specified with a ''from <<color>>'' value at the start of the function.
855
- This includes the optional alpha channel, if specified.
856
- * If an [=origin color=] is specified,
857
- the remaining arguments can either be specified directly, as normal,
858
- or be specified as a <dfn>channel keyword</dfn>
859
- referring to one of the channels of the [=origin color=] .
860
- [=Math functions=] can also use these keywords
861
- to do dynamic modifications of the [=origin color's=] channels.
862
- * [=Relative color=] syntax doesn't change whether an argument is required or optional.
863
- If the alpha value is omitted, however,
864
- it defaults to taking from the [=origin color=]
865
- (rather than defaulting to ''100%'' , as it does in the absolute syntax).
866
- * Relative color syntax only applies to the [=modern color syntax=] .
867
- It <em> cannot</em> be used with <a>legacy color syntax</a>
868
- and attempting to do so is an error.
869
- * However, the [=origin color=] can use either modern or legacy syntax.
870
-
871
- The [=channel keywords=] return a <<number>> ;
872
- if they were originally specified as a <<percentage>> or an <<angle>> ,
873
- that <<percentage>> is resolved to a <<number>>
874
- and the <<angle>> is resolved to a <<number>> of degrees
875
- (which is the [=canonical unit=] )
876
- in the range [0, 360] .
877
-
878
921
<div class=example>
879
922
For example, if a color is specified using <<percentage>> ,
880
923
then RCS in the same colorspace will use the resolved <<number>> form:
@@ -913,12 +956,6 @@ in the range [0, 360].
913
956
914
957
</div>
915
958
916
- <p id="required-conversion"> If the
917
- <dfn export>originally specified color space</dfn>
918
- for the [=origin color=] used a different color function,
919
- it's first converted into the chosen color function,
920
- so it has meaningful values for the channels.</p>
921
-
922
959
<div class=example>
923
960
By using the [=channel keywords=] in a [=math function=] ,
924
961
an [=origin color=] can be manipulated in more advanced ways.
@@ -958,14 +995,6 @@ so it has meaningful values for the channels.</p>
958
995
regardless of what the [=origin color's=] opacity was.
959
996
</div>
960
997
961
- When relative color syntax is used,
962
- color channel values,
963
- whether directly specified
964
- or arising from color space conversion,
965
- are <em> not</em> clamped to the reference ranges but are retained as-is.
966
- This preserves out of gamut values,
967
- if the destination color space is capable of representing them.
968
-
969
998
<div class="example">
970
999
For example, a Display P3 color
971
1000
which is outside the gamut of sRGB can still be represented,
@@ -983,9 +1012,6 @@ if the destination color space is capable of representing them.
983
1012
<span class="swatch" style="--color: rgb(100% 100% 15.37%)"></span> rgb(100% 100% 15.37%)
984
1013
</div>
985
1014
986
- However, when relative color syntax is used,
987
- alpha channels <em> are</em> clamped to the reference range.
988
-
989
1015
<div class="example">
990
1016
For example, attempting to double an alpha of 0.7 in the origin color
991
1017
results in an alpha in the result of 1, not 1.4.
@@ -996,9 +1022,6 @@ alpha channels <em>are</em> clamped to the reference range.
996
1022
</pre>
997
1023
</div>
998
1024
999
- While most uses of [=relative color=] syntax
1000
- will use the [=channel keywords=] in their corresponding argument,
1001
- you can use them in any position.
1002
1025
1003
1026
<div class=example>
1004
1027
For example, to do a rough approximation of grayscaling a color:
@@ -1037,12 +1060,6 @@ you can use them in any position.
1037
1060
which determines how "colorful" the color is.)
1038
1061
</div>
1039
1062
1040
- Beware when using components outside their normal position;
1041
- when percentages are resolved to numbers,
1042
- there is no "magic scaling"
1043
- to account for the changed position
1044
- if those numbers are used in a different place.
1045
-
1046
1063
<div class="example" id="ex-no-percentage-magic">
1047
1064
<p> For example,</p>
1048
1065
@@ -1073,12 +1090,6 @@ you can use them in any position.
1073
1090
1074
1091
</div>
1075
1092
1076
- Missing components are handled the same way as with
1077
- [[css-color-4#interpolation-missing]] :
1078
- the origin colorspace and the relative function colorspace
1079
- are checked for [=analogous components=]
1080
- which are then carried forward as missing.
1081
-
1082
1093
<div class="example" id="ex-missing-analogous">
1083
1094
In this example the achromatic origin color has a missing hue;
1084
1095
the [=relative color=] also has a missing hue,
0 commit comments