diff options
author | Nicolas Bornand <nicolas74@gmail.com> | 2014-05-11 13:26:02 +0200 |
---|---|---|
committer | Nicolas Bornand <nicolas74@gmail.com> | 2014-05-11 13:26:02 +0200 |
commit | b6cd744f3e9e5854236d3afb2a80ffb8b97b1110 (patch) | |
tree | b2ff1e0cd664181235f942abbdc7c0b630dc3ef3 | |
parent | d559fccdb5dd6eb57a1c0029a677c90408f38c46 (diff) | |
parent | 4e999d147f88ee4ea2dad679ee1e6c25c76baa66 (diff) | |
download | playGraph-b6cd744f3e9e5854236d3afb2a80ffb8b97b1110.tar.gz playGraph-b6cd744f3e9e5854236d3afb2a80ffb8b97b1110.tar.bz2 playGraph-b6cd744f3e9e5854236d3afb2a80ffb8b97b1110.zip |
Merge origin/master
-rw-r--r-- | app/css/app.css | 2 | ||||
-rw-r--r-- | app/index.html | 2 | ||||
-rw-r--r-- | app/js/controllers.js | 2 | ||||
-rw-r--r-- | app/js/directives.js | 72 |
4 files changed, 36 insertions, 42 deletions
diff --git a/app/css/app.css b/app/css/app.css index f70614d..9fb3c90 100644 --- a/app/css/app.css +++ b/app/css/app.css @@ -7,7 +7,7 @@ .world { position: relative; - overflow: hidden; + border: solid #999999 1px; } .world .line { diff --git a/app/index.html b/app/index.html index b3bc63a..4f960a6 100644 --- a/app/index.html +++ b/app/index.html @@ -46,7 +46,7 @@ </div> <div id="column-middle"> <div class="world" style="width: 100%; height: 500px;"> - <div data-pg-line="line" class="line" resize></div> + <div data-pg-line data-line="line" data-list="playseq"class="line" resize></div> <div data-ng-repeat="point in points" data-pg-draggable="point" class="point" style="top: {{point.y}}px; left: {{point.x}}px;" data-ng-class="{selected: point.selected==true}"> <div class="circle"></div> diff --git a/app/js/controllers.js b/app/js/controllers.js index 97e6366..11e6950 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -12,7 +12,7 @@ app.controller('pointCtrl', function($scope, $http, pathService){ var update = function(newPoints, newLine) { if(newLine.length > 0) { - $scope.playlist=pathService.computePlaylist(newPoints, newLine, 60); + $scope.playseq=pathService.computePlaylist(newPoints, newLine, 60); } } diff --git a/app/js/directives.js b/app/js/directives.js index 2ae53e6..f8b8403 100644 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -4,6 +4,10 @@ app.directive('pgLine', function () { return { restrict: 'A', replace: 'false', + scope: { + line: '=', + list: '=' + }, template: '<canvas width=100%; height: 100%></canvas>', link: function (scope, elems, attrs) { var canvas = elems[0]; @@ -11,50 +15,35 @@ app.directive('pgLine', function () { mainTool.activate(); - scope.line = scope.$eval(attrs.pgLine); + //scope.line = scope.$eval(attrs.pgLine); paper.setup(canvas); var path; - var selected = null; var drag = false; mainTool.onMouseDown = function(event) { - var hit = paper.project.hitTest(event.point) - if (hit) { - selected = hit.item; - } else { - paper.project.clear(); - // If we produced a path before, deselect it: - if (path) { - - path.selected = false; - } - - // Create a new path and set its stroke color to black: - path = new paper.Path({ - segments: [event.point], - strokeColor: 'rgba(7,140,255,.5)', - strokeWidth: 100, - fullySelected: true, - strokeCap: 'round' - }); - selected = null; - }; - + paper.project.clear(); + // If we produced a path before, deselect it: + if (path) { + path.selected = false; + } + // Create a new path and set its stroke color to black: + path = new paper.Path({ + segments: [event.point], + strokeColor: 'rgba(7,140,255,.5)', + strokeWidth: 100, + fullySelected: true, + strokeCap: 'round' + }); + drag = true; }; mainTool.onMouseMove = function(event) { - console.log(event.point); if (drag) { - if (selected) { - selected.position = event.point; - scope.$apply(); - } else { - path.add(event.point); - } + path.add(event.point); } } @@ -76,17 +65,22 @@ app.directive('pgLine', function () { scope.$apply(); } -/* - scope.$watchCollection('points', function(newVal) { + + + + scope.$watch('list', function(newPoints) { console.log("update"); - if (newVal) { - paper.project.clear(); - drawPoints(scope.points); + if (newPoints) { + for (var i = 0; i < newPoints.length - 1; ++i) { + if (newPoints[i].selected) { + var line = paper.Path.Line(newPoints[i], newPoints[i+1]); + line.strokeColor = 'red'; + line.strokeWidth = 2; + } + } } }, true); -*/ - - } + } } }); |