Processing seemingly capped at 35% cpu

Those 2 can be shortened as females.parallelStream():
Docs.Oracle.com/en/java/javase/11/docs/api/java.base/java/util/Collection.html#parallelStream()

When a lambda expression got 1 parameter only we can omit its parens: female ->

1 Like

That’s the XOR operator:
http://voidexception.weebly.com/java-xor-exclusive-or-operator-on-booleans.html

Together w/ the assignment = operator:
if (isLooping ^= true)if (isLooping = isLooping ^ true)

When isLooping is true, isLooping ^ true evals as false: true ^ true = false
When isLooping is false, isLooping ^ true evals as true: false ^ true = true

That is equivalent to if (isLooping = !isLooping):

That’s the conditional operator, which acts upon 3 operands (ternary):

Yes, 2 PGraphics objects:

mainCanvas = createCanvas();
altCanvas  = createCanvas();

The idea is while render() (which is run by another Thread):
thread("render");

is busy working on the 1st PGraphics:
final PGraphics pg = isMainCanvas? main : alt;

the “Animation” Thread displays the 2nd PGraphics object:
background(isMainCanvas? altCanvas : mainCanvas);

and vice-versa: isMainCanvas ^= true;

2 Likes

Thanks very much @GoToLoop! Yeah I elected for the more verbose construction to hopefully improve readability but your version is probably more common online.

2 Likes

I noticed this and honestly like this feature, so often one has to loop through a bunch of functions which makes for repetitive code which can be avoided through the chaining method.

Particle script(final PGraphics pg) {
    return move().bounce().gravity().display(pg);
  }


and I like how its called

for (int j, i = 0; i < NUM; ) {
      pg.stroke(0);
      final Particle b = particles[j = i++].script(pg);
    }

Aah cool. I shall have to give this a go.