舞台
4. 画布
4.4. 画布存为图像
saveCanvas()
示例:
function setup(){
createCanvas(100,100);
background('#ff0000');
saveCanvas('myCanvas', 'jpg');
};
舞台区显示的画布内容如下:
Description
Save the current canvas as an image. The browser will either save the file immediately, or prompt the user with a dialogue window.
Syntax
saveCanvas(selectedCanvas, [filename], [extension])
saveCanvas([filename], [extension])
Parameters
-
selectedCanvasp5.Element|HTMLCanvasElement:
a variable representing a specific html5 canvas (optional)
-
filenameString: (Optional)
-
extensionString:
'jpg' or 'png'
(Optional)