App-WIoZ
    
    
  
  
  
view release on metacpan or search on metacpan
App::WIoZ is an acronym for "Words for Io by Zeus", look for the Correggio painting to watch the cloud.
App::WIoZ is based on `Wordle` strategy and `yawc` perl clone.
Usage:
    my $File = 'words.txt';
    
    my $wioz = App::WIoZ->new(
      font_min => 18, font_max => 64,
      set_font => "DejaVuSans,normal,bold",
      filename => "testoutput",
      basecolor => '226666'); # violet
    
    if (-f $File) {
      my @words = $wioz->read_words($File);
      $wioz->do_layout(@words);
    }
    else {
      $wioz->chg_font("LiberationSans,normal,bold");
      $wioz->update_colors('testoutput.sl.txt');
    }
watch `doc/freq.pl` to create a `words.txt` file.
# STATUS
App::WIoZ is actually a POC to play with Moose, Cairo or Math::PlanePath. 
The use of an Hilbert curve to manage free space is for playing with Math::PlanePath modules.
image width, default to 800
## font_min, font_max
required min and max font size
## set_font, chg_font, font
accessors for font name, type and weight
`set_font` : set font in new WIoZ object, default is `'LiberationSans,normal,bold'`
`chg_font` : change font
`font` : read font object
Usage :
    $wioz = App::WIoZ->new( font_min => 18, font_max => 64,
                            set_font => 'DejaVuSans,normal,bold');
        
    
    $fontname = $wioz->font->{font};
    $wioz->chg_font('LiberationSans,normal,bold');
    
## filename
file name output, extension `.png` or `.svg` will be added 
## svg
produce a svg output, default value
     exit;
}
my $File = $ARGV[0];
&usage if !$File ;
my $wioz = App::WIoZ->new( 
   font_min => 18, font_max => 64,
   filename => "testoutput",
   #set_font => 'DejaVuSans,normal,bold',
   basecolor => '226666'); # violet
   #basecolor => '084A93'); # bleu
   #basecolor => '29872F'); # vert
if (-f $File) {
 my @words = $wioz->read_words($File);
 $wioz->do_layout(@words);
}
else {
 $wioz->update_colors('testoutput.sl.txt');
lib/App/WIoZ.pm view on Meta::CPAN
App::WIoZ is an acronym for "Words for Io by Zeus", look for the Correggio painting to watch the cloud.
App::WIoZ is based on C<Wordle> strategy and C<yawc> perl clone.
Usage:
  my $File = 'words.txt';
  my $wioz = App::WIoZ->new(
    font_min => 18, font_max => 64,
    set_font => "DejaVuSans,normal,bold",
    filename => "testoutput",
    basecolor => '226666'); # violet
  if (-f $File) {
    my @words = $wioz->read_words($File);
    $wioz->do_layout(@words);
  }
  else {
    $wioz->chg_font("LiberationSans,normal,bold");
    $wioz->update_colors('testoutput.sl.txt');
  }
watch C<doc/freq.pl> to create a C<words.txt> file.
=head1 STATUS
App::WIoZ is actually a POC to play with Moose, Cairo or Math::PlanePath. 
The use of an Hilbert curve to manage free space is for playing with Math::PlanePath modules.
lib/App/WIoZ.pm view on Meta::CPAN
=cut
has ['font_min','font_max'] => (
    is => 'ro', required => 1, isa => 'Int'
);
=head2 set_font, chg_font, font
accessors for font name, type and weight
C<set_font> : set font in new WIoZ object, default is C<'LiberationSans,normal,bold'>
C<chg_font> : change font
C<font> : read font object
Usage :
  $wioz = App::WIoZ->new( font_min => 18, font_max => 64,
                          set_font => 'DejaVuSans,normal,bold');
  
  $fontname = $wioz->font->{font};
  $wioz->chg_font('LiberationSans,normal,bold');
=cut
has 'font' => (
   isa    => 'HashRef',
   is => 'ro', lazy => 1,
   writer => 'chg_font',
   builder => '_set_font'
);
# for font builder
has 'set_font' => ( is => 'rw',isa => 'Str' );
sub _set_font {
    my ($self,$font) = @_;
    my ($fname,$ftype,$fweight) = split ',', ($self->set_font || ',,');
    return ( { font => $fname || 'LiberationSans',
               type => $ftype || 'normal',
               weight => $fweight || 'bold' });
};
# for font change
around 'chg_font' => sub  {
        my ($next,$self,$font) = @_;
        my ($fname,$ftype,$fweight) = split ',', $font;
        $self->$next( {font => $fname, type => $ftype, weight => $fweight});
};
has 'backcolor' => (
lib/App/WIoZ/Word.pm view on Meta::CPAN
has 'text' => (
    is => 'ro', required => 1, isa => 'Str'
);
has 'weight' => (
    is => 'ro', required => 0, isa => 'Int'
);
has 'font' => (
    is => 'rw', isa => 'HashRef',
    default => sub { {font => 'LiberationSans', type => 'normal', weight => 'bold'} }
);
has 'width' => (
    is => 'rw', isa => 'Int'
);
has 'height' => (
    is => 'rw', isa => 'Int'
);
t/00-wioz.t view on Meta::CPAN
@words = $wioz->read_words($dirname.'test-words.txt'); 
is ($words[0]->font->{font},'DejaVuSans','word with DejaVuSans font');
$wioz->do_layout(@words); # compute image
is(-f $dirname.'test.png',1,"create image ".$dirname.'test.png');
is(-f $dirname.'test.sl.txt',1,"save layout ".$dirname.'test.sl.txt');
# update colorsa nd font
#$wioz->chg_font('strenuous,normal,normal');
$wioz->chg_font('LiberationSans,normal,bold');
is($wioz->font->{font},'LiberationSans','chg_font to LiberationSans');
$wioz->filename($dirname.'test2');
$wioz->update_colors($dirname.'test.sl.txt');
is(-f $dirname.'test2.png',1,"create image with new color ".$dirname.'test2.png');
# update colors
$wioz->filename($dirname.'test3');
$wioz->update_colors($dirname.'test.sl.txt');
is(-f $dirname.'test3.png',1,"create image with new color ".$dirname.'test3.png');
# test directory clean up
unlink $dirname.'test.sl.txt';
unlink $dirname.'test.svg';
unlink $dirname.'test.png';
unlink $dirname.'test2.png';
unlink $dirname.'test3.png';
$wioz = App::WIoZ->new( height => 300, font_min => 18, font_max => 64, set_font => 'DejaVuSans,normal,bold');
( run in 2.781 seconds using v1.01-cache-2.11-cpan-c333fce770f )