a port of the Processing Visualization Language


void setup() {

  size(320, 240);



void draw() {

  line(0, 0, width, height);

Description Defines the dimension of the display window in units of pixels. The size() function must 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.

Employ numeric values in the size() statement, and then use the built-in width and height variables inside your program when you need the dimensions of the display window.

Rendering graphics requires tradeoffs between speed, accuracy, and general usefulness of the available features. None of the renderers are perfect, so we provide multiple options so that you can decide what tradeoffs make the most sense for your project. We'd prefer all of them to have perfect visual accuracy, high performance, and support a wide range of features, but that's simply not possible.

Again, the size() method must be the first line of the code (or first item inside setup). Any code that appears before the size() command may run more than once, which can lead to confusing results.
size(width, height)
width int: width of the display window in units of pixels
height int: height of the display window in units of pixels
Returns None
Usage Web & Application

This reference is licensed under the CC BY-NC-SA 2.0 license:

Creative Commons License
Fork me on GitHub