Toggle navigation
Sign Up
Log In
Explore
Works
Folders
Tools
Collections
Artists
Groups
Groups
Topics
Tasks
Tasks
Jobs
Teams
Jobs
Recommendation
More Effects...
JS
function load() { Canvas = document.getElementById('Canvas'); Canvas.width = document.body.clientWidth*0.97; Canvas.height = document.body.clientHeight*0.97; ctx = Canvas.getContext('2d'); mousePower = 1000; motionBlur = (90/100); numberOfParticles = 2000; frictionFactor = (960/1000); randomFactor = (2/10); randomFactorNonParticle = (0/10); useText = false; textToUse = ""; colorPump = true; colorThreshold = 50; colorPumpFactor = 80; gleam = true; grayScale = false; drawNonParticles = false; overlayScreen = true; speed = 0.2; rotate = false; startInCircleOfRadius = [true,100]; isPaused = false; drawOptionBox(); Magnets = [new magnet(3.5,null,null,[0,0])] //Magnets = []; //for (var i=1;i<5;i++) {Magnets[i] = getRandomMovingMagnet();} Repulsors = [new repulsor(35000,null,null,[0,0])]; //Repulsors = []; //for (var i=1;i<100;i++) {Repulsors[i] = getRandomMovingRepulsor();} particles = []; for (var i=0;i
Mouse Power
" + "
Motion Blur (0-1)
" + "
Friction (0-1)
" + "
Speed (0-1)
" + "
Random Factor
" + "
Text To Use
" + "
Color Pump
" + "
Gleam
" + "
GrayScale
" + "
Overlay Screen
" + "
Rotate
" + "
"; document.body.appendChild(optionsPane); } document.body.appendChild(op); } function discard() { document.body.removeChild(optionsPane); } function saveChanges() { numberOfParticles = getField('nop'); mousePower = getField('mp'); motionBlur = getField('mb'); frictionFactor = getField('fr'); speed = getField('sp'); randomFactor = getFieldString('rf'); textToUse = getFieldString('tx'); useText = (textToUse != "")?true:false; colorPump = getCheck('cp'); gleam = getCheck('gl'); grayScale = getCheck('gr'); overlayScreen = getCheck('ov'); rotate = getCheck('ro'); reload(); } function get(x) { return (x)?"checked":""; } function getField(f) { return parseFloat(document.getElementById(f).value); } function getFieldString(f) { return document.getElementById(f).value; } function getCheck(f) { return document.getElementById(f).checked; } function particle(color,vector,x,y) { this.color = color; this.vector = vector; this.x = x; this.y = y; this.size = 4; this.t = 0; this.drawSelf = function (increment) { this.t+=increment; if ((this.x > Canvas.width+500) || (this.x < -500)) { this.vector = [this.vector[0]*(-1.1),this.vector[1]*(1.1)]; } if ((this.y > Canvas.height+500) || (this.y < -500)) { this.vector = [this.vector[0]*(1.1),this.vector[1]*(-1.1)]; } this.x+=this.vector[0]*increment; this.y+=this.vector[1]*increment; this.vector = [this.vector[0]*frictionFactor,this.vector[1]*frictionFactor]; for (var i=0;i
0) { var x = this.x%Canvas.width; } else { var x = (Canvas.width+this.x); } if (this.y > 0) { var y = this.y%Canvas.height; } else { var y = (Canvas.height+this.y); } } else { var x = this.x; var y = this.y; } if (useText) { ctx.fillText(textToUse,x,y); } else { ctx.fillRect(x,y,this.size,this.size); } } } function getRandomParticle() { var col = getRandomColor(); if (startInCircleOfRadius[0]) { var r = startInCircleOfRadius[1]; var theta = ((Math.random()*359)*(Math.PI/180)); var x = r*Math.sin(theta) + (Canvas.width/2); var y = r*Math.cos(theta) + (Canvas.height/2); var vect = [0,0]; } else { var vX = Math.ceil(Math.random()*20); var vY = Math.ceil(Math.random()*20); var vect = [vX,vY]; var x = Math.ceil(Math.random()*Canvas.width); var y = Math.ceil(Math.random()*Canvas.height); } return new particle(col,vect,x,y); } function getRandomColor() { if (grayScale) { var r = Math.ceil(Math.random()*255); var g = r; var b = r; } else { var r = Math.ceil(Math.random()*255); var g = Math.ceil(Math.random()*255); var b = Math.ceil(Math.random()*255); } // colorPump - Brian Zhang (c) 2010 // modified - Zac Connelly (c) 2010 if (colorPump) { if ((r > (g+colorThreshold)) || (r > (b + colorThreshold))) { r+=colorPumpFactor; } else if ((g > (r + colorThreshold)) || (g > (b + colorThreshold))) { g+=colorPumpFactor; } else if ((b > (r + colorThreshold)) || (b > (g + colorThreshold))) { b+=colorPumpFactor; } } return "rgba(" + r + "," + g + "," + b + ",1)"; } function magnet(strength,x,y,vector) { if (x == undefined) { this.x = Canvas.width/2; } else { this.x = x; } if (y == undefined) { this.y = Canvas.height/2; } else { this.y = y; } this.strength = strength; this.vector = vector; this.counter = 0; this.drawSelf = function() { if (drawNonParticles) { ctx.fillStyle = "white"; ctx.fillRect(this.x,this.y,10,10); } } this.applyForce = function(particle) { this.counter++; if ((this.x > Canvas.width) || (this.x < 0)) { this.vector = [this.vector[0]*(-1),this.vector[1]]; this.x+=this.vector[0]*2; this.y+=this.vector[1]*2; } if ((this.y > Canvas.height) || (this.y < 0)) { this.vector = [this.vector[0],this.vector[1]*(-1)]; this.x+=this.vector[0]*2; this.y+=this.vector[1]*2; } if (this.counter == particles.length) { this.counter = 0; this.vector[0] = this.vector[0]+((Math.random()-0.5)*(randomFactorNonParticle/10)); this.vector[1] = this.vector[1]+((Math.random()-0.5)*(randomFactorNonParticle/10)); this.x+=this.vector[0]; this.y+=this.vector[1]; this.drawSelf(); } var distanceSquared = Math.pow((particle.x - this.x),2)+Math.pow((particle.y - this.y),2); var factor = (this.strength/Math.sqrt(distanceSquared)); particle.vector = [particle.vector[0]+((this.x-particle.x)*factor),particle.vector[1]+((this.y-particle.y)*factor)]; } } function getRandomMagnet() { var str = Math.random()*4+1; var x = Math.random()*Canvas.width; var y = Math.random()*Canvas.height; return new magnet(str,x,y); } function getRandomWeakMagnet() { var str = Math.random()+0.5; var x = Math.random()*Canvas.width; var y = Math.random()*Canvas.height; return new magnet(str,x,y); } function getRandomMovingMagnet() { var str = (Math.random()-0.5)*5+3; var x = Math.random()*Canvas.width; var y = Math.random()*Canvas.height; var vX = (Math.random()-0.5)*20; var vY = (Math.random()-0.5)*20; return new magnet(str,x,y,[vX,vY]); } function repulsor(strength,x,y,vector) { if (x == undefined) { this.x = Canvas.width/2; } else { this.x = x; } if (y == undefined) { this.y = Canvas.height/2; } else { this.y = y; } this.strength = strength; this.counter = 0; this.vector = vector; this.drawSelf = function() { if (drawNonParticles) { ctx.fillStyle = "Blue"; ctx.fillRect(this.x,this.y,10,10); } } this.applyForce = function(particle) { this.counter++; if ((this.x > Canvas.width) || (this.x < 0)) { this.vector = [this.vector[0]*(-1),this.vector[1]]; this.x+=this.vector[0]*2; this.y+=this.vector[1]*2; } if ((this.y > Canvas.height) || (this.y < 0)) { this.vector = [this.vector[0],this.vector[1]*(-1)]; this.x+=this.vector[0]*2; this.y+=this.vector[1]*2; } if (this.counter == particles.length) { this.counter = 0; this.vector[0] = this.vector[0]+((Math.random()-0.5)*(randomFactorNonParticle/10)); this.vector[1] = this.vector[1]+((Math.random()-0.5)*(randomFactorNonParticle/10)); this.x+=this.vector[0]; this.y+=this.vector[1]; this.drawSelf(); } var distanceSquared = Math.pow((particle.x - this.x),2)+Math.pow((particle.y - this.y),2); var factor = this.strength/Math.pow(distanceSquared,2); particle.vector = [particle.vector[0]+((particle.x-this.x)*factor),particle.vector[1]+((particle.y-this.y)*factor)]; } } function getRandomRepulsor() { var str = Math.random()*5000+2500; var x = Math.random()*Canvas.width; var y = Math.random()*Canvas.height; return new repulsor(str,x,y,[0,0]); } function getRandomWeakRepulsor() { var str = Math.random()*500+250; var x = Math.random()*Canvas.width; var y = Math.random()*Canvas.height; return new repulsor(str,x,y); } function getRandomMovingRepulsor() { var str = Math.random()*7000+4000; var vX = (Math.random()-0.5)*10//*20; var vY = (Math.random()-0.5)*10//20; return new repulsor(str,null,null,[vX,vY]); } function particleGun(color,vector,x,y,useRandCol) { this.color = color; this.vector = vector; this.x = x; this.y = y; this.fire = function() { if (useRandCol) { particles[particles.length] = new particle(getRandomColor(),this.vector,this.x,this.y); } else { particles[particles.length] = new particle(this.color,this.vector,this.x,this.y); } } } function mclick(e) { var mx = e.offsetX; var my = e.offsetY; for (var i=0;i
3) factor = 3; particles[i].vector = [particles[i].vector[0]+((particles[i].x-mx)*factor),particles[i].vector[1]+((particles[i].y-my)*factor)]; } } function toColor(r,g,b) { var rgb = "rgb(" + r + "," + g + "," + b + ")"; return rgb; } function toRgb(color) { var r = color.substring(5,color.indexOf(",")); var color = color.substring(color.indexOf(",")+1,color.length); var g = color.substring(0,color.indexOf(",")); var color = color.substring(color.indexOf(",")+1,color.length); var b = color.substring(0,color.length-1); var rgb = [parseFloat(r),parseFloat(g),parseFloat(b)]; return rgb; } function kpress(e) { if ((e.keyCode == 32) && (!document.getElementById('options'))) { if (isPaused) { document.getElementById('canvasImage').style.display = 'none'; document.getElementById('Canvas').style.display = 'block'; execution = setInterval("ctx.fillStyle = 'rgba(0,0,0," + motionBlur + ")';ctx.fillRect(0,0," + Canvas.width + "," + Canvas.height + ");for(var i=0;i
CSS
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