Skip to content

Commit 00d2f26

Browse files
committed
fiddle with contrast utility
1 parent 1d6f704 commit 00d2f26

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

css-color-4/contrast.html

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,23 @@
77
// then use the contrast() utility function
88
// to compute WCAG contrast.
99

10-
var back=document.querySelector(#fg);
11-
var fore=document.querySelector(#bg);
12-
back.addEventListener("input", updateFirst, false);
13-
fore.addEventListener("input", updateFirst, false);
10+
var back, fore, bgcol, fgcol;
11+
window.addEventListener("load", startup, false);
12+
13+
function startup() {
14+
back=document.querySelector(#fg);
15+
fore=document.querySelector(#bg);
16+
back.addEventListener("input", watchpickers, false);
17+
fore.addEventListener("input", watchpickers, false);
18+
}
1419

1520
function watchpickers(event) {
16-
// if either picker changes,
21+
// if either picker changes, update the two colors
22+
// and output the contrast ratio
23+
24+
var contrast = document.querySelector("result>span");
25+
bgcol = event.target.value;
26+
fgcol =
1727
}
1828
</script>
1929
<style>

css-color-4/utilities.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function sRGB_to_LCH(RGB) {
3535
return Lab_to_LCH(XYZ_to_Lab(D65_to_D50(lin_sRGB_to_XYZ(lin_sRGB(RGB)))));
3636
}
3737

38-
functions LCH_to_sRGB(LCH) {
38+
function LCH_to_sRGB(LCH) {
3939
// convert an array of CIE LCH values
4040
// to CIE Lab, and then to XYZ,
4141
// adapt from D50 to D65,
@@ -46,5 +46,5 @@ functions LCH_to_sRGB(LCH) {
4646
// or components greater than 1.0
4747
// so check for that :)
4848

49-
return gam(sRGB(XYZ_to_lin_sRGB(Lab_to_XYZ(D50_to_D65(LCH_to_Lab(LCH)))));
49+
return gam(sRGB(XYZ_to_lin_sRGB(Lab_to_XYZ(D50_to_D65(LCH_to_Lab(LCH))))));
5050
}

0 commit comments

Comments
 (0)