Overlaps Node

john's Avatar


21 Mar, 2023 09:32 AM

Attached is a demo of a new node: overlaps

Overlaps returns all possible intersections of up to ten overlapping shapes. One obvious application is Venn diagrams. The attached demo shows a five-way Venn diagram.

Overlaps takes a single input: a list of shapes. It returns a list of all shapes formed by every possible combination of overlaps. In the demo you can see a total of 31 shapes (2^n -1) produced by an input list of 5 ellipses. The fragment labeled ABE, for example, is the region formed by the overlaps of ovals A, B, and E with no participation by ovals C and D.

If the input shapes are colored, the overlaps will be as well, with colors similar to what you would see if the input shapes were translucent. The resulting amalgam looks translucent but is not; all fragment shapes are opaque (full alpha) even if the inputs were translucent.

Overlaps will always return 2^n -1 shapes corresponding to the binary representation of every possible combination even if some of the input shapes do not overlap. For combinations that do not occur, those shapes will be null. You can automatically discard these null shapes by leaving the Remove nulls checkbox checked. But if you want to provide a color key or label each combination in cases where some combos are missing, you will need to uncheck that box and use the position number in the resulting list to figure out which fragment belongs to which combo. After this is done, you can then remove the nulls by culling all shapes with zero area.

Normally each shape returned will be a single path. But if a particular combination of overlaps produces disjoint fragments, those fragments will be grouped into a geometry. This is convenient for labeling purposes. But if you want to work with the individual fragments separately, just ungroup the geometries.

Although overlaps is perfect for making Venn diagrams, it can be used for many other purposes. It works as a kind of X-ray to see the structure behind overlapping opaque shapes. Once formed, the individual fragments can be exploded or highlighted or rearranged to create generational art and other interesting effects. You can use it as a filter to recover only certain combinations of overlapping shapes. For visualizations in which the areas of the input shapes represent some value, the areas of the overlaps will then become meaningful as well and can be measured and used.

Because the calculations are computationally expensive and the number of combinations increases exponentially, the node can only handle a limited number of shapes. Calculating the 1023 fragments for ten overlapping nodes takes over 30 seconds, so I have placed a limit of ten so as not to inadvertently freeze your computer. If more than ten shapes are submitted, overlaps will only look at the first ten.

The five-way Venn diagram in the demo takes about 5 seconds to render, but most of this time is due to the place_label node. The demo requires the concat_list.py external module (included), but this is only needed to generate the ABCDE labels. The overlaps node does not require any external code modules.

(Aside: this was a tricky node to make. The algorithm requires recursion - which Nodebox cannot do - but obviously I found a way around this. If anyone out there is curious how I did it, feel free to peek under the hood.)

The overlaps node will be included in the next rev of my Cartan Node Library. I will be curious to hear back from anyone using it.



  1. 1 Posted by Jussi Jokinen on 05 Apr, 2023 02:29 PM

    Jussi Jokinen's Avatar

    I love this node! Even though haven't yet figured out what to do with it, it still works _smooth_. Thank you!

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Already uploaded files

  • Venn_Overlaps_Screenshot.png 614 KB
  • Venn_Overlaps_Demo.zip 48.5 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

17 Jun, 2024 02:26 PM
15 Jun, 2024 01:44 PM
08 Jun, 2024 09:05 AM
08 Jun, 2024 09:00 AM
04 Jun, 2024 04:37 AM