Image-ButtonMaker
view release on metacpan or search on metacpan
lib/Image/ButtonMaker.pm view on Meta::CPAN
sub is_error {
my $self = shift;
return ($self->{error} != 0);
}
#### Package Methods #######################################
sub find_file_in_dirs {
my $file = shift;
my $dirs = shift;
foreach my $d (@$dirs) {
my $f = "$d/$file";
return $f if(-f $f);
}
return undef;
}
1;
__END__
=head1 NAME
Image::ButtonMaker - Button generator.
=head1 SYNOPSIS
#Create Image::ButtonMaker object
$bmaker = Image::ButtonMaker->new();
# Add directory with some truetype fonts in it
$bmaker->add_font_dir('./happyfonts');
# Add directory with icons to be used inside buttons
$bmaker->add_image_dir('./happyfaces');
#This is where the output will go
$bmaker->set_target_dir('/httpd/happybuttons');
# Read the list of classes
$bmaker->read_classfile('happyclasses.pl');
# Read the list of buttons to be generated
$bmaker->read_buttonfile('buttonlist.pl');
# Generate buttons
$bmaker->generate;
=head1 DESCRIPTION
Image::ButtonMaker is a helper module for people who need to generate
vast amounts of button images. The module supports dividing your
buttons into classes, who inherit appearance from each other and
overriding needed parameters on class level or on single button level.
Image::ButtonMaker was developed as a part of a large scale web
application with multiple language support, themes and products.
Image::ButtonMaker B<requires> Image::Magick with TrueType Font
support to run.
=head1 MAIN PRINCIPLES
Each button has a set of different attributes, which determine the
appearance of the button. The button can belong to a B<class> which
acts as a template for the button. The class can be a member of a
B<class tree>, where attributes are inherited from parent class to child
class.
The class tree can be stored in one or multiple files. The
Image::ButtonMaker object method C<read_classfile> will read those
files and build the class tree.
With the class tree in place it is time for the button definition.
=head1 CLASS FILE SYNTAX
Class file contains a list of classes written in Perl syntax as a list
of lists:
## Button class list
[
[
classname => 'basicbutton',
properties => {
FileType => 'png',
HeightMin => 17,
HeightMax => 17,
WidthMin => 90,
CanvasType => 'pixmap',
CanvasTemplateImg => 'rounded_button_template.png',
CanvasCutRight => 1,
CanvasCutLeft => 1,
CanvasCutTop => 1,
CanvasCutBottom => 1,
ArtWorkType => 'text',
ArtWorkHAlign => 'center',
ArtWorkVAlign => 'baseline',
TextColor => '#606060',
TextSize => 11,
TextFont => 'verdana.ttf',
TextAntiAlias => 'yes',
MarginLeft => 6,
MarginRight => 6,
MarginTop => 3,
MarginBottom => 4,
}
],
[
classname => 'basicbutton_with_arrow',
parent => 'basicbutton',
properties => {
ArtWorkType => 'icon+text',
( run in 2.276 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )