Parent Directory
|
Revision Log
initial import
1 #!/usr/bin/perl 2 use GD; 3 use Carp; 4 use CGI; 5 use strict; 6 my @position = (0,0); 7 # my $inFile = "Zip 100:test_file"; 8 # open(INPUT,"<$inFile") || die "can't open $inFile"; 9 my $q = new CGI; 10 # print "size=", $q->param('size'); 11 # print STDOUT "fn=", join("\n",$q->param('fn')),"\n"; 12 # get size; 13 14 unless ($q->param('size') ) { 15 croak "ERROR: The size of the gif must be defined."; 16 } 17 my @size = split( "\s*,\s*", $q->param('size') ); 18 19 # create a new image 20 my $im = new GD::Image(@size); 21 22 # allocate some colors 23 my %colors; 24 $colors{'white'} = $im->colorAllocate(255,255,255); 25 $colors{'black'} = $im->colorAllocate(0,0,0); 26 $colors{'red'} = $im->colorAllocate(255,0,0); 27 $colors{'blue'} = $im->colorAllocate(0,0,255); 28 $colors{'green'} = $im->colorAllocate(0,255,0); 29 $colors{'yellow'} = $im->colorAllocate(255,255,0); 30 31 # make the background transparent and interlaced 32 # $im->transparent($colors{'white'}); 33 $im->interlaced('true'); 34 35 # Put a black frame around the picture 36 $im->rectangle(0,0,$size[0]-1,$size[1]-1,$colors{'black'}); 37 38 #draw some lines 39 40 my @functions = $q ->param('fn'); 41 my $fn; 42 foreach $fn (@functions) { 43 polyline( split("\s*,\s*",$fn) ); 44 } 45 # GD::Image::string(font,x,y,string,color) Object Method 46 # gdSmallFont, gdMediumBoldFont, gdTinyFont and gdLargeFont. 47 my @labels = $q -> param('lb'); 48 my $lb; 49 foreach $lb (@labels) { 50 my ($font,$x,$y,$string,$clr) = split("\s*;\s*",$lb); 51 $im->string( gdMediumBoldFont,$x,$y,$string,$colors{$clr}); 52 } 53 # Convert the image to GIF and print it on standard output 54 # my $fileName = "Zip 100:foo.gif"; 55 # open(OUTPUT, ">$fileName")||die "Can't open foo"; 56 print "content-type: image/gif\n\n"; 57 print $im->gif; 58 # MacPerl::SetFileInfo("MOSS","GIFf",$fileName); 59 # close(OUTPUT); 60 61 sub polyline { 62 my @pts = @_; 63 my $clr = $colors{shift @pts}; 64 my @pos = splice(@pts,0,2); 65 while (@pts) { 66 my @temp = splice(@pts,0,2); 67 $im->line(@pos,@temp,$clr); 68 @pos = @temp; 69 } 70 } 71
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |