Change size commands number with a variable

Is it imposible to change the number of size with a variable

    void setup() {
      size(255, 200);


void setup() {
int something = 0
  size(something, 200);


  • Answer ✓

    Generally it's not recommended due to JS Mode.
    Anyways, if you wanna go for it, better use constants rather than variables for it:

    // change-size-commands-number-with-a-variable
    static final int W = 300, H = 200;
    void setup() {
      size(W, H);
  • Actually, it is simpler to just set the values in the size() call, and use width and height variables. And recommended, because Processing can parse the numerical values, not the constants, to find out the size of the canvas after export.

Sign In or Register to comment.