Toggle navigation
Sign Up
Log In
Explore
Works
Folders
Tools
Collections
Artists
Groups
Groups
Topics
Tasks
Tasks
Jobs
Teams
Jobs
Recommendation
More Effects...
JS
window.addEventListener("resize", resizeCanvas, false); window.addEventListener("DOMContentLoaded", onLoad, false); window.requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) { window.setTimeout(callback, 1000/60); }; var canvas, ctx, w, h, particles = [], probability = 0.04, xPoint, yPoint; var img = new Image(); img.src = "img/fire.png"; function onLoad() { canvas = document.getElementById("canvas"); ctx = canvas.getContext("2d"); resizeCanvas(); window.requestAnimationFrame(updateWorld); } // fin de onLoad(); function resizeCanvas() { if (!!canvas) { w = canvas.width = window.innerWidth; h = canvas.height = window.innerHeight; } } // fin de resizeCanvas(); function updateWorld() { update(); paint(); window.requestAnimationFrame(updateWorld); } // fin de update(); function update() { if (particles.length < 500 && Math.random() < probability) { createFirework(); } var alive = []; for (var i=0; i
vy) { particle.vy = particle.vy>0 ? vy: -vy; } particles.push(particle); } } // fin de createParticles(); function Particle() { this.w = this.h = Math.random()*4+1; // Position this.x = xPoint-this.w/2; this.y = yPoint-this.h/2; // Velocidades x e y entre -5 y +5 this.vx = (Math.random()-0.5)*10; this.vy = (Math.random()-0.5)*10; // Tiempo de vida this.alpha = Math.random()*.5+.5; // color this.color; } // fin de Particle(); Particle.prototype = { gravity: 0.05, move: function () { this.x += this.vx; this.vy += this.gravity; this.y += this.vy; this.alpha -= 0.01; if (this.x <= -this.w || this.x >= screen.width || this.y >= screen.height || this.alpha <= 0) { return false; } return true; }, draw: function (c) { c.save(); c.beginPath(); c.translate(this.x+this.w/2, this.y+this.h/2); c.arc(0, 0, this.w, 0, Math.PI*2); c.fillStyle = this.color; c.globalAlpha = this.alpha; c.closePath(); c.fill(); c.restore(); } } // fin de Particle.prototype;
CSS
body { background-color: #000; overflow: hidden; margin: 0; } canvas { background-color: #000; }
HTML
No tiene habilitado JavaScript. Debería habilitarlo para poder disfrutar al completo de los contenidos de esta página.
Tu navegador no soporta el elemento
canvas
de HTML5.
Join Effecthub.com
Working with Global Gaming Artists and Developers!
Login
Sign Up
Or Login with Your Email Address:
Email
Password
Remember
Or Sign Up with Your Email Address:
Your Email
This field must contain a valid email
Set Password
Password should be at least 1 character
Stay informed via email