App-WIoZ

 view release on metacpan or  search on metacpan

lib/App/WIoZ.pm  view on Meta::CPAN

=head2 update_colors

Read words position from file and update colors.

Usage:

   $wioz->update_colors("file.sl.txt");

=cut

sub update_colors{
    my ($self, $filename) = @_;

    open my $fh, '<:utf8', $filename or die $filename . ' : ' .$!;
    my @L = <$fh>;
    close $fh;

    my @color = Color::Mix->new->analogous($self->basecolor, 12, 12);

    # reset background
    $self->cr->rectangle (0, 0, $self->width, $self->height);

lib/App/WIoZ/Word.pm  view on Meta::CPAN


has 'show' => (
    is => 'rw', isa => 'Int',
);

has 'angle' => (
    is => 'ro', isa => 'Str',
    default => sub {return rand(1.0) > 0.85 ? -1 * 2 * atan2(1, 1) : 0;}
);

sub update_c {
    my ($self,$c) = @_;
    my $th = $self->height;
    my $tl = $self->width;
    my $center = App::WIoZ::Point->new(x=>$c->x,y=>$c->y);
    my $p = App::WIoZ::Point->new(x=>$c->x-int($tl/2),y=>$c->y+int($th/2));
    my $p2 = App::WIoZ::Point->new(x=>$c->x+int($tl/2),y=>$c->y-int($th/2));
    $self->c($center);
    $self->p($p);
    $self->p2($p2);
}

sub update_size {
    my ($self,$ya,$size) = @_;
    $ya->cr->select_font_face($self->font->{font},$self->font->{type},$self->font->{weight});
    $ya->cr->set_font_size($size);
    #$ya->cr->rotate($self->angle);
    my $te = $ya->cr->text_extents ($self->text);
    my $fe = $ya->cr->font_extents;
    #my $th = $fe->{"height"};#-4*$fe->{"descent"};
    my $th = $fe->{"height"}-2*$fe->{"descent"};
    my $tl = $te->{"width"};#+2*$te->{"x_bearing"};
    $self->size($size);

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.992 second using v1.00-cache-2.02-grep-82fe00e-cpan-4673cadbf75 )