Source

gd-libgd / src / fontwheeltest.c

Diff from to

src/fontwheeltest.c

 }
 
 void
-dowheel (gdImagePtr im, int color, char *fontfile,
-	 int fontsize, double angle, int x, int y, char *string)
+dowheel (gdImagePtr im, int color, char *fontfile, int fontsize,
+	double angle, int x, int y, int offset, char *string)
 {
   int brect[8];
   FILE *err;
-  double curang;
+  double curangrads, curang, x0, y0;
   char *cp;
 
   err = fopen ("err.out", "a");
 
   for (curang = 0.0; curang < 360.0; curang += angle)
     {
+      curangrads = DEGTORAD(curang);
+      x0 = x + cos (curangrads) * offset;
+      y0 = y - sin (curangrads) * offset;
+
       /* The case of newlines is taken care of in the gdImageStringTTF call */
 #if defined(OLDER_GD)
-      cp =
-	gdImageStringTTF (im, brect, color, fontfile, fontsize,
-			  DEGTORAD (curang), x, y, string);
+      cp = gdImageStringTTF (im, brect, color, fontfile, fontsize,
+			  curangrads, x0, y0, string);
 #else
-      cp =
-	gdImageStringFT (im, brect, color, fontfile, fontsize,
-			 DEGTORAD (curang), x, y, string);
+      cp = gdImageStringFT (im, brect, color, fontfile, fontsize,
+			 curangrads, x0, y0, string);
 #endif
       if (cp)
 	doerr (err, cp);
+
+      gdImagePolygon (im, (gdPointPtr)brect, 4, color);
     }
 
   fclose (err);
 }
 
+#if 0
 void
 dolines (gdImagePtr im, int color, double incr, int x, int y, int offset,
 	 int length)
       gdImageLine (im, x0, y0, x1, y1, color);
     }
 }
+#endif
 
 void
 dotest (char *font, int size, double incr,
 
   out = fopen (filename, "wb");
 
-  dowheel (im, fc, font, size, incr, xc, yc, string);
+  dowheel (im, fc, font, size, incr, xc, yc, 20, string);
+#if 0
   dolines (im, lc, incr, xc, yc, 20, 120);
+#endif
 
 #if defined(HAVE_LIBPNG)
   gdImagePng (im, out);
 {
 
 #if defined(HAVE_LIBPNG)
-  dotest ("times", 16, 20.0, 400, 400, ".....Hello, there!",
+  dotest ("times", 16, 20.0, 400, 400, "Hello, there!",
 	  "fontwheeltest1.png");
-  dotest ("times", 16, 30.0, 400, 400, ".....Hello, there!",
+  dotest ("times", 16, 30.0, 400, 400, "Hello, there!",
 	  "fontwheeltest2.png");
-  dotest ("arial", 16, 45.0, 400, 400, ".....Hello, there!",
+  dotest ("arial", 16, 45.0, 400, 400, "Hello, there!",
 	  "fontwheeltest3.png");
-  dotest ("arial", 16, 90.0, 400, 400, ".....Hello, there!",
+  dotest ("arial", 16, 90.0, 400, 400, "Hello\nthere!",
 	  "fontwheeltest4.png");
 #elif defined(HAVE_LIBJPEG)
-  dotest ("times", 16, 20.0, 400, 400, ".....Hello, there!",
+  dotest ("times", 16, 20.0, 400, 400, "Hello, there!",
 	  "fontwheeltest1.jpeg");
-  dotest ("times", 16, 30.0, 400, 400, ".....Hello, there!",
+  dotest ("times", 16, 30.0, 400, 400, "Hello, there!",
 	  "fontwheeltest2.jpeg");
-  dotest ("arial", 16, 45.0, 400, 400, ".....Hello, there!",
+  dotest ("arial", 16, 45.0, 400, 400, "Hello, there!",
 	  "fontwheeltest3.jpeg");
-  dotest ("arial", 16, 90.0, 400, 400, ".....Hello, there!",
+  dotest ("arial", 16, 90.0, 400, 400, "Hello\nthere!",
 	  "fontwheeltest4.jpeg");
 #else
   fprintf (stderr, "no PNG or JPEG support\n");