<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hello!</p>
<p>The _entents-functions return coordinates in the current
user-coordinate-system, that is the same transform as when drawing
the rectangle needs to be applied for meaningful results.</p>
<div class="moz-cite-prefix">Am 17.04.2021 um 22:03 schrieb Moazin
K:<br>
</div>
<blockquote type="cite"
cite="mid:CABgJyi5XzJqK5CcNf+hwNzDJNCeQDmO0CNJdHreK1OSR0hQAHA@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div class="gmail_quote">
<div dir="ltr">Hi all,
<div><br>
</div>
<div>While playing with the `*_extents` functions of Cairo,
I discovered that `cairo_fill_extents` and
`cairo_stroke_extents` give slightly poor results when a
rotation transform has been applied on the path.</div>
<div><br>
</div>
<div>My code is pretty simple:</div>
<div><br>
</div>
<div><font face="monospace">
cairo_set_source_rgb(state->cr, 1.0, 0.0, 0.0);<br>
cairo_translate(state->cr, 500, 500);<br>
cairo_rotate(state->cr, M_PI / 4);<br>
cairo_translate(state->cr, -500, -500);<br>
cairo_rectangle(state->cr, 400, 400, 200, 200);<br>
double x0, y0, x1, y1;<br>
cairo_fill_extents(state->cr, &x0, &y0,
&x1, &y1);<br>
cairo_fill(state->cr);<br>
<br>
cairo_identity_matrix(state->cr);<br>
cairo_set_source_rgb(state->cr, 0.0, 0.0, 1.0);<br>
cairo_set_line_width(state->cr, 1);<br>
cairo_rectangle(state->cr, x0, y0, x1 - x0 + 1, y1
- y0 + 1);<br>
cairo_stroke(state->cr);</font><br>
</div>
<div><br>
</div>
<div>Extents come out to be:</div>
<div>[x0 y0 x1 y1] -> [299.999266 299.999266 700.000734
700.000734]<br>
</div>
<div><br>
</div>
<div>The picture `cairo-rotate-problem.png` visualizes this.
I think the result should be as shown in
`cairo-rotate-problem-right-result-imho.png`. Please tell
me if this is the expected behavior or a bug or
enhancement and I can appropriately create an issue on the
Gitlab issue tracker.</div>
<div><br>
</div>
<div>It didn't make sense to me why the function behaves
this way, when calculating the tight bounds is actually
easy. I can get my desired results by removing the
transform, calculating extents and then transforming those
extents to get a quadrilateral on which I can fit a
rectangle to get the tight bounds.</div>
<div><br>
</div>
<div>Thank you,</div>
<div>Moazin</div>
<div><font face="monospace"><br>
</font></div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
</blockquote>
</body>
</html>