 |
 |
 |
 |
Name |
|
size() |
 |
|
|
Examples |
|
void setup() {
size(320, 240);
background(153);
}
void draw() {
line(0, 0, width, height);
}
|
|
void setup() {
size(320, 240, P3D);
background(153);
}
void draw() {
line(0, 0, 0, width, height, -200);
}
|
|
import processing.opengl.*;
void setup() {
size(screen.width, screen.height, OPENGL);
background(153);
}
void draw() {
line(0, 0, 0, width, height, -200);
}
|
|
|
Description |
|
Defines the dimension of the display window in units of pixels. The size() function should be the first line in setup(). If size() is not called, the default size of the window is 100x100 pixels. The system variables width and height are set by the parameters passed to the size() function. Using variables as the parameters to size() is strongly discouraged and can create problems. Use the width and height variables if you need to know the dimensions of the display window within your program.
The MODE parameters selects which rendering engine to use. For example, if you will be drawing 3D shapes for the web use P3D, if you want to export a program with OpenGL graphics accelleration use OPENGL. A brief description of the 4 different renderers follows:
P2D (Processing 2D) - 2D renderer supporting Java 1.1 export (NOT CURRENTLY IMPLEMENTED)
P3D (Processing 3D) - Fast 3D renderer for the web
JAVA2D - The default renderer, higher quality in general, but slower than P2D
OPENGL - Interface with OpenGL hardware accelleration to increase speed if an OpenGL graphics card is installed. |
 |
|
|
Syntax |
|
size(width, height)
size(width, height, MODE)
|
 |
|
|
Parameters |
|
width |
|
int: width of the display window in units of pixels
|
height |
|
int: height of the display window in units of pixels
|
MODE |
|
Either P2D, P3D, JAVA2D, or OPENGL
|
|
 |
|
|
Returns |
|
None |
 |
|
|
Usage |
|
Web & Application |
 |
|
|
|
|