Skip to content

Commit 0101c5a

Browse files
committed
add color-adjust function with example
1 parent c075412 commit 0101c5a

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

css-color-5/Overview.bs

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ Introduction {#intro}
3636
and two colors with visually different lightness,
3737
like yellow and blue, can have the same HSL lightness).
3838

39-
This module adds two functions:
39+
This module adds three functions:
4040
''color-mix'',
41-
''color-contrast''.
41+
''color-contrast'',
42+
''color-adjust''
4243

4344
The perceptually uniform ``lch()`` colorspace
4445
is used for mixing by default,
@@ -158,3 +159,35 @@ Selecting the most contrasting color: the ''color-contrast()'' function {#colorc
158159

159160
</div>
160161

162+
Adjusting colors: the ''color-adjust'' function {#coloradjust}
163+
=====================================================
164+
165+
This function takes one <<color>> specification
166+
and returns the result of adjusting that color,
167+
in a given colorspace,
168+
by a specified transform function.
169+
170+
Unless otherwise specified,
171+
the adjustment is done in the ''lch()'' colorspace.
172+
173+
Multiple color functions can be specified.
174+
175+
<pre class='prod'>
176+
<dfn>color-adjust()</dfn> = color-adjust( <<color>> [ <<color-function>> <<colorspace>>? ]?] )
177+
</pre>
178+
179+
<div class="example">
180+
This example produces the adjustment of red,
181+
in ''lch()'' colorspace (the default),
182+
with the lightness being increased by 30%.
183+
The chroma and hue of red are left unchanged.
184+
185+
<pre class="lang-css">adjust-color(red, lightness(30%));</pre>
186+
187+
The calculation is as follows:
188+
* sRGB red (#F00) is lch(54.2917 106.8390 40.8526)
189+
* adjusted lightness is 54.2917 + 30 = 84.2917
190+
* adjusted result is lch(84.2917 106.8390 40.8526)
191+
* which is a gray color: rgb(218.5126% 218.5197% 218.4963%)
192+
</div>
193+

0 commit comments

Comments
 (0)