TLDR: This is a single-header C++ library with no dependencies beyond the standard C++ library. In about 2300 lines of 78-column code (not counting blanks or comments), or 1300 semicolons, it implements an API based on the basic W3C <canvas> specification to draw 2D vector graphics into an image buffer:
- Strokes and fills (with antialiasing and gamma-correct blending)
- Linear and radial gradients
- Patterns (with repeat modes and bi-cubic resampling)
- Line caps and line joins (handling high curvature)
- Dash patterns and dash offsets
- Transforms
- Lines, quadratic and cubic Beziers, arcs, and rectangles
- Text (very basic, but does its own TTF font file parsing)
- Raster images (i.e., sprites)
- Clipping (via masking)
- Compositing modes (Porter-Duff)
- Drop shadows with Gaussian blurs
Why? Some years ago I needed to programmatically draw on an image file. I looked at Skia and was put off by its size and build complexity. Cairo was much better, but by then I was spoiled by the STB single-header libraries. I like tiny code and writing a single-header but powerful vector graphics library seemed like a fun challenge and a good way to pay things forward. I ended up with something that can compile down to less than 36 KiB of object code on x86-64 and uncovered a lot of interesting browser <canvas> quirks along the way with my testing suite. Enjoy!