Canvas.toTempFilePathSync
JS
string Canvas.toTempFilePathSync(Object object)Saves the current canvas content as a temporary file.
This is the synchronous version of Canvas.toTempFilePath. The webgl context can only be operated within the render loop (the 2d context is not subject to this restriction). Calling this API inside the requestAnimationFrame callback function ensures it runs within the render loop.
Parameters
- Object object: Input parameters. See the table below for details.
object properties:
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
| x | number | No | 0 | X coordinate of the top-left corner of the canvas region to capture |
| y | number | No | 0 | Y coordinate of the top-left corner of the canvas region to capture |
| width | number | No | canvas width | Width of the canvas region to capture |
| height | number | No | canvas height | Height of the canvas region to capture |
| destWidth | number | No | canvas width | Width of the output file; the captured region will be stretched or compressed to this value; only effective when fileType is jpg |
| destHeight | number | No | canvas height | Height of the output file; the captured region will be stretched or compressed to this value; only effective when fileType is jpg |
| fileType | string | No | png | Type of the output file; only png and jpg are supported |
| quality | number | No | 1.0 | Quality of the jpg image; only effective when fileType is jpg. Valid range is 0.0 (lowest) - 1.0 (highest), excluding 0. Values out of range are treated as 1.0 |
Return Value
- string: Temporary file path generated by canvas (local path)
