#!/usr/bin/perl -w use strict; use GD::Text::Arc; use CGI; my $boldfont = "Frabk.ttf"; my $thirdfont = "Forte.ttf"; my $savedir = "."; my $q = new CGI; my $name = $q->param('name') || "Anon"; $name =~ s/\W//g; $name .= "'s"; $name = substr($name,0,10); my @param = ("use Perl;", "$name Coaster"); @param = ("use Perl;", " "); my $image = &calcImage(@param); &drawImage($image); #&saveImage($image); sub calcImage { my $image = GD::Image->new(400,400); my $camel = GD::Image->new("./camel.jpg") || die "oops, can't find camel"; $image->copy($camel,150,150,0,0,90,100); my $white = $image->colorAllocate(255,255,255); my $red = $image->colorAllocate(128,75,75); my $tan = $image->colorAllocate(128,115,115); my $gray = $image->colorAllocate(75,75,75); # $image->trueColor(); my $radius = 120; my $centerX;# = 150; my $centerY;# = 258; my $paramNo = 0; my $ta = GD::Text::Arc->new($image); $ta->set('colour', $gray); # $ta->set('ptsize', $size); $ta->set('radius', $radius); $ta->set('font', $boldfont); $ta->set('center_x', $centerX); $ta->set('center_y', $centerY); $ta->set('side', 'inside'); $ta->set_font($boldfont, 36); foreach my $name (@param) { my $value = $name; $ta->set('text', $value); if ($paramNo eq 0) { $ta->set('orientation', 'clockwise'); } else { $ta->set('orientation', 'counterclockwise'); # $ta->set('side', 'outside'); # $ta->set('radius', ($ta->get('radius') - 2 * $ta->get_height())); $ta->set('color', $red); $ta->set_font($thirdfont,36); } $ta->draw(); $paramNo++; } # $ta->set('text', 'da@itha.ca'); # $ta->set('side', 'inside'); # $ta->set_font($thirdfont,16); # $ta->set('radius', 60); # $ta->set('color', $tan); # $ta->draw(); return $image; } sub drawImage { my $image = shift; print $q->header(-type => 'image/jpeg'); print $image->jpeg; } sub saveImage { my $image = shift; my $paramNum = 0; my $savefilename; $savefilename = "${savedir}/beer-test.jpg"; # save graphic open(my $fileH, ">$savefilename") || die "failed for '$savefilename': $!"; print $fileH $image->jpeg; close($fileH); }