requestAnimationFrame 和 canvas 的 clip 一起时,会非常卡顿,
那如果想在小游戏中实现类似 scroll-view 这样的对象,只显示部分内容的裁剪效果,该怎么做呢
解决方案如下:
ctx.fillRect(x, y, width, height); // 遮罩层尺寸
ctx.globalCompositeOperation = “source-atop”;
// 中间加显示内容
ctx.globalCompositeOperation = “source-over”;