Term-Graille
view release on metacpan or search on metacpan
- Adds a Graille::Font module that imports converts and loads and saves fonts
- loadGrf() moved to the new separate Graille::Font module
0.06
- Added print colour("reset") as suggested by https://github.com/jwrightecs
- Added block2braille (convert 2d binary data to 2d braille)
- Added blockBlit (blit 2d blocks of characters)
- Added loadGrf (load blocks e.g. fonts)
- Added importCanvas and exportCanvas (load/save canvas from/to file)
- Added font2grf to examples folder (convert fonts from https://damieng.com/typography/zx-origins to grf)
- Added image2grl (convert image to file loadable by Term::Graille *Needs Image::Magick)
- Added testanimate (convert a folder containingg frames into Graille Animation *Needs Image::Magick)
0.05
Failing CpanTesters
- Error in 1.t corected
- Added Import and export images
- Created an image converter (Depends on Image::Magick)
0.04
Corrected error hightlighted by https://old.reddit.com/user/tarje
- Perl Version set at v5.10.0
- License file removed
0.03 June 2022
First version unploaded to CPAN
0.02 June 2022
examples/image2grl.pl view on Meta::CPAN
#! /usr/bin/env perl
use strict; use warnings;
use Term::Graille qw/colour paint printAt clearScreen border/;
use Image::Magick;
# convert2grl--converts an image to .grl format.
my %params=%ARGV;
my $canvas = Term::Graille->new(
width => $params{width}||72,
height => $params{height}||60,
top=>2,
left=>10,
borderStyle => "double",
);
clearScreen();
my $inFile=$params{-i}||"perl2.jpg";
my $outFile=$params{-o}||($inFile=~s/\..+$//r).".grl";
loadImage($inFile);
$canvas->exportCanvas($outFile);
sub loadImage{
my $imgfile=shift;
my $image = Image::Magick->new();
my $wh = $image->Read($imgfile);
$image->Resize(geometry => "$canvas->{width}x$canvas->{height}", filter=>"Cubic");
warn $wh if $wh;
$image->set('monochrome'=>'True','dither'=>'True','dither-method'=>"Floyd-Steinberg");
for (my $x =0;$x<$canvas->{width};$x++){
for (my $y=0;$y<$canvas->{height};$y++){
$canvas->set($x,$y) if $image->GetPixel("x"=>$x,"y",$canvas->{height}-$y);
}
}
}
examples/testanimate.pl view on Meta::CPAN
#! /usr/bin/env perl
use strict; use warnings;
#use lib "../lib/";
use Term::Graille qw/colour paint printAt clearScreen border/;
use Image::Magick;
use Time::HiRes "sleep";
# convert2grl--converts an image to .grv format.
my $animationFolder=$ARGV[0]||"./animations/cheetah/";
opendir my $dir,$animationFolder or die;
my @files=sort grep !/^(\.|\.\.|.*\.pl)$/,readdir $dir;
my $canvas = Term::Graille->new(
width => 120,
examples/testanimate.pl view on Meta::CPAN
foreach my $frame (1..@$animation){
next unless ref $animation->[$frame];
$canvas->{grid}=$animation->[$frame];
$canvas->draw();
sleep 0.08;
}
}
sub loadImage{
my $imgfile=shift;
my $image = Image::Magick->new();
my $wh = $image->Read($imgfile);
$image->Resize(geometry => "$canvas->{width}x$canvas->{height}");
die $wh if $wh;
$image->set('monochrome'=>'True');
$image->Negate();
for (my $x =0;$x<$canvas->{width};$x++){
for (my $y=0;$y<$canvas->{height};$y++){
$canvas->set($x,$y) if $image->GetPixel("x"=>$x,"y",$canvas->{height}-$y);
}
}
( run in 0.743 second using v1.01-cache-2.11-cpan-beeb90c9504 )