-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathct-hue-sat.html
88 lines (67 loc) · 2.2 KB
/
ct-hue-sat.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='X-UA-Compatible' content='IE=edge'/>
<title>Hue Rounding</title>
<style type='text/css' title='common'>
html, body {border:0 none; margin:0; padding:0; }
body {font-family:Arial, Helvetica, sans-serif; font-size: 16px; vertical-align: middle; }
#main { width: 100%; height: 100vh; }
#main span {
width: 9.1%;
height: 5.0em;
margin: 0.125em;
box-sizing: border-box;
display: inline-block;
border: 1px solid hsl(0,0%,0%);
vertical-align: middle;
}
#main span div { padding: 0.125em 0 0.125em 2.0em; background-color: #fff; }
#main span div::first-child { padding-top: 1.5em; }
h2 { text-align: center; }
</style>
<script type='text/javascript'>
'use strict';
function eDOMContent(e) {
// paintSLGrid()'
var nl,
str,
main = document.getElementById('main');
nl = main.querySelector('div.row');
for (var i = 0, el; i < 6; i++) {
el = nl.cloneNode(true);
main.appendChild(el);
}
nl = document.getElementById('main').querySelectorAll('span');
for (var i = 0, el, aId; el = nl[i]; i++) {
str = 'hsl(' + (0.1*i).toFixed(1) + ', 100%, 50%)';
el.style.backgroundColor = str;
el.firstElementChild.textContent = 'hsl ' + (0.1*i).toFixed(1);
}
for (var i = 0, el, clr; el = nl[i]; i++) {
clr = window.getComputedStyle(el).backgroundColor.replace(/\(\d+,/, ' ');
el.lastElementChild.textContent = clr.replace(/, *\d+\)$/,'');
}
}
window.addEventListener('DOMContentLoaded', eDOMContent, false);
</script>
</head>
<body>
<h2>HSL to RGB mapping, hsl using s = 100% and l = 50%,<br>
hsl hue value shown, rgb green value shown</h2>
<div id='main'>
<div class='row'>
<span><div></div><div></div></span>
<span><div></div><div></div></span>
<span><div></div><div></div></span>
<span><div></div><div></div></span>
<span><div></div><div></div></span>
<span><div></div><div></div></span>
<span><div></div><div></div></span>
<span><div></div><div></div></span>
<span><div></div><div></div></span>
<span><div></div><div></div></span>
</div>
</div>
</body>
</html>