Skip to content

Instantly share code, notes, and snippets.

@svgeesus
Last active September 9, 2022 13:53
Show Gist options
  • Save svgeesus/fb50e8c9bdfdf2392ea2eb0fc3336463 to your computer and use it in GitHub Desktop.
Save svgeesus/fb50e8c9bdfdf2392ea2eb0fc3336463 to your computer and use it in GitHub Desktop.

Contrast algorithm comparison

Read more

let white = new Color("white");
let black =new Color("black");
let gray18 =new Color("color(srgb-linear 0.18 0.18 0.18)");
white.contrast(black, "WCAG21");
white.contrast(black, "Weber");
white.contrast(black, "Michelson");
white.contrast(black, "APCA");
white.contrast(black, "Lstar");
white.contrast(black, "DeltaPhi");

gray18.contrast(gray18, "WCAG21");
gray18.contrast(gray18, "Weber");
gray18.contrast(gray18, "Michelson");
gray18.contrast(gray18, "APCA");
gray18.contrast(gray18, "Lstar");
gray18.contrast(gray18, "DeltaPhi");

black.contrast(white, "WCAG21");
black.contrast(white, "Weber");
black.contrast(white, "Michelson");
black.contrast(white, "APCA");
black.contrast(white, "Lstar");
black.contrast(white, "DeltaPhi");

black.contrast(gray18, "WCAG21");
black.contrast(gray18, "Weber");
black.contrast(gray18, "Michelson");
black.contrast(gray18, "APCA");
black.contrast(gray18, "Lstar");
black.contrast(gray18, "DeltaPhi");

white.contrast(gray18, "WCAG21");
white.contrast(gray18, "Weber");
white.contrast(gray18, "Michelson");
white.contrast(gray18, "APCA");
white.contrast(gray18, "Lstar");
white.contrast(gray18, "DeltaPhi");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment