setResizable

edited February 2017 in How To...

Hi There,

I am using 'setResizable' for change the size of the window. It works perfectly!

But when I am changing the size of the window, the content in the window is flickering. Is there a method to make it more smooth when the size of the window is changing?

J

Answers

  • What do you mean by flickering? Do you have some sample code?

  • edited February 2017

    You can run this code by yourself:

    void setup() {
      size(500, 500);
      surface.setResizable(true);
    }
    
    void draw() {
     rect(100, 100, 100, 100); 
    }
    

    If you change the size of the window, the rectangle inside the window will dance, which i don't like.

  • @GoToLoop -- would you mind explaining a bit more?

    How does the reference entry for width explain what is causing the rect to "dance" during vigorous window resizing -- especially given that the rect() is not defined in terms of width in the demo code?

  • Dunno whether using width & height can fix the "flickering" problem.
    Only that rect(100, 100, 100, 100); is clearly wrong for surface.setResizable(true);.

  • edited February 2017

    Ah, I'm still not getting it. Are you saying that rect() should be called with different arguments if surface is resizable? Or that a different rectMode should be used?

    I would have expected rect(10, 10, 20, 20) to draw a 20x20 rect that is offset 10x10 from the upper-left origin, 0,0, of any sketch -- regardless of the size() declaration, and regardless of resizing the lower right corner -- even if width/height lagged in updating, I wouldn't expect it to affect drawing position at all because rect() in default mode doesn't care how big the sketch is -- it just offsets from 0,0 by a fixed amount.

    The "dancing" (both vertical and horizontal) when vigorously dragging the lower right-hand corner (tested on OS X 10.12.3) makes me wonder if this relates to delayed suppression of invisible scrollbar regions in the resized window object, or if there is a delay in translating the new size to an upper-left origin -- although I would expect that to cause only vertical jumping, not both.

  • edited February 2017

    I just think that the rect()'s coords & dimensions should change following canvas´ dimensions. :-\"

  • Hi There,

    Well, the problem has nothing to do with the width of an element i think. The problem is that the elements are flickering when i am changing the size of the window; the elements are blinking.. I think it has something to do with the graphics of processing. I made a screen video to show you the problem. Is there a possibility to upload any movie inside this forum, than i can show you.. :)

  • @GoToLoop No, that would not explain the flickering. Obviously, you're right in saying that the size of the element should depend on the width and height of the sketch in this case, but that's no reason it should flicker.

  • Click on the image button on the extreme left of the "New Comment" section header (the same place where B, I, S, C, another image button etc are there). It will allow you to upload any file to the forum.

Sign In or Register to comment.