diff options
author | Jakob Odersky <jodersky@gmail.com> | 2014-05-11 13:55:20 +0200 |
---|---|---|
committer | Jakob Odersky <jodersky@gmail.com> | 2014-05-11 13:55:20 +0200 |
commit | 89639a36f7412e1855d539dcca26f86e8daa4a0e (patch) | |
tree | 83f0445f72107835d1990efdca17783e40994eb3 | |
parent | 40ceac96c8d6cb46f02397ec9e8d8a90b6a04aa2 (diff) | |
download | playGraph-89639a36f7412e1855d539dcca26f86e8daa4a0e.tar.gz playGraph-89639a36f7412e1855d539dcca26f86e8daa4a0e.tar.bz2 playGraph-89639a36f7412e1855d539dcca26f86e8daa4a0e.zip |
refactor line drawing
-rw-r--r-- | app/index.html | 2 | ||||
-rw-r--r-- | app/js/app.js | 42 | ||||
-rw-r--r-- | app/js/directives.js | 12 |
3 files changed, 52 insertions, 4 deletions
diff --git a/app/index.html b/app/index.html index 8bb6176..3b7e019 100644 --- a/app/index.html +++ b/app/index.html @@ -42,7 +42,7 @@ <fieldset> <legend>TrackList :</legend> <ul> - <li data-ng-repeat="song in playseq | filter:{selected:true}">{{song.label}}</li> + <li data-ng-repeat="song in playseq">{{song.label}}</li> </ul> </fieldset> </div> diff --git a/app/js/app.js b/app/js/app.js index 504311b..c59b849 100644 --- a/app/js/app.js +++ b/app/js/app.js @@ -97,7 +97,47 @@ var dummyPoints= [ x: 420, y: 490, label:"piste f" - } + }, + { + x: 700, + y: 750, + label:"just beat it" + }, + { + x: 650, + y: 730, + label:"piste f" + }, + { + x: 900, + y: 850, + label:"piste f" + }, + { + x: 800, + y: 600, + label:"piste f" + }, + { + x: 850, + y: 610, + label:"piste f" + }, + { + x: 640, + y: 880, + label:"piste f" + }, + { + x: 900, + y: 350, + label:"piste f" + }, + { + x: 800, + y: 750, + label:"piste f" + }, ] diff --git a/app/js/directives.js b/app/js/directives.js index a367920..add724b 100644 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -53,7 +53,9 @@ app.directive('pgLine', function () { var points = Array(); // When the mouse is released, simplify it: - path.simplify(10); + path.simplify(1); + path.smooth(1); + for(var i=0; i<path._segments.length; i++) { @@ -64,14 +66,20 @@ app.directive('pgLine', function () { scope.$apply(); } + var lines = []; scope.$watch('list', function(newPoints) { console.log("update"); +angular.forEach(lines, function(line) { + line.remove(); + }); 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]); + var line = new paper.Path.Line(newPoints[i], newPoints[i+1]); line.strokeColor = 'red'; line.strokeWidth = 2; + lines.push(line) } } } |