Resamp Curv

john's Avatar

john

04 Sep, 2024 05:01 AM

Yet another new node, one I've been wanting to add for years: resamp_curv.

Resamp_curv works similarly to the resample node, but only resamples curves, leaving line segments alone. This is especially useful for text paths, which are composed of a mix of straight lines and curves. When you resample typographical characters the resample points usually don't align exactly with corners, which causes them to appear rounded or dented.

I do already have one solution to this problem in my library: even_sample. Even_sample has a "Curves Only" mode which does the same thing, but it has two problems. First, it is rather slow (because it distributes points on curves evenly which is hard to do); in fact, it's so slow that it becomes unusable for resampling, say, a whole paragraph of text.

Its second problem is that it doesn't handle paths with multiple contours - a significant problem since many typographical characters have two or more contours. (A percent sign has FIVE contours). There is a workaround to this: you can use my contours node to separate the contours before resampling, then use my join_contours node to rejoin them, but join_contours requires an external code module - which is a minor pain.

So even_sample can resample characters without denting their corners, but requires a lot of extra bother and is too slow for long text paths.

Resamp_curve provides a much faster, much easier alternative with no external code module required (up to a max of 6 contours). It takes three parameters, which are similar to resample:

  • Method. Choose either "By length" or "By amount".
  • Length. The amount of space between points on the resampled curve.
  • Amount. The number of points on each revamped curve; the minimum of 2 leaves each curve unchanged.

You may not need many pixels per curve because the curves on a typographical character are usually composed of many smaller curve segments. Just decrease the length or increase the amount until the resamples curves look smooth enough at the size you need.

I worked especially hard to handle characters seamlessly without requiring an external code module. My compromise was to allow only a maximum of SIX contours. This is enough to handle any single character I've ever encountered. You can even resample "ABC" in one fell swoop (since ABC has exactly 6 contours). But if you want to resample sentences or paragraphs, you will need to first break them into individual characters (with a make_strings node). Reassembling those characters into a paragraph is tricky, but possible. If anyone needs to do this, please post a question on the forum and I'll show you how.

The attached demo has two screenshots.

Screenshot 1 shows three versions of a capital B with draw_dots used to show the points: the original B with both curves and straight edges, a resampled B with straight edges only, and a B with only the curves converted to straight edges. As you can see by the magnified lower left corners, resampling blunts the corners while resamp_curv leaves them pristine.

Screenshot 2 demonstrates that resamp_curv is not just for text. You can feed any path into it - but it won't take geometries so you will have to ungroup those before resampling. As you can see with the balloons, the original is mostly curves. The resampled version looks almost as good, but has no curves at all.

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

  • resamp_curv_screesnhot1.png 804 KB
  • resamp_curve_screenshot2.png 1.28 MB
  • resample_curve.ndbx.zip 324 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