
Image::ButtonMaker::Button - A Button object for the ButtonMaker module

use Image::ButtonMaker::Button;
my $but = Image::ButtonMaker::Button->new
( print_warnings => 1,
name => 'submitButton',
properties => {
WidthMin => 100,
HeightMin => 55,
HeightMax => 55,
CanvasType => 'pixmap',
CanvasTemplateImg => 'pinky.png',
CanvasCutRight => 1,
CanvasCutLeft => 1,
CanvasCutTop => 2,
CanvasCutBottom => 2,
ArtWorkType => 'text',
ArtWorkHAlign => 'center',
ArtWorkVAlign => 'baseline',
Text => 'Submit Form',
TextColor => '#000000',
TextSize => 18,
TextFont => '/home/users/piotr/head/uws-hosts/globals/autobuttons/fonts/arial.ttf',
TextAntiAlias => 'no',
MarginLeft => 25,
MarginRight => 30,
MarginTop => 8,
MarginBottom => 24,
AfterResizeY => 30,
}
) or die "$Image::ButtonMaker::Button::errorstr";
my $img = $but->render || die "$Image::ButtonMaker::Button::errorstr";

This module is used to create single button objects and is capable of rendering image objects. The module uses Image::Magick as a backend and some methods return and deal with Image::Magick objects.

This is a class method and a constuctor for Image::ButtonMaker::Button. When a Image::ButtonMaker::Button object is created, it also creates some lower-level objects for internal use.
Most of the parameters for the new method are actually parameters for these lower level objects.
Name of the button. I is used by the write method to compute the filename.
Name of button class. It is only used, when Image::ButtonMaker::Button is used from inside the Image::ButtonMaker module.
Reference to a Image::ButtonMaker::ClassContainer object. It is only used, when Image::ButtonMaker::Button is used from inside the Image::ButtonMaker module.
Boolean attribute. Send warnings to STDERR.
Boolean attrbute.
Boolean attribute. A warning could be: "Text does not fit into button" or a similar 'minor' error.
Hash reference. It is a hash of legal button-properties. Following properties are allowed:
File type of the file generated by the write method. Could be 'png' or 'gif' or something more exotic, as long as Image::Magick supports it.
Minimum width of the generated button.
Maximum width of the generated button.
Minimum height of the generated button.
Maximum height of the generated button.
The type of graphics, that will be rendered into the button. Options are 'text', 'text+icon' or 'icon+text'
Horizontal alignment of the graphics inside the button. The legal options are 'left', 'right', 'center'
Horizontal alignment of the graphics inside the button. The legal options are 'top', 'bottom' and 'baseline'. Where 'top' and 'bottom' place the graphics at top or bottom of the available space, the 'baseline' option is a bit different. What it does is to place the baseline of the rendered text, which is the line between the ascendant and descendant parts of the text, and place it at the line defined by MarginBottom.
Left margin of the artwork area.
Right margin of the artwork area.
Top margin of the artwork area/
Bottom margin of the artwork area. When using ArtworkVAlign, the bottom margin will be crossed by some letters like 'y' or 'j'.
Canvas is the template of the button. At this point two types of canvas are supported and they are 'pixmap' and 'color'. 'pixmap' type uses a template which is sliced up and stretched for each button, while 'color' is just for plain rectangular buttons with plain background and a maybe a border.
When CanvasType is set to 'pixmap' this is the path tho the template image. The image must be readable by Image::Magick to be usefull.
When CanvasType is set to 'pixmap' this is the number of pixels, that will be cut off and placed in the right stretch area.
When CanvasType is set to 'pixmap' this is the number of pixels, that will be cut off and placed in the left stretch area.
When CanvasType is set to 'pixmap' this is the number of pixels, that will be cut off and placed in the top stretch area.
When CanvasType is set to 'pixmap' this is the number of pixels, that will be cut off and placed in the bottom stretch area.
When CanvasType is set to 'color' this is the background color.
When CanvasType is set to 'color' this is the border color.
When CanvasType is set to 'color' this is the border width. Border is only drawn when CanvasBorderWidth is different from 0.
This is the text to be rendered inside a button.
A path to a .ttf (True Type Font) file containing your favorite font to be used inside the button.
A color of the text. Can be an RGB value like '#ff00aa' or some symbolic name understood by Image::Magick.
Text size. F.ex '9' or maybe even '11'
Make the text nice and soft in the edges. Options are 'yes' or 'no'.
Scale factor for the text. This one defaults to 1.0.
If the ArtworkType is 'text+icon' or 'icon+text' this must contain the path to the icon image.
Amount of horizontal space between the text and the icon.
Sometimes it is nice to be able to lift or lower the icon compared to the text. This is the amount of pixels for that. Positive values lift and negative lower the icon.
Resize button to height AfterResizeY after it has been rendered. It can be used for solving problems with antialiasing of text and icons by rendering a really big image, and resizing it to smaller size afterwards.
Resize button to with AfterResizeX after it has been rendered.
Render the button.
Write the button to file with prefix from the 'name' attribute of the object and suffix defined by the FileType property.
Return $self->{name}
Return $self->{name} suffixed with the FileType button property
Lookup and return a button property. If running from ButtonMaker with a ClassContainer object defined, the property can be obtained from the class definition or a parent class.
Set a button property inside the object.

Piotr Czarny <picz@sifira.dk> wrote this module and this crappy documentation.