aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2014-05-11 13:16:35 +0200
committerJakob Odersky <jodersky@gmail.com>2014-05-11 13:16:35 +0200
commit4e999d147f88ee4ea2dad679ee1e6c25c76baa66 (patch)
tree626b5beb9ead70e3b676165e2a0c736d024925f6
parent17444bc53876df25c17c62493fd1000e6d617659 (diff)
parent071d1be3301f85bcf33e2bcfb649979935a6bd31 (diff)
downloadplayGraph-4e999d147f88ee4ea2dad679ee1e6c25c76baa66.tar.gz
playGraph-4e999d147f88ee4ea2dad679ee1e6c25c76baa66.tar.bz2
playGraph-4e999d147f88ee4ea2dad679ee1e6c25c76baa66.zip
Merge branch 'jodersky'
-rw-r--r--app/css/app.css2
-rw-r--r--app/index.html2
-rw-r--r--app/js/controllers.js2
-rw-r--r--app/js/directives.js72
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 d4433a3..f3c9ddf 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);
-*/
-
- }
+ }
}
});