[cairo] Where are the stroking (and filling) guts?

Nigel Tao nigel.tao.gnome at gmail.com
Wed Jun 30 18:39:24 PDT 2010


On 30 June 2010 11:22, Lutz Gehlen <lrg_ml at gmx.net> wrote:
> I would like to learn a bit more about stroking and filling is done
> in modern graphics software, mainly out of academic interest. I am
> particularly interested in thick stroking including antialiasing,
> but also in filling.

It's not cairo, but I recently ported [0] the freetype rasterizer to
the Go programming language [1]. It's an all-software scanline
rasterizer (and IIUC the same algorithm that is used by the anti-grain
library) and a Lisp programmer has written a nice visualization of
that algorithm [2].

The freetype-go rasterizer code is relatively small (it's only 1370
lines of code), including some stroking code I added this week (it
does stroke-to-path), so it should be relatively easy to understand (I
also haven't done any performance work, stress testing or corner-case
QA'ing yet). I haven't got my head around Bentley&Ottmann yet but if
you understand the cubic Bézier approximation to the quarter-circle
then you should be able to follow the math in the stroking algorithm.

I'd be curious to know how it compares with other rasterization
algorithms (in quality as well as performance) whether from research
literature or from other graphics libraries.

[0] http://code.google.com/p/freetype-go/
[1] http://golang.org/
[2] http://projects.tuxee.net/cl-vectors/section-the-cl-aa-algorithm

cheers,
Nigel.


More information about the cairo mailing list