I'm looking to add a snow animation using JavaScript. I currently have it running at 200ms which is decent but not smooth enough. Would changing the interval to 20ms make it more fluid, or would it be inefficient and strain the CPU?
window.setInterval(snow.draw, 20);
Check out an example here
snow = {
count: 60,
delay: 20,
flutter: 0.2,
wind: 1.0,
w1: 1,
minSpeed: 0.3,
maxSpeed: 4,
cv: null,
flakes: [],
toggle: function() {
if(window.snowtimer)
snow.stop();
else
snow.start();
},
resize: function() {
snow.cv.width = innerWidth;
snow.cv.height = innerHeight;
snow.gt = snow.ct.createLinearGradient(0,0,0,snow.cv.height);
snow.gt.addColorStop(0.0, '#6666ff');
snow.gt.addColorStop(1.0, '#ffffff');
snow.ct.fillStyle = snow.gt;
},
// Additional functions go here...
};