git @ Cat's Eye Technologies HTML5-Gewgaws / c2d9d53
Make percent to hold fixed configurable during init(). catseye 11 years ago
1 changed file(s) with 11 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
4343 var info;
4444 var numBalls = 200;
4545 var pctToHoldFixedCtrl;
46 var options;
47 var percentToHoldFixed;
4648
4749 var t = 0;
4850
49 this.init = function(c) {
51 this.init = function(c, opts) {
52 options = opts || {};
53 percentToHoldFixed = options.percentToHoldFixed || 10;
5054 canvas = c;
5155 ctx = canvas.getContext("2d");
5256 info = document.getElementById('info');
8892 balls[i].draw(ctx, t);
8993 }
9094
91 var numFixed = balls.length * (pctToHoldFixedCtrl.value / 100);
95 var p = percentToHoldFixed;
96 if (pctToHoldFixedCtrl) {
97 p = pctToHoldFixedCtrl.value;
98 }
99 var numFixed = balls.length * (p / 100);
92100 for (var i = 0; i < balls.length; i++) {
93101 if (i < numFixed) continue;
94102 balls[i].updateXY(balls[i].getPct(t));
95103 }
96
104
97105 t += 1;
98106 };
99107 };