AcePerl
view release on metacpan or search on metacpan
Ace/Graphics/GlyphFactory.pm view on Meta::CPAN
}
sub options {
my $self = shift;
my $g = $self->{options};
$self->{options} = shift if @_;
$g;
}
sub panel {
my $self = shift;
my $g = $self->{panel};
$self->{panel} = shift if @_;
$g;
}
sub option {
my $self = shift;
my $option_name = shift;
my $o = $self->{options} or return;
my $d = $o->{$option_name};
$o->{$option_name} = shift if @_;
$d;
}
# set the foreground and background colors
# expressed as GD color indices
sub _fgcolor {
my $self = shift;
my $c = $self->option('color',@_) || $self->option('fgcolor',@_) || $self->option('outlinecolor',@_);
$self->translate($c);
}
sub fgcolor {
my $self = shift;
my $linewidth = $self->option('linewidth');
return $self->_fgcolor unless defined($linewidth) && $linewidth > 1;
$self->panel->set_pen($linewidth,$self->_fgcolor);
return gdBrushed;
}
sub fontcolor {
my $self = shift;
my $c = $self->option('fontcolor',@_);
$self->translate($c);
# return $self->_fgcolor;
}
sub bgcolor {
my $self = shift;
my $c = $self->option('bgcolor',@_);
$self->translate($c);
}
sub fillcolor {
my $self = shift;
my $c = $self->option('fillcolor',@_) || $self->option('color',@_);
$self->translate($c);
}
sub length { shift->option('length',@_) }
sub offset { shift->option('offset',@_) }
sub translate { my $self = shift; $self->panel->translate(@_) || $self->fgcolor; }
sub rgb { shift->panel->rgb(@_) }
# create a new glyph from configuration
sub glyph {
my $self = shift;
my $feature = shift;
return $self->{glyphclass}->new(-feature => $feature,
-factory => $self);
}
1;
__END__
=head1 NAME
Ace::Graphics::GlyphFactory - Create Ace::Graphics::Glyphs
=head1 SYNOPSIS
use Ace::Graphics::GlyphFactory;
my $factory = Ace::Graphics::GlyphFactory($glyph_name,@options);
=head1 DESCRIPTION
The Ace::Graphics::GlyphFactory class is used internally by
Ace::Graphics::Track and Ace::Graphics::Glyph to hold the options
pertaining to a set of related glyphs and creating them on demand.
This class is not ordinarily useful to the end-developer.
=head1 METHODS
This section describes the class and object methods for
Ace::Graphics::GlyphFactory.
=head2 CONSTRUCTORS
There is only one constructor, the new() method. It is ordinarily
called by Ace::Graphics::Track, in the make_factory() subroutine.
=over 4
=item $factory = Ace::Graphics::GlyphFactory->new($glyph_name,@options)
The new() method creates a new factory object. The object will create
glyphs of type $glyph_name, and using the options specified in
@options. Generic options are described in L<Ace::Graphics::Panel>,
and specific options are described in each of the
Ace::Graphics::Glyph::* manual pages.
=back
=head2 OBJECT METHODS
Once a track is created, the following methods can be invoked:
=over 4
=item $glyph = $factory->glyph($feature)
( run in 0.524 second using v1.01-cache-2.11-cpan-fe3c2283af0 )