function createSound(name, url) { var deferred = Q.defer(); soundManager.createSound({ id: name, url: url, autoLoad: true, onload: function() { deferred.resolve(this); } }); return deferred.promise; } function sign(x) { return x > 0 ? 1 : x < 0 ? -1 : 0; } function lerp(from, to, p) { return to * p + from * (1 - p); } function ease(v) { return v * v * (3 - 2 * v); } function easeOutExpo(t, b, c, d) { return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; } function color(r,g,b,a) { return 'rgba('+r+','+g+','+b+','+a.toFixed(5)+')'; }