The Cairo samples, drawn by Nile

Cairo's samples page, each sample drawn again by compiled Nile beside its C: arcs, curves, fills under either rule, strokes, dashes, clipping, gradients, images and text.

How to use: the picture on the left is Nile's, the C on the right is Cairo's; under each is the Nile that drew it. The renderer menu moves the rasterizing to the GPU; a card the GPU presenter cannot draw says why it stays on the CPU.

The samples use about 800 lines of Nile in all, and 300 lines of TypeScript for paths, text and pixels. The font is Source Serif where Cairo's asks for Sans.

Cairo's sample code is by Øyvind Kolås, public domain.

See the Nile pipeline

Building the path (the arcs, the curves, the glyph outlines from the font) is TypeScript, as it is C on Cairo's side; everything from the path on is Nile: gezira's kernels, unmodified, and a few more written for these pages (the even-odd rule, dashes, clipping to a shape, painting with an image). Nile has no memory to read, so the one thing the host supplies is ReadImage, the pixel under a point; its image is the tiger, drawn by the same Nile, where Cairo's is a photograph. A twentieth card draws what Cairo's examples index calls Bezier gradients: a Coons patch, cut into pieces and summed per pixel. On the GPU, a card's fills and strokes become beziers on the CPU, as before, and RasterizePixels, lowered to WGSL from its intermediate form in the browser, draws them. The pipeline above is what every card shares: filling under either rule, stroking, clipping, and painting spans; each card quotes its own besides.