My obligatory first attempt at a JAPH, so I'd welcome comment and/or constructive critique. I do not really consider it obfu; thus my confusion on where to post it, since Obfuscations did not seem quite right. (If there is a better place to move it to, please suggest it. Thank you.)
Basic process is as follows. In attempting not to use the words themselves, I created a hash containing the positions of the letters appearing in the words. I then created a hash containing a mapping of character positions for drawing each character (thus its length). I then built each line's display, and began to loop, writing only a specified length segment of the lines each time, and using Term::ANSIScreen to move back to the beginning so it would appear somewhat "animated".
#!/usr/bin/perl -w
use strict;
use Term::ANSIScreen;
$| = 1;
my $delay = 0.1;
my $width = 75;
my $charwidth = 9;
my $looptimes = 10;
my %lpos = (
' ' => [ 4, 12, 17, 24 ],
'a' => [ 5, 19 ],
'c' => [20],
'e' => [ 10, 14, 22 ],
'h' => [ 9, 18 ],
'J' => [0],
'k' => [21],
'l' => [16],
'n' => [6],
'o' => [7],
'p' => [13],
'r' => [ 11, 15, 23 ],
's' => [2],
't' => [ 3, 8 ],
'u' => [1]
);
my (%letters);
{
my ($x);
my ($y);
foreach $y ( 0 .. 7 ) {
foreach $x ( 0 .. 6 ) {
push( @{ $letters{' '} }, { 'x' => $x, 'y' => $y } );
}
}
foreach $x ( 1 .. 5 ) {
push( @{ $letters{'a'} }, { 'x' => $x, 'y' => 2 } );
}
foreach $x ( 5 .. 6 ) {
push( @{ $letters{'a'} }, { 'x' => $x, 'y' => 3 } );
}
foreach $x ( 0 .. 1, 5 .. 6 ) {
push( @{ $letters{'a'} }, { 'x' => $x, 'y' => 5 } );
}
foreach $y ( 4, 6 ) {
foreach $x ( 1 .. 3, 5 .. 6 ) {
push( @{ $letters{'a'} }, { 'x' => $x, 'y' => $y } );
}
}
foreach $y ( 2, 6 ) {
foreach $x ( 2 .. 4 ) {
push( @{ $letters{'c'} }, { 'x' => $x, 'y' => $y } );
}
}
foreach $y ( 3 .. 5 ) {
foreach $x ( 0 .. 1 ) {
push( @{ $letters{'c'} }, { 'x' => $x, 'y' => $y } );
}
}
foreach $x ( 1 .. 4 ) {
push( @{ $letters{'e'} }, { 'x' => $x, 'y' => 2 } );
}
foreach $x ( 0 .. 1, 4 .. 5 ) {
push( @{ $letters{'e'} }, { 'x' => $x, 'y' => 3 } );
}
foreach $x ( 0 .. 5 ) {
push( @{ $letters{'e'} }, { 'x' => $x, 'y' => 4 } );
}
foreach $x ( 0 .. 1 ) {
push( @{ $letters{'e'} }, { 'x' => $x, 'y' => 5 } );
}
foreach $x ( 1 .. 5 ) {
push( @{ $letters{'e'} }, { 'x' => $x, 'y' => 6 } );
}
foreach $y ( 0 .. 2 ) {
push(
@{ $letters{'h'} },
{ 'x' => 0, 'y' => $y },
{ 'x' => 1, 'y' => $y }
);
}
foreach $x ( 0 .. 4 ) {
push( @{ $letters{'h'} }, { 'x' => $x, 'y' => 3 } );
}
foreach $y ( 4 .. 6 ) {
foreach $x ( 0 .. 1, 4 .. 5 ) {
push( @{ $letters{'h'} }, { 'x' => $x, 'y' => $y } );
}
}
foreach $x ( 2 .. 6 ) {
push( @{ $letters{'J'} }, { 'x' => $x, 'y' => 0 } );
}
foreach $y ( 1 .. 4 ) {
push(
@{ $letters{'J'} },
{ 'x' => 4, 'y' => $y },
{ 'x' => 5, 'y' => $y }
);
}
foreach $x ( 1 .. 2, 4 .. 5 ) {
push( @{ $letters{'J'} }, { 'x' => $x, 'y' => 5 } );
}
foreach $x ( 2 .. 4 ) {
push( @{ $letters{'J'} }, { 'x' => $x, 'y' => 6 } );
}
foreach $y ( 0 .. 1 ) {
push(
@{ $letters{'k'} },
{ 'x' => 0, 'y' => $y },
{ 'x' => 1, 'y' => $y }
);
}
foreach $x ( 0 .. 4 ) {
push( @{ $letters{'k'} }, { 'x' => $x, 'y' => 4 } );
}
foreach $y ( 2 .. 3 ) {
foreach $x ( 0 .. 1, 6 - $y .. 7 - $y ) {
push( @{ $letters{'k'} }, { 'x' => $x, 'y' => $y } );
}
}
foreach $y ( 5 .. 6 ) {
foreach $x ( 0 .. 1, $y - 2 .. $y - 1 ) {
push( @{ $letters{'k'} }, { 'x' => $x, 'y' => $y } );
}
}
foreach $y ( 1 .. 5 ) {
push(
@{ $letters{'l'} },
{ 'x' => 1, 'y' => $y },
{ 'x' => 2, 'y' => $y }
);
}
foreach $x ( 0 .. 3 ) {
push( @{ $letters{'l'} }, { 'x' => $x, 'y' => 0 } );
}
foreach $x ( 2 .. 4 ) {
push( @{ $letters{'l'} }, { 'x' => $x, 'y' => 6 } );
}
foreach $x ( 0, 2 .. 5 ) {
push( @{ $letters{'n'} }, { 'x' => $x, 'y' => 3 } );
}
foreach $y ( 4 .. 6 ) {
foreach $x ( 0 .. 1, 5 .. 6 ) {
push( @{ $letters{'n'} }, { 'x' => $x, 'y' => $y } );
}
}
foreach $y ( 2, 6 ) {
foreach $x ( 2 .. 4 ) {
push( @{ $letters{'o'} }, { 'x' => $x, 'y' => $y } );
}
}
foreach $y ( 3 .. 5 ) {
foreach $x ( 0 .. 1, 5 .. 6 ) {
push( @{ $letters{'o'} }, { 'x' => $x, 'y' => $y } );
}
}
foreach $y ( 2, 5 ) {
foreach $x ( 0 .. 1, 3 .. 5 ) {
push( @{ $letters{'p'} }, { 'x' => $x, 'y' => $y } );
}
}
foreach $y ( 3 .. 4 ) {
foreach $x ( 0 .. 2, 6 ) {
push( @{ $letters{'p'} }, { 'x' => $x, 'y' => $y } );
}
}
foreach $y ( 6 .. 7 ) {
push(
@{ $letters{'p'} },
{ 'x' => 0, 'y' => $y },
{ 'x' => 1, 'y' => $y }
);
}
foreach $x ( 0, 2 .. 5 ) {
push( @{ $letters{'r'} }, { 'x' => $x, 'y' => 2 } );
}
foreach $x ( 0 .. 1, 5 .. 6 ) {
push( @{ $letters{'r'} }, { 'x' => $x, 'y' => 3 } );
}
foreach $y ( 4 .. 6 ) {
push(
@{ $letters{'r'} },
{ 'x' => 0, 'y' => $y },
{ 'x' => 1, 'y' => $y }
);
}
foreach $y ( 2, 4, 6 ) {
foreach $x ( 0 .. 4 ) {
push( @{ $letters{'s'} }, { 'x' => $x, 'y' => $y } );
}
}
foreach $x ( 0 .. 1 ) {
push( @{ $letters{'s'} }, { 'x' => $x, 'y' => 3 } );
}
foreach $x ( 4 .. 5 ) {
push( @{ $letters{'s'} }, { 'x' => $x, 'y' => 5 } );
}
foreach $y ( 2, 4 .. 5 ) {
foreach $x ( 2 .. 3 ) {
push( @{ $letters{'t'} }, { 'x' => $x, 'y' => $y } );
}
}
foreach $x ( 0 .. 5 ) {
push( @{ $letters{'t'} }, { 'x' => $x, 'y' => 3 } );
}
foreach $x ( 3 .. 5 ) {
push( @{ $letters{'t'} }, { 'x' => $x, 'y' => 6 } );
}
foreach $y ( 3 .. 5 ) {
foreach $x ( 0 .. 1, 4 .. 5 ) {
push( @{ $letters{'u'} }, { 'x' => $x, 'y' => $y } );
}
}
foreach $x ( 1 .. 3, 5 ) {
push( @{ $letters{'u'} }, { 'x' => $x, 'y' => 6 } );
}
}
my (@characterline);
{
my (@s);
{
foreach my $k ( keys(%lpos) ) {
foreach my $i ( @{ $lpos{$k} } ) { $s[$i] = $k; }
}
}
my (@characterblock);
foreach my $y ( 0 .. 8 ) {
foreach my $x ( 0 .. ( scalar(@s) * $charwidth ) ) {
$characterblock[$y][$x] = ' ';
}
}
my $x = 0;
foreach my $l (@s) {
foreach my $i ( 0 .. $#{ $letters{$l} } ) {
$characterblock[ $letters{$l}[$i]{'y'} ]
[ $x + $letters{$l}[$i]{'x'} ] = $l;
}
$x += $charwidth;
}
foreach my $y ( 0 .. 8 ) {
$characterline[$y] =
join( '', @{ $characterblock[$y] } );
}
}
my $console = Term::ANSIScreen->new;
{
$console->Cls();
foreach my $i ( 0 .. ( $looptimes - 1 ) ) {
foreach my $x ( 0 .. length( $characterline[0] ) ) {
$console->Cursor( 1, 1 );
foreach my $y ( 0 .. 8 ) {
print
substr( $characterline[$y] x 2, $x, $width ),
"\n";
}
select undef, undef, undef, $delay;
}
}
}