Version Tk de este simple script para hacer ASCII Art desde una palabra.
El codigo
#!usr/bin/perl
#ASCII Art 0.1
#Version Tk
#Coded By Doddy H
#Thanks to : reLlene,MARKO,explorer
use Tk;
use Tk::Dialog;
use List::Util "max";
if ( $^O eq 'MSWin32' ) {
use Win32::Console;
Win32::Console::Free();
}
my %letras = (
a => "
@
@
@ @
@ @
@ @
@ @
@@@@@
@ @
@ @
",
b => "
@@@@
@ @
@ @
@ @
@@@@
@ @
@ @
@ @
@@@@
",
c => "
@@@@
@ @
@
@
@
@
@
@ @
@@@@
",
d => "
@@@@
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@@@@
",
e => "
@@@@@
@
@
@
@@@@
@
@
@
@@@@@
",
f => "
@@@@@
@
@
@
@@@@
@
@
@
@
",
g => "
@@@@
@ @
@
@
@ @@@
@ @
@ @
@ @@
@@@ @
",
h => "
@ @
@ @
@ @
@ @
@@@@@@
@ @
@ @
@ @
@ @
",
i => "
@
@
@
@
@
@
@
@
@
",
j => "
@
@
@
@
@
@
@ @
@ @
@@
",
k => "
@ @
@ @
@ @
@@
@@
@ @
@ @
@ @
@ @
",
l => "
@
@
@
@
@
@
@
@
@@@@@
",
@ @
@ @
@@ @@
@@ @@
@ @ @ @
@ @ @ @
@ @ @
@ @ @
@ @
",
n => "
@ @
@@ @
@@ @
@ @ @
@ @ @
@ @ @
@ @@
@ @@
@ @
",
o => "
@@@@
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@@@@
",
p => "
@@@@@
@ @
@ @
@ @
@@@@@
@
@
@
@
",
@@@@
@ @
@ @
@ @
@ @
@ @
@ @ @
@ @@
@@@@
@
",
r => "
@@@@@
@ @
@ @
@ @
@@@@@
@ @
@ @
@ @
@ @
",
@@@
@ @
@
@
@@@
@
@
@ @
@@@
",
t => "
@@@@@
@
@
@
@
@
@
@
@
",
u => "
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@@@@
",
v => "
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@
@
",
W => "
@ @
@ @
@ @ @
@ @ @
@ @ @
@ @ @ @
@ @ @ @
@ @
@ @
",
x => "
@ @
@ @
@ @
@ @
@
@ @
@ @
@ @
@ @
",
@ @
@ @
@ @
@ @
@
@
@
@
@
",
z => "
@@@@@@@
@
@
@
@
@
@
@
@@@@@@@
"
);
my $color_fondo = "black";
my $color_texto = "green";
my $ven =
MainWindow->new( -background => $color_fondo, -foreground => $color_texto );
$ven->title("ASCII Art 0.1 || Written By Doddy H");
$ven->geometry("555x300+20+20");
$ven->resizable( 0, 0 );
my $fondo = $ven->Text(
-width => 75,
-heigh => 15,
-background => $color_fondo,
-foreground => $color_texto
)->place( -x
=> 15, -y => 10 ); $ven->Label(
-text => "Text : ",
-font => "Impact1",
-background => $color_fondo,
-foreground => $color_texto
)->place( -x
=> 20, -y => 250 ); my $tengo = $ven->Entry(
-width => 40,
-background => $color_fondo,
-foreground => $color_texto
)->place( -x
=> 66, -y => 254 ); $ven->Button(
-command => \&now,
-text => "Now!",
-width => 10,
-background => $color_fondo,
-foreground => $color_texto,
-activebackground => $color_texto
)->place( -x
=> 320, -y => 252 ); $ven->Button(
-command => \&about,
-text => "About",
-width => 10,
-background => $color_fondo,
-foreground => $color_texto,
-activebackground => $color_texto
)->place( -x
=> 395, -y => 252 ); $ven->Button(
-command => \&exitnow,
-text => "Exit",
-width => 10,
-background => $color_fondo,
-foreground => $color_texto,
-activebackground => $color_texto
)->place( -x
=> 470, -y => 252 );
MainLoop;
sub about {
$ven->Dialog(
-title => "About",
-buttons => ["OK"],
-text => "Coded By Doddy H",
-background => $color_fondo,
-foreground => $color_texto,
-activebackground => $color_texto
)->Show();
}
sub exitnow {
}
sub now {
$fondo->delete( "0.1", "end" );
my $now = $tengo->get;
my $code = artnow($now);
$fondo->insert( "end", $code );
}
sub artnow {
my $fondo = " ";
my $espacio = 0;
my $lugar;
my @lotengo;
my $tipox = $letras{"a"};
my @lineas = split /\n/, $tipox; $altura = @lineas + 1;
for ( 1 .. $altura ) {
push @lotengo, $fondo x
( ( $anchura + $espacio ) * length $target ); }
for my $letra ( split //, $target ) { my @lineas = split /\n/, $letras{$letra};
for my $i ( 0 .. $altura - 1 ) {
( my $plan = $lineas[$i] ) =~ s/ /$fondo/g;
$plan = $fondo x $anchura if not $plan;
}
$lugar += $anchura + $espacio;
}
}
#The End ?
Una imagen
(http://doddyhackman.webcindario.com/images/asciiuno.jpg)
quizas para la version 0.3 porque para la 0.2 tenia pensado usar un modulo de cpan que me ahorra hacer ese hash infernal aunque el estilo del modulo ese no sea tan bueno como el de este script.