Ten years in the making!
The offset node traces a path a fixed distance inside or outside of another path. Sounds simple, and it is for any three-year-old, but it's surprisingly hard for computers to do.
There's a story here, but I will save it for a separate post in this thread.
Offset takes three parameters:
-
Path The base path. Can be open or closed, grouped or ungrouped. If grouped, it will be ungrouped into separate paths and regrouped. A path with multiple contours will be broken into separate offsets for each contour.
-
Offset. The distance of the offset. For shapes, a positive value will draw outside, a negative value will draw inside. For open paths, a positive value will fall on whichever side creates the broader path; a negative value will trace the tighter path.
-
Join Type. The type of join connecting gaps between any unconnected segments:
- Miter. The segments continue along their tangents until they intersect (up to a maximum distance of ten times the offset).
- Bevel. The segments are connected by a straight line.
- Round. The segments are connected by a round arc.
The node outputs the offset path in dark red with a translucent slate interior if the offset is closed. This coloring makes it easier to compare with the source path. In practice you will usually want to recolor it depending on the application.
Offset requires path_offset.py (included). You will need to add a copy to your code library.
The attached demo shows an outer offset of 10 units drawn around three letters, each with a different join style. Notice that offsets also extend around the bowl contours in the first two characters.
A second offset of -10 is drawn near an open curve. The negative offset causes the red path to be drawn under the curve inside its self-intersecting part.
Try changing the offset values in both offset nodes to see the effect.
Offsets are surprisingly complex. Weirdness may occur if you extend the offset too far away from the base path. If small loops or other anomalies form, try changing the join type or decreasing the offset amount. If problems persist, please post your example so I can improve the node.
You can use offsets to create nested rings or geometric patterns, borders, glows, movement along shapes, and many other interesting effects.
This node was particularly hard to make. I look forward to seeing what people will do with it.