Re: Unsymmetrical rotation

Olaf Schmidt <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
Am 04.03.2013 22:03, schrieb Blagoj Kupev:

> Does anyone else have any other idea? Can this be a bug in cairo?

I'm pretty sure, it's not a bug - and could also be done whilst
working against the canvas directly - but why not trying a nicer
base-approach, which would allow you to "pre-set" certain things
for even more drawing-objects than just a "single box" (in case
you want to go there in the future).


What helped me with "complex individual rotations" of different
drawing-objects (having all kind of individual sizes on a given
"base-canvas"), was to just wrap the surface of any such image
in a pattern - and then using the *pattern*-matrix to set the
individual centerpoint and rotation for each of those child-objects.

Based on a simple sequence against the the current pattern-matrix, using 
the current sub-surface width/height as follows:
   Translate CurImgWidth / 2, CurImgHeight / 2
     Rotate YourAngle
   Translate -CurImgWidth / 2, -CurImgHeight / 2

After pattern-wrapping and applying such an individual pattern-
matrix, the main-rendering-routine for those child-objects didn't
need to be changed at all (with regards to the x- and y-Offsets
for the placement of those child-objects on the canvas).
You can then treat those child-containers offsets, as if they'd
be always (or still) in "original, unchanged simple box-mode".

Only thing to change of course in the main-rendering-routine,
in case it contains a sub-routine like this (or will be changed
to use something like the following one in a first step - still
using unrotated "box-surfaces" and no patterns - just for testing):

place_box_surface(cr, boxSrf, xOffs, yOffs){
   cairo_save cr
     cairo_translate cr, xOffs, yOffs
     cairo_set_source_surface cr, boxSrf, 0, 0
     cairo_paint cr
   cairo_restore cr
}

Will be the replacment of the above:
   cairo_set_source_surface cr, boxSrf, 0, 0
with:
   cairo_set_source cr, boxPat

So later, when you have your pattern-wrapped surface(s) in place -
and the individual box-rotation applied to the pattern-matrix,
you could switch-over to something like that routine here:

place_box_pattern(cr, boxPat, xOffs, yOffs){
   cairo_save cr
     cairo_translate cr, xOffs, yOffs
     cairo_set_source cr, boxPat
     cairo_paint cr
   cairo_restore cr
}


Olaf

-- 
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.