CanvasContext.drawImage
Draw the image, and the image keeps the original size information.
Parameters
It is Object type.
Field | Type | Description |
imageResource | String | The image resource, only online cdn resouce and offline resource are supported. The online cdn resource should contains Access-Control-Allow-Origin: * in header |
x | Number | The x coordinate of left-upper corner of image |
y | Number | The y coordinate of left-upper corner of image |
width | Number | The width of the image |
height | Number | The 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()