Re: Unsymmetrical rotation

Bill Spitzak <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
On 03/04/2013 11:15 PM, Carlos López González wrote:
> Hi Blagoj,
> I don't think it is a bug I think that you need to do one extra step:
> If alpha is the angle (ccw), origin is the rotation center (in device
> units) and w,h are the final image dimensions you have to do this:
>
> cairo_translate(cr, origin.x, origin.y);
>
> cairo_rotate(cr, -1.0*angle);
>
> cairo_translate(cr, -origin.x, -origin.y);
>
> cairo_set_source_surface(cr, source, x, y);
>
> where x and y are the result of the minimum x and minimum y of the
> clockwise rotated corners
> of the source surface top_left(0,0), top_right(w, 0), bottom_left(0, h)
> and bottom_right(w, h).

So you are saying the xy arguments for cairo_set_source_surface are the 
location to put the top-left corner of the bounding box of the 
transformed image? That's totally useless and very hard to believe! The 
only way to get a predictable result is for both Cairo and the caller to 
do the exact same bounding box calculation, thus they both have to do 
the transform?

I'm pretty certain the xy cause a translation from some location that 
Cairo considers "natural" and that it is either in the source surface 
space (that might be useful) or in the CTM (in which case another 
cairo_translate would do the same thing). I know I have gotten correct 
transforms out of Cairo, though it is not easy. I think this was done by 
passing 0,0 for the x,y.

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.