what are the differences between setup() and settings()?

It's in the API, but the explanation there is too vague for me. I don't get it. Can someone elucidate?


  • Answer ✓
    • Both settings() & setup() run once only each.
    • settings() is for choosing the renderer & smoothness of the sketch's main canvas.
    • While setup() is for other initialization for preparing the sketch before draw() starts.
    • Processing 3's IDE (PDE) can automatically create settings() and move the 1st size() & smooth() found into settings().
  • edited April 2018 Answer ✓


    Most of the time you don't need settings. The main reason I find using settings is if I want to initialize a sketch based on the same of an image. Something like this:

    PImage img;
    void settings(){
    void setup(){
    void draw(){

    There are some other situations you might need to use settings (GH Wiki reports settings() to be explicitly implemented when using Eclipse and the ADT plugin). I would say you are safe omitting settings().


  • edited April 2018 Answer ✓

    From the current reference:

    The settings() function is new with Processing 3.0. It's not needed in most sketches. It's only useful when it's absolutely necessary to define the parameters to size() with a variable. Alternately, the settings() function is necessary when using Processing code outside of the Processing Development Environment (PDE). For example, when using the Eclipse code editor, it's necessary to use settings() to define the size() and smooth() values for a sketch..

    The settings() method runs before the sketch has been set up, so other Processing functions cannot be used at that point. For instance, do not use loadImage() inside settings(). The settings() method runs "passively" to set a few variables, compared to the setup() command that call commands in the Processing API.

    Settings is rarely used. One of the most common use cases for settings() is, as @kfrajer mentions, to establish dynamic width and height parameters for size(). If you try to do this in setup() you get an error.

Sign In or Register to comment.