Variable-width Bézier curves (2025) luthert.web.illinois.edu · 12 points · 3 com...

@best

Variable-width Bézier curves (2025) luthert.web.illinois.edu · 12 points · 3 comments · HN thread

TL;DR The author describes how to draw Bézier curves that carry a pen-width coordinate, so that pen pressure can vary stroke width smoothly for whiteboard-style handwriting. The post covers circular-offset stroking, the math for stroke outlines and per-pixel rendering, and notes that no common vector formats support variable-width strokes. Reference implementations are released into the public domain under the Unlicense.

  • Pressure-driven stroke width comes in three models: fixed-axis linear offset (calligraphy-like), stroke-aligned linear offset, and circular offset; the author uses circular offsets because they are robust to hand jitter and digital stylus noise.
  • Pressure p is mapped to radius r with roughly r = w·p^1.5 to w·p^2, where w is a width multiplier adjusted by a keyboard shortcut.
  • Each sample point is joined by a cubic Bézier curve in (x, y, r) space, with tangents chosen from neighbouring points and drawing delayed by one sample so the next point is known.
  • Stroke outlines are computed from the curve and its hodograph, with breaks and end caps at cusps; per-pixel rendering uses root finding or Newton hill climbing on a distance polynomial and is more expensive but suits GPUs.
  • Common vector and print formats (PostScript, PDF, SVG, AI) support only fixed-width strokes, so exporting variable-width strokes currently requires approximating outlines with polygons or Bézier curves.
  • The implementations are provided on the page under the Unlicense, with no royalty or attribution required.

Discussion The thread is small, with three comments, and its tone is appreciative. One commenter praises the article as clear and careful writing in contrast to LLM-generated prose. Another points out that a 3D version of the stroke-boundary idea would describe a V-carving toolpath for a CNC router, which is a concrete application the author said they did not know of. A third criticises the article for having no pictures despite being about curves.

  • Article is clear and carefully written, a refreshing contrast (some): One commenter says it stands out from the flood of LLM-written text on the web by explaining the concept clearly and carefully.
  • Ring-based 3D stroke idea fits CNC V-carving (a few): A commenter notes that generating a ring of boundary points per sample would describe a V-carving toolpath for a CNC router, answering the author's question about uses.
  • Missing diagrams hurt the article (a few): One commenter asks why a post about Bézier curves has no pictures, implying the mathematics would be easier to follow with figures.

#bezierCurves #graphicsTablet #vectorGraphics #strokeRendering #computerGraphics