1

I'm using processing, just for test purposes in a trainings program.

When I use fill(alpha) it becomes dark the more frames there are, since (I assume) Processing creates more and more of the shapes, overlapping everytime a bit more. After executing draw() it goes back to PApplet and then back to draw() again.

Can I tell Programming to only execute draw() once without inventing some weird bypass?

half circles supposed to overlap on the edges

 public void draw(){

    int winkel=0;
    translate(300,300);
    fill(150, 15);

    for (int i =0;i<8;i++){

        rotate(radians(winkel));
       kreisschnitt(100,0,200,200,0, PI);
       winkel=winkel+45;
    }
}

public void kreisschnitt(int x, int y, int breite, int hoehe,float anfang, float ende){
    noStroke();

    arc(x,y,breite,hoehe,anfang,ende);

}

IDEA 2018.2 Java 8

Kevin Workman
  • 41,537
  • 9
  • 68
  • 107
pikkuez
  • 310
  • 1
  • 18
  • 1
    Found it myself. draw() will loop the inside code until noLoop() is called or program is forced to stop. – pikkuez Sep 23 '18 at 08:26

1 Answers1

1

Yes, the draw() loop is called 60 times per second by default.

You can disable this by calling noLoop() which stops calling draw() until you call loop() again.

Or you could move all of your code inside the setup() function, which is only called once.

For simple sketches, you can get rid of all of your functions and write your code directly, like this:

size(500, 500);
background(32);
ellipse(250, 250, 100, 100);
Kevin Workman
  • 41,537
  • 9
  • 68
  • 107
  • @pikkuez You're welcome. Note that if an answer helped you, you can [accept it](https://stackoverflow.com/help/someone-answers) so your question stops showing up as needing an answer. – Kevin Workman Sep 24 '18 at 17:23