Color change for overlapping objects

With two objects (circles, rectangles, …) overlapping I’d like to color them in another color on the overlapping part.

For example two objects are blue and the overlapping part is orange.

  1. Could this be done by any filter function and the circle(), rect(), …? Or drawing point by point?

I also know about drawing the forms by coding the x/y coordinates.

  1. How do I get the color of a point (x, y)? I tried brightness(get(x, y));. Is that right?

  2. For setting the color of a pixel point() is to slow and I have to use pixels[], right?

Thank you for helping me with this topic.

After writing the article I had the idea of filtering or blending and found the solution:

blendMode(DIFFERENCE);

So easy after all the coding… :wink: