perfect-freehand exports getStroke to turn pointer samples into smoothed polygon outlines for drawing apps, with simulated or stylus pressure and SVG helpers.
Overview
perfect-freehand provides a getStroke function that converts input points into polygon outlines suitable for freehand drawing. It builds spline points from samples, then computes outline geometry you can render in SVG, Canvas, or other engines.
Options control size, thinning, smoothing, streamline, tapering at start and end, easing, and whether pressure is simulated from velocity or taken from stylus data. Auxiliary exports expose stroke point preparation and outline generation for advanced customization.
The TypeScript package ships with rendering examples that turn stroke arrays into SVG path data or Path2D objects. Community ports exist for other languages, and a Figma plugin demonstrates design-tool usage.
Development packages include a local demo server and tests under the MIT license.
Key features
- getStroke outline generation
- Simulated or real pressure
- Configurable taper and caps
- SVG path helper examples
- Exported stroke point utilities
- TypeScript types for options
- Velocity-based pressure fallback
- Community ports and Figma plugin
Use cases
- Whiteboard drawing tools
- Signature capture widgets
- Vector ink in canvas apps
- Stylus smoothing for tablets