[cairo] transforming text

Matt Bartolome mattxbart at gmail.com
Wed Aug 5 10:49:18 PDT 2009


And of course I forgot to attach the image. Sorry :).

On Wed, Aug 5, 2009 at 10:47 AM, Matt Bartolome<mattxbart at gmail.com> wrote:
> Hi,
> I'm drawing in geographic units so I applied a transform and translate
> to draw correctly in pixel space. This works fine. When I draw the
> text using the same transformation it appears vertically reflected
> (this is what I would expect it to do). How would you go about drawing
> the text so it doesn't appear flipped, but still in the correct x,y
> position and rotation? Attached is a clip of the image I'm getting,
> obviously the text is wrong and is what I'm trying to correct.
>
> Hints, pointers appreciated!
> Thanks,
> Matt
>
> #bounds in geographic units
> xmin, ymin, xmax, ymax = max_bounds(sticks)
>
> #scale factor
> scale_x = width / (xmax-xmin)
> scale_y = height / (ymax-ymin)
> scale = min([scale_x, scale_y])
>
> ctx.save()
> ctx.scale(scale,scale)
> #flip y
> matrix = cairo.Matrix(1, 0, 0, -1, 0, 0)
> ctx.transform(matrix)
> #output from 0,0
> ctx.translate(xmin, -ymax)
>
> #draw 2d profile components
> ctx = horizontal_center(ctx, sticks)
> ctx = stick_head(ctx, sticks)
> ctx = surface_elevations(ctx, sticks)
> ctx.restore()
>
> #at this point I would like to draw the text somehow with the proper
> transform, rotation etc...
> ctx = draw_text(ctx,sticks)
>
> surface.finish()
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: surface0.png
Type: image/png
Size: 14717 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20090805/8616669f/attachment.png 


More information about the cairo mailing list