diff --git a/animation.js b/animation.js index 51eb4a2..763c243 100644 --- a/animation.js +++ b/animation.js @@ -88,3 +88,107 @@ var semiBar = new ProgressBar.SemiCircle("#semi-container", { semiBar.animate(0.75, { duration: 2000 }); + +var points = [], + velocity2 = 5, // velocity squared + canvas = +document.getElementById('container'), + context = canvas.getContext('2d'), + radius = 5, + boundaryX = 200, + boundaryY = 200, + numberOfPoints = 30; + +init(); + +function init() { + // create points + for (var i = 0; i boundaryX-radius) { + resetVelocity(point, 'x', -1); + } else if(point.y < 0+radius) { + resetVelocity(point, 'y', 1); + } else if(point.y > boundaryY-radius) { + resetVelocity(point, 'y', -1); + } + } +} + +function animate() { + context.clearRect ( 0 , 0 , 200 , 200 ); + draw(); + requestAnimationFrame(animate); +}