替换javascript上下文.带图像的圆弧

Replace javascript context.arc with an image

本文关键字:图像 javascript 上下文 替换      更新时间:2023-09-26

我有这个代码在画布上画一个圆。

        create: function(){
            context.beginPath();
            context.arc(this.x, this.y, this.radius, 0, Math.PI * 2, false);
            context.fill();
        }

是否可以用图像代替圆圈?

看起来像HTML5 Canvas - Fill circle with image.

MDN上有一个很好的剪辑示例:https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Compositing#A_clip_example