Skip to content

Commit

Permalink
Merge pull request #5 from jamesnw/css-rec2020
Browse files Browse the repository at this point in the history
Add CSS Rec2020 variant
  • Loading branch information
LeaVerou authored Jun 13, 2024
2 parents 604fed7 + 28accb4 commit 13d65cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gamut-mapping/gradients.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let app = createApp({
const urlToColor = params.get("to");
const from = urlFromColor || "oklch(90% .4 250)";
const to = urlToColor || "oklch(40% .1 20)";
const methods = ["none", "clip", "scale-lh", "css", "raytrace", "edge-seeker", "chromium"];
const methods = ["none", "clip", "scale-lh", "css", "css-rec2020", "raytrace", "edge-seeker", "chromium"];
const runResults = {};
methods.forEach(method => runResults[method] = []);
return {
Expand Down
10 changes: 10 additions & 0 deletions gamut-mapping/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ const methods = {
label: "CSS",
description: "CSS Color 4 gamut mapping method.",
},
"css-rec2020": {
label: "CSS Rec2020",
description: "CSS Color 4 gamut mapping to rec2020, then Naïve clipping to the P3 gamut.",
compute: (color) => {
return color
.clone()
.toGamut({ space: "rec2020", method: "css" })
.toGamut({ space: "p3", method: "clip" });
},
},
"scale-lh": {
label: "Scale LH",
description: "Runs Scale, sets L, H to those of the original color, then runs Scale again.",
Expand Down

0 comments on commit 13d65cb

Please sign in to comment.