Acme-SaBalTongMun
view release on metacpan or search on metacpan
lib/Acme/SaBalTongMun.pm view on Meta::CPAN
has 'color' => ( isa => 'Str', is => 'rw', required => 1 );
has 'people' => ( isa => 'ArrayRef[Str]', is => 'rw', required => 1 );
sub generate {
my $self = shift;
my $max_string_width
= max( map length, @{$self->people} ) * $self->font_size;
my $cx = $self->radius + $max_string_width;
my $cy = $self->radius + $max_string_width;
my $width = ( $self->radius + $max_string_width ) * 2;
my $height = ( $self->radius + $max_string_width ) * 2;
my $angle = ( 2 * 3.14 ) / @{$self->people};
#
# Make GD::Image
lib/Acme/SaBalTongMun.pm view on Meta::CPAN
$image->stringFT(
$image->colorAllocate( _get_rgb( $self->color ) ), # fgcolor
$self->font, # .ttf path
$self->font_size, # point size
$string_angle, # rotation angle
$dest_x, # X coordinates
$dest_y, # Y coordinates
$string,
{
charmap => $self->font_charset,
},
);
$dest_angle += $angle;
}
return $image;
}
sub _get_rgb { map hex, $_[0] =~ m/^#(..)(..)(..)$/ }
__PACKAGE__->meta->make_immutable;
no Moose;
1;
__END__
=pod
=encoding utf-8
lib/Acme/SaBalTongMun.pm view on Meta::CPAN
=head1 ATTRIBUTES
=head2 radius
This attribute stores the radius
which is the center circle of the round robin.
=head2 font
This attribute stores the TrueType(*.ttf) font path.
Only the font which has unicode charmap is allowed.
=head2 font_size
This attribute stores the size of the font.
=head2 font_charset
This attribute stores the charset of the font.
This is optional and the default value is "Unicode".
( run in 1.971 second using v1.01-cache-2.11-cpan-49f99fa48dc )