<?xml version="1.0" encoding="windows-1252"?>
<node id="371396" title="JAPH attempt using Term::ANSIScreen" created="2004-07-02 09:59:10" updated="2005-08-10 14:21:59">
<type id="1588">
obfuscated</type>
<author id="70929">
atcroft</author>
<data>
<field name="doctext">
&lt;p&gt;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.)

&lt;p&gt;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 [cpan://Term::ANSIScreen] to move back to the beginning so it would appear somewhat "animated".

&lt;p&gt;Enjoy.

&lt;readmore&gt;
&lt;code&gt;
#!/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      = (
    ' ' =&gt; [ 4, 12, 17, 24 ],
    'a' =&gt; [ 5, 19 ],
    'c' =&gt; [20],
    'e' =&gt; [ 10, 14, 22 ],
    'h' =&gt; [ 9,  18 ],
    'J' =&gt; [0],
    'k' =&gt; [21],
    'l' =&gt; [16],
    'n' =&gt; [6],
    'o' =&gt; [7],
    'p' =&gt; [13],
    'r' =&gt; [ 11, 15, 23 ],
    's' =&gt; [2],
    't' =&gt; [ 3, 8 ],
    'u' =&gt; [1]
);
my (%letters);
{
    my ($x);
    my ($y);
    foreach $y ( 0 .. 7 ) {
        foreach $x ( 0 .. 6 ) {
            push( @{ $letters{' '} }, { 'x' =&gt; $x, 'y' =&gt; $y } );
        }
    }
    foreach $x ( 1 .. 5 ) {
        push( @{ $letters{'a'} }, { 'x' =&gt; $x, 'y' =&gt; 2 } );
    }
    foreach $x ( 5 .. 6 ) {
        push( @{ $letters{'a'} }, { 'x' =&gt; $x, 'y' =&gt; 3 } );
    }
    foreach $x ( 0 .. 1, 5 .. 6 ) {
        push( @{ $letters{'a'} }, { 'x' =&gt; $x, 'y' =&gt; 5 } );
    }
    foreach $y ( 4, 6 ) {
        foreach $x ( 1 .. 3, 5 .. 6 ) {
            push( @{ $letters{'a'} }, { 'x' =&gt; $x, 'y' =&gt; $y } );
        }
    }
    foreach $y ( 2, 6 ) {
        foreach $x ( 2 .. 4 ) {
            push( @{ $letters{'c'} }, { 'x' =&gt; $x, 'y' =&gt; $y } );
        }
    }
    foreach $y ( 3 .. 5 ) {
        foreach $x ( 0 .. 1 ) {
            push( @{ $letters{'c'} }, { 'x' =&gt; $x, 'y' =&gt; $y } );
        }
    }
    foreach $x ( 1 .. 4 ) {
        push( @{ $letters{'e'} }, { 'x' =&gt; $x, 'y' =&gt; 2 } );
    }
    foreach $x ( 0 .. 1, 4 .. 5 ) {
        push( @{ $letters{'e'} }, { 'x' =&gt; $x, 'y' =&gt; 3 } );
    }
    foreach $x ( 0 .. 5 ) {
        push( @{ $letters{'e'} }, { 'x' =&gt; $x, 'y' =&gt; 4 } );
    }
    foreach $x ( 0 .. 1 ) {
        push( @{ $letters{'e'} }, { 'x' =&gt; $x, 'y' =&gt; 5 } );
    }
    foreach $x ( 1 .. 5 ) {
        push( @{ $letters{'e'} }, { 'x' =&gt; $x, 'y' =&gt; 6 } );
    }
    foreach $y ( 0 .. 2 ) {
        push(
            @{ $letters{'h'} },
            { 'x' =&gt; 0, 'y' =&gt; $y },
            { 'x' =&gt; 1, 'y' =&gt; $y }
        );
    }
    foreach $x ( 0 .. 4 ) {
        push( @{ $letters{'h'} }, { 'x' =&gt; $x, 'y' =&gt; 3 } );
    }

    foreach $y ( 4 .. 6 ) {
        foreach $x ( 0 .. 1, 4 .. 5 ) {
            push( @{ $letters{'h'} }, { 'x' =&gt; $x, 'y' =&gt; $y } );
        }
    }
    foreach $x ( 2 .. 6 ) {
        push( @{ $letters{'J'} }, { 'x' =&gt; $x, 'y' =&gt; 0 } );
    }
    foreach $y ( 1 .. 4 ) {
        push(
            @{ $letters{'J'} },
            { 'x' =&gt; 4, 'y' =&gt; $y },
            { 'x' =&gt; 5, 'y' =&gt; $y }
        );
    }
    foreach $x ( 1 .. 2, 4 .. 5 ) {
        push( @{ $letters{'J'} }, { 'x' =&gt; $x, 'y' =&gt; 5 } );
    }
    foreach $x ( 2 .. 4 ) {
        push( @{ $letters{'J'} }, { 'x' =&gt; $x, 'y' =&gt; 6 } );
    }
    foreach $y ( 0 .. 1 ) {
        push(
            @{ $letters{'k'} },
            { 'x' =&gt; 0, 'y' =&gt; $y },
            { 'x' =&gt; 1, 'y' =&gt; $y }
        );
    }
    foreach $x ( 0 .. 4 ) {
        push( @{ $letters{'k'} }, { 'x' =&gt; $x, 'y' =&gt; 4 } );
    }
    foreach $y ( 2 .. 3 ) {
        foreach $x ( 0 .. 1, 6 - $y .. 7 - $y ) {
            push( @{ $letters{'k'} }, { 'x' =&gt; $x, 'y' =&gt; $y } );
        }
    }
    foreach $y ( 5 .. 6 ) {
        foreach $x ( 0 .. 1, $y - 2 .. $y - 1 ) {
            push( @{ $letters{'k'} }, { 'x' =&gt; $x, 'y' =&gt; $y } );
        }
    }
    foreach $y ( 1 .. 5 ) {
        push(
            @{ $letters{'l'} },
            { 'x' =&gt; 1, 'y' =&gt; $y },
            { 'x' =&gt; 2, 'y' =&gt; $y }
        );
    }
    foreach $x ( 0 .. 3 ) {
        push( @{ $letters{'l'} }, { 'x' =&gt; $x, 'y' =&gt; 0 } );
    }
    foreach $x ( 2 .. 4 ) {
        push( @{ $letters{'l'} }, { 'x' =&gt; $x, 'y' =&gt; 6 } );
    }
    foreach $x ( 0, 2 .. 5 ) {
        push( @{ $letters{'n'} }, { 'x' =&gt; $x, 'y' =&gt; 3 } );
    }
    foreach $y ( 4 .. 6 ) {
        foreach $x ( 0 .. 1, 5 .. 6 ) {
            push( @{ $letters{'n'} }, { 'x' =&gt; $x, 'y' =&gt; $y } );
        }
    }
    foreach $y ( 2, 6 ) {
        foreach $x ( 2 .. 4 ) {
            push( @{ $letters{'o'} }, { 'x' =&gt; $x, 'y' =&gt; $y } );
        }
    }
    foreach $y ( 3 .. 5 ) {
        foreach $x ( 0 .. 1, 5 .. 6 ) {
            push( @{ $letters{'o'} }, { 'x' =&gt; $x, 'y' =&gt; $y } );
        }
    }
    foreach $y ( 2, 5 ) {
        foreach $x ( 0 .. 1, 3 .. 5 ) {
            push( @{ $letters{'p'} }, { 'x' =&gt; $x, 'y' =&gt; $y } );
        }
    }
    foreach $y ( 3 .. 4 ) {
        foreach $x ( 0 .. 2, 6 ) {
            push( @{ $letters{'p'} }, { 'x' =&gt; $x, 'y' =&gt; $y } );
        }
    }
    foreach $y ( 6 .. 7 ) {
        push(
            @{ $letters{'p'} },
            { 'x' =&gt; 0, 'y' =&gt; $y },
            { 'x' =&gt; 1, 'y' =&gt; $y }
        );
    }
    foreach $x ( 0, 2 .. 5 ) {
        push( @{ $letters{'r'} }, { 'x' =&gt; $x, 'y' =&gt; 2 } );
    }
    foreach $x ( 0 .. 1, 5 .. 6 ) {
        push( @{ $letters{'r'} }, { 'x' =&gt; $x, 'y' =&gt; 3 } );
    }
    foreach $y ( 4 .. 6 ) {
        push(
            @{ $letters{'r'} },
            { 'x' =&gt; 0, 'y' =&gt; $y },
            { 'x' =&gt; 1, 'y' =&gt; $y }
        );
    }
    foreach $y ( 2, 4, 6 ) {
        foreach $x ( 0 .. 4 ) {
            push( @{ $letters{'s'} }, { 'x' =&gt; $x, 'y' =&gt; $y } );
        }
    }
    foreach $x ( 0 .. 1 ) {
        push( @{ $letters{'s'} }, { 'x' =&gt; $x, 'y' =&gt; 3 } );
    }
    foreach $x ( 4 .. 5 ) {
        push( @{ $letters{'s'} }, { 'x' =&gt; $x, 'y' =&gt; 5 } );
    }
    foreach $y ( 2, 4 .. 5 ) {
        foreach $x ( 2 .. 3 ) {
            push( @{ $letters{'t'} }, { 'x' =&gt; $x, 'y' =&gt; $y } );
        }
    }
    foreach $x ( 0 .. 5 ) {
        push( @{ $letters{'t'} }, { 'x' =&gt; $x, 'y' =&gt; 3 } );
    }
    foreach $x ( 3 .. 5 ) {
        push( @{ $letters{'t'} }, { 'x' =&gt; $x, 'y' =&gt; 6 } );
    }
    foreach $y ( 3 .. 5 ) {
        foreach $x ( 0 .. 1, 4 .. 5 ) {
            push( @{ $letters{'u'} }, { 'x' =&gt; $x, 'y' =&gt; $y } );
        }
    }
    foreach $x ( 1 .. 3, 5 ) {
        push( @{ $letters{'u'} }, { 'x' =&gt; $x, 'y' =&gt; 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-&gt;new;
{
    $console-&gt;Cls();
    foreach my $i ( 0 .. ( $looptimes - 1 ) ) {
        foreach my $x ( 0 .. length( $characterline[0] ) ) {
            $console-&gt;Cursor( 1, 1 );
            foreach my $y ( 0 .. 8 ) {
                print
                  substr( $characterline[$y] x 2, $x, $width ),
                  "\n";
            }
            select undef, undef, undef, $delay;
        }
    }
}
&lt;/code&gt;
&lt;/readmore&gt;
&lt;p&gt;&lt;b&gt;Update:&lt;/b&gt; (02-Jul-2004) Changed looping to be configurable.</field>
</data>
</node>
