Pausing draw function.

edited November 2016 in Library Questions

Is there a way where I can pause my draw function so I can have new backgrounds also those backgrounds should be behind the buttons from ControlP5 library. Because I am creating a GUI that needs to show the rPi Camera but needs to have a clicked button first. Any help can be considered! Thanks and more powers.



  • Could you show what code do you have?

    I will think using loop/noLoop will answer your question:

    However, to change background you don't need to stop the draw() function. Instead you could do this::

    void setup() {
      size(200, 200);  
    void draw() {
      background(0);  //Setting background to black
      // (...)
      // (...)  Here you add your drawing actions
      // (...)

    Regarding your GUI using controlP5, you set them up in your setup function and then you do not have to worry for the background function drawing over them. ControlP5 objects are always redrawn over whichever background you have set so far in your draw function. If you are running into some other issues, you could provide more details or a small running code showing your problem.


  • Following up on @kfrajer 's suggestion, here is a recent thread on several different ways to toggle the draw looping status off and on.

    You can't draw backgrounds "behind" anything -- only "before" things that come after (and therefor on top of).

    void draw(){
       drawMyBackground(); // always first / underneath
       drawMyButtons();   // always second / on top
  • edited November 2016

    Here's my code. I can say that the code in Camera() subroutine should be put on the draw for continuous Rpi Camera display. Hope you can help me. Also the Level function does not update very well due to my plan of changing background. Hope you understand my bad english

Sign In or Register to comment.