Skip to content

Instantly share code, notes, and snippets.

@svgeesus
Last active November 13, 2020 14:57
Show Gist options
  • Save svgeesus/59ff507fc2d686a97323cb81cd1d699b to your computer and use it in GitHub Desktop.
Save svgeesus/59ff507fc2d686a97323cb81cd1d699b to your computer and use it in GitHub Desktop.

Interpolating two colors in Lab

let color1 = new Color("rgb(50% 100% 25%)");
color1.p3;
let color2 = new Color("color(display-p3 1 0 0)");
color2.p3;
let blend= color1.range(color2, {
    space: "lab", // interpolation space
    outputSpace: "lch"
});
let badblend = color1.range (color2, {
    space: "p3"});
let mid = blend(.5); // midpoint
let midP3 = mid.to("p3");
let badmid = badblend(.5);
badmid.lch;
let badmidP3 = badmid.to("p3");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment