[cairo] negative line widths

lloyd konneker bootch at nc.rr.com
Wed Aug 17 14:35:41 PDT 2011


Bill Spitzak wrote:

> I agree that the line width should use the absolute value of what is 
> passed. Except negative numbers cause the path to be stroked
> backwards 
> (this can be visible if the dash pattern or line caps have some 
> orientation).
> 
> Without this it becomes annoying to do arbitrary, including mirror, 
> transforms.
> 
> Also I believe this is necessary if cairo is ever fixed to keep the
> pen 
> in device coordinates. If you flip the coordinates, set the pen width
> to 
> a positive value, then flip back, it is going to be negative anyway 
> (well the 2x2 matrix will have negative entries) so it must be
> handled 
> anyway.
> 

I'm sorry, i am not sure I understand what you are saying.  So I will
paraphrase:

You are are quoting specifications, how cairo DOES work.  You are saying
that cairo does use the absolute value of the passed line width
parameter, but also uses the sign of the passed line width parameter to
determine the stroking direction.  You are also saying that a backward
stroking direction is not always visible but depends on the orientation
of the dash pattern and/or line caps.  Then you discuss design issues,
why it is a good design: because it lets the user do arbitrary
transforms, and because it is on a path for future development of cairo
to keep the pen width in device coordinates.

I am sure I don't understand all the issues and I appreciate your
clarification.

If you take the first example at
http://cairographics.org/pycairo/tutorial/
and change the sign of the line width parameter, it changes the result,
the shape is invisible. The example seems to use the default dash and
line caps and an ordinary transform. The results are non-intuitive and
something for naive users like me to be aware of.

If ever I let the user choose a mirror transform or a dash and line cap,
I may revisit the problem.  Until then, I will use abs() to insure I
always pass a positive number to set_line_width.









More information about the cairo mailing list