浅谈利用缓存来优化HTML5 Canvas程序的性能

2020-04-24 18:59:39易采站长站整理

                }   
                this.useCache = useCache;   
                if(useCache){   
                    this.cache();   
                }   
            }   
  
            function getZ(num){   
                var rounded;   
                rounded = (0.5 + num) | 0;   
                // A double bitwise not.   
                rounded = ~~ (0.5 + num);   
                // Finally, a left bitwise shift.   
                rounded = (0.5 + num) << 0;   
  
                return rounded;   
            }   
  
            ball.prototype = {   
                paint:function(ctx){   
                    if(!this.useCache){   
                        ctx.save();   
                        var j=0;   
                        ctx.lineWidth = borderWidth;