January 9, 2026

Straight lines, crooked comments

Show HN: Various shape regularization algorithms

Clean-up tool for messy shapes wins fans, sparks speed wars

TLDR: A pure-Python tool called shreg cleans up messy shapes and snaps corners for neater maps, diagrams, and contours. Fans praise real-world utility and ask for smart label placement, while others push for performance boosts with Numba—sparking a friendly simplicity-versus-speed showdown.

A new Show HN drop, shreg, promises to clean up messy lines and wobbly outlines—think crooked floor plans and jittery maps—so they look neat and aligned. In plain English: it straightens wonky shapes and snaps loose corners together. The community’s reaction? Real-world pros are hyped, speed nerds are already revving the engine, and the jokes are flying.

A land surveyor swooped in calling this “the thing I wished existed,” then asked for the next big feature: smart label placement so text tags don’t clutter drawings. That opened the comment floodgates of “please make it map-friendly,” with users imagining tidier blueprints, CAD diagrams, and even comic-book panels. Meanwhile, the drama: Pure Python vs. Turbo Mode. The tool proudly ships with no dependencies, but performance hawks immediately yelled “Numba!” (a speed-up tool) and nudged for acceleration. Some applauded the “easy install,” others wanted “go-fast now,” and one wag joked it should also fix their handwriting.

Memes? Plenty. Folks compared snapping endpoints to Lego bricks and cheered the promise of “watertight polygons” like it’s a watertight alibi. Bottom line: shreg is clever, clean, and already inspiring feature requests—and a friendly feud over keeping it simple vs. making it scream.

Key Points

  • shreg is a Python library implementing shape regularization for line segments and closed contours.
  • Features include segment, snap, metric, and contour regularization, plus T-junction detection and visualization.
  • Segment regularization uses quadratic programming to align angles and offsets of line segments.
  • Installation is available via pip, uv, or from source using git clone and editable pip install.
  • Quick-start examples demonstrate configuration parameters and functions for different regularization tasks.

Hottest takes

"This is the thing I wished existed somewhere and didn’t know how to search for" — marquesine
"Have you considered trying numba for acceleration? It’s great for number crunching" — walterlw
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.