CanvasContext.toTempFilePath

Export the canvas to an image and return the file path

Parameters

It is Object type.

PropertyType

Required

Default ValueDescription
xNumberNo0The start point of x coordinate of canvas.
yNumberNo0The start point of y coordinate of canvas.
widthNumberNoBy default is the width of canvas.The width of canvas.
heightNumberNoBy default is the height of canvas.The height of canvas.
destWidthNumberNoEquals to width by default.The dest width of exported image.
destHeightNumberNoEquals to height by default.The dest height of exported image.
fileTypeStringNopngThe type of the picture, png or jpg.
qualityNumberNo-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.
successFunctionNo -Callback function upon call success.
failFunctionNo-Callback function upon call failure.
completeFunctionNo-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() {},
});