Perfect Freehand
A Rust port of perfect-freehand library
A library for creating smooth, natural-looking freehand strokes from input points. It produces an array of outline points that form a polygon around the input, perfect for drawing applications.
Installation
Add this to your Cargo.toml:
[]
= "0.1"
Usage
The main function is get_stroke(), which takes an array of input points (like those from mouse movements) and returns a vector of outline points forming a smooth stroke polygon.
// pseudocode-ish
use ;
Rendering
You can render the stroke points with any graphics library. Here's an example using a hypothetical graphics backend:
use ;
To get filled strokes, you can triangulate the polygon using a library like earcutr and then render the triangles:
use ;
use earcut;
Acknowledgements
This project is a port of perfect-freehand
by Steve Ruiz. Huge thanks to him for the original work. This Rust implementation is based on and improves upon previous Rust ports of the library.
License
This project is licensed as the original under the MIT License.
Copyright (c) 2021 Steve Ruiz - Original
Copyright (c) 2025 Sibai Eshak - Rust port