Basic Graphics |
| sample code |
use GD;
my($im) = new GD::Image(100,50);
my $black = $im->colorAllocate(0, 0, 0);
my $white = $im->colorAllocate(255, 255, 255);
my $red = $im->colorAllocate(255, 0, 0);
my $blue = $im->colorAllocate(0,0,255);
$im->arc(50, 25, 98, 48, 0, 360, $white);
$im->fill(50, 21, $red);
print $im->png;
|
| GD::Image |
![]() |
| sample code |
use GD;
my $font = "./Generic.ttf";
my $im = GD::Image->new(400,250);
my($white,$black,$red,$blue,$yellow) =
(
$im->colorAllocate(255, 255, 255),
$im->colorAllocate(0, 0, 0),
$im->colorAllocate(255, 0, 0),
$im->colorAllocate(0,0,255),
$im->colorAllocate(255,250,205)
);
$im->stringFT($black,$font,12.0,0.0,20,20,"Hello world!");
$im->stringFT($red,$font,14.0,0.0,20,80,"Hello world!");
$im->stringFT($blue,$font,30.0,-0.5,60,100,"Goodbye cruel world!");
print $im->png;
|
| GD::Image stringFT |
![]() |
goto [Course index] [Section index] [Previous] [Next] Dr Jaime Prilusky, course@weizmann.ac.il. |