diff options
author | Nicolas Bornand <nicolas74@gmail.com> | 2014-05-10 21:30:06 +0200 |
---|---|---|
committer | Nicolas Bornand <nicolas74@gmail.com> | 2014-05-10 21:30:06 +0200 |
commit | d4d6500ff3dd707c5bce7b162813efc273b1c3f4 (patch) | |
tree | a261cb68d4026a536bdb634c0620f6ddd4509f3f /app/js/services.js | |
parent | 12c891f855ad5f8b8bc8e30f306ec89642d70f58 (diff) | |
download | playGraph-d4d6500ff3dd707c5bce7b162813efc273b1c3f4.tar.gz playGraph-d4d6500ff3dd707c5bce7b162813efc273b1c3f4.tar.bz2 playGraph-d4d6500ff3dd707c5bce7b162813efc273b1c3f4.zip |
modify the way points are randomly chosen
Diffstat (limited to 'app/js/services.js')
-rw-r--r-- | app/js/services.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/app/js/services.js b/app/js/services.js index 8a2ced3..622717a 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -31,12 +31,14 @@ app.service('pathService', function() { //select the songs var selection = []; var tuning = .5; - songListCopy.sort(function(song){ - console.log(song.minDist, (tuning + tuning*Math.random())*song.minDist) - return (tuning + tuning*Math.random())*song.minDist;} - ); + angular.forEach(songListCopy, function(song){ + song.rand = (tuning + tuning*Math.random())*song.minDist; + }); + songListCopy.sort(function(a,b){return a.rand-b.rand;}); + //take from the sorted list util we reach the desired duration while(duration > 0 && songListCopy.length > 0){ var removed = songListCopy.splice(0, 1); + console.log(removed[0].minDist); selection.push(removed[0]); duration -= 10; } |