[cairo] Translate and scale question

Carl Worth cworth at cworth.org
Wed Jul 22 11:11:15 PDT 2009


On Wed, 2009-07-22 at 11:04 -0700, Bill Spitzak wrote:
> W,H = size of drawing surface.
> xmin, ymin, xmax, ymax = coordinates of lower-left and upper-right corners.
> 
> scale((xmax-xmin)/W, (ymax-ymin)/H)
> translate((xmax+xmin)/2, (ymax+ymin)/2)

Hi Bill,

I think you may have reversed some of the operations in the scaling
there.

Let's take the common case where the user wants a normalized user space,
(0, 0) - (1.0, 1.0) so xmax-xmin = 1.0, and ymax-ymin = 1.0.

In that case, your scaling code gives:

	cairo_scale (1.0/surface_width, 1.0/surface_height);

But what is actually desired is:

	cairo_scale (surface_width, surface_height);

I hope that helps,

-Carl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.cairographics.org/archives/cairo/attachments/20090722/ec986a64/attachment.pgp 


More information about the cairo mailing list