Rounding corners

Jussi Jokinen's Avatar

Jussi Jokinen

13 Oct, 2022 05:18 PM


I'm finding that the results from the round segments node are not always what I'm looking for.
Attached are two screenshots of the pretty much the same shape, other made with Nodebox's rounding node and other with Illustrator's corner rounding. As you can see the results are pretty different. Nodebox distorts the shape in a way that is not normally my intention. Do you know if there's Illustrator style rounding node/code available for Nodebox 3?

The results what I'm looking for are pretty much shown in this article:

  1. Support Staff 1 Posted by john on 13 Oct, 2022 11:04 PM

    john's Avatar


    Thanks for this interesting and important question.

    You're right: the round_segments node often does not give us the results we desire. As you can tell from reading that article you linked to, rounding the corners of a polygon is a surprisingly tricky business. I believe even the algorithm described there would fail in certain corner cases (like self-intersecting paths),

    A few years ago I took a run at this problem using a different algorithm I found. My fit_curve node calculates a curved path from scratch but produces results not much different than round_segment. In fact, I later removed it from my library for that reason. In some cases, though, it is slightly better, so I've been thinking about restoring it or trying to make a better one.

    For simple shapes like rectangles, an alternative is to use the roundness parameter on the rect node. By using this with a compound node, you can sometimes produce the paths you want. You can also use my explode and curve nodes to construct exact paths from scratch. This can be rather cumbersome, but it is possible.

    The attached demo provides a summary of options in the particular case of a cross (see screenshot).

    • I start with a simple cross with sharp corners.
    • Below that you see the results of applying the round_segments node (as you also showed).
    • Below that is my fit_curve node which, as you can see, is similar to round_segments.
    • If all you want to do is round the tips of the cross, you can just build it using rounded rectangles.
    • Finally, for results like Illustrator, you can create a specialize subnetwork

    So to answer your question: no, I do not currently know of a general purpose polygon rounding node that would produce results like Illustrator apparently does.

    But the algorithm you found gives me new hope. It could certainly be implemented as a subnetwork node. I also followed a link in one of the comments from that article to what appears to be an even more general-purpose algorithm. I'm a tad busy at the moment, but when I get a chance I might try implementing that algorithm and see how well it works.

    Even in Illustrator I think you will find that providing a single roundness or radius value is often not sufficient to produce the path you really want. For ideal results you may need to provide a different level of roundness for each corner (or even pick and choose which corners you want to round). In Illustrator this can be done by adjusting the spline curves by hand. The more general-purpose algorithm I found also provides a way of overriding the roundness value for particular corners; that might be feasible for simple shapes but would become cumbersome for shapes with hundreds or thousands of corners.

    Sorry I don't have a quick fix for this one. If I come up with something more I will respond to this thread.


  2. 2 Posted by florisdejonge on 02 Nov, 2022 05:46 PM

    florisdejonge's Avatar

    Hi John and Jussi,

    I tried a different approach to rounding corners earlier. Don't know to what extent it proves useful for other cases, but I used the resampling of a shape, of which corners are omitted and the points subsequently traced. Attached the example.

    Kind regards,

  3. 3 Posted by Jussi Jokinen on 02 Nov, 2022 08:28 PM

    Jussi Jokinen's Avatar


    Wow, that's very clever! And the result (at least with specifically set parameters) is just what I was after. If only one could detect the indices of the corner points of any kind of shape, then this solution could be much more generic.

    - Jussi

  4. Support Staff 4 Posted by john on 03 Nov, 2022 08:06 AM

    john's Avatar


    I think removing the corners altogether and then replacing them with nearby points on the original path is an inspired idea. It inspired me to play with the idea and take up Jussi's challenge to make it more generic.

    I did that and was pleasantly surprised how well it works!

    Attached is a demo of a new node called soften. Soften removes all the corners from a closed path and replaces them with two points moved off a given distance along that path. I then replace each pair of corner points with a curve using the original corner point as control points. This produces a gentle curve where the corner used to be.

    I also limit the amount of softening to no more than half way along the edges leading to each corner. This prevents wierdness and places an upper limit on how curvy you can make the path.

    I tried it out on a variety of shapes and was surprised how well it worked (see screenshot). In the demo I show three variants for each shape:

    • the original shape
    • the shape using the soften node
    • the shape using the standard round_segments node

    The softened cross looks exactly like what Jussi originally asked for: all 12 corner softened with straight lines in between. A rectangle softens just the corners without causing an unsightly bulge along the edges. Even very pointy stars turn out just right. Arbitrary shapes (made by wiggling polygons or connecting scattered points) do well with both concave and convex segments.

    I didn't intend on using this node with curved splines like ellipses or text paths, but to my surprise even those shapes weren't TOO bad - at least they don't explode. If you ever do need to soften a shape that already has curves, I would just resample it first.

    The demo allows you experiment with many more shapes. You can fiddle with the existing shapes (e.g. change the dimensions, number of sides, wiggle parameters or random seeds) or the amount of softening. Or come up with even crazier shapes to test.

    Please give this node a workout. If you guys think it's worthwhile, I will add it to the next release of my node library.


  5. Support Staff 5 Posted by john on 03 Nov, 2022 08:47 AM

    john's Avatar


    Attached is an improved version of soften that can also handle open paths. Please use this version with your tests.

  6. 6 Posted by Jussi Jokinen on 03 Nov, 2022 01:40 PM

    Jussi Jokinen's Avatar


    Based on some quick testing your solution seems superior to that of Illustrator's :)
    Whereas in Illustrator rounding is limited to the maximum rounding of the corner with smallest distance to its' neighbours, in your solution such limit doesn't exist. Very nice and please add this to your library.

  7. 7 Posted by florisdejonge on 04 Nov, 2022 06:03 PM

    florisdejonge's Avatar


    That's a terrific node once again! After I posted this I started thinking about making it more genereric (I was experimenting with it to apply it to my generated landscapes). Attached is what I could come up with (right). As a test, I compared it to your solution (left). And I must say, the latter is far superior and yields more clean results and probably more control. So, please add it to the next update of your library! (I've might have got some requests/questions btw, but I'll add them to the thread on your library). Thanks.


  8. Support Staff 8 Posted by john on 05 Nov, 2022 08:40 AM

    john's Avatar

    Thanks, Floris!

    I have added the soften node to version 3.1 of my library. I hope to release it sometime soon.


Reply to this discussion

Internal reply

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

Attaching KB article:


Already uploaded files

  • Screenshot_2022-10-13_at_20.09.32.png 32.9 KB
  • Screenshot_2022-10-13_at_20.09.18.png 41.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

25 May, 2024 11:52 AM
24 May, 2024 07:39 AM
16 May, 2024 02:11 AM
16 May, 2024 01:58 AM
14 May, 2024 01:29 AM


13 May, 2024 12:36 AM
12 May, 2024 07:46 PM
05 May, 2024 04:38 PM
03 May, 2024 06:50 AM
03 May, 2024 12:30 AM
03 May, 2024 12:09 AM