Skip to content

Commit 1c24b52

Browse files
committed
[css-color-5] redo color-adjust example
1 parent 791fbd2 commit 1c24b52

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

css-color-4/LCHplayground.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<html>
2+
<meta charset="utf-8"></meta>
3+
<script src="math.js"></script>
4+
<script src="conversions.js"></script>
5+
<script src="utilities.js"></script>
6+
<title>LCH playground</title>
7+
</html>

css-color-5/Overview.bs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ spec:css-color-4; type:dfn; text:colorspace
2020
spec:css-color-4; type:dfn; text:gamut
2121
</pre>
2222

23+
<style>
24+
.swatch {display: inline-block; height: 1.2em; width: 1.2em;}
25+
.peru {background-color: peru;}
26+
.darkperu {background-color: rgb(57.58%, 32.47%, 3.82%);}
27+
</style>
28+
2329
Introduction {#intro}
2430
=====================
2531

@@ -188,18 +194,18 @@ Adjusting colors: the ''color-adjust'' function {#coloradjust}
188194
</pre>
189195

190196
<div class="example">
191-
This example produces the adjustment of red,
197+
This example produces the adjustment of peru (#CD853F),
192198
in ''lch()'' colorspace (the default),
193-
with the lightness being increased by 30%.
199+
with the lightness being reduced by 20%.
194200
The chroma and hue of red are left unchanged.
195201

196-
<pre class="lang-css">adjust-color(red, lightness(30%));</pre>
202+
<pre class="lang-css">adjust-color(peru, lightness(-20%));</pre>
197203

198204
The calculation is as follows:
199-
* sRGB red (#F00) is lch(54.2917 106.8390 40.8526)
200-
* adjusted lightness is 54.2917 + 30 = 84.2917
201-
* adjusted result is lch(84.2917 106.8390 40.8526)
202-
* which is a light red color: rgb(218.5126% 218.5197% 218.4963%)
205+
* peru (#CD853F) <span class="swatch peru"> </span> is lch(62.2532% 54.0114 63.6769)
206+
* adjusted lightness is 62.2532% - 20% = 42.2532%
207+
* adjusted result is lch(42.2532% 54.0114 63.6769)
208+
* which is rgb(57.58%, 32.47%, 3.82%) <span class="swatch darkperu"> </span>
203209
</div>
204210

205211
<img src="images/adjust_red_lightness30.png" alt="Result of adjust-color(red, lightness(30%)" />

0 commit comments

Comments
 (0)