-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchromastream.html
42 lines (40 loc) · 1.01 KB
/
chromastream.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
<html lang="en">
<head>
<script src="http://lab2.acm.uiuc.edu:8009/socket.io/socket.io.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
var socket = io.connect('http://lab2.acm.uiuc.edu:8009');
socket.on('stream', function (data) {
var colordata = $.parseJSON(data.data);
$.each(colordata.colors, function(index,color) {
$("#light-"+index).css("background-color","rgb("+Math.round(color[0]/4)+","+Math.round(color[1]/4)+","+Math.round(color[2]/4)+")");
});
});
$(function() {
for (var i=0; i<24; i++) {
$("#container").append("<div id='light-"+i+"' class='lights'></div>");
}
});
</script>
<style type="text/css">
.lights {
float: left;
width: 100px;
height: 100px;
}
#container {
margin-left: auto;
margin-right: auto;
width:400px;
background-color:#000;
margin-top: 50px;
}
body {
background-color:#000;
}
</style>
</head>
<body>
<div id="container">
</div>
</body>