-
Notifications
You must be signed in to change notification settings - Fork 0
/
mesh.js
66 lines (55 loc) · 1.3 KB
/
mesh.js
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
// Generated by CoffeeScript 1.4.0
var SIO, color, i, io, polys, send, socks, update, _, ___;
SIO = (parseInt(process.argv[2])) || 4567;
_ = require('underscore');
color = (require('onecolor'))('hsv(0,100%,100%)');
___ = function(x) {
return console.log(x);
};
socks = [];
io = (require('socket.io')).listen(SIO, {
'log level': 1
});
io.sockets.on('connection', function(s) {
socks.push(s);
s.on('e', function(d) {
___("<<" + d);
return update(d);
});
return s.on('fade_out', function(d) {
var ss, _i, _len, _results;
___("<<" + d[0] + " " + d[1] + " fade out");
_results = [];
for (_i = 0, _len = socks.length; _i < _len; _i++) {
ss = socks[_i];
_results.push(ss.emit('fade_out', d));
}
return _results;
});
});
___("opened socket.io " + SIO);
polys = (function() {
var _i, _results;
_results = [];
for (i = _i = 0; _i <= 9; i = ++_i) {
_results.push(color);
}
return _results;
})();
update = function(i) {
polys[i] = polys[i].hue(0.1, true);
return send();
};
send = function() {
var l, s, _i, _len, _results;
l = _.map(polys, function(p) {
return p.hex();
});
___(">>" + l);
_results = [];
for (_i = 0, _len = socks.length; _i < _len; _i++) {
s = socks[_i];
_results.push(s.emit('u', l));
}
return _results;
};