[cairo] set_matrix affect stroke?
Jerónimo Barraco
jerobarraco at yahoo.com.ar
Thu May 13 16:35:17 PDT 2010
that was nice info, though i think the context allows a method called
init_matrix()
but i have no idea if it's better/faster. maybe you should take into
account that using python maybe there's an overhead with the object
creation (the empty matrix)
so instead of
cairo_ctx.set_matrix(cairo.Matrix())
you could use
cairo_ctx.init_matrix()
at least that's what i've been using.
c ya.
On Thu, 13 May 2010 15:31:20 -0300, Stuart Axon <stuaxo2 at yahoo.com> wrote:
>> 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()
>
>
>
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
More information about the cairo
mailing list