diff options
Diffstat (limited to 'src/gddemo.c')
-rw-r--r-- | src/gddemo.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/gddemo.c b/src/gddemo.c index 7643698..1057e1f 100644 --- a/src/gddemo.c +++ b/src/gddemo.c @@ -4,6 +4,7 @@ #endif #include <stdio.h> +#include <math.h> #include "gd.h" #include "gdfontg.h" #include "gdfonts.h" @@ -31,13 +32,14 @@ main (void) /* Points for polygon */ gdPoint points[3]; - /* Create output image, in true color. */ + /* Create output image, in true color. */ im_out = gdImageCreateTrueColor (256 + 384, 384); /* 2.0.2: first color allocated would automatically be background in a - palette based image. Since this is a truecolor image, with an - automatic background of black, we must fill it explicitly. */ + palette based image. Since this is a truecolor image, with an + automatic background of black, we must fill it explicitly. */ white = gdImageColorAllocate (im_out, 255, 255, 255); - gdImageFilledRectangle(im_out, 0, 0, gdImageSX(im_out), gdImageSY(im_out), white); + gdImageFilledRectangle (im_out, 0, 0, gdImageSX (im_out), + gdImageSY (im_out), white); /* Set transparent color. */ gdImageColorTransparent (im_out, white); @@ -58,16 +60,16 @@ main (void) im_in = gdImageCreateFromPng (in); fclose (in); /* Now copy, and magnify as we do so */ - gdImageCopyResized (im_out, im_in, - 32, 32, 0, 0, 192, 192, 255, 255); + gdImageCopyResized (im_out, im_in, 32, 32, 0, 0, 192, 192, 255, 255); /* Now display variously rotated space shuttles in a circle of our own */ - for (a = 0; (a < 360); a += 45) { - int cx = cos(a * .0174532925) * 128; - int cy = - sin(a * .0174532925) * 128; - gdImageCopyRotated(im_out, im_in, - 256 + 192 + cx, 192 + cy, - 0, 0, gdImageSX(im_in), gdImageSY(im_in), a); - } + for (a = 0; (a < 360); a += 45) + { + int cx = cos (a * .0174532925) * 128; + int cy = -sin (a * .0174532925) * 128; + gdImageCopyRotated (im_out, im_in, + 256 + 192 + cx, 192 + cy, + 0, 0, gdImageSX (im_in), gdImageSY (im_in), a); + } } red = gdImageColorAllocate (im_out, 255, 0, 0); green = gdImageColorAllocate (im_out, 0, 255, 0); @@ -117,10 +119,8 @@ main (void) gdImageLine (im_out, 0, 255, 255, 0, gdStyledBrushed); } /* Text */ - gdImageString (im_out, gdFontGiant, 32, 32, - (unsigned char *) "hi", red); - gdImageStringUp (im_out, gdFontSmall, 64, 64, - (unsigned char *) "hi", red); + gdImageString (im_out, gdFontGiant, 32, 32, (unsigned char *) "hi", red); + gdImageStringUp (im_out, gdFontSmall, 64, 64, (unsigned char *) "hi", red); /* Make output image interlaced (progressive, in the case of JPEG) */ gdImageInterlace (im_out, 1); out = fopen ("demoout.png", "wb"); @@ -133,7 +133,7 @@ main (void) gdImageDestroy (im_in); } #else - fprintf(stderr,"No PNG library support.\n"); + fprintf (stderr, "No PNG library support.\n"); #endif /* HAVE_LIBPNG */ return 0; } |