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 => "
@
@
@
@
@
@
@
@
@@@@@
",
m => "
@ @
@ @
@@ @@
@@ @@
@ @ @ @
@ @ @ @
@ @ @
@ @ @
@ @
",
n => "
@ @
@@ @
@@ @
@ @ @
@ @ @
@ @ @
@ @@
@ @@
@ @
",
o => "
@@@@
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@@@@
",
p => "
@@@@@
@ @
@ @
@ @
@@@@@
@
@
@
@
",
q => "
@@@@
@ @
@ @
@ @
@ @
@ @
@ @ @
@ @@
@@@@
@
",
r => "
@@@@@
@ @
@ @
@ @
@@@@@
@ @
@ @
@ @
@ @
",
s => "
@@@
@ @
@
@
@@@
@
@
@ @
@@@
",
t => "
@@@@@
@
@
@
@
@
@
@
@
",
u => "
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@@@@
",
v => "
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@
@
",
W => "
@ @
@ @
@ @ @
@ @ @
@ @ @
@ @ @ @
@ @ @ @
@ @
@ @
",
x => "
@ @
@ @
@ @
@ @
@
@ @
@ @
@ @
@ @
",
y => "
@ @
@ @
@ @
@ @
@
@
@
@
@
",
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 {
exit(1);
}
sub now {
$fondo->delete( "0.1", "end" );
my $now = $tengo->get;
my $code = artnow($now);
$fondo->insert( "end", $code );
}
sub artnow {
my $target = shift;
my $fondo = " ";
my $espacio = 0;
my $lugar;
my @lotengo;
my $tipox = $letras{"a"};
my @lineas = split /\n/, $tipox;
$altura = @lineas + 1;
$anchura = max map { length $_ } @lineas;
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;
substr( $lotengo[$i], $lugar, length $plan ) = $plan;
}
$lugar += $anchura + $espacio;
}
return ( join "\n", @lotengo );
}
#The End ?
Una imagen
(http://doddyhackman.webcindario.com/images/asciiuno.jpg)
+1
Gracias por compartirlo en TK Doddy
Te animo a que saques alguna idea de este script que dejé a medias:
http://pastebin.com/MVnhRi2a
[RUBY] Proyecto sin finalizar Art ASCII Factory ¿Alguien me toma el relevo? (http://foro.elhacker.net/empty-t362610.0.html)
Bueno, más bien que saques los estilos xD
Sería genial que añadieras todos esos estilos a una versión 0.2 o que los sacases de donde los saqué yo ( http://patorjk.com/software/taag/ )
Me gusta el Art ASCII !! ;D
un saludo ;-)
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.