Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

https://github.com/a-e-k/canvas_ity

A tiny, single-header <canvas>-like 2D rasterizer for C++

More detail -- This is an STB-style 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
I also uncovered a number of interesting browser <canvas> quirks along the way with the HTML5 port of my testing suite.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: