CanvasContext.toTempFilePath
Export the canvas to an image and return the file path
Parameters
It is Object type.
Field | Type | Mandatory | Default Value | Description |
x | Number | No | 0 | The start point of x coordinate of canvas |
y | Number | No | 0 | The start point of y coordinate of canvas |
width | Number | No | By default is the width of canvas | The width of canvas |
height | Number | No | By default is the height of canvas | The height of canvas |
destWidth | Number | No | Equals to width by default | The dest width of exported image |
destHeight | Number | No | Equals to height by default | The dest height of exported image |
fileType | String | No | png | The type of the picture, png or jpg |
quality | Number | No | - | The quality of the image corresponding to the data URL when the image format is JPG. Values range from 0 to 1, and will default to 1 if exceeded. Other image formats this parameter is ignored |
success | Function | No | - | The success callback function |
fail | Function | No | - | The fail callback function |
complete | Function | No | - | The complete callback function |
Sample Code
copy
//.js
const ctx = my.createCanvasContext('awesomeCanvas');
ctx.toTempFilePath({
success() {},
});