First, like all non-standard Perl modules, you will need to install GD::Simple from CPAN, and then you can include it at the top of your Perl programs with the use statement:
Then, to get started drawing, you must create your canvas by creating an image:
To change the colors of objects, you can use fgcolor to set the pen and border colors, and bgcolor to set the fill color for your shapes.
$img = GD::Simple->new(640, 480);
You can use methods like rectangle or ellipse to draw some shapes. With rectangle, you set the x,y coordinates for the top left corner and the bottom right corner. The ellipse function is called with the width and height, centered on the current location of the pen.
You could even use it to create quick graphical headers:
$img->rectangle(10, 10, 50, 50); $img->ellipse(50, 50);
Learning to use GD::Simple is a great way to get into the more complex and powerful GD Module by taking it in smaller, easier steps.
$img->moveTo(200,25); $img->font('Times:italic'); $img->fontsize(18); $img->string('Drawn With Perl');