[cairo] set_matrix affect stroke?
Stuart Axon
stuaxo2 at yahoo.com
Thu May 13 11:31:20 PDT 2010
> On Wed, 12 May 2010, Stuart Axon wrote:
>
> > I'm still getting a weird error where I get a really fat stroke.
>
> The line width of a stroke is set in userspace units in effect at
> cairo_stroke() time. One tip for getting consistent line widths is to
> reset the matrix to a constant state and set the line width just
> before the cairo_stroke() call.
>
Cheers, this was exactly what I needed to do, for anyone googling
this, my draw function now looks like this:
# Go to initial point (CORNER or CENTER):
transform = self._call_transform_mode(self._transform)
cairo_ctx.set_matrix(transform)
# Run the path commands on the cairo context:
self._traverse(cairo_ctx)
## Matrix affects stroke, so we need to reset it:
cairo_ctx.set_matrix(cairo.Matrix())
if self._fillcolor:
cairo_ctx.set_source_rgba(*self._fillcolor)
if self._strokecolor:
cairo_ctx.fill_preserve()
else:
cairo_ctx.fill()
if self._strokecolor:
cairo_ctx.set_line_width(self._strokewidth)
cairo_ctx.set_source_rgba(*self._strokecolor)
cairo_ctx.stroke()
More information about the cairo
mailing list