<div style="color:black;font: 10pt arial;">
<div> <font size="2"><br>
A path in user space can change it's bounding box size with a transform. A scale or rotation can change the size of a bounding box.<br>
<br>
With your code, test the output by drawing it. That is one of the cool things about drawing. If you are working on a tough drawing you can often see mistakes that you might miss otherwise.<br>
<br>
Eric</font></div>

<div><font size="2"><br>
</font></div>

<div><font size="2"><br>
//gcc -Wall bounding_box1.c -o bounding_box1 `pkg-config --cflags --libs cairo` -lm<br>
<br>
#include<cairo.h><br>
#include<stdio.h><br>
#include<math.h><br>
<br>
int main()<br>
  {<br>
    double width=500.0;<br>
    double height=500.0;<br>
    double x1=0.0;<br>
    double y1=0.0;<br>
    double x2=0.0;<br>
    double y2=0.0;<br>
    cairo_surface_t *surface=cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);<br>
    cairo_t *cr=cairo_create(surface);<br>
   <br>
    //Paint the background.<br>
    cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 1.0);<br>
    cairo_paint(cr);<br>
<br>
    //Translate shape.<br>
    cairo_save(cr);<br>
    cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 1.0);<br>
    cairo_translate(cr, width/4.0, height/4.0);<br>
    cairo_move_to(cr, 100.0, 0.0);<br>
    cairo_curve_to(cr, 50.0, -50.0, -50.0, -50.0, -100.0, 0.0);<br>
    cairo_curve_to(cr, -50.0, 50.0, 50.0, 50.0, 100.0, 0.0);<br>
    cairo_path_extents(cr, &x1, &y1, &x2, &y2);<br>
    cairo_fill(cr);<br>
    cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0);<br>
    cairo_rectangle(cr, x1, y1, x2-x1, y2-y1);<br>
    cairo_stroke(cr);<br>
    cairo_restore(cr);<br>
<br>
    //Translate and scale shape.<br>
    cairo_save(cr);<br>
    cairo_set_source_rgba(cr, 0.0, 1.0, 0.0, 1.0);<br>
    cairo_translate(cr, 3.0*width/4.0, height/4.0);<br>
    cairo_scale(cr, 0.75, 0.75);<br>
    cairo_move_to(cr, 100.0, 0.0);<br>
    cairo_curve_to(cr, 50.0, -50.0, -50.0, -50.0, -100.0, 0.0);<br>
    cairo_curve_to(cr, -50.0, 50.0, 50.0, 50.0, 100.0, 0.0);<br>
    cairo_path_extents(cr, &x1, &y1, &x2, &y2);<br>
    cairo_fill(cr);<br>
    cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0);<br>
    cairo_rectangle(cr, x1, y1, x2-x1, y2-y1);<br>
    cairo_stroke(cr);<br>
    cairo_restore(cr);<br>
<br>
    //Translate and rotate shape.<br>
    cairo_save(cr);<br>
    cairo_set_source_rgba(cr, 0.0, 0.0, 1.0, 1.0);<br>
    cairo_translate(cr, width/4.0, 3.0*height/4.0);<br>
    cairo_rotate(cr, M_PI/2.0);<br>
    cairo_move_to(cr, 100.0, 0.0);<br>
    cairo_curve_to(cr, 50.0, -50.0, -50.0, -50.0, -100.0, 0.0);<br>
    cairo_curve_to(cr, -50.0, 50.0, 50.0, 50.0, 100.0, 0.0);<br>
    cairo_path_extents(cr, &x1, &y1, &x2, &y2);<br>
    cairo_fill(cr);<br>
    cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0);<br>
    cairo_rectangle(cr, x1, y1, x2-x1, y2-y1);<br>
    cairo_stroke(cr);<br>
    cairo_restore(cr);<br>
    <br>
    printf("Output to bounding_box.png\n");<br>
    cairo_surface_write_to_png(surface, "bounding_box.png");<br>
<br>
    cairo_destroy(cr);<br>
    cairo_surface_destroy(surface);<br>
 <br>
    return 0;<br>
  }</font><br>
</div>

<div> <br>
</div>
<br>
</div>