Skip to content

Instantly share code, notes, and snippets.

@thash
Created May 17, 2011 16:05
Show Gist options
  • Save thash/976746 to your computer and use it in GitHub Desktop.
Save thash/976746 to your computer and use it in GitHub Desktop.
var remote_down = false;
socket.on('message', function(data) {
switch (data.act) {
case "down":
remote_down = true;
ctx.strokeStyle = data.color;
ctx.beginPath();
ctx.moveTo(data.x, data.y);
case "move":
console.log("remote: " + data.x, data.y);
ctx.lineTo(data.x, data.y);
ctx.stroke();
case "up":
if (!remote_down) return;
ctx.lineTo(data.x, data.y);
ctx.stroke();
ctx.closePath();
remote_down = false;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment