HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
a-e-k
canvas_ity
C++2022–2026
a-e-k / canvas_ity

canvas_ity

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

4Distinct people
11Mentions
0Explicit recommenders
627GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

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

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 3:56:07 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year11 dated mentions

Observed mentions: 2022-10-10 06:51:33 UTC to 2026-02-22 01:59:26 UTC.

01232022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 2 mentions; 2 submissions, 0 comments20222023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments20242025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2026-01-01 00:00:00 UTC to 2027-01-01 00:00:00 UTC (exclusive): 3 mentions; 1 submissions, 2 comments. Incomplete calendar period.2026*

* An incomplete calendar period is marked with an outlined bar. Its count is not directly comparable with a full period.

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC220
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC303
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC303
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC000
2026 (partial)2026-01-01 00:00:00 UTC2027-01-01 00:00:00 UTC312

What Hacker News says

11 sources
Author here. I have a JavaScript port of my automated test suite (https://github.com/a-e-k/canvas_ity/blob/main/test/test.html) that I used to compare my library against browser <canvas> implementations. I was surprised by all of the browser quirks that I found! But compiling to WASM and running side-by-side on that page is definitely something that I've thought about to make the comparison easier. (For now, I just have my test suite write out PNGs and compare them in an image viewer split-screen with the browser.)
In Canvas_ity: A tiny, single-header -like 2D rasterizer for C++
There's a relatively straightforward trick that you can do here. If you've got a transform that turns a circle into an ellipse with the relative radii and orientation that you want, then: 1. Apply the inverse of that transform to your path. 2. Stroke the path. 3. Apply the transform to the result. This way, the path stays in place but the stroke is transformed to give it a calligraphic look. With a JavaScript Canvas, you can just set the transform after defining the path, but before stroking. JSFiddle example: [0]. (This was something that I tested in my tiny, single-header <canvas>-like 2D rasterizer library for C++ and my Javascript port of its test suite [1].) For Inkscape, I think you can convert an object to a path, apply the inverse transform, do a minimal simplification to bake the transform into the path, stroke it, and then app
Read the rest
ly the forward transform. It's a bit clumsy, but I bet someone could easily create an extension script to do it. [0] https://jsfiddle.net/y7m16wa0/ [1] https://github.com/a-e-k/canvas_ity/blob/main/test/test.cpp#..., https://github.com/a-e-k/canvas_ity/blob/main/test/test.html...
In GPU-Friendly Stroke Expansion
I'm the author of another CPU-only 2D vector graphics library that might be of interest: - Canvas Ity (https://github.com/a-e-k/canvas_ity) It's a tiny single-header C++ library in the style of the STB libraries. My aim was to make it dirt simple to be able to drop into almost any project and get high-quality rendering while providing an API comfortable to those used to <canvas>. I've been checking out Blend2D every now and then. It seems like a very nice option for the bigger, but faster and more fully-featured end of the spectrum. (Though for what it's worth, while raw performance isn't my priority, my little library still can hit about 70fps rendering the Postscript Tiger to 733x757 res with a single thread on my 7950x. :-)
In WebKit switching to Skia for 2d graphics rendering
I have a small TTF implementation in C++ that's only a little bigger than that and is open source. It's part of my canvas_ity single-header library [0] that's around 2300 LOC / 36 KB object size and implements a C++ version of most of the 2D HTML5 canvas spec [1]. The core implementation of the TTF parsing and drawing is in L1526-L1846 with another small bit at L3205-L3274 of src/canvas_ity.hpp. It's something of a toy implementation that only supports western left-to-right text, and doesn't do any hinting at all, nor kerning, nor shaping. But it's enough to draw a basic "Hello world!" using any typical TTF file. The test suite in test/test.cpp L84-304 embeds a few custom Base64-encoded TTF files. They're small and only have a few glyphs but they do exercise a number of interesting edge cases in the OpenType TTF spec [2]. Have a look
Read the rest
at the HTML5 port of the test suite at test/test.html in different browsers to see how their canvas implementations render those fonts. [0] https://github.com/a-e-k/canvas_ity [1] https://www.w3.org/TR/2015/REC-2dcontext-20151119/ [2] https://standards.iso.org/ittf/PubliclyAvailableStandards/c0...
In Writing a TrueType font renderer
Agreed, that sort of documentation is pure gold when done well. It's something I always try to pay forward by doing in my own code. For example, one of my own lone-developer projects was an STB-style single-header <canvas>-like rasterizer library for C++. I started the implementation half of the library with a short overview of the rendering pipeline's dataflow and the top-level functions responsible for each stage: https://github.com/a-e-k/canvas_ity/blob/f32fbb37e2fe7c0fcae...
In The Lone Developer Problem
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., s
Read the rest
prites) - 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.
In Ask HN: What have you created that deserves a second chance on HN?
a_e_k·Oct 10, 2022Submission

Show HN: canvas_ity - A tiny, single-header canvas-like 2D rasterizer for C++

Hi HN! After a few years of off-and-on work on it, I'm pleased to release my canvas_ity library as open source. 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) - Co
Read the rest
mpositing 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!
8 points · Open discussion

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.