CanvasContext.toTempFilePath
Export the canvas to an image and return the file path
Parameters
It is Object type.
Property | Type | Required | 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 | - | Callback function upon call success. |
fail | Function | No | - | Callback function upon call failure. |
complete | Function | No | - | Callback function upon call completion (to be executed upon either call success or failure). |
Sample Code
copy
//.js
const ctx = my.createCanvasContext('awesomeCanvas');
ctx.toTempFilePath({
success() {},
});