How do you add/subtract width and height on resize no matter how they resize/ check if resize

edited November 2016 in How To...

Hello, I am Try to make it to when people resize the window/surface it add or subtracts height and width no matter how they resize it. Similar to the game window in TERA.

I Have used if statements checking the current size to the change but it simply did not work.

Tagged:

Answers

  • I don't believe this can be done... when you check width and height variables, it is looking for the canvas

  • I never understood what you asked, but to resize the window in code, use surface.setSize(width, height)

  • See also the settings() reference page:

    The settings() function is new with Processing 3.0. It's not needed in most sketches. It's only useful when it's absolutely necessary to define the parameters to size() with a variable.

  • @jeremydouglass Can the settings function be called in code without causing errors? surface.setSize(width, height) can be used anywhere in the sketch, even in draw().
    @evilhatter Anyways, the window is not resizable unless you specify with surface.setResizable(true) , so I don't see what the problem is.

  • Can the settings function be called in code without causing errors?

    No. It is called by Processing once, at startup. This would be in addition to calling surface.setSize() -- or, as an alternative, you might be setting a maximum size programmatically and then and scale it e.g. with image().

    To the original question: I'm not sure if Processing / Java can access a variable that changes whenever you manually resize the sketch window using the mouse (assuming it has been set as resizable.

  • Exactly what I thought. What exactly is the question anyway?

Sign In or Register to comment.