舞台
3. cheatsheet
3.2. 启动设置
setup()
示例:
let a = 0;
function setup() {
background(0);
noStroke();
fill(102);
}
function draw() {
rect(a++ % width, 10, 2, 80);
}
舞台区显示的画布内容如下:
Description
The setup() function is called once when the program starts. It's used to define initial environment properties such as screen size and background color and to load media such as images and fonts as the program starts. There can only be one setup() function for each program and it shouldn't be called again after its initial execution.
Note: Variables declared within setup() are not accessible within other functions, including draw().
Syntax
setup()