<div dir="ltr">Thanks, that works. :-)</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Apr 18, 2021 at 1:37 AM Heiko Lewin <<a href="mailto:hlewin@gmx.de">hlewin@gmx.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div>
    <p>PS: Try this</p>
    <pre><font face="monospace">
 cairo_set_source_rgb(state->cr, 1.0, 0.0, 0.0);
 cairo_translate(state->cr, 500, 500);
 cairo_rotate(state->cr, M_PI / 4);
 cairo_translate(state->cr, -500, -500);
 cairo_rectangle(state->cr, 400, 400, 200, 200);
 double x0, y0, x1, y1;</font><font face="monospace"><font face="monospace">
</font></font></pre>
    <pre><font face="monospace"><font face="monospace">  cairo_identity_matrix(state->cr);</font>
</font></pre>
    <pre><font face="monospace">  cairo_fill_extents(state->cr, &x0, &y0, &x1, &y1);
  cairo_fill(state->cr);
...
</font></pre>
    <div>Am 17.04.2021 um 22:15 schrieb Heiko
      Lewin:<br>
    </div>
    <blockquote type="cite">
      
      <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>Am 17.04.2021 um 22:03 schrieb Moazin
        K:<br>
      </div>
      <blockquote type="cite">
        
        <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></fieldset>
      </blockquote>
      <br>
      <fieldset></fieldset>
    </blockquote>
  </div>

-- <br>
cairo mailing list<br>
<a href="mailto:cairo@cairographics.org" target="_blank">cairo@cairographics.org</a><br>
<a href="https://lists.cairographics.org/mailman/listinfo/cairo" rel="noreferrer" target="_blank">https://lists.cairographics.org/mailman/listinfo/cairo</a><br>
</blockquote></div>