Skip to content

Commit

Permalink
Remove gamut mapping from hsl, hwb and hsv (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnw committed Oct 11, 2023
1 parent f71745c commit 6a3535a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/spaces/hsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export default new ColorSpace({

formats: {
"hsl": {
toGamut: true,
coords: ["<number> | <angle>", "<percentage>", "<percentage>"],
},
"hsla": {
Expand Down
5 changes: 0 additions & 5 deletions src/spaces/hsv.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,5 @@ export default new ColorSpace({
(l === 0 || l === 1)? 0 : ((v - l) / Math.min(l, 1 - l)) * 100,
l * 100
];
},
formats: {
color: {
toGamut: true,
}
}
});
1 change: 0 additions & 1 deletion src/spaces/hwb.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export default new ColorSpace({

formats: {
"hwb": {
toGamut: true,
coords: ["<number> | <angle>", "<percentage>", "<percentage>"],
}
}
Expand Down
34 changes: 34 additions & 0 deletions tests/conversions.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
let convertToOK = convertTo("oklab");
let convertToOKLCh = convertTo("oklch");
let convertTosrgbLin = convertTo("srgb-linear");
let convertToHSV = convertTo("hsv");

</script>

Expand Down Expand Up @@ -176,6 +177,39 @@ <h1>sRGB to HWB</h1>
</table>
</section>

<section>
<h1>Out of RGB gamut conversions</h1>
<table class="reftest" data-test="numbers" data-columns="3" data-colors="1">
<tr title="HWB">
<td>color(rec2020 0 0 1)</td>
<td>
<script>
convertToHWB();
</script>
</td>
<td>230.639, -29.921, -5.0489</td>
</tr>
<tr title="HSL">
<td>color(rec2020 0 0 1)</td>
<td>
<script>
convertToHSL();
</script>
</td>
<td>230.639, 179.655, 37.564</td>
</tr>
<tr title="HSV">
<td>color(rec2020 0 0 1)</td>
<td>
<script>
convertToHSV();
</script>
</td>
<td>230.639, 128.483, 105.0489</td>
</tr>
</table>
</section>

<section>
<h1>sRGB to HSL</h1>
<table class="reftest" data-test="numbers" data-columns="3" data-colors="1">
Expand Down
4 changes: 2 additions & 2 deletions tests/parse.html
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ <h1>hsl()</h1>
<td>{"spaceId":"hsl","coords":[NaN,0,0],"alpha":0.5}</td>
</tr>
<tr title="hsla(), oog color(rec2020 0 0 1)">
<td>hsl(90deg 0% 0% / .5)</td>
<td>{"spaceId":"hsl","coords":[90,0,0],"alpha":0.5}</td>
<td>hsl(230.6 179.7% 37.56% / 1)</td>
<td>{"spaceId":"hsl","coords":[230.6,179.7,37.56],"alpha":1}</td>
</tr>
<tr title="hsl(), none hue ">
<td>hsl(none, 50%, 50%)</td>
Expand Down

0 comments on commit 6a3535a

Please sign in to comment.