[cairo] Extents under rotation

Uli Schlachter psychon at znc.in
Sun Dec 8 09:21:25 PST 2013


Hi again,

On 07.12.2013 08:31, Donn wrote:
> On 06/12/2013 17:13, Bill Spitzak wrote:
>> The matrices are multiplied before this is done, so this error does not
>> accumulate. For instance if you rotate by 45 degrees and then back by 45
>> degrees, it will act like a rotation of 0 and produce your expected
>> bounding box, rather than enlarging the bounding box twice.
>
> I'm sure I will face these things soon when I institute picking beyond a
> basic bbox hit approach.
>
>
>
> Bill,
> Do you have a way to draw a tight bbox in user-space around a path?
[...]

I was bored, so:

See the attached test program (written in C since I don't know vala). It uses 
three different ways for getting the extents of a circle.

1) cairo_path_extents()
2) cairo_path_extents() after cairo_identity_matrix()
3) Some slow calculations with cairo_copy_path_flat(). See get_path_extents().

The first row is painted without any rotation (I needed this since I made a typo 
at first with x1/y1/x2/y2 that I took a while to find) with the calculations as 
mentioned above.

The second row is rotated by 67° and the individual rectangles are again 
calculated as above.

Hope this helps,
Uli
-------------- next part --------------
A non-text attachment was scrubbed...
Name: img.png
Type: image/png
Size: 9044 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20131208/8f4f1ae3/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: text/x-csrc
Size: 2333 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20131208/8f4f1ae3/attachment-0001.c>


More information about the cairo mailing list