Last active
December 25, 2015 03:59
-
-
Save syohex/6913642 to your computer and use it in GitHub Desktop.
AA of fujiwara-san
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl | |
use strict; | |
use warnings; | |
use Furl; | |
use Imager; | |
use Text::AAlib qw(:all); | |
my $url = 'https://1.gravatar.com/avatar/ca6281fff64797dc419b78f51f25c0a5?d=https%3A%2F%2Fidenticons.github.com%2F51beaebc231c8720d18d10b0008693dc.png&s=420'; | |
my $ua = Furl->new; | |
my $res = $ua->get($url); | |
unless ($res->is_success) { | |
die "Can't download $url"; | |
} | |
my $img = Imager->new(); | |
$img->read(data => $res->content) or die $img->errstr; | |
$img->write(file => "fujiwara.jpg") or die $img->errstr; | |
system("convert -resize 20% fujiwara.jpg fujiwara2.jpg") == 0 or die "Can't convert"; | |
$img = Imager->new; | |
$img->read(file => "fujiwara2.jpg"); | |
my ($width, $height) = ($img->getwidth, $img->getheight); | |
my $aa = Text::AAlib->new( | |
width => $width, | |
height => $height, | |
mask => AA_REVERSE_MASK, | |
); | |
$aa->put_image(image => $img); | |
my $aa_str = $aa->render(); | |
$aa_str =~ s{\.}{ }msg; | |
$aa_str =~ s{^\s*$}{}msg; | |
print $aa_str; | |
unlink "fujiwara.jpg", "fujiwara2.jpg"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
______ | |
_=++~~-~:+====+++~~-~-+++=, | |
==- -<, | |
_> +; | |
|` = | |
>` = | |
=` > | |
= _|` | |
= _>_ _=|===|==|+~- | |
= _+---+=_;___=|~~- | |
= =~ ----- : | |
:: == : | |
; | __, = | |
= > =wX!!!l| <ausv;_ | |
= :; --- -(+: | |
< | > | |
:; :~ = | |
:; =<c _|=|=: ___ < | |
|= >= ; -+~~-+) | |
v`=`= < :: | |
r:= : -; :; | |
<===i:: <:=: < = | |
|>`==:: < < | |
:v' - = +|==__== = | |
<>: | :=_ - ~+"~ - : :: | |
z-= = -++===_________=%` :; | |
~ =;_%` --~~~+~~~~"- :: | |
-~ :` | |
=` | |
> | |
=` | |
=, =` | |
-+_ =` | |
+=_ _=` | |
-+|_ ==~ | |
~|==__ ___|~- | |
-~+-+====|||==~-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use List::Util qw/max/; | |
use Time::HiRes qw/sleep/; | |
my $aa = <<'...'; | |
______ | |
_=++~~-~:+====+++~~-~-+++=, | |
==- -<, | |
_> +; | |
|` = | |
>` = | |
=` > | |
= _|` | |
= _>_ _=|===|==|+~- | |
= _+---+=_;___=|~~- | |
= =~ ----- : | |
:: == : | |
; | __, = | |
= > =wX!!!l| <ausv;_ | |
= :; --- -(+: | |
< | > | |
:; :~ = | |
:; =<c _|=|=: ___ < | |
|= >= ; -+~~-+) | |
v`=`= < :: | |
r:= : -; :; | |
<===i:: <:=: < = | |
|>`==:: < < | |
:v' - = +|==__== = | |
<>: | :=_ - ~+"~ - : :: | |
z-= = -++===_________=%` :; | |
~ =;_%` --~~~+~~~~"- :: | |
-~ :` | |
=` | |
> | |
=` | |
=, =` | |
-+_ =` | |
+=_ _=` | |
-+|_ ==~ | |
~|==__ ___|~- | |
-~+-+====|||==~-- | |
... | |
my @data = split /\n/, $aa; | |
sub put { | |
my ($x, $y, $str) = @_; | |
printf "\033[%d;%dH%s\n", $y, $x, $str; | |
} | |
sub clear { | |
print "\033[2J"; | |
} | |
my $max_width = max map { length $_ } @data; | |
@data = map { $_ . (" " x ($max_width - length $_))} @data; | |
my $height = scalar @data; | |
for my $x (0..$max_width) { | |
clear(); | |
for my $y (0..($height-1)) { | |
my $line = substr $data[$y], $x; | |
die "x=$x, y=$y, str=$data[$y]" unless defined $line; | |
put(0, $y, $line); | |
} | |
sleep 0.05; | |
} | |
clear(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment