CanvasContext.toTempFilePath

Export the canvas to an image and return the file path

Parameters

It is Object type.

FieldTypeMandatoryDefault ValueDescription
xNumberNo0The start point of x coordinate of canvas
yNumberNo0The start point of y coordinate of canvas
widthNumberNoBy default is the width of canvasThe width of canvas
heightNumberNoBy default is the height of canvasThe height of canvas
destWidthNumberNoEquals to width by defaultThe dest width of exported image
destHeightNumberNoEquals to height by defaultThe 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-The success callback function
failFunctionNo-The fail callback function
completeFunctionNo-The complete callback function

Sample Code

copy
//.js
const ctx = my.createCanvasContext('awesomeCanvas');
ctx.toTempFilePath({
  success() {},
});