World Map and Place_label Node
Attached is a demo of a new node, place_label, which automatically sizes and places names into arbitrary shapes - in this case 176 different oddly-shaped countries. It can also serve as an example of map-making in Nodebox.
Place_label takes three inputs, a shape, the label text, and a font. It returns a reasonably large textpath, sized and positioned to fit entirely within that shape. If the label text contains more than one word it may break the label into multiple lines. Two additional options let you increase the margin around the label and limit its maximum height.
The first screenshot shows how challenging this can be. In this case, place_label was given the shape of Indonesia which consists of multiple contours (islands), each highly complex. Here the label nicely fills the largest contour in the approximate center.
The second screenshot shows a world map with labels for 176 different countries with varying text lengths and a wide variety of shapes. Place_label does a remarkably good job. It can be a bit slow for multiple shapes, though: the node took over 30 seconds to compute all 176 labels on the world map. Simpler shapes are faster; it can place labels into a thousand circles in under a minute.
Placing labels into arbitrary shapes is not an exact science. My algorithm is a compromise between speed and precision. In some cases reasonable minds could differ on the most aesthetically pleasing size and placement. If you peer inside the node you will find at the top a fudge factor called "tune"which, in extreme cases, can alter the horizontal placement and size of the label. If you are unhappy with the placement you can try changing this value, but doing so will only rarely make any significant improvement overall.
This demo also shows how to color and label an SVG map. The SVG in this case, worldLow.svg, is free for non-commercial use (see Read Me in folder). The map is now at least ten years old, so may be somewhat out of date. But you could use similar techniques with other map files.
Place_label will be included in the next rev of the Cartan Node Library. Please give it a try and report back how well it works for your labeling needs.
Enjoy!
John
- Map_highlight_screenshot.png 574 KB
- Map_full_screenshot.png 919 KB
- World_Map.zip 476 KB
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