[HELP][ Python vs Java ] size(width,height)

:coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee:

Why am I able to do this in Python

width = 700
height = 500

def setup():
    size (width,height)
    
def draw():
    rect(100,100,100,100)

but not in Java?

int width = 700;
int height = 500;

void setup(){
size (width,height); // cant do
}

void draw(){
 rect(100,100,100,100);
}

:coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee::snake::coffee:

IMO, Processing’s devs could easily make the pre-processor to move size(w, h); from setup() to settings() together w/ the dimension arguments when they’re variables. :face_with_monocle:

The pre-processor can move the 3rd renderer variable argument already: :flushed:

static final String RENDER = FX2D;

void setup() {
  size(800, 600, RENDER);
  noLoop();
}

So what’s the excuse for not moving the 1st & 2nd variable arguments as well!? :crazy_face:

1 Like

BUT
you can do like @GoToLoop mentioned

int mywidth=800, myheight=600;

void settings() {
  size(mywidth,myheight);
}

void setup() {
  println("canvas: "+width+" * "+height);
}

void draw() {
  background(200,200,0);
}
1 Like