[cairo] thin antialiased lines
Carl Worth
cworth at cworth.org
Wed Feb 20 10:26:16 PST 2008
[Here's an *ancient* draft message I just found lying around that it
looks like I never sent. Perhaps it might be interesting to somebody?
Or maybe I did send this and this is just a useless copy now? Either
way, here it is.]
On Sun, 15 Jul 2007 15:44:51 +0200, "control H" wrote:
> Or how to draw non anti aliased lines _nice_ lines like gdk_draw_line()?
Actually, gdk_draw_line doesn't draw nice non-antialiased lines. (But,
yes, cairo's non-anti-aliased lines are even worse.)
There _are_ known techniques for drawing very nice non-antialiased
lines, (much better than what GDK does I believe). The key idea is to
use a specially-created polygon for the pen called a Pen
Polygon. This a technique developed by John Hobby for his Ph.D. and
then also described much more succinctly here:
[Hobby89] John D. Hobby, Rasterizing Curves of Constant Width,
JACM 36(2), 1
http://cm.bell-labs.com/who/hobby/87_2-04.pdf
A very interesting thing is that cairo's stroke algorithm already
works exactly as Hobby's algorithm requires, (we really liked the
performance and robustness aspects of using a polygonal approximation
of the pen). We didn't originally implement the Pen Polygon part
since we didn't care about (or even make available) non-antialiased
line stroking.
So, augmenting cairo to do this well is really as simple as writing a
single function that accepts a desired line width and computes a Pen
Polygon, (several Pen Polygons for small, common sizes could even be
pre-computed and just returned from a table).
I think that the mailing list archives even have some messages from
someone who experimented with doing this in cairo quite some time ago,
(I don't recall now who or when or how the results were).
-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080220/36fad447/attachment.pgp
More information about the cairo
mailing list