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); }
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.
size(w, h);
The pre-processor can move the 3rd renderer variable argument already:
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!?
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); }