diff --git a/Animation/Animation.js b/Animation/Animation.js index dc5c5f6..0e83320 100644 --- a/Animation/Animation.js +++ b/Animation/Animation.js @@ -14,6 +14,16 @@ /** @namespace jsOMS.Animation.Animation */ jsOMS.Autoloader.defineNamespace('jsOMS.Animation.Animation'); + /** + * requestAnimationFrame wrapper + * + * @return {function} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Animation.requestAnimationFrame = (function () { return window.requestAnimationFrame || diff --git a/Animation/Canvas/Particle.js b/Animation/Canvas/Particle.js index 911275f..2b714f9 100644 --- a/Animation/Canvas/Particle.js +++ b/Animation/Canvas/Particle.js @@ -32,33 +32,101 @@ this.color = {r: 255, g: 255, b: 255, a: 0.5}; }; + /** + * Get particle radius + * + * @return {int} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Canvas.Particle.prototype.getRadius = function () { return this.radius; }; + /** + * Set particle position + * + * @param {int} posX Position x + * @param {int} posY Position y + * + * @return {void} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Canvas.Particle.prototype.setPosition = function (posX, posY) { this.posX = posX; this.posY = posY; }; + /** + * Get position + * + * @return {Object} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Canvas.Particle.prototype.getPosition = function () { return {x: this.posX, y: this.posY}; }; + /** + * Set particle velocity + * + * @param {float} velX Velocity x + * @param {float} velY Velocity y + * + * @return {void} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Canvas.Particle.prototype.setVelocity = function (velX, velY) { this.velX = velX; this.velY = velY; }; + /** + * Get velocity + * + * @return {Object} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Canvas.Particle.prototype.getVelocity = function () { return {x: this.velX, y: this.velY}; }; + /** + * Draw particle to canvas + * + * @param {object} ctx Canvas + * + * @return {void} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Canvas.Particle.prototype.draw = function (ctx) { ctx.fillStyle = 'rgba(' + this.color.r + ', ' + this.color.g + ', ' + this.color.b + ', ' + this.color.a + ')'; diff --git a/Animation/Canvas/ParticleAnimation.js b/Animation/Canvas/ParticleAnimation.js index 3234ae9..d3f54a9 100644 --- a/Animation/Canvas/ParticleAnimation.js +++ b/Animation/Canvas/ParticleAnimation.js @@ -1,5 +1,5 @@ /** - * Particle class. + * Particle animation class. * * @author OMS Development Team * @author Dennis Eichhorn @@ -15,6 +15,9 @@ jsOMS.Autoloader.defineNamespace('jsOMS.Animation.Canvas'); /** + * + * @param {object} canvas Canvas + * * @constructor * * @since 1.0.0 @@ -45,6 +48,18 @@ } }; + /** + * Draw everything + * + * @param {object} self Object reference for self invoke + * + * @return {void} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Canvas.ParticleAnimation.prototype.draw = function (self) { self = typeof self !== 'undefined' ? self : this; @@ -63,11 +78,31 @@ }); }; + /** + * Invalidate/clean canvas + * + * @return {void} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Canvas.ParticleAnimation.prototype.invalidate = function () { this.ctx.clearRect(0, 0, this.width, this.height); }; + /** + * Update particle + * + * @return {void} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Canvas.ParticleAnimation.prototype.updateParticles = function () { let particle, @@ -107,6 +142,19 @@ } }; + /** + * Handle distance between particles + * + * @param {Particle} p1 Particle + * @param {Particle} p2 Particle + * + * @return {void} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Canvas.ParticleAnimation.prototype.updateDistance = function (p1, p2) { let pos1 = p1.getPosition(),