-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
32 lines (27 loc) · 827 Bytes
/
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>socket.io</title>
</head>
<body>
<canvas id="canvas" width="2000" height="2000"></canvas>
<script src="/socket.io/socket.io.js" type="text/javascript"></script>
<script type="text/javascript">
var socket = io.connect();
socket.on('nuevo pixel', dibujar);
window.addEventListener('onmousemove', function(e) {
var p = {
x: e.clientX,
y: e.clientY
}
dibujar(p);
socket.emit('pixel', p);
});
var context = document.getElementById('canvas').getContext('2d');
function dibujar(p) {
context.fillRect(p.x, p.y, 5, 5);
}
</script>
</body>
</html>