FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Suggestions
   Software Suggestions
(Moderator: fry)
   width & height not assigned default size values
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: width & height not assigned default size values  (Read 646 times)
kevinP

Email
width & height not assigned default size values
« on: Jan 27th, 2004, 11:12pm »

From ref page:
"If size() is not called, the default size of the window is 100x100 pixels. The system variables width and height are set based on the parameters passed to the size() function."
 
I expected that if I didn't explicitly call size(), that the default values of "100" and "100" would also be passed to width and height.
 
There's no error msg. just an unexpected result.
 
-K
 

Kevin Pfeiffer
benelek

35160983516098 WWW Email
Re: width & height not assigned default size value
« Reply #1 on: Jan 27th, 2004, 11:54pm »

what's the unexpected result? are width and height given other values, or no values...?
 
kevinP

Email
Re: width & height not assigned default size value
« Reply #2 on: Feb 2nd, 2004, 9:56am »

on Jan 27th, 2004, 11:54pm, benelek wrote:
what's the unexpected result are width and height given other values, or no values...

 
(Sorry, I didn't see your question.)
 
The variables width and height are left empty...
 
Actually, I'm not sure -- as I recall in my code they were treated as if they had values of 0. I think this was the case because otherwise I should have had a null pointer error (or); instead I was getting the wrong positioning of something that relied on these.
 
-K
« Last Edit: Feb 2nd, 2004, 9:58am by kevinP »  

Kevin Pfeiffer
fry


WWW
Re: width & height not assigned default size value
« Reply #3 on: Feb 3rd, 2004, 12:12am »

if size() is not called, it gets called internally. so width & height should be set to 100 even if you don't use size() in your program. so if it's not doing that, then it'd be a bug. but it seems to be working ok, i just tried this program:
 
println(width);
 
and it printed 100 to the console, which is the expected behavior.
 
kevinP

Email
Re: width & height not assigned default size value
« Reply #4 on: Feb 3rd, 2004, 12:40am »

yep... that seems to be "user error" as I, too, get "100". I'll see if I can figure out what was happening (in case I can figure out in which sketch that was).
 
-K
 

Kevin Pfeiffer
kevinP

Email
Re: width & height not assigned default size value
« Reply #5 on: Feb 3rd, 2004, 9:09pm »

Okay, here's what I think happened:
Code:

// Based on REAS's Setup and Loop
 
void setup()
{
  size(200, 200);
  stroke(255);
  framerate(15);
}
 
float y;
 
void loop() {
  background(0);
  y = y - 1;
  if (y < 0) { y = height; }
  line(0, y, width, y);
}
 
// another block
{
  println(width);  // prints "0"
}

 
Shouldn't the last println() statement have thrown an error (ince this is not laid back Perl)?
 
-K
 

Kevin Pfeiffer
Pages: 1 

« Previous topic | Next topic »