-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.html
56 lines (47 loc) · 1.45 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>colorcube-js</title>
<style>
li {
color: white;
}
</style>
</head>
<body>
<h1><a href="https://github.com/amonks/colorcube-js">colorcube-js</a></h1>
<div id="output"></div>
<img src="images/cocacola.jpg" id="coke">
<button id="do-coke">Do It!</button>
<img src="images/andrew-monks.png" id="me">
<button id="do-me">Do It!</button>
<script src="//cdnjs.cloudflare.com/ajax/libs/core-js/0.9.18/core.min.js"></script>
<script src="dist/colorcube.min.js"></script>
<script>
var cc = new ColorCube(20, 0.2, 0.4);
function do_it(image_id) {
var image = document.getElementById(image_id);
var colors = cc.get_colors(image);
console.log(colors);
outputColors(colors);
}
function outputColors(colors) {
var output = document.getElementById('output');
output.innerHTML = "<h2>Found These Colors</h2><ul id='colors'></ul>";
var colors_list = document.getElementById('colors');
for (var c in colors) {
var color = colors[c];
colors_list.innerHTML += "<li style='background: " + color + "'>" + color + "</li>";
}
}
var me_button = document.getElementById('do-me');
me_button.addEventListener("click", function() {
do_it('me');
});
var coke_button = document.getElementById('do-coke');
coke_button.addEventListener("click", function() {
do_it('coke');
});
</script>
</body>
</html>