[cairo] Re: On recovery from errors in cairo

Bill Spitzak spitzak at d2.com
Fri Sep 22 14:01:07 PDT 2006

Mike Emmel wrote:

> I disagree that a line to results in a move to if no point is set it should
> do a line to from 00 to the point its a lineto not a move to.
> I feel the sematics of having the default gstate be a movto 00 are
> more consistent
> then what your describing. Starting with zero is well defined in most
> branches of mathematics :)

I think the no-current-point state is needed for the arc drawing 
commands to be useful for both adding arcs to a shape and drawing 
stand-alone arcs. Making line-to have matching behavior is actually very 
useful so that calling code that draws shapes, since the first point 
does not have to be special-cased.

I do agree that there is no reason to throw errors if the 
no-current-point state is set. I would prefer that the cairo_t keep 
track of the current point continuously, you would actually get the most 
recent point used by any path construction. closepath should set the 
current point to the starting point of the shape.

As I see it there is a current x,y and a "have current point" flag. 
Initial state of a cairo_t is 0,0,false. The have-current-point flag 
makes line-to and arc-to and perhaps other things add a line segment 
from the current point to the start of their drawing. Most everything 
that sets the current point turns on have-current-point..

move-to turns off the have-current-point flags and does line-to.

newpath turns off the have-current-point flag.

closepath sets the current point to the start of the curve and turns off 
the have-current-point flag.

rlineto(0,0) can be used to turn on the have-current-point flag and not 
do anything else.

More information about the cairo mailing list