舞台
4. 画布
4.2. 缩放画布
resizeCanvas()
示例:
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(0, 100, 200);
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}
舞台区显示的画布内容如下:
Description
Resizes the canvas to given width and height. The canvas will be cleared and draw will be called immediately, allowing the sketch to re-render itself in the resized canvas.
Syntax
resizeCanvas(w, h, [noRedraw])
Parameters
- wNumber:
width of the canvas
- hNumber:
height of the canvas
- noRedrawBoolean:
don't redraw the canvas immediately
(Optional)