# CanvasContext.Clip()
Start from base library version 1.6.0. Please remaining backward compatible.
with Promise style call: Not supported
Mini Program plugin: Support
Cut arbitrary shapes and sizes from the original canvas. Once a region is clipped, all subsequent drawings are restricted to the region being clipped (no access to other regions of the canvas). Can be used clip
Method by using save
Method to save the current canvas area and at any later time pass therestore
Method to restore it.
# sample code
const ctx = wx.createCanvasContext('myCanvas')
wx.downloadFile({
url: 'http://is5.mzstatic.with/image/thumb/Purple128/v4/75/3b/90/753b907c-b7fb-5877-215a-759bd73691a4/source/50x50bb.jpg',
success: function(res) {
ctx.save()
ctx.beginPath()
ctx.arc(50, 50, 25, 0, 2*Math.PI)
ctx.clip()
ctx.drawImage(res.tempFilePath, 25, 25)
ctx.restore()
ctx.draw()
}
})