Hello Hacker News!
This is a side project I’ve been working on: Ambigram Generator (https://www.ambigramgenerator.me/). It generates rotational ambigrams, which are words or phrases that read the same when inverted (rotated 180 degrees).
The Technical Challenge: Why is Ambigram Generation Hard?
The core challenge isn’t just about flipping letters; it’s about solving a complex substitution cipher problem while maintaining legibility and aesthetic coherence.
Character Pair Mapping (The Logic): The system relies on a massive, pre-rendered and manually optimized database of character pair combinations (e.g., ‘A’ flips to ‘V’ or ‘L’ flips to ‘J’). The difficulty lies in optimizing the system to prioritize aesthetically pleasing pairings over just mechanically correct ones. Our current engine holds hundreds of pairing rules derived from hand-drawn ambigram work.
Aesthetic Coherence (The Design): Unlike a simple font swap, generating an ambigram requires that the ‘A’ from one side perfectly melds into a ‘T’ on the inverted side. We implemented a weight and stress system for each transition, preferring connections that share visual weight and line thickness.
The Feedback Loop: Early versions used rudimentary stroke merging, which failed for 90% of inputs. The current iteration uses an SVG-based rendering pipeline with custom path merging logic to smooth out the joins between characters like ‘N’ and ‘Z’ when inverted.
Key Trade-offs and Open Questions
Trade-off: Speed vs. Quality: We could use a full ML/AI approach for higher flexibility, but the latency and cost would be prohibitive for a simple, fun tool. We opted for a highly optimized, rule-based system for near-instant results.
Trade-off: Font Flexibility: The system is currently tied to a single optimized, high-contrast serif typeface. Making it work across multiple fonts requires rebuilding the entire character-pair database, which is a massive undertaking.
Open Question for the Community: The current system uses a brute-force approach on the character dictionary. Has anyone here worked on a similar combinatorial design problem? I’d love input on whether a Constraint Satisfaction Problem (CSP) solver could be a more efficient long-term solution for finding valid character pairings.
We’re offering this tool for fun and to revive interest in this niche art form. Feel free to try generating your own name and let me know which letter pairings look the worst, or if you have any suggestions on the SVG path smoothing logic!
Thanks!
Comments URL: https://news.ycombinator.com/item?id=45546236
Points: 1
# Comments: 1
Source: www.ambigramgenerator.me