Attached is a demo of my latest node: Stack_tight. Stack_tight works just like the Stack node, except that it can tuck shapes tightly together.
The stack node bases its adjustments on the boundary around each shape (the maximum width and height). This makes it unsuitable for general purpose kerning or for pressing convex shapes snugly into concave shapes.
Fitting shapes together like jigsaw puzzle pieces is one of those things that is effortless for people but hard for computers. In order to do it I had to find key points along the north, east, south, or west sides of a shape and measure the distances to similar points on each adjoining shape. I finally found a way of doing this that is reasonably fast even for large shapes or long sequences.
The fit is not always perfect. My method requires resampling each shape. The finer the resolution the more accurate the fit, but the longer the computation time. For most case you can keep resolution at 1 pixel (the finest setting), but if you have very large or numerous shapes you can speed the computations by making the resolution more coarse.
Stack_tight works best with a consecutive list of shapes all roughly in a line (like characters in a sentence). if you use it to stack widely scattered shapes there may be some unexpected results. If a shape is not adjacent at any point to its nearest neighbor it has no way of determining how far to slide, so will just stay put (but will still move with the rest of the list).
The attached demo includes several demonstrations (see screenshot):
- At the top you can see output from the edge_points node, a node inside stack_tight that may be useful in other situations as well. It finds regularly spaced points on the north, east, south, or west sides of a shape (shown as red dots).
- At mid left I show a simple demo of the string "sTack*" first using a normal stack node and then, below it, using stack_tight. You can see that with stack_tight the T is kerned tightly between the s and a, and the asterisk at the end snuggles into the k.
- At the bottom I show "sTackTight" stacked tightly with three rows of stars, at various rotations, falling into the crevices of the text. The stars are first tucked together horizontally and then stacked vertically one at a time.
- The bottom example can be animated (MP4 attached). A wave node feeding into stack_tight's margin port causes the text to expand and contract; as it does so some of the stars fall further down or bounce back up as they catch edges of the text characters. Set to loop for a groovy viewing experience.
- As an added bonus I also include a pentagram node, handy for making perfect five-point stars (using the golden ratio).
I've wanted to make a node like this for years. It has many possible uses. Feedback appreciated.
Enjoy!
John