CanvasContext.drawImage

Draw the image, and the image keeps the original size information.

Parameters

It is Object type.

FieldTypeDescription
imageResourceStringThe image resource, only online cdn resouce and offline resource are supported. The online cdn resource should contains Access-Control-Allow-Origin: * in header
xNumberThe x coordinate of left-upper corner of image
yNumberThe y coordinate of left-upper corner of image
widthNumberThe width of the image
heightNumberThe height of the image

Sample Code

copy
//.js
const ctx = my.createCanvasContext('awesomeCanvas')
ctx.drawImage('https://img.alicdn.com/tfs/TB1GvVMj2BNTKJjy0FdXXcPpVXa-520-280.jpg', 2, 2, 250, 80)
ctx.draw()