How to anti-alias clip() edges in html5 canvas under Chrome Windows?

后端 未结 5 1739
故里飘歌
故里飘歌 2020-12-02 20:20

I\'m using the clip() function on a canvas.

Results: \"using

As you c

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 21:11

    I came across the same issue with Chrome and clip().

    In my circumstance I achieved better browser compatibility by setting the canvas globalCompositeOperation.

    context.globalCompositeOperation = 'source-atop';
    

    So draw your shape, a circle in this case. Then switch to 'source-atop' and draw your kitten image.

    Note, this is a quick fix for basic drawing and assumes a blank canvas. Previous canvas drawing will affect your clip.

提交回复
热议问题