Created
October 25, 2012 02:49
-
-
Save frankpinto/3950173 to your computer and use it in GitHub Desktop.
This scope?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Receive the data from the server and draw what the other client sent | |
*/ | |
// Get current PaperScope context | |
var newScope = (function(paper, socket) { | |
console.log(this); | |
paper.install(this); | |
var originalLayer; | |
var secondLayer; | |
var pathsDrawn = 0; | |
socket.on('pathReady', function(packet) { | |
if (!secondLayer) | |
{ | |
originalLayer = project.activeLayer; | |
secondLayer = new Layer(); | |
} | |
else | |
secondLayer.activate(); | |
console.log('About to draw here'); | |
paths = packet.data; | |
while (pathsDrawn < paths.length) | |
{ | |
var newPath = new Path(); | |
newPath.strokeColor = 'red'; | |
newPath.fillColor = 'red'; | |
newPath.strokeWidth = 1; | |
newPath.closed = true; | |
for (index in paths[pathsDrawn].points) | |
newPath.add(paths[pathsDrawn].points[index]); | |
pathsDrawn++; | |
} | |
// Make sure it draws immediately | |
var canvasElement = document.getElementById('canvas'); | |
view.draw(); | |
// Switch back to what user is doing | |
originalLayer.activate(); | |
}); | |
return this; | |
})(paper, socket); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment