GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Processing
  • Download
  • Reference
  • Environment
  • Libraries
  • Tools
  • Wiki
  • Tutorials
  • Examples
  • Books
  • Forum
  • Overview
  • People
  • Privacy

This view

  • Original page
  • New address

GeezerVison is showing processing.org — setup() / Reference

Reference+
Documentation→Reference→Structure

Name

setup()

Description

The setup() function is run once, when the program starts. It's used to define initial environment properties such as screen size 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.

If the sketch is a different dimension than the default, the size() function or fullScreen() function must be the first line in setup().

Note: Variables declared within setup() are not accessible within other functions, including draw().

Examples

  • int x = 0;
    
    void setup() {
      size(200, 200);
      background(0);
      noStroke();
      fill(102);
    }
    
    void draw() {
      rect(x, 10, 2, 80); 
      x = x + 1;
    }
    
  • int x = 0;
    
    void setup() {
      fullScreen();
      background(0);
      noStroke();
      fill(102);
    }
    
    void draw() {
      rect(x, height*0.2, 1, height*0.6); 
      x = x + 2;
    }
    

Syntax

  • setup()

Return

  • void

Related

  • size()
  • loop()
  • noLoop()
  • draw()
Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.