AlexandruIca / FlatteningQuadraticBezierCurves

Implementing a simple renderer for quadratic Bézier curves using Raph Levien's method for converting them to lines

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flattening Quadratic Bézier Curves

Here I've implemented the algorithm presented by Raph Levien here and used it to render a few glyphs from some TrueType fonts. Here are 3 glyphs:

Glyph '@' Glyph 'F' Glyph 'W'

I've also implemented the De Casteljau method and rendered the same glyphs with it (images named glyph_<index>_recursive_subdivision). The differences are practically invisible, but Levien's method requires less number of segments generated and is much faster.

Reproduce the results

As long as you have Rust installed, to build this project and see the outputs you only need to:

git clone https://github.com/AlexandruIca/FlatteningQuadraticBezierCurves
cd FlatteningQuadraticBezierCurves/

cargo run

# Now a bunch of `.png`s will be generated and you can see the results for yourself

If you use Nix, you can just nix-shell inside this repo and you're good to go.

About

Implementing a simple renderer for quadratic Bézier curves using Raph Levien's method for converting them to lines

License:MIT License


Languages

Language:Rust 98.2%Language:Nix 1.8%