<font color='black' size='2' face='arial'>
<div> <font size="2"><br>
It is worth mentioning here that when you draw lines around the box with the usual way of doing this,<br>
<br>
cairo_fill_preserve(cr);<br>
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0);<br>
cairo_stroke(cr);<br>
<br>
the scale will cause the lines to be non uniform. This is mentioned in the Cairo Tutorial under Working with Transforms.<br>
<br>
To get the lines around the box to be uniform, the transformed points can be mapped to device space or the starting coordinates that cairo uses. Then the lines around the box can be drawn. The following shows this.<br>
<br>
Have fun drawing.<br>
Eric<br>
<br>
...<br>
//Order transforms and draw.<br>
cairo_save(cr);<br>
cairo_translate(cr, center_box_x, center_box_y);<br>
cairo_rotate(cr, rotate);<br>
cairo_scale(cr, box_width/fabs(2.0*move_x), box_height/fabs(2.0*move_y));<br>
cairo_set_source_rgba(cr, 0.0, 1.0, 0.0, 0.4);<br>
double r1=-fabs(scale_x);<br>
double r2=-fabs(scale_y);<br>
double r3=fabs(2.0*scale_x);<br>
double r4=fabs(2.0*scale_y);<br>
cairo_rectangle(cr, r1, r2, r3, r4);<br>
cairo_fill(cr);<br>
//Save device cordinates for the rectangle so that lines are drawn correctly.<br>
double c1=r1;<br>
double c2=r2;<br>
double c3=r1;<br>
double c4=r2+r4;<br>
double c5=r1+r3;<br>
double c6=r2+r4;<br>
double c7=r1+r3;<br>
double c8=r2;<br>
cairo_user_to_device(cr, &c1, &c2);<br>
cairo_user_to_device(cr, &c3, &c4);<br>
cairo_user_to_device(cr, &c5, &c6);<br>
cairo_user_to_device(cr, &c7, &c8);<br>
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0);<br>
cairo_move_to(cr, move_x, move_y);<br>
cairo_show_text(cr, string);<br>
cairo_restore(cr); <br>
<br>
//Draw box lines.<br>
cairo_save(cr);<br>
cairo_set_source_rgba(cr, 0.0, 0.0, 1.0, 1.0);<br>
cairo_set_line_width(cr, 4.0);<br>
//Reset transform matrix.<br>
cairo_identity_matrix(cr);<br>
cairo_move_to(cr, c1, c2);<br>
cairo_line_to(cr, c3, c4);<br>
cairo_line_to(cr, c5, c6);<br>
cairo_line_to(cr, c7, c8);<br>
cairo_close_path(cr);<br>
cairo_stroke(cr);<br>
cairo_restore(cr);<br>
}<br>
</font><br>
</div>
<div> <br>
</div>
<div> <br>
</div>
<div style="font-family:arial,helvetica;font-size:10pt;color:black"><br>
</div>
</font>