Generate printable hanging mobiles with letters and shapes.
uv tool install --upgrade git+https://github.com/astaff/mobile.git
mbl "HELLO"Shape modes:
# Built-in shape, normalized to 25 mm diameter at shape-scale 1.0
mbl "LOVE" --shape heart
# Seven hearts for mom
mbl "❤️❤️❤️❤️❤️❤️❤️"
# MOM stencil-cut into hearts
mbl "MOM" --shape heart
# Emoji are mapped to built-in shapes automatically
mbl "⭐❤️😊🐙☀️"
# Right-to-left languages are detected automatically
mbl "שלום" --shape blank --text-scale 2.0
# Custom SVG, normalized to 25 mm diameter at shape-scale 1.0
mbl "HELLO" --shape custom-shape.svg
# Use whitespace if no text is needed
mbl " " --shape shopify
# Scale shape and font (relative to the scaled shape)
mbl "HELLO" --shape custom-shape.svg --shape-scale 1.5 --text-scale 0.8
# Print a stage timing profile
mbl "HELLO" --shape custom-shape.svg --profileKey flags:
--shape:circle(default),burst,star,heart,shopify,peace,cup,eclipse,octopus,smile,sun,blank, or path to.svg--shape-scale: background shape multiplier (default1.0)--text-scale: text multiplier (default0.8)--leaf-mass-scale: solver calibration for leaf mass (1.0same,<1lighter,>1heavier)
from pathlib import Path
from mbl import Arc, Leaf, to_3mf
STATES = Path(__file__).parent / "shapes" / "new_england"
def leaf(name: str, scale: float = 0.17) -> Leaf:
return Leaf.from_svg(STATES / f"{name}.svg") * scale
levels = [
[ Arc(100, 22) @ leaf("ME")],
[ Arc(90, 18) ],
[leaf("VT") @ Arc(45, 12) @ leaf("NH"), Arc(50, 10) @ leaf("MA")],
[leaf("CT") @ Arc(35, 10) @ leaf("RI")],
]
# pass config=MobileConfig(...) to override generation parameters
out = to_3mf(levels, "new-england.3mf")- Default shape is
circle. shape_scale=1.0means shape diameter is normalized to25 mm.- Built-ins (
circle,burst,star,heart,shopify,peace,cup,eclipse,octopus,smile) are normalized the same way. - Custom SVGs are loaded and normalized to
25 mmdiameter beforeshape_scaleis applied. - Text subtraction/geometry uses
text_scaleindependently ofshape_scale.
The following built-in shapes are sourced from Noun Project under Creative Commons:
| Shape | Author | Noun Project ID |
|---|---|---|
| cup | Adrien Coquet | 7683336 |
| eclipse | Amazona Adorada | 7666379 |
| octopus | Moreno | 8216521 |
| smile | Dwi ridwanto | 7786982 |
| sun | Creative Stall | 130085 |