-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
61 lines (51 loc) · 1.31 KB
/
index.html
File metadata and controls
61 lines (51 loc) · 1.31 KB
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
<!doctype html>
<html>
<head>
<title>HUSley demo</title>
<style>
html {
font-family: sans-serif;
color: #333;
background: #eee;
}
canvas {
display: block;
padding: 1px;
border: 1px solid #ccc;
}
</style>
<script src="husley.js"></script>
</head>
<body>
<h1>HUSLey demo</h1>
<p>HUSLey is the most basic library offering a human-friendly HSL-like color representation preserving the lightness.</p>
<input id="lightness" type="range" value="50" min="0" max="100" step="1"></input>
<canvas id="output" width="360" height="100"></canvas>
<script>
window.addEventListener('load', function() {
var lightness = document.getElementById('lightness');
var ctx = document.getElementById('output').getContext('2d');
var imageData = ctx.getImageData(0, 0, 360, 100);
function update(e) {
var l = Number(lightness.value) / 100;
var data = imageData.data;
var index = 0;
for (var y = 100; y--; ) {
var s = y / 100;
for (var x = 0; x < 360; x++) {
var h = x * Math.PI / 180;
var rgb = HUSLey(h, s, l);
data[index++] = rgb[0];
data[index++] = rgb[1];
data[index++] = rgb[2];
data[index++] = 255;
}
}
ctx.putImageData(imageData, 0, 0);
};
lightness.addEventListener('change', update);
update();
});
</script>
</body>
</html>