Best way to create a circle with gaps?
I've just begun working with Nodebox, and am having a great time. As a simple project to learn, I am trying to create a circle with gaps in it (see the attached image for reference). I understand how to create a partial or complete circle using a sample, coordinates, and connect node - but I'm unsure on how to open gaps in that circle efficiently, and to have easy control over how many gaps there are. Is this even the best way to approach this?
Any help would be much appreciated! Looking forward to learning more about Nodebox.
- circle-example.png 10.3 KB
|?||Show this help|
|ESC||Blurs the current field|
|r||Focus the comment reply box|
|^ + ↩||Submit the comment|
You can use
Command ⌘ instead of
Control ^ on Mac
Support Staff 1 Posted by john on 09 Sep, 2018 10:18 AM
There are several different ways of doing this. One simple way is to represent the gaps as a series of pie slices (using the arc node) and subtract them from a circle using a compound node.
Zipped example code and screenshot attached.
I begin by building a table of gap starting points (in degrees from 0 to 360) and gap widths (in degrees). You could import these values from a CSV file or generate them within NodeBox.
For this example I used random numbers. You can adjust the number node at the top to change the number of gaps and fiddle with the random nodes to control the range of gap widths or try different random seeds. You can replace this section with whatever logic you want to create a gap table.
Once I have the gap starts and widths I feed them into an arc node set to "pie" mode and group them to produce a single shape representing all the gaps (including overlaps and wraparounds).
I then create a ring by using a compound node to subtract a slightly smaller circle from the main circle. Notice that this compound node is set to Difference with Invert Difference checked. You can adjust the diameter of the outer circle and the thickness of the circle outline. The Diameter node also controls the size of the gap pie slices; I use a slightly bigger circle for them to make sure they extend beyond the main circle.
Now all we have to do is subtract the gap pies from the ring using another compound node. This one is set to Difference but with Invert Difference unchecked.
Please let me know if that solves your conundrum and if you have any other questions. Welcome to the NodeBox community!
2 Posted by Elliot on 10 Sep, 2018 02:05 AM
Thank you! Incredibly helpful and very informative. Very appreciated.