Size(); not working for me / Processing 3.5

I’m preparing to deliver the Arduino CTC-101 program, which uses Processing to teach programming topics. One of the first modules introduces the size(); function, but it has no effect on my sketch.

The sketch is super-simple: line 1 sets the window size, line 2 draws an ellipse in the centre of the screen. While I do get my ellipse, my window remains 100 x 100 and the ellipse is centred in this 100 x 100 window. Additionally, I’ve tried several of the included example sketches (Array and Array 2D) - they also fail to resize the program window.

Running Processing 3.5 on a MacBook Pro under OSX 10.14.2.

Code:

size(400, 200);
ellipse(width/2, height/2, width-1, height-1);

While no errors are generated, the size() function does not resize the program window and it does not effect the width or height values. There is a message in the Console: “Could not parse -1 for —display”, which may be related.

Thanks for your help!

1 Like

there is a basic sketch structure,
example:

thanks to @Maxxxxz

for Processing 3.4 only
( on my Raspberry Pi not have a 3.5 available )

int diam=200;

void setup() {
  size(200,200);
  stroke(200,0,0);
  fill(0,200,0);
}

void draw() {
  background(200,200,0);
  ellipse(width/2,height/2,diam,diam);
}

void mousePressed() {
  diam=mouseX;
}

Hello, I can confirm this problem is happening for more than just you.
kll, your code should normally work, but in Processing 3.5 the size() function just does not seem to work. Fresh install as well.
sizeproblem

EDIT: utilizing settings() allows for proper sketch sizing. This is because in Processing 3.5, size() must now be in settings(). This should fix your problem.

1 Like

that are

Updated on January 20, 2019 05:42:15pm EST

but nothing mentioned like that.
until now the settings() was usable but only NEEDED
for eclipse? ( as the above reference states )

can not test on Raspberry Pi RASPBIAN linux until available,
but on win 7 64bit and right

int diam=200;

// used for eclipse and mandatory at rev 3.5 ???
void settings() {
   size(200,200); 
}

void setup() {
//  size(200,200);
  stroke(200,0,0);
  fill(0,200,0);
}

void draw() {
  background(200,200,0);
  ellipse(width/2,height/2,diam,diam);
}

void mousePressed() {
  diam=mouseX;
}

or just a bug what might be fixed, as so much documentation and
millions of user sketches would needed to be changed??

https://raw.githubusercontent.com/processing/processing/master/build/shared/revisions.txt
does not indicate that that is a wanted change!


would be nice if there could be a UPDATE STICKY here at the forum
that 3.5 now available?

also a news info / or a BLOG with the new features / at

could help


more play with it:

//  https://raw.githubusercontent.com/processing/processing/master/build/shared/revisions.txt

// here it is the update to : Processing 3.5
// starts with what i think is a bug that size() in setup() not work anymore
// only in settings() seems to work
// tested 21.1.2019 win7 64b // processing 3.5

int off=40, xw = 50, mywidth=300, myheight=300;

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

//void setup(){}

void draw() {
  background(200,200,0);
  //____________________________________________ play new features v3.5
  push();                                  // incl. Matrix && Style
  fill(200,0,0);
  translate(width/2,height/2);
  circle(0,0,xw);
  pop();
  square(width/2+off,height/2+off,xw);
}


The answer to this comes up relatively easily using google.

1 Like

Given PDE v3.5 is buggy, we should warn NOT to grab it instead! :bug:

I generally wait before grabbing a new version. Other times, I even skip a version entirely! :smiling_imp:

2 Likes

and very fast:

Processing 3.5.1

https://raw.githubusercontent.com/processing/processing/master/build/shared/revisions.txt

test win7 64b worked, but only with the second try,
see this:

( settings must be erased completely )

O̶h̶ ̶n̶o̶,̶ ̶s̶o̶ ̶I̶ ̶g̶u̶e̶s̶s̶ ̶t̶h̶i̶n̶g̶s̶ ̶h̶a̶v̶e̶n̶’̶t̶ ̶b̶e̶e̶n̶ ̶f̶i̶x̶e̶d̶ ̶c̶o̶m̶p̶l̶e̶t̶e̶l̶y̶.̶ ̶ ̶S̶e̶t̶t̶i̶n̶g̶s̶ ̶u̶s̶e̶d̶ ̶t̶o̶ ̶b̶e̶ ̶a̶ ̶g̶o̶o̶d̶ ̶p̶l̶a̶c̶e̶ ̶t̶o̶ ̶k̶e̶e̶p̶ ̶i̶n̶i̶t̶i̶a̶l̶i̶z̶a̶t̶i̶o̶n̶s̶ ̶t̶h̶a̶t̶ ̶y̶o̶u̶ ̶w̶a̶n̶t̶e̶d̶ ̶t̶o̶ ̶r̶u̶n̶ ̶b̶e̶f̶o̶r̶e̶ ̶s̶e̶t̶u̶p̶ ̶o̶r̶ ̶t̶o̶ ̶s̶t̶a̶r̶t̶ ̶a̶s̶y̶n̶c̶h̶r̶o̶n̶o̶u̶s̶ ̶p̶r̶o̶c̶e̶s̶s̶e̶s̶ ̶e̶a̶r̶l̶y̶.̶ ̶n̶o̶w̶ ̶i̶t̶ ̶c̶a̶n̶’̶t̶ ̶b̶e̶ ̶u̶s̶e̶d̶ ̶a̶t̶ ̶a̶l̶l̶ ̶u̶n̶l̶e̶s̶s̶ ̶i̶f̶ ̶i̶t̶’̶s̶ ̶u̶s̶e̶d̶ ̶t̶o̶ ̶a̶s̶s̶i̶g̶n̶ ̶a̶ ̶v̶a̶r̶i̶a̶b̶l̶e̶ ̶b̶a̶s̶e̶d̶ ̶s̶i̶z̶e̶.̶ ̶ ̶k̶l̶l̶ ̶l̶e̶t̶ ̶m̶e̶ ̶k̶n̶o̶w̶ ̶i̶f̶ ̶y̶o̶u̶ ̶a̶r̶e̶n̶’̶t̶ ̶g̶o̶n̶n̶a̶ ̶a̶d̶d̶ ̶t̶h̶i̶s̶ ̶t̶o̶ ̶p̶r̶o̶c̶e̶s̶s̶i̶n̶g̶’̶s̶ ̶i̶s̶s̶u̶e̶ ̶t̶r̶a̶c̶k̶e̶r̶ ̶o̶n̶ ̶g̶i̶t̶h̶u̶b̶,̶ ̶s̶o̶m̶e̶o̶n̶e̶ ̶s̶h̶o̶u̶l̶d̶ ̶p̶r̶o̶b̶a̶b̶l̶y̶ ̶r̶e̶p̶o̶r̶t̶ ̶i̶t̶ ̶s̶o̶o̶n̶.̶

Edit: I just looked into it and this is actually expected behavior
Processing 3.4 didn’t let you set size with setup when settings existed.
The reference states that settings is only used for the purpose of handling size early/dynamically and nothing more.

The error could be made better by telling you to delete the settings function but as far as it goes beginners won’t use the settings function unless forced to.

1 Like

Justs to summarize:

  1. If your sketch has no setup() and draw() (immediate mode)
    • you can call size() in 3.4 or in 3.51. In 3.5 this does not work due to a (fixed) bug:
  1. If your sketch has setup() and draw(), put size() in setup.
1 Like

Thanks! 3.5.2 seems to have corrected the problem and I appreciate the additional info.