Toggle navigation
Sign Up
Log In
Explore
Works
Folders
Tools
Collections
Artists
Groups
Groups
Topics
Tasks
Tasks
Jobs
Teams
Jobs
Recommendation
More Effects...
JS
// Try messing around with the variables in the newParticle function to change the effect var newParticle = function(){ //The Particle constructor accepts a particlesystem, life time in ms and a config object new Particle(ps,1500,{ //Linear is just a method of the particle system which animates from parameter 1 to parameter 2. //You could also input static values for the variables in the config object //or why not extend the particle system with your own method for non linear animation x: ps.linear(ps.width/2,Math.random()*ps.width), y: ps.accelerating(ps.height/2,Math.random()*-0.1-0.5,0.0009), size: ps.linear(60,0), //radialGradientLinearHSLA does like linear animate from parameter 1 to parameter 2 //but the parameters each contain 2 hsla colors for the gradient // [h1,s1,l1,a1,h2,s2,l2,a2] fillStyle: ps.radialGradientLinearHSLA([20,90,70,0,40,60,50,0],[1440,100,70,1,1430,100,50,0]) }); } //The newParticle function below will produce snow //Uncomment it to test it /* var newParticle = function(){ var x = Math.random()*600 new Particle(ps,5000,{ x: ps.linear(x,x), y: ps.linear(0,Math.random()*ps.height/2+ps.height/2), size: ps.linear(Math.random()*15+5,5), fillStyle: ps.radialGradientLinearHSLA([0,0,100,1,0,0,100,0],[0,0,100,0,0,0,100,0]) }); } */ window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame; Ps = function(canvas){ this.ctx = canvas.getContext('2d'); this.width = canvas.width; this.height = canvas.height; this.stack = []; this.time = performance.now(); this.steps = 0 this.pause = false this.ctx.globalCompositeOperation = 'lighter'; this.draw = function(){ this.ctx.setTransform(1,0,0,1,0,0); this.ctx.clearRect(0,0,this.width,this.height); for(var i=0;i
255){ a[i] = 255; }else if((i+1)%4===0&&a[i]>1){ a[i] = 1 } } grd = ps.ctx.createRadialGradient(0.5,0.5,0,0.5,0.5,0.5); grd.addColorStop(0,'rgba('+a[0].toFixed()+','+a[1].toFixed()+','+a[2].toFixed()+','+a[3].toFixed(5)+')'); grd.addColorStop(1,'rgba('+a[4].toFixed()+','+a[5].toFixed()+','+a[6].toFixed()+','+a[7].toFixed(5)+')'); return grd; } }; }; }; this.radialGradientLinearHSLA = function(start,end){ return function(life,ps){ var a = start; var b = []; for(var i=0;i
CSS
body{ background: #222; margin: 0; } canvas{ display: block; margin: 20px auto 0 auto; background: #111; border-radius: 10px; border: 1px solid #333; }
HTML
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