[cairo] Drawing a sequence of line segments

ax487 ax487 at gmx.de
Thu May 29 04:16:31 PDT 2014


Hello all,

I am using cairo to draw a stroke, that is a sequence of line segments,
onto a canvas, which is represented as a cairo_surface_t* internally.
The canvas is used in a Gtk+ application, the stroke is extended
whenever the mouse moves. Obviously, the redraw needs to be fast enough
such that there is no visible lag. A minimal example is here:
http://pastebin.com/RtaPajcU
I have tried the following approaches:

1: Redraw the entire stroke whenever the mouse moves. This works
correctly apart from the fact that there is a lag which increases as
more points are drawn.

2: Only draw the stroke between the last two points whenever the mouse
moves. This is noticeably faster but the drawing is incorrect: Pixels
are repeatedly overdrawn so the alpha value increases along certain
paths of the stroke.

I would like to go for fast and correct. Any ideas?

ax487


More information about the cairo mailing list