We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Control the size of the display window !
Page Index Toggle Pages: 1
Control the size of the display window ?! (Read 576 times)
Control the size of the display window ?!
Sep 11th, 2008, 5:58pm
 
Hello,
a little post to know if it's possible that the x and y coordinates of the size() function could be variables.

whatever the answer is,
is it possible to control the size of the display window ?

thanks indeed
Re: Control the size of the display window ?!
Reply #1 - Sep 12th, 2008, 3:03pm
 
Parameters of size() are not x, y coordinates but width and height...
Reference advises not to compute these parameters, ie. just put literal constants there. You can put variables, but then PDE won't be able to find the size of the applet when exporting, and there might be other side effects.
Now search resize on this forum, you will find a couple of related recent messages. Although I am not sure if that's what you mean by "control the size".
Re: Control the size of the display window ?!
Reply #2 - Sep 12th, 2008, 4:00pm
 
If at some point you need to set a new window-size, this code works:

Code:

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

void draw()
{
background(128);
ellipse(random(width),random(height),random(width),random(height));
}

void setNewSize(int w, int h)
{
frame.setSize(w,h);
size(w,h);
}

void mousePressed()
{
setNewSize(width*2,width*2);
}


And this, allows users to resize their window themselves:
Code:

void setup()
{
size(300,200);
fill(255);
stroke(0);
frame.setResizable(true);
}

void draw()
{
background(128);
ellipse(random(width),random(height),random(width),random(height));
}
Re: Control the size of the display window ?!
Reply #3 - Sep 12th, 2008, 8:52pm
 
but don't mix frame.setSize() and the size() command... there's no need to call size() because setSize() will take care of resizing the window *and* the drawing surface (and updating the width/height variables). (if that's not working in 0148, please file a bug.)
Re: Control the size of the display window ?!
Reply #4 - Nov 24th, 2008, 8:17pm
 
this doesn't seem to work with the lastest version of processing in openGL.

the window resizes ok, but the drawing area stays at the bottom left of the frame (when mazimised) and is not resized with the actual frame.

it works fine it JAVA2D. but not in OPENGL.


if size(width,height); is called on frame resize i get the following :
Exception in thread "Animation Thread" processing.core.PApplet$RendererChangeException
at processing.core.PApplet.size(PApplet.java:984)
at processing.core.PApplet.size(PApplet.java:925)processing.core.PApplet$RendererCh
angeException

is this a bug ? or is this a limitation due to OPENGL ?

cheers !
Re: Control the size of the display window ?!
Reply #5 - Jan 5th, 2009, 11:12am
 
Question is old, but I found it back when searching something... A recent solution was given, I cross-reference to ease further searches: Re: OpenGL canvas does not resize when embeded
Page Index Toggle Pages: 1