Acme-SaBalTongMun
view release on metacpan or search on metacpan
lib/Acme/SaBalTongMun.pm view on Meta::CPAN
package Acme::SaBalTongMun;
our $VERSION = '1.100830';
use Moose;
# ENCODING: utf-8
# ABSTRACT: make a round robin (ì¬ë°íµë¬¸, æ²é¢éæ)
use namespace::autoclean;
use common::sense;
use GD;
use List::Util qw( max );
has 'radius' => ( isa => 'Int', is => 'rw', required => 1 );
has 'font' => ( isa => 'Str', is => 'rw', required => 1 );
has 'font_size' => ( isa => 'Int', is => 'rw', required => 1 );
has 'font_charset' => ( isa => 'Str', is => 'rw', default => 'Unicode' );
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
#
my $image = GD::Image->new($width, $height);
my $white = $image->colorAllocate( _get_rgb("#FFFFFF") );
my $black = $image->colorAllocate( _get_rgb("#000000") );
# make the background transparent and interlaced
$image->transparent( _get_rgb("#FFFFFF") );
$image->interlaced('true');
my $dest_angle = 0;
for my $string ( @{$self->people} ) {
my $dest_x = $cx + ( $self->radius * cos $dest_angle );
my $dest_y = $cy + ( $self->radius * sin $dest_angle );
my $string_angle = (2 * 3.14) - $dest_angle;
$image->stringFT(
$image->colorAllocate( _get_rgb( $self->color ) ), # fgcolor
$self->font, # .ttf path
( run in 1.610 second using v1.01-cache-2.11-cpan-b16cb0d3907 )