You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: There are currently two proposals for modifying colors:
185
-
''color-adjust'' and [[#extended-color|Extending color() to add modifiers]].
185
+
''color-adjust'' and [[#relative-colors|Relative color syntax]].
186
186
187
187
Issue(3187): there are two proposals for color modification (<a href="https://github.com/w3c/csswg-drafts/issues/3187#issuecomment-499126198">proposal 1</a>, <a href="https://gist.github.com/una/edcfa0d3600e0b89b2ebf266bf549721">proposal 2</a>).
188
188
The CSS WG expects that the best aspects of each
@@ -237,6 +237,111 @@ Adjusting colors: the ''color-adjust'' function {#coloradjust}
237
237
238
238
<img src="images/adjust_red_lightness30.png" alt="Result of adjust-color(red, lightness(30%)" />
239
239
240
-
Extending ''color()'' to add modifiers {#extended-color}
Besides specifying absolute coordinates, all color functions can also be used with a *relative syntax* to produce colors in the function's target color space, based on an existing color. This syntax consists of the keyword `from`, a <<color>> value, and optionally numerical coordinates specific to the color function. To allow calculations on the original color's coordinates, there are single-letter keywords for each coordinate and `alpha` that corresponds to the color's alpha. If no coordinates are specified, the function merely converts the origin color to the target function's color space.
244
+
245
+
The following sections outline the relative color syntax for each color function.
246
+
247
+
Issue: A future version of this specification may define a relative syntax for ''color()'' as well.
248
+
249
+
<h4>Relative RGB colors</h4>
250
+
251
+
The grammar of the ''rgb()'' function is extended as follows:
The following keywords can also be used in this function (provided the end result conforms to the expected type for the parameter) and correspond to:
321
+
322
+
- 'l' is a <<percentage>> that corresponds to the origin color's CIE Lightness
323
+
- 'c' is a <<number>> that corresponds to the origin color's LCH chroma
324
+
- 'h' is a <<number>> that corresponds to the origin color's LCH hue, normalized to a [0, 360) range.
325
+
- 'alpha' is a <<percentage>> that corresponds to the origin color's alpha transparency
326
+
327
+
<div class="example">
328
+
''lch(from peru calc(l * 0.8) c h)'' produces a color that is 20% darker than <span class="swatch" style="--color: peru"></span> peru or lch(62.2532% 54.0114 63.6769), with its chroma and hue left unchanged.
329
+
The result is <span class="swatch" style="--color: rgb(57.58%, 32.47%, 3.82%)"></span> lch(49.80256% 54.0114 63.6769)
330
+
</div>
331
+
332
+
<h4>Relative grayscale colors</h4>
333
+
334
+
The grammar of the ''gray()'' function is extended as follows:
0 commit comments