[cairo] How to get extents of transformed graphics

Uli Schlachter psychon at znc.in
Sun Sep 18 08:40:18 UTC 2022


Hi,

Am 17.09.22 um 15:31 schrieb Andreas Falkenhahn:
> On 17.09.2022 at 13:47 Uli Schlachter wrote:
[...]
> It's a bit frustrating that nobody corrected this misconception because I
> actually started my very first email on 28th August with it. I wrote:
> 
> "Is there any way to get the *exact* extents of transformed graphics? AFAICS,
> cairo_fill_extents() is in user coordinates, i.e. it doesn't take any transformation
> settings into account."
> 
> If someone had just said "Hey, cairo_fill_extents() *does* take the transformation
> settings into account" it would have spared me a lot of trouble :-(

Sorry for that. I am (currently - I guess also back then) 
misunderstanding this question as what the attached example 
demonstrates. The "exact" made me think you meant this.

Left part of the image: A rectangle and its extents according to 
cairo_path_extents().
Right part: The same thing, but with the user coordinate space rotated 
by 45°.

To everyone who wonders what is going on: Cairo internally works in 
device space. All translation from user to device space is done at the 
API boundary. Thus, cairo_path_extents() internally gets the extents in 
device space. This describes a rectangle. This rectangle is then 
translated to user space. Thus, the white rectangle in the image would 
be "exact" if I had drawn a rectangle instead of a circle.

Dunno if the above makes sense and sorry for misunderstanding the 
original question in this direction originally and again sorry for not 
answering even then.

Cheers,
Uli
-- 
- He made himself, me nothing, you nothing out of the dust
- Er machte sich mir nichts, dir nichts aus dem Staub
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: text/x-csrc
Size: 1084 bytes
Desc: not available
URL: <https://lists.cairographics.org/archives/cairo/attachments/20220918/9d16eaae/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tmp.png
Type: image/png
Size: 1577 bytes
Desc: not available
URL: <https://lists.cairographics.org/archives/cairo/attachments/20220918/9d16eaae/attachment.png>


More information about the cairo mailing list