[cairo-commit] cairo/test text_rotate.c,1.2,1.3
Carl Worth
commit at pdx.freedesktop.org
Tue Nov 9 14:27:34 PST 2004
Committed by: cworth
Update of /cvs/cairo/cairo/test
In directory gabe:/tmp/cvs-serv16710
Modified Files:
text_rotate.c
Log Message:
(draw): Move x_off, y_off calculation outside of loop to emphasize
loop-independence.
Index: text_rotate.c
===================================================================
RCS file: /cvs/cairo/cairo/test/text_rotate.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- text_rotate.c 9 Nov 2004 22:22:37 -0000 1.2
+++ text_rotate.c 9 Nov 2004 22:27:32 -0000 1.3
@@ -74,7 +74,7 @@
static void
draw (cairo_t *cr, int width, int height)
{
- int i;
+ int i, x_off, y_off;
cairo_text_extents_t extents;
static char text[] = "cairo";
@@ -88,15 +88,15 @@
cairo_translate (cr, WIDTH/2.0, HEIGHT/2.0);
cairo_text_extents (cr, text, &extents);
+
+ if (NUM_TEXT == 1) {
+ x_off = y_off = 0;
+ } else {
+ y_off = - round (extents.height / 2.0);
+ x_off = round ((extents.height+1) / (2 * tan (M_PI/NUM_TEXT)));
+ }
for (i=0; i < NUM_TEXT; i++) {
- double x_off, y_off;
- if (NUM_TEXT == 1) {
- x_off = y_off = 0.0;
- } else {
- y_off = - round (extents.height / 2.0);
- x_off = round ((extents.height+1) / (2 * tan (M_PI/NUM_TEXT)));
- }
cairo_save (cr);
cairo_rotate (cr, 2*M_PI*i/NUM_TEXT);
cairo_set_line_width (cr, 1.0);
More information about the cairo-commit
mailing list