GD-Text-Arc
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
package GD::Text::Arc;
$GD::Text::Arc::VERSION = '0.02';
use strict;
use GD 1.2; # fails if version < 1.20 (no TrueType support)
use base qw(GD::Text);
use Carp;
use constant PI => 4 * atan2(1, 1);
sub new
{
my $proto = shift;
my $class = ref($proto) || $proto;
my $gd = shift;
ref($gd) and $gd->isa('GD::Image')
or croak "Not a GD::Image object";
my $self = $class->SUPER::new() or return;
$self->{gd} = $gd;
bless $self => $class;
$self->_init();
$self->set(@_);
return $self;
}
# fill these in with defaults
my %defaults = (
align => 'left',
angle => 0,
font => '',
text => '',
orientation => 'clockwise',
side => 'outside',
compress_factor => .9,
points_to_pixels_factor => .8
);
sub _init
{
my $self = shift;
while (my ($k, $v) = each(%defaults))
{
$self->{$k} = $v;
}
$self->{colour} = 1; # if indexed, 1 is the first non-background color.
# if truecolor, (0,0,1) is nearly black.
$self->{color} = $self->{colour};
$self->{center_x} = ($self->{gd}->getBounds())[0] / 2;
$self->{center_y} = ($self->{gd}->getBounds())[1] / 2;
$self->{radius} = _min( $self->{center_x}, $self->{center_y});
}
sub set
{
my $self = shift;
$@ = "Incorrect attribute list (one left over)", return if @_%2;
my %args = @_;
my @super;
foreach (keys %args)
{
/^align/ and do {
$self->set_align($args{$_});
next;
};
/^angle/ and do {
$self->set_angle($args{$_});
next;
};
/^center_x/ and do {
$self->{center_x} = $args{$_};
next;
};
/^center_y/ and do {
$self->{center_y} = $args{$_};
next;
};
/^orientation/ and do {
view all matches for this distributionview release on metacpan - search on metacpan
( run in 3.459 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )