.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "GD 3pm" .TH GD 3pm "2016-08-13" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" GD.pm \- Interface to Gd Graphics Library .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use GD; \& \& # create a new image \& $im = new GD::Image(100,100); \& \& # allocate some colors \& $white = $im\->colorAllocate(255,255,255); \& $black = $im\->colorAllocate(0,0,0); \& $red = $im\->colorAllocate(255,0,0); \& $blue = $im\->colorAllocate(0,0,255); \& \& # make the background transparent and interlaced \& $im\->transparent($white); \& $im\->interlaced(\*(Aqtrue\*(Aq); \& \& # Put a black frame around the picture \& $im\->rectangle(0,0,99,99,$black); \& \& # Draw a blue oval \& $im\->arc(50,50,95,75,0,360,$blue); \& \& # And fill it with red \& $im\->fill(50,50,$red); \& \& # make sure we are writing to a binary stream \& binmode STDOUT; \& \& # Convert the image to PNG and print it on standard output \& print $im\->png; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fB\s-1GD\s0.pm\fR is a port of Thomas Boutell's gd graphics library (see below). \s-1GD\s0 allows you to create color drawings using a large number of graphics primitives, and emit the drawings as \s-1PNG\s0 files. .PP \&\s-1GD\s0 defines the following three classes: .ie n .IP """GD::Image""" 5 .el .IP "\f(CWGD::Image\fR" 5 .IX Item "GD::Image" An image class, which holds the image data and accepts graphic primitive method calls. .ie n .IP """GD::Font""" 5 .el .IP "\f(CWGD::Font\fR" 5 .IX Item "GD::Font" A font class, which holds static font information and used for text rendering. .ie n .IP """GD::Polygon""" 5 .el .IP "\f(CWGD::Polygon\fR" 5 .IX Item "GD::Polygon" A simple polygon object, used for storing lists of vertices prior to rendering a polygon into an image. .PP A Simple Example: .PP .Vb 1 \& #!/usr/local/bin/perl \& \& use GD; \& \& # create a new image \& $im = new GD::Image(100,100); \& \& # allocate some colors \& $white = $im\->colorAllocate(255,255,255); \& $black = $im\->colorAllocate(0,0,0); \& $red = $im\->colorAllocate(255,0,0); \& $blue = $im\->colorAllocate(0,0,255); \& \& # make the background transparent and interlaced \& $im\->transparent($white); \& $im\->interlaced(\*(Aqtrue\*(Aq); \& \& # Put a black frame around the picture \& $im\->rectangle(0,0,99,99,$black); \& \& # Draw a blue oval \& $im\->arc(50,50,95,75,0,360,$blue); \& \& # And fill it with red \& $im\->fill(50,50,$red); \& \& # make sure we are writing to a binary stream \& binmode STDOUT; \& \& # Convert the image to PNG and print it on standard output \& print $im\->png; .Ve .PP Notes: .IP "1. To create a new, empty image, send a \fInew()\fR message to GD::Image, passing it the width and height of the image you want to create. An image object will be returned. Other class methods allow you to initialize an image from a preexisting \s-1PNG, GD\s0 or \s-1XBM\s0 file." 5 .IX Item "1. To create a new, empty image, send a new() message to GD::Image, passing it the width and height of the image you want to create. An image object will be returned. Other class methods allow you to initialize an image from a preexisting PNG, GD or XBM file." .PD 0 .IP "2. Next you will ordinarily add colors to the image's color table. colors are added using a \fIcolorAllocate()\fR method call. The three parameters in each call are the red, green and blue (rgb) triples for the desired color. The method returns the index of that color in the image's color table. You should store these indexes for later use." 5 .IX Item "2. Next you will ordinarily add colors to the image's color table. colors are added using a colorAllocate() method call. The three parameters in each call are the red, green and blue (rgb) triples for the desired color. The method returns the index of that color in the image's color table. You should store these indexes for later use." .IP "3. Now you can do some drawing! The various graphics primitives are described below. In this example, we do some text drawing, create an oval, and create and draw a polygon." 5 .IX Item "3. Now you can do some drawing! The various graphics primitives are described below. In this example, we do some text drawing, create an oval, and create and draw a polygon." .IP "4. Polygons are created with a \fInew()\fR message to GD::Polygon. You can add points to the returned polygon one at a time using the \fIaddPt()\fR method. The polygon can then be passed to an image for rendering." 5 .IX Item "4. Polygons are created with a new() message to GD::Polygon. You can add points to the returned polygon one at a time using the addPt() method. The polygon can then be passed to an image for rendering." .ie n .IP "5. When you're done drawing, you can convert the image into \s-1PNG\s0 format by sending it a \fIpng()\fR message. It will return a (potentially large) scalar value containing the binary data for the image. Ordinarily you will print it out at this point or write it to a file. To ensure portability to platforms that differentiate between text and binary files, be sure to call ""binmode()"" on the file you are writing the image to." 5 .el .IP "5. When you're done drawing, you can convert the image into \s-1PNG\s0 format by sending it a \fIpng()\fR message. It will return a (potentially large) scalar value containing the binary data for the image. Ordinarily you will print it out at this point or write it to a file. To ensure portability to platforms that differentiate between text and binary files, be sure to call \f(CWbinmode()\fR on the file you are writing the image to." 5 .IX Item "5. When you're done drawing, you can convert the image into PNG format by sending it a png() message. It will return a (potentially large) scalar value containing the binary data for the image. Ordinarily you will print it out at this point or write it to a file. To ensure portability to platforms that differentiate between text and binary files, be sure to call binmode() on the file you are writing the image to." .PD .SH "Method Calls" .IX Header "Method Calls" .SS "Creating and Saving Images" .IX Subsection "Creating and Saving Images" .ie n .IP """new""" 5 .el .IP "\f(CWnew\fR" 5 .IX Item "new" \&\f(CW\*(C`GD::Image\->new(width,height)\*(C'\fR \fIclass method\fR .Sp To create a new, blank image, send a \fInew()\fR message to the GD::Image class. For example: .Sp .Vb 1 \& $myImage = new GD::Image(100,100) || die; .Ve .Sp This will create an image that is 100 x 100 pixels wide. If you don't specify the dimensions, a default of 64 x 64 will be chosen. If something goes wrong (e.g. insufficient memory), this call will return undef. .ie n .IP """newFromPng""" 5 .el .IP "\f(CWnewFromPng\fR" 5 .IX Item "newFromPng" \&\f(CW\*(C`GD::Image\->newFromPng(FILEHANDLE)\*(C'\fR \fIclass method\fR .Sp This will create an image from a \s-1PNG\s0 file read in through the provided filehandle. The filehandle must previously have been opened on a valid \s-1PNG\s0 file or pipe. If successful, this call will return an initialized image which you can then manipulate as you please. If it fails, which usually happens if the thing at the other end of the filehandle is not a valid \s-1PNG\s0 file, the call returns undef. Notice that the call doesn't automatically close the filehandle for you. But it does call \f(CW\*(C`binmode(FILEHANDLE)\*(C'\fR for you, on platforms where this matters. .Sp To get information about the size and color usage of the information, you can call the image query methods described below. .Sp .Vb 1 \& Example usage: \& \& open (PNG,"barnswallow.png") || die; \& $myImage = newFromPng GD::Image(PNG) || die; \& close PNG; .Ve .ie n .IP """newFromXbm""" 5 .el .IP "\f(CWnewFromXbm\fR" 5 .IX Item "newFromXbm" \&\f(CW\*(C`GD::Image\->newFromXbm(FILEHANDLE)\*(C'\fR \fIclass method\fR .Sp This works in exactly the same way as \f(CW\*(C`newFromPng\*(C'\fR, but reads the contents of an X Bitmap (black & white) file: .Sp .Vb 3 \& open (XBM,"coredump.xbm") || die; \& $myImage = newFromXbm GD::Image(XBM) || die; \& close XBM; .Ve .Sp Note that this function also calls \f(CW\*(C`binmode(FILEHANDLE)\*(C'\fR before reading from the filehandle. .ie n .IP """newFromXpm""" 5 .el .IP "\f(CWnewFromXpm\fR" 5 .IX Item "newFromXpm" \&\f(CW\*(C`GD::Image\->newFromXpm($filename)\*(C'\fR \fIclass method\fR .Sp This creates a new GD::Image object starting from a \fBfilename\fR. This is unlike the other \fInewFrom()\fR functions because it does not take a filehandle. This difference comes from an inconsistency in the underlying gd library. .Sp .Vb 1 \& $myImage = newFromXpm GD::Image(\*(Aqearth.xpm\*(Aq) || die; .Ve .Sp This function is only available if libgd was compiled with \s-1XPM\s0 support. .Sp \&\s-1NOTE:\s0 As of version 1.7.3 of the libgd library, I can't get the underlying \fIcreateFromXpm()\fR function to return a valid image \*(-- I just get black. .ie n .IP """newFromGd2""" 5 .el .IP "\f(CWnewFromGd2\fR" 5 .IX Item "newFromGd2" \&\f(CW\*(C`GD::Image\->newFromGd2(FILEHANDLE)\*(C'\fR \fIclass method\fR .Sp This works in exactly the same way as \f(CW\*(C`newFromgd()\*(C'\fR, but uses the new compressed \s-1GD2\s0 image format. .ie n .IP """newFromGd""" 5 .el .IP "\f(CWnewFromGd\fR" 5 .IX Item "newFromGd" \&\f(CW\*(C`GD::Image\->newFromGd(FILEHANDLE)\*(C'\fR \fIclass method\fR .Sp This works in exactly the same way as \f(CW\*(C`newFromPng\*(C'\fR, but reads the contents of a \s-1GD\s0 file. \s-1GD\s0 is Tom Boutell's disk-based storage format, intended for the rare case when you need to read and write the image to disk quickly. It's not intended for regular use, because, unlike \&\s-1PNG\s0 or \s-1JPEG,\s0 no image compression is performed and these files can become \fB\s-1BIG\s0\fR. .Sp .Vb 3 \& open (GDF,"godzilla.gd") || die; \& $myImage = newFromGd GD::Image(GDF) || die; \& close GDF; .Ve .Sp Note that this function also calls \f(CW\*(C`binmode(FILEHANDLE)\*(C'\fR before reading from the supplied filehandle. .ie n .IP """newFromGd2""" 5 .el .IP "\f(CWnewFromGd2\fR" 5 .IX Item "newFromGd2" \&\f(CW\*(C`GD::Image\->newFromGd2(FILEHANDLE)\*(C'\fR \fIclass method\fR .Sp This works in exactly the same way as \f(CW\*(C`newFromgd()\*(C'\fR, but uses the new compressed \s-1GD2\s0 image format. .ie n .IP """newFromGd2Part""" 5 .el .IP "\f(CWnewFromGd2Part\fR" 5 .IX Item "newFromGd2Part" \&\f(CW\*(C`GD::Image\->newFromGd2Part(FILEHANDLE,srcX,srcY,width,height)\*(C'\fR \fIclass method\fR .Sp This class method allows you to read in just a portion of a \s-1GD\s0 version 2 image file. In additionto a filehandle, it accepts the top-left corner and dimensions (width,height) of the region of the image to read. For example: .Sp .Vb 3 \& open (GDF,"godzilla.gd2") || die; \& $myImage = GD::Image\->newFromGd2Part(GDF,10,20,100,100) || die; \& close GDF; .Ve .Sp This reads a 100x100 square portion of the image starting from position (10,20). .ie n .IP """png""" 5 .el .IP "\f(CWpng\fR" 5 .IX Item "png" \&\f(CW\*(C`$image\->png\*(C'\fR \fIobject method\fR .Sp This returns the image data in \s-1PNG\s0 format. You can then print it, pipe it to a display program, or write it to a file. Example: .Sp .Vb 5 \& $png_data = $myImage\->png; \& open (DISPLAY,"| display \-") || die; \& binmode DISPLAY; \& print DISPLAY $png_data; \& close DISPLAY; .Ve .Sp Note the use of \f(CW\*(C`binmode()\*(C'\fR. This is crucial for portability to DOSish platforms. .ie n .IP """gd""" 5 .el .IP "\f(CWgd\fR" 5 .IX Item "gd" \&\f(CW\*(C`$image\->gd\*(C'\fR \fIobject method\fR .Sp This returns the image data in \s-1GD\s0 format. You can then print it, pipe it to a display program, or write it to a file. Example: .Sp .Vb 2 \& binmode MYOUTFILE; \& print MYOUTFILE $myImage\->gd; .Ve .ie n .IP """gd2""" 5 .el .IP "\f(CWgd2\fR" 5 .IX Item "gd2" \&\f(CW\*(C`$image\->gd2\*(C'\fR \fIobject method\fR .Sp Same as \fIgd()\fR, except that it returns the data in compressed \s-1GD2\s0 format. .SS "Color Control" .IX Subsection "Color Control" .ie n .IP """colorAllocate""" 5 .el .IP "\f(CWcolorAllocate\fR" 5 .IX Item "colorAllocate" \&\f(CW\*(C`$image\->colorAllocate(red,green,blue)\*(C'\fR \fIobject method\fR .Sp This allocates a color with the specified red, green and blue components and returns its index in the color table, if specified. The first color allocated in this way becomes the image's background color. (255,255,255) is white (all pixels on). (0,0,0) is black (all pixels off). (255,0,0) is fully saturated red. (127,127,127) is 50% gray. You can find plenty of examples in /usr/X11/lib/X11/rgb.txt. .Sp If no colors are allocated, then this function returns \-1. .Sp Example: .Sp .Vb 3 \& $white = $myImage\->colorAllocate(0,0,0); #background color \& $black = $myImage\->colorAllocate(255,255,255); \& $peachpuff = $myImage\->colorAllocate(255,218,185); .Ve .ie n .IP """colorDeallocate""" 5 .el .IP "\f(CWcolorDeallocate\fR" 5 .IX Item "colorDeallocate" \&\f(CW\*(C`$image\->colorDeallocate(colorIndex)\*(C'\fR \fIobject method\fR .Sp This marks the color at the specified index as being ripe for reallocation. The next time colorAllocate is used, this entry will be replaced. You can call this method several times to deallocate multiple colors. There's no function result from this call. .Sp Example: .Sp .Vb 2 \& $myImage\->colorDeallocate($peachpuff); \& $peachy = $myImage\->colorAllocate(255,210,185); .Ve .ie n .IP """colorClosest""" 5 .el .IP "\f(CWcolorClosest\fR" 5 .IX Item "colorClosest" \&\f(CW\*(C`$image\->colorClosest(red,green,blue)\*(C'\fR \fIobject method\fR .Sp This returns the index of the color closest in the color table to the red green and blue components specified. If no colors have yet been allocated, then this call returns \-1. .Sp Example: .Sp .Vb 1 \& $apricot = $myImage\->colorClosest(255,200,180); .Ve .ie n .IP """colorExact""" 5 .el .IP "\f(CWcolorExact\fR" 5 .IX Item "colorExact" \&\f(CW\*(C`$image\->colorExact(red,green,blue)\*(C'\fR \fIobject method\fR .Sp This returns the index of a color that exactly matches the specified red green and blue components. If such a color is not in the color table, this call returns \-1. .Sp .Vb 2 \& $rosey = $myImage\->colorExact(255,100,80); \& warn "Everything\*(Aqs coming up roses.\en" if $rosey >= 0; .Ve .ie n .IP """colorResolve""" 5 .el .IP "\f(CWcolorResolve\fR" 5 .IX Item "colorResolve" \&\f(CW\*(C`$image\->colorResolve(red,green,blue)\*(C'\fR \fIobject method\fR .Sp This returns the index of a color that exactly matches the specified red green and blue components. If such a color is not in the color table and there is room, then this method allocates the color in the color table and returns its index. .Sp .Vb 2 \& $rosey = $myImage\->colorResolve(255,100,80); \& warn "Everything\*(Aqs coming up roses.\en" if $rosey >= 0; .Ve .ie n .IP """colorsTotal""" 5 .el .IP "\f(CWcolorsTotal\fR" 5 .IX Item "colorsTotal" \&\f(CW\*(C`$image\->colorsTotal)\*(C'\fR \fIobject method\fR .Sp This returns the total number of colors allocated in the object. .Sp .Vb 1 \& $maxColors = $myImage\->colorsTotal; .Ve .ie n .IP """getPixel""" 5 .el .IP "\f(CWgetPixel\fR" 5 .IX Item "getPixel" \&\f(CW\*(C`$image\->getPixel(x,y)\*(C'\fR \fIobject method\fR .Sp This returns the color table index underneath the specified point. It can be combined with \fIrgb()\fR to obtain the rgb color underneath the pixel. .Sp Example: .Sp .Vb 2 \& $index = $myImage\->getPixel(20,100); \& ($r,$g,$b) = $myImage\->rgb($index); .Ve .ie n .IP """rgb""" 5 .el .IP "\f(CWrgb\fR" 5 .IX Item "rgb" \&\f(CW\*(C`$image\->rgb(colorIndex)\*(C'\fR \fIobject method\fR .Sp This returns a list containing the red, green and blue components of the specified color index. .Sp Example: .Sp .Vb 1 \& @RGB = $myImage\->rgb($peachy); .Ve .ie n .IP """transparent""" 5 .el .IP "\f(CWtransparent\fR" 5 .IX Item "transparent" \&\f(CW\*(C`$image\->transparent(colorIndex)\*(C'\fR \fIobject method\fR .Sp This marks the color at the specified index as being transparent. Portions of the image drawn in this color will be invisible. This is useful for creating paintbrushes of odd shapes, as well as for making \s-1PNG\s0 backgrounds transparent for displaying on the Web. Only one color can be transparent at any time. To disable transparency, specify \-1 for the index. .Sp If you call this method without any parameters, it will return the current index of the transparent color, or \-1 if none. .Sp Example: .Sp .Vb 6 \& open(PNG,"test.png"); \& $im = newFromPng GD::Image(PNG); \& $white = $im\->colorClosest(255,255,255); # find white \& $im\->transparent($white); \& binmode STDOUT; \& print $im\->png; .Ve .SS "Special Colors" .IX Subsection "Special Colors" \&\s-1GD\s0 implements a number of special colors that can be used to achieve special effects. They are constants defined in the \s-1GD::\s0 namespace, but automatically exported into your namespace when the \s-1GD\s0 module is loaded. .ie n .IP """setBrush""" 5 .el .IP "\f(CWsetBrush\fR" 5 .IX Item "setBrush" .PD 0 .ie n .IP """gdBrushed""" 5 .el .IP "\f(CWgdBrushed\fR" 5 .IX Item "gdBrushed" .PD \&\f(CW\*(C`$image\->setBrush( )\*(C'\fR and \f(CW\*(C`GD::gdBrushed\*(C'\fR .Sp You can draw lines and shapes using a brush pattern. Brushes are just images that you can create and manipulate in the usual way. When you draw with them, their contents are used for the color and shape of the lines. .Sp To make a brushed line, you must create or load the brush first, then assign it to the image using \f(CW\*(C`setBrush\*(C'\fR. You can then draw in that with that brush using the \f(CW\*(C`gdBrushed\*(C'\fR special color. It's often useful to set the background of the brush to transparent so that the non-colored parts don't overwrite other parts of your image. .Sp Example: .Sp .Vb 6 \& # Create a brush at an angle \& $diagonal_brush = new GD::Image(5,5); \& $white = $diagonal_brush\->allocateColor(255,255,255); \& $black = $diagonal_brush\->allocateColor(0,0,0); \& $diagonal_brush\->transparent($white); \& $diagonal_brush\->line(0,4,4,0,$black); # NE diagonal \& \& # Set the brush \& $myImage\->setBrush($diagonal_brush); \& \& # Draw a circle using the brush \& $myImage\->arc(50,50,25,25,0,360,gdBrushed); .Ve .ie n .IP """setStyle""" 5 .el .IP "\f(CWsetStyle\fR" 5 .IX Item "setStyle" .PD 0 .ie n .IP """gdStyled""" 5 .el .IP "\f(CWgdStyled\fR" 5 .IX Item "gdStyled" .PD \&\f(CW\*(C`$image\->setStyle(@colors)\*(C'\fR and \f(CW\*(C`GD::gdStyled\*(C'\fR .Sp Styled lines consist of an arbitrary series of repeated colors and are useful for generating dotted and dashed lines. To create a styled line, use \f(CW\*(C`setStyle\*(C'\fR to specify a repeating series of colors. It accepts an array consisting of one or more color indexes. Then draw using the \f(CW\*(C`gdStyled\*(C'\fR special color. Another special color, \&\f(CW\*(C`gdTransparent\*(C'\fR can be used to introduce holes in the line, as the example shows. .Sp Example: .Sp .Vb 6 \& # Set a style consisting of 4 pixels of yellow, \& # 4 pixels of blue, and a 2 pixel gap \& $myImage\->setStyle($yellow,$yellow,$yellow,$yellow, \& $blue,$blue,$blue,$blue, \& gdTransparent,gdTransparent); \& $myImage\->arc(50,50,25,25,0,360,gdStyled); .Ve .Sp To combine the \f(CW\*(C`gdStyled\*(C'\fR and \f(CW\*(C`gdBrushed\*(C'\fR behaviors, you can specify \&\f(CW\*(C`gdStyledBrushed\*(C'\fR. In this case, a pixel from the current brush pattern is rendered wherever the color specified in \fIsetStyle()\fR is neither gdTransparent nor 0. .ie n .IP """gdTiled""" 5 .el .IP "\f(CWgdTiled\fR" 5 .IX Item "gdTiled" Draw filled shapes and flood fills using a pattern. The pattern is just another image. The image will be tiled multiple times in order to fill the required space, creating wallpaper effects. You must call \&\f(CW\*(C`setTile\*(C'\fR in order to define the particular tile pattern you'll use for drawing when you specify the gdTiled color. details. .ie n .IP """gdStyled""" 5 .el .IP "\f(CWgdStyled\fR" 5 .IX Item "gdStyled" The gdStyled color is used for creating dashed and dotted lines. A styled line can contain any series of colors and is created using the \&\f(CW\*(C`setStyled\*(C'\fR command. .SS "Drawing Commands" .IX Subsection "Drawing Commands" .ie n .IP """setPixel""" 5 .el .IP "\f(CWsetPixel\fR" 5 .IX Item "setPixel" \&\f(CW\*(C`$image\->setPixel(x,y,color)\*(C'\fR \fIobject method\fR .Sp This sets the pixel at (x,y) to the specified color index. No value is returned from this method. The coordinate system starts at the upper left at (0,0) and gets larger as you go down and to the right. You can use a real color, or one of the special colors gdBrushed, gdStyled and gdStyledBrushed can be specified. .Sp Example: .Sp .Vb 2 \& # This assumes $peach already allocated \& $myImage\->setPixel(50,50,$peach); .Ve .ie n .IP """line""" 5 .el .IP "\f(CWline\fR" 5 .IX Item "line" \&\f(CW\*(C`$image\->line(x1,y1,x2,y2,color)\*(C'\fR \fIobject method\fR .Sp This draws a line from (x1,y1) to (x2,y2) of the specified color. You can use a real color, or one of the special colors gdBrushed, gdStyled and gdStyledBrushed. .Sp Example: .Sp .Vb 3 \& # Draw a diagonal line using the currently defind \& # paintbrush pattern. \& $myImage\->line(0,0,150,150,gdBrushed); .Ve .ie n .IP """dashedLine""" 5 .el .IP "\f(CWdashedLine\fR" 5 .IX Item "dashedLine" \&\f(CW\*(C`$image\->dashedLine(x1,y1,x2,y2,color)\*(C'\fR \fIobject method\fR .Sp This draws a dashed line from (x1,y1) to (x2,y2) in the specified color. A more powerful way to generate arbitrary dashed and dotted lines is to use the \fIsetStyle()\fR method described below and to draw with the special color gdStyled. .Sp Example: .Sp .Vb 1 \& $myImage\->dashedLine(0,0,150,150,$blue); .Ve .ie n .IP """rectangle""" 5 .el .IP "\f(CWrectangle\fR" 5 .IX Item "rectangle" \&\f(CW\*(C`GD::Image::rectangle(x1,y1,x2,y2,color)\*(C'\fR \fIobject method\fR .Sp This draws a rectangle with the specified color. (x1,y1) and (x2,y2) are the upper left and lower right corners respectively. Both real color indexes and the special colors gdBrushed, gdStyled and gdStyledBrushed are accepted. .Sp Example: .Sp .Vb 1 \& $myImage\->rectangle(10,10,100,100,$rose); .Ve .ie n .IP """filledRectangle""" 5 .el .IP "\f(CWfilledRectangle\fR" 5 .IX Item "filledRectangle" \&\f(CW\*(C`$image\->filledRectangle(x1,y1,x2,y2,color)\*(C'\fR \fIobject method\fR .Sp This draws a rectangle filed with the specified color. You can use a real color, or the special fill color gdTiled to fill the polygon with a pattern. .Sp Example: .Sp .Vb 4 \& # read in a fill pattern and set it \& open(PNG,"happyface.png") || die; \& $tile = newFromPng GD::Image(PNG); \& $myImage\->setTile($tile); \& \& # draw the rectangle, filling it with the pattern \& $myImage\->filledRectangle(10,10,150,200,gdTiled); .Ve .ie n .IP """polygon""" 5 .el .IP "\f(CWpolygon\fR" 5 .IX Item "polygon" \&\f(CW\*(C`$image\->polygon(polygon,color)\*(C'\fR \fIobject method\fR .Sp This draws a polygon with the specified color. The polygon must be created first (see below). The polygon must have at least three vertices. If the last vertex doesn't close the polygon, the method will close it for you. Both real color indexes and the special colors gdBrushed, gdStyled and gdStyledBrushed can be specified. .Sp Example: .Sp .Vb 5 \& $poly = new GD::Polygon; \& $poly\->addPt(50,0); \& $poly\->addPt(99,99); \& $poly\->addPt(0,99); \& $myImage\->polygon($poly,$blue); .Ve .ie n .IP """filledPolygon""" 5 .el .IP "\f(CWfilledPolygon\fR" 5 .IX Item "filledPolygon" \&\f(CW\*(C`$image\->filledPolygon(poly,color)\*(C'\fR \fIobject method\fR .Sp This draws a polygon filled with the specified color. You can use a real color, or the special fill color gdTiled to fill the polygon with a pattern. .Sp Example: .Sp .Vb 5 \& # make a polygon \& $poly = new GD::Polygon; \& $poly\->addPt(50,0); \& $poly\->addPt(99,99); \& $poly\->addPt(0,99); \& \& # draw the polygon, filling it with a color \& $myImage\->filledPolygon($poly,$peachpuff); .Ve .ie n .IP """arc""" 5 .el .IP "\f(CWarc\fR" 5 .IX Item "arc" \&\f(CW\*(C`$image\->arc(cx,cy,width,height,start,end,color)\*(C'\fR \fIobject method\fR .Sp This draws arcs and ellipses. (cx,cy) are the center of the arc, and (width,height) specify the width and height, respectively. The portion of the ellipse covered by the arc are controlled by start and end, both of which are given in degrees from 0 to 360. Zero is at the top of the ellipse, and angles increase clockwise. To specify a complete ellipse, use 0 and 360 as the starting and ending angles. To draw a circle, use the same value for width and height. .Sp You can specify a normal color or one of the special colors gdBrushed, gdStyled, or gdStyledBrushed. .Sp Example: .Sp .Vb 2 \& # draw a semicircle centered at 100,100 \& $myImage\->arc(100,100,50,50,0,180,$blue); .Ve .ie n .IP """fill""" 5 .el .IP "\f(CWfill\fR" 5 .IX Item "fill" \&\f(CW\*(C`$image\->fill(x,y,color)\*(C'\fR \fIobject method\fR .Sp This method flood-fills regions with the specified color. The color will spread through the image, starting at point (x,y), until it is stopped by a pixel of a different color from the starting pixel (this is similar to the \*(L"paintbucket\*(R" in many popular drawing toys). You can specify a normal color, or the special color gdTiled, to flood-fill with patterns. .Sp Example: .Sp .Vb 3 \& # Draw a rectangle, and then make its interior blue \& $myImage\->rectangle(10,10,100,100,$black); \& $myImage\->fill(50,50,$blue); .Ve .ie n .IP """$image\->fillToBorder(x,y,bordercolor,color)"" \fIobject method\fR" 5 .el .IP "\f(CW$image\->fillToBorder(x,y,bordercolor,color)\fR \fIobject method\fR" 5 .IX Item "$image->fillToBorder(x,y,bordercolor,color) object method" Like \f(CW\*(C`fill\*(C'\fR, this method flood-fills regions with the specified color, starting at position (x,y). However, instead of stopping when it hits a pixel of a different color than the starting pixel, flooding will only stop when it hits the color specified by bordercolor. You must specify a normal indexed color for the bordercolor. However, you are free to use the gdTiled color for the fill. .Sp Example: .Sp .Vb 3 \& # This has the same effect as the previous example \& $myImage\->rectangle(10,10,100,100,$black); \& $myImage\->fillToBorder(50,50,$black,$blue); .Ve .SS "Image Copying Commands" .IX Subsection "Image Copying Commands" Two methods are provided for copying a rectangular region from one image to another. One method copies a region without resizing it. The other allows you to stretch the region during the copy operation. .PP With either of these methods it is important to know that the routines will attempt to flesh out the destination image's color table to match the colors that are being copied from the source. If the destination's color table is already full, then the routines will attempt to find the best match, with varying results. .ie n .IP """copy""" 5 .el .IP "\f(CWcopy\fR" 5 .IX Item "copy" \&\f(CW\*(C`$image\->copy(sourceImage,dstX,dstY,srcX,srcY,width,height)\*(C'\fR \fIobject method\fR .Sp This is the simplest of the several copy operations, copying the specified region from the source image to the destination image (the one performing the method call). (srcX,srcY) specify the upper left corner of a rectangle in the source image, and (width,height) give the width and height of the region to copy. (dstX,dstY) control where in the destination image to stamp the copy. You can use the same image for both the source and the destination, but the source and destination regions must not overlap or strange things will happen. .Sp Example: .Sp .Vb 7 \& $myImage = new GD::Image(100,100); \& ... various drawing stuff ... \& $srcImage = new GD::Image(50,50); \& ... more drawing stuff ... \& # copy a 25x25 pixel region from $srcImage to \& # the rectangle starting at (10,10) in $myImage \& $myImage\->copy($srcImage,10,10,0,0,25,25); .Ve .ie n .IP """clone""" 5 .el .IP "\f(CWclone\fR" 5 .IX Item "clone" \&\f(CW\*(C`$image\->clone()\*(C'\fR \fIobject method\fR .Sp Make a copy of the image and return it as a new object. The new image will look identical. However, it may differ in the size of the color palette and other nonessential details. .Sp Example: .Sp .Vb 3 \& $myImage = new GD::Image(100,100); \& ... various drawing stuff ... \& $copy = $myImage\->clone; .Ve .Sp \&\f(CW\*(C`$image\->copyMerge(sourceImage,dstX,dstY,srcX,srcY,width,height,percent)\*(C'\fR \fIobject method\fR .Sp This copies the indicated rectangle from the source image to the destination image, merging the colors to the extent specified by percent (an integer between 0 and 100). Specifying 100% has the same effect as \fIcopy()\fR \*(-- replacing the destination pixels with the source image. This is most useful for highlighting an area by merging in a solid rectangle. .Sp Example: .Sp .Vb 7 \& $myImage = new GD::Image(100,100); \& ... various drawing stuff ... \& $redImage = new GD::Image(50,50); \& ... more drawing stuff ... \& # copy a 25x25 pixel region from $srcImage to \& # the rectangle starting at (10,10) in $myImage, merging 50% \& $myImage\->copyMerge($srcImage,10,10,0,0,25,25,50); .Ve .Sp \&\f(CW\*(C`$image\->copyMergeGray(sourceImage,dstX,dstY,srcX,srcY,width,height,percent)\*(C'\fR \fIobject method\fR .Sp This is identical to \fIcopyMerge()\fR except that it preserves the hue of the source by converting all the pixels of the destination rectangle to grayscale before merging. .ie n .IP """copyResized""" 5 .el .IP "\f(CWcopyResized\fR" 5 .IX Item "copyResized" \&\f(CW\*(C`$image\->copyResized(sourceImage,dstX,dstY,srcX,srcY,destW,destH,srcW,srcH)\*(C'\fR \fIobject method\fR .Sp This method is similar to \fIcopy()\fR but allows you to choose different sizes for the source and destination rectangles. The source and destination rectangle's are specified independently by (srcW,srcH) and (destW,destH) respectively. \fIcopyResized()\fR will stretch or shrink the image to accommodate the size requirements. .Sp Example: .Sp .Vb 7 \& $myImage = new GD::Image(100,100); \& ... various drawing stuff ... \& $srcImage = new GD::Image(50,50); \& ... more drawing stuff ... \& # copy a 25x25 pixel region from $srcImage to \& # a larger rectangle starting at (10,10) in $myImage \& $myImage\->copyResized($srcImage,10,10,0,0,50,50,25,25); .Ve .SS "Character and String Drawing" .IX Subsection "Character and String Drawing" Gd allows you to draw characters and strings, either in normal horizontal orientation or rotated 90 degrees. These routines use a GD::Font object, described in more detail below. There are four built-in fonts, available in global variables gdGiantFont, gdLargeFont, gdMediumBoldFont, gdSmallFont and gdTinyFont. Currently there is no way of dynamically creating your own fonts. .ie n .IP """string""" 5 .el .IP "\f(CWstring\fR" 5 .IX Item "string" \&\f(CW\*(C`$image\->string(font,x,y,string,color)\*(C'\fR \fIObject Method\fR .Sp This method draws a string startin at position (x,y) in the specified font and color. Your choices of fonts are gdSmallFont, gdMediumBoldFont, gdTinyFont, gdLargeFont and gdGiantFont. .Sp Example: .Sp .Vb 1 \& $myImage\->string(gdSmallFont,2,10,"Peachy Keen",$peach); .Ve .ie n .IP """stringUp""" 5 .el .IP "\f(CWstringUp\fR" 5 .IX Item "stringUp" \&\f(CW\*(C`$image\->stringUp(font,x,y,string,color)\*(C'\fR \fIObject Method\fR .Sp Just like the previous call, but draws the text rotated counterclockwise 90 degrees. .ie n .IP """char""" 5 .el .IP "\f(CWchar\fR" 5 .IX Item "char" .PD 0 .ie n .IP """charUp""" 5 .el .IP "\f(CWcharUp\fR" 5 .IX Item "charUp" .PD \&\f(CW\*(C`$image\->char(font,x,y,char,color)\*(C'\fR \fIObject Method\fR \&\f(CW\*(C`$image\->charUp(font,x,y,char,color)\*(C'\fR \fIObject Method\fR .Sp These methods draw single characters at position (x,y) in the specified font and color. They're carry-overs from the C interface, where there is a distinction between characters and strings. Perl is insensible to such subtle distinctions. .ie n .IP """stringTTF""" 5 .el .IP "\f(CWstringTTF\fR" 5 .IX Item "stringTTF" \&\f(CW\*(C`@bounds = $image\->stringTTF(fgcolor,fontname,ptsize,angle,x,y,string)\*(C'\fR \fIObject Method\fR \&\f(CW\*(C`@bounds = GD::Image\->stringTTF(fgcolor,fontname,ptsize,angle,x,y,string)\*(C'\fR \fIClass Method\fR .Sp This method uses TrueType to draw a scaled, antialiased string using the TrueType vector font of your choice. It requires that libgd to have been compiled with TrueType support, and for the appropriate TrueType font to be installed on your system. .Sp The arguments are as follows: .Sp .Vb 6 \& fgcolor Color index to draw the string in \& fontname An absolute or relative path to the TrueType (.ttf) font file \& ptsize The desired point size (may be fractional) \& angle The rotation angle, in radians \& x,y X and Y coordinates to start drawing the string \& string The string itself .Ve .Sp If successful, the method returns an eight-element list giving the boundaries of the rendered string: .Sp .Vb 4 \& @bounds[0,1] Lower left corner (x,y) \& @bounds[2,3] Lower right corner (x,y) \& @bounds[4,5] Upper right corner (x,y) \& @bounds[6,7] Upper left corner (x,y) .Ve .Sp In case of an error (such as the font not being available, or \s-1TTF\s0 support not being available), the method returns an empty list and sets $@ to the error message. .Sp You may also call this method from the GD::Image class name, in which case it doesn't do any actual drawing, but returns the bounding box using an inexpensive operation. You can use this to perform layout operations prior to drawing. .SS "Miscellaneous Image Methods" .IX Subsection "Miscellaneous Image Methods" .ie n .IP """interlaced""" 5 .el .IP "\f(CWinterlaced\fR" 5 .IX Item "interlaced" \&\f(CW\*(C`$image\->interlaced( )\*(C'\fR \f(CW\*(C`$image\->interlaced(1)\*(C'\fR \fIObject method\fR .Sp This method sets or queries the image's interlaced setting. Interlace produces a cool venetian blinds effect on certain viewers. Provide a true parameter to set the interlace attribute. Provide undef to disable it. Call the method without parameters to find out the current setting. .ie n .IP """getBounds""" 5 .el .IP "\f(CWgetBounds\fR" 5 .IX Item "getBounds" \&\f(CW\*(C`$image\->getBounds( )\*(C'\fR \fIObject method\fR .Sp This method will return a two-member list containing the width and height of the image. You query but not not change the size of the image once it's created. .ie n .IP """compare""" 5 .el .IP "\f(CWcompare\fR" 5 .IX Item "compare" \&\f(CW\*(C`$image1\->compare($image2)\*(C'\fR .Sp Compare two images and return a bitmap describing the differenes found, if any. The return value must be logically ANDed with one or more constants in order to determine the differences. The following constants are available: .Sp .Vb 8 \& GD_CMP_IMAGE The two images look different \& GD_CMP_NUM_COLORS The two images have different numbers of colors \& GD_CMP_COLOR The two images\*(Aq palettes differ \& GD_CMP_SIZE_X The two images differ in the horizontal dimension \& GD_CMP_SIZE_Y The two images differ in the vertical dimension \& GD_CMP_TRANSPARENT The two images have different transparency \& GD_CMP_BACKGROUND The two images have different background colors \& GD_CMP_INTERLACE The two images differ in their interlace .Ve .Sp The most important of these is \s-1GD_CMP_IMAGE,\s0 which will tell you whether the two images will look different, ignoring differences in the order of colors in the color palette and other invisible changes. The constants are not imported by default, but must be imported individually or by importing the :cmp tag. Example: .Sp .Vb 6 \& use GD qw(:DEFAULT :cmp); \& # get $image1 from somewhere \& # get $image2 from somewhere \& if ($image1\->compare($image2) & GD_CMP_IMAGE) { \& warn "images differ!"; \& } .Ve .SS "Polygon Methods" .IX Subsection "Polygon Methods" A few primitive polygon creation and manipulation methods are provided. They aren't part of the Gd library, but I thought they might be handy to have around (they're borrowed from my qd.pl Quickdraw library). .ie n .IP """new""" 5 .el .IP "\f(CWnew\fR" 5 .IX Item "new" \&\f(CW\*(C`GD::Polygon\->new\*(C'\fR \fIclass method\fR .Sp Create an empty polygon with no vertices. .Sp .Vb 1 \& $poly = new GD::Polygon; .Ve .ie n .IP """addPt""" 5 .el .IP "\f(CWaddPt\fR" 5 .IX Item "addPt" \&\f(CW\*(C`$poly\->addPt(x,y)\*(C'\fR \fIobject method\fR .Sp Add point (x,y) to the polygon. .Sp .Vb 4 \& $poly\->addPt(0,0); \& $poly\->addPt(0,50); \& $poly\->addPt(25,25); \& $myImage\->fillPoly($poly,$blue); .Ve .ie n .IP """getPt""" 5 .el .IP "\f(CWgetPt\fR" 5 .IX Item "getPt" \&\f(CW\*(C`$poly\->getPt(index)\*(C'\fR \fIobject method\fR .Sp Retrieve the point at the specified vertex. .Sp .Vb 1 \& ($x,$y) = $poly\->getPt(2); .Ve .ie n .IP """setPt""" 5 .el .IP "\f(CWsetPt\fR" 5 .IX Item "setPt" \&\f(CW\*(C`$poly\->setPt(index,x,y)\*(C'\fR \fIobject method\fR .Sp Change the value of an already existing vertex. It is an error to set a vertex that isn't already defined. .Sp .Vb 1 \& $poly\->setPt(2,100,100); .Ve .ie n .IP """deletePt""" 5 .el .IP "\f(CWdeletePt\fR" 5 .IX Item "deletePt" \&\f(CW\*(C`$poly\->deletePt(index)\*(C'\fR \fIobject method\fR .Sp Delete the specified vertex, returning its value. .Sp .Vb 1 \& ($x,$y) = $poly\->deletePt(1); .Ve .ie n .IP """toPt""" 5 .el .IP "\f(CWtoPt\fR" 5 .IX Item "toPt" \&\f(CW\*(C`$poly\->toPt(dx,dy)\*(C'\fR \fIobject method\fR .Sp Draw from current vertex to a new vertex, using relative (dx,dy) coordinates. If this is the first point, act like \&\fIaddPt()\fR. .Sp .Vb 4 \& $poly\->addPt(0,0); \& $poly\->toPt(0,50); \& $poly\->toPt(25,\-25); \& $myImage\->fillPoly($poly,$blue); .Ve .ie n .IP """length""" 5 .el .IP "\f(CWlength\fR" 5 .IX Item "length" \&\f(CW\*(C`$poly\->length\*(C'\fR \fIobject method\fR .Sp Return the number of vertices in the polygon. .Sp .Vb 1 \& $points = $poly\->length; .Ve .ie n .IP """vertices""" 5 .el .IP "\f(CWvertices\fR" 5 .IX Item "vertices" \&\f(CW\*(C`$poly\->vertices\*(C'\fR \fIobject method\fR .Sp Return a list of all the verticies in the polygon object. Each membver of the list is a reference to an (x,y) array. .Sp .Vb 4 \& @vertices = $poly\->vertices; \& foreach $v (@vertices) \& print join(",",@$v),"\en"; \& } .Ve .ie n .IP """bounds""" 5 .el .IP "\f(CWbounds\fR" 5 .IX Item "bounds" \&\f(CW\*(C`$poly\->bounds\*(C'\fR \fIobject method\fR .Sp Return the smallest rectangle that completely encloses the polygon. The return value is an array containing the (left,top,right,bottom) of the rectangle. .Sp .Vb 1 \& ($left,$top,$right,$bottom) = $poly\->bounds; .Ve .ie n .IP """offset""" 5 .el .IP "\f(CWoffset\fR" 5 .IX Item "offset" \&\f(CW\*(C`$poly\->offset(dx,dy)\*(C'\fR \fIobject method\fR .Sp Offset all the vertices of the polygon by the specified horizontal (dh) and vertical (dy) amounts. Positive numbers move the polygon down and to the right. .Sp .Vb 1 \& $poly\->offset(10,30); .Ve .ie n .IP """map""" 5 .el .IP "\f(CWmap\fR" 5 .IX Item "map" \&\f(CW\*(C`$poly\->map(srcL,srcT,srcR,srcB,destL,dstT,dstR,dstB)\*(C'\fR \fIobject method\fR .Sp Map the polygon from a source rectangle to an equivalent position in a destination rectangle, moving it and resizing it as necessary. See polys.pl for an example of how this works. Both the source and destination rectangles are given in (left,top,right,bottom) coordinates. For convenience, you can use the polygon's own bounding box as the source rectangle. .Sp .Vb 2 \& # Make the polygon really tall \& $poly\->map($poly\->bounds,0,0,50,200); .Ve .ie n .IP """scale""" 5 .el .IP "\f(CWscale\fR" 5 .IX Item "scale" \&\f(CW\*(C`$poly\->scale(sx,sy)\*(C'\fR \fIobject method\fR .Sp Scale each vertex of the polygon by the X and Y factors indicated by sx and sy. For example scale(2,2) will make the polygon twice as large. For best results, move the center of the polygon to position (0,0) before you scale, then move it back to its previous position. .ie n .IP """transform""" 5 .el .IP "\f(CWtransform\fR" 5 .IX Item "transform" \&\f(CW\*(C`$poly\->transform(sx,rx,sy,ry,tx,ty)\*(C'\fR \fIobject method\fR .Sp Run each vertex of the polygon through a transformation matrix, where sx and sy are the X and Y scaling factors, rx and ry are the X and Y rotation factors, and tx and ty are X and Y offsets. See the Adobe PostScript Reference, page 154 for a full explanation, or experiment. .SS "Font Utilities" .IX Subsection "Font Utilities" The libgd library (used by the Perl \s-1GD\s0 library) has built-in support for about half a dozen fonts, which were converted from public-domain X Windows fonts. For more fonts, compile libgd with TrueType support and use the \fIstringTTF()\fR call. .PP If you wish to add more built-in fonts, the directory bdf_scripts contains two contributed utilities that may help you convert X\-Windows BDF-format fonts into the format that libgd uses internally. However these scripts were written for earlier versions of \s-1GD\s0 which included its own mini-gd library. These scripts will have to be adapted for use with libgd, and the libgd library itself will have to be recompiled and linked! Please do not contact me for help with these scripts: they are unsupported. .ie n .IP """gdSmallFont""" 5 .el .IP "\f(CWgdSmallFont\fR" 5 .IX Item "gdSmallFont" \&\f(CW\*(C`GD::Font\->Small\*(C'\fR \fIconstant\fR .Sp This is the basic small font, \*(L"borrowed\*(R" from a well known public domain 6x12 font. .ie n .IP """gdLargeFont""" 5 .el .IP "\f(CWgdLargeFont\fR" 5 .IX Item "gdLargeFont" \&\f(CW\*(C`GD::Font\->Large\*(C'\fR \fIconstant\fR .Sp This is the basic large font, \*(L"borrowed\*(R" from a well known public domain 8x16 font. .ie n .IP """gdMediumBoldFont""" 5 .el .IP "\f(CWgdMediumBoldFont\fR" 5 .IX Item "gdMediumBoldFont" \&\f(CW\*(C`GD::Font\->MediumBold\*(C'\fR \fIconstant\fR .Sp This is a bold font intermediate in size between the small and large fonts, borrowed from a public domain 7x13 font; .ie n .IP """gdTinyFont""" 5 .el .IP "\f(CWgdTinyFont\fR" 5 .IX Item "gdTinyFont" \&\f(CW\*(C`GD::Font\->Tiny\*(C'\fR \fIconstant\fR .Sp This is a tiny, almost unreadable font, 5x8 pixels wide. .ie n .IP """gdGiantFont""" 5 .el .IP "\f(CWgdGiantFont\fR" 5 .IX Item "gdGiantFont" \&\f(CW\*(C`GD::Font\->Giant\*(C'\fR \fIconstant\fR .Sp This is a 9x15 bold font converted by Jan Pazdziora from a sans serif X11 font. .ie n .IP """nchars""" 5 .el .IP "\f(CWnchars\fR" 5 .IX Item "nchars" \&\f(CW\*(C`$font\->nchars\*(C'\fR \fIobject method\fR .Sp This returns the number of characters in the font. .Sp .Vb 1 \& print "The large font contains ",gdLargeFont\->nchars," characters\en"; .Ve .ie n .IP """offset""" 5 .el .IP "\f(CWoffset\fR" 5 .IX Item "offset" \&\f(CW\*(C`$font\->offset\*(C'\fR \fIobject method\fR .Sp This returns the \s-1ASCII\s0 value of the first character in the font .ie n .IP """width""" 5 .el .IP "\f(CWwidth\fR" 5 .IX Item "width" .PD 0 .ie n .IP """height""" 5 .el .IP "\f(CWheight\fR" 5 .IX Item "height" .PD \&\f(CW\*(C`$font\->width\*(C'\fR \f(CW\*(C`GD::Font::height\*(C'\fR \fIobject methods\fR .Sp These return the width and height of the font. .Sp .Vb 1 \& ($w,$h) = (gdLargeFont\->width,gdLargeFont\->height); .Ve .SH "Obtaining the C\-language version of gd" .IX Header "Obtaining the C-language version of gd" libgd, the C\-language version of gd, can be obtained at \s-1URL\s0 http://www.boutell.com/gd/. Directions for installing and using it can be found at that site. Please do not contact me for help with libgd. .SH "Copyright Information" .IX Header "Copyright Information" The \s-1GD\s0.pm interface is copyright 1995\-1999, Lincoln D. Stein. It is distributed under the same terms as Perl itself. See the \*(L"Artistic License\*(R" in the Perl source code distribution for licensing terms. .PP The latest versions of \s-1GD\s0.pm are available at .PP .Vb 1 \& http://stein.cshl.org/WWW/software/GD .Ve