#!/usr/bin/perl # # # colors ;; /usr/X11/lib/X11/rgb.txt # # on swamp, in ~/ ORCmakebox # use GD; ## chomp($text = ); ##$text = "View Source"; $l_text = length($text); $loa = 15; $offset = ($loa - $l_text) / 2 ; ## add centering logic # we'll throw this first one away # $im = new GD::Image($x,$y); # $font = "gdGiantFont"; # GD::Font($font); # ($w,$h) = ($font->width,$font->height); $w = 9; $h = 15; $x = $w * ($loa + 2); $y = $h + (2 * 5); # create a new image $im = new GD::Image($x,$y); # allocate some colors $white = $im->colorAllocate(255,255,255); $gray = $im->colorAllocate(127,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($gray); $im->interlaced('true'); # Put a black frame around the picture $im->rectangle(0,0,($x - 1) ,($y - 1) ,$black); # Draw a blue oval #$im->arc(50,50,95,75,0,360,$blue); # And fill it with red $im->fill(1,1,$gray); # Fonts are # gdTinyFont 5x8 # gdSmallFont 6x12 # gdMediumBoldFont 7x13 # gdLargeFont 8x16 # gdGiantFont 9x15 # # Doing text layout math: # width # # height # GD::Font::width GD::Font::height object methods # # These return the width and height of the font. # # ($w,$h) = (gdLargeFont->width,gdLargeFont->height); # # $im->string(gdGiantFont, $w * (1+ $offset), 5, $text, $blue); # make sure we are writing to a binary stream binmode STDOUT; # Convert the image to GIF and print it on standard output print $im->gif;