[cairo] too long lines?

Chris Wilson chris at chris-wilson.co.uk
Wed Dec 15 04:24:26 PST 2010


On Wed, 15 Dec 2010 12:53:57 +0100, "Fried, Vojtech" <vojtech.fried at streamserve.com> wrote:
> I have a following pycairo sample and it seems to be that the black
> lines are too long. They cross the red rectangle (their bounding box) at
> the bottom corners. It is even more than one pixel outside the
> rectangle. See http://yfrog.com/f/6clonglinesp
> 
> Am I doing anything wrong? (cairo 1.10, all surfaces I tried, both linux
> and windows)

The artefact you are seeing is the result of the mitre join between the
strokes. The lines are joined at such an acute angle that the miter width
(the distance between the inner join and the outer join of the two lines)
is indeed several pixels wide. Above a certain limit, the mitre join is
replaced by a bevel to prevent excessively long and thin joins. You can
adjust the mitre limit or change the line join style to control the
behaviour to suit.

  cairoctx.set_line_join(cairo.LINE_JOIN_BEVEL) # alternatively,
                                                # cairo.LINE_JOIN_ROUND
or 

  cairoctx.set_miter_limit(2) # |outer-inner| / line_width

Have fun with Cairo,
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the cairo mailing list