Section: User Contributed Perl Documentation (3)
Updated: 2003-03-04
Index Return to Main Contents


Image::Button::Rect - Builds rectangular PNG buttons  


  use Image::Button::Rect;

  my $b1 = new Image::Button::Rect(text     => 'text b1',
                                   font     => 'newsgotn.ttf',
                                   fontsize => 20,
                                   file     => 'b1.png');




Builds reasonably good looking rectangular buttons, with shadows and all, using GD with TrueType support. See Image::Button for more details about things you can do with Buttons.  


    my $b = new Image::Button::Rect(text     => 'text',
                                    font     => 'newsgotn.ttf',
                                    fontsize => 20,
                                    file     => 'file.png');

The arguments are

text => 'button text'
Defaults to ''.
font => 'something.ttf'
The TrueType font with which to print. It should be located either in the current directory or in the directory pointed at by the environment variable TTFONTS. Mandatory.
fontsize => 12
Font size. Defaults to 12 points.
file => 'button.png'
File where the button will be saved. Can be overridden in the print function. Mandatory if you plan to use Image::Button::Set to output several related buttons at a time. Defaults to the button text, replacing spaces by '-'. Use '>-' if you want to send the image to standard output.
btcolor => [ 238, 238, 204 ]
Button color in RGB (so [255,255,255] is white and [0,0,0] is black). Defaults to [238,238,204], which is as nice a color as any other.
fgcolor => [ 0, 0, 0 ]
Foreground (text) color in RGB. Defaults to [0,0,0].
bgcolor => [ 255, 255, 255 ]
Background color in RGB. This is the color you want to be equal to your page background. Defaults to [255,255,255]. You might want to set this transparent, but (1) it's not implemented---in, GD knows how to do it--- and (2) IE, or at least some versions of it, doesn't handle transparent PNGs correctly.
vmargin => 4
Vertical margin under and over the text, more or less. Defaults to 4 pixels.
hmargin => 4
Horizontal margin left and right of the text, more or less. Defaults to 4 pixels.


Image::Button for a description of how to make buttons, and other functions you can use with Image::Button::Rect.

Image::Button::Set for building sets of related buttons.  


Juan M. García-Reyero <>  


Copyright (C) 2003 Juan M. García-Reyero. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.



COPYRIGHT manual pages