Pair_Contour Node

john's Avatar

john

27 Aug, 2024 12:08 AM

Attached is a new node: pair_contour.

Paths in Nodebox can have multiple contours. The most common example is an alphabet character. Letters like "a" have one contour to describe the outside and a separate contour to describe the hole on the inside. Letter's like i have two contours (the shaft and the dot) that are separate but are handled and colored together as a single path.

Pair_contour takes two closed paths, contour A and contour B, and combines them into one - with no external code module required. If A is completely inside B then A will appear as a hole inside B, or vice versa if B is completely inside A. If A and B are separate they will stay that way but be represented as a single path. If A overlaps B, the shared portion will appear as a hole. The combined path will retain the coloring of the first contour even if the second has different coloring.

The Cartan Node Library already has a join_contours node that can join any number of contours (like the letters of a word or phrase) into a single path. But it requires an external Python module, which is a bit of a nuisance. Pair_contour does not require an external module. It can only handle two contours, but in many situations that's all you need. For a letter with two holes, like B, you can use it twice.

The attached demo shows three ways to combine the two contours of a lower case 'a' into a single path. A second subnet on the upper right shows how to recombine the three contours of a capital B.

A subnet on the lower right shows a comparison of pair_contour and join_contours. Both combine two differently colored circles to form a single torus. But join_contours requires that you add contours.py to your code library. It also requires a combine node to form the two contours into a list and a rev_dir node from the Cartan Node Library to reverse the direction of the second circle. In order to form a hole, the two contours have to be ordered in opposing directions (one clockwise, the other counter-clockwise). Pair_contour is an easier way to make a donut.

Enjoy!

Reply to this discussion

Internal reply

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

Attaching KB article:

»

Already uploaded files

  • pair_contour_screenshot.png 521 KB
  • pair_contour_node.zip 11.8 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

Generic

? 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

01 Oct, 2024 07:59 AM
30 Sep, 2024 11:37 PM
30 Sep, 2024 11:11 AM
30 Sep, 2024 02:37 AM
28 Sep, 2024 10:33 AM

 

26 Sep, 2024 06:41 AM
24 Sep, 2024 12:32 AM
24 Sep, 2024 12:27 AM
13 Sep, 2024 12:07 AM
12 Sep, 2024 11:54 PM
07 Sep, 2024 05:16 AM