diff --git a/.gitmodules b/.gitmodules index c4df61d..195f8e0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "server"] path = server - url = https://github.com/OpenShades/wearscript-server + url = git@github.com:wearscript/wearscript-server.git diff --git a/README.md b/README.md index 872ff65..6edda9a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Wearscript Playground # - + ## About ## The web-based IDE for WearScript. Write code, pair glass, save, and enjoy. @@ -18,7 +18,7 @@ The web-based IDE for WearScript. Write code, pair glass, save, and enjoy. 1. Clone repo and submodules ```bash - git clone git@github.com:OpenShades/wearscript-playground.git + git clone git@github.com:wearscript/wearscript-playground.git cd wearscript-playground git submodule update --init ``` diff --git a/app/scripts/controllers/annotation.js b/app/scripts/controllers/annotation.js index 3d33c4b..0e2fff9 100644 --- a/app/scripts/controllers/annotation.js +++ b/app/scripts/controllers/annotation.js @@ -6,10 +6,11 @@ angular.module('wearscriptPlaygroundApp') $scope.images = {}; // [device] = imageb64 this.canvas = document.querySelector('#canvas'); this.context = this.canvas.getContext('2d'); - + this.pointCount = -1; + this.points = []; + this.response = ''; this.initCanvas = function () { - this.context.fillStyle = '#FFFFFF'; // set canvas background color - this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); // now fill the canvas + this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); var tool = {}; function ev_canvas (ev) { @@ -44,6 +45,15 @@ angular.module('wearscriptPlaygroundApp') }; tool.mousedown = function (ev) { + if (this.pointCount > 0) { + this.points.push([ev._x, ev._y]); + if (this.points.length == this.pointCount) { + this.pointCount = -1; + ws.publish(this.response, this.points); + this.points = []; + this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); + } + } this.context.beginPath(); this.context.arc(ev._x, ev._y, 50, 0, 2 * Math.PI); this.context.strokeStyle = '#0b61a4'; @@ -65,21 +75,24 @@ angular.module('wearscriptPlaygroundApp') } this.initCanvas(); - - this.image_cb = function (channel, time, imageData, numPoints, description) { - var image = new Image(); + this.image_cb = function (channel, response, imageData, numPoints, description) { + this.pointCount = numPoints; + this.points = []; + this.response = response; + var image = new Image(); + console.log(channel); image.onload = function (image_id) { this.context.drawImage(image, 0, 0); + console.log('Height: ' + image.naturalHeight + ' Width: ' + image.naturalWidth); }.bind(this); - image.src = 'data:image/jpeg;base64,' + btoa(imageData); + image.src = 'data:image/jpeg;base64,' + imageData; console.log(image.src.length); document.querySelector('#canvas') - $scope.numPoints = numPoints; $scope.description = description; $scope.$apply(); // HACK(brandyn): Not sure why we have to do this }.bind(this); - ws.subscribe('image', this.image_cb); + ws.subscribe('annotationimagepoints', this.image_cb); $scope.$on('$destroy', function cleanup() { ws.unsubscribe('image'); }); diff --git a/app/views/annotation.html b/app/views/annotation.html index 84257f6..997cf65 100644 --- a/app/views/annotation.html +++ b/app/views/annotation.html @@ -1 +1 @@ - + diff --git a/server b/server index 54fd4c8..df98b21 160000 --- a/server +++ b/server @@ -1 +1 @@ -Subproject commit 54fd4c8c51706fe9608c8cedf5b6bbfa31a82f5b +Subproject commit df98b21eca5b2618752bebbea73b5b864e82f4ca