elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Únete al Grupo Steam elhacker.NET


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  [Perl Tk] ASCII Art 0.1
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [Perl Tk] ASCII Art 0.1  (Leído 2,000 veces)
BigBear


Desconectado Desconectado

Mensajes: 545



Ver Perfil
[Perl Tk] ASCII Art 0.1
« en: 3 Octubre 2012, 01:14 am »

Version Tk de este simple script para hacer ASCII Art desde una palabra.

El codigo

Código
  1. #!usr/bin/perl
  2. #ASCII Art 0.1
  3. #Version Tk
  4. #Coded By Doddy H
  5. #Thanks to : reLlene,MARKO,explorer
  6.  
  7. use Tk;
  8. use Tk::Dialog;
  9. use List::Util "max";
  10.  
  11. if ( $^O eq 'MSWin32' ) {
  12.    use Win32::Console;
  13.    Win32::Console::Free();
  14. }
  15.  
  16. my %letras = (
  17.  
  18.    a => "        
  19.   @  
  20.   @  
  21.  @ @  
  22.  @ @  
  23. @   @
  24. @   @
  25. @@@@@
  26. @     @
  27. @     @
  28. ",
  29.  
  30.    b => "
  31. @@@@
  32. @   @
  33. @   @
  34. @   @
  35. @@@@
  36. @   @
  37. @   @
  38. @   @
  39. @@@@
  40. ",
  41.  
  42.    c => "
  43.  @@@@
  44. @    @
  45. @    
  46. @    
  47. @    
  48. @    
  49. @    
  50. @    @
  51.  @@@@
  52. ",
  53.  
  54.    d => "
  55. @@@@  
  56. @   @
  57. @    @
  58. @    @
  59. @    @
  60. @    @
  61. @    @
  62. @   @
  63. @@@@  
  64. ",
  65.  
  66.    e => "
  67. @@@@@
  68. @    
  69. @    
  70. @    
  71. @@@@
  72. @    
  73. @    
  74. @    
  75. @@@@@
  76. ",
  77.    f => "
  78. @@@@@
  79. @    
  80. @    
  81. @    
  82. @@@@
  83. @    
  84. @    
  85. @    
  86. @    
  87. ",
  88.    g => "
  89.  @@@@
  90. @    @
  91. @    
  92. @    
  93. @  @@@
  94. @    @
  95. @    @
  96. @   @@
  97.  @@@ @
  98. ",
  99.    h => "
  100. @    @
  101. @    @
  102. @    @
  103. @    @
  104. @@@@@@
  105. @    @
  106. @    @
  107. @    @
  108. @    @
  109. ",
  110.    i => "
  111. @
  112. @
  113. @
  114. @
  115. @
  116. @
  117. @
  118. @
  119. @
  120. ",
  121.    j => "
  122.   @
  123.   @
  124.   @
  125.   @
  126.   @
  127.   @
  128. @  @
  129. @  @
  130. @@
  131. ",
  132.    k => "
  133. @   @
  134. @  @  
  135. @ @  
  136. @@    
  137. @@    
  138. @ @  
  139. @  @  
  140. @   @
  141. @    @
  142. ",
  143.    l => "
  144. @    
  145. @    
  146. @    
  147. @    
  148. @    
  149. @    
  150. @    
  151. @    
  152. @@@@@
  153. ",
  154.    m => "
  155. @     @
  156. @     @
  157. @@   @@
  158. @@   @@
  159. @ @ @ @
  160. @ @ @ @
  161. @  @  @
  162. @  @  @
  163. @     @
  164. ",
  165.    n => "
  166. @    @
  167. @@   @
  168. @@   @
  169. @ @  @
  170. @ @  @
  171. @  @ @
  172. @   @@
  173. @   @@
  174. @    @
  175. ",
  176.    o => "
  177.  @@@@
  178. @    @
  179. @    @
  180. @    @
  181. @    @
  182. @    @
  183. @    @
  184. @    @
  185.  @@@@
  186. ",
  187.    p => "
  188. @@@@@
  189. @    @
  190. @    @
  191. @    @
  192. @@@@@
  193. @    
  194. @    
  195. @    
  196. @    
  197. ",
  198.    q => "
  199.  @@@@
  200. @    @
  201. @    @
  202. @    @
  203. @    @
  204. @    @
  205. @  @ @
  206. @   @@
  207.  @@@@
  208.      @
  209. ",
  210.    r => "
  211. @@@@@
  212. @    @
  213. @    @
  214. @    @
  215. @@@@@
  216. @    @
  217. @    @
  218. @    @
  219. @    @
  220. ",
  221.    s => "
  222.  @@@
  223. @   @
  224. @    
  225. @    
  226.  @@@
  227.     @
  228.     @
  229. @   @
  230.  @@@
  231. ",
  232.    t => "
  233. @@@@@
  234.   @  
  235.   @  
  236.   @  
  237.   @  
  238.   @  
  239.   @  
  240.   @  
  241.   @  
  242. ",
  243.    u => "
  244. @    @
  245. @    @
  246. @    @
  247. @    @
  248. @    @
  249. @    @
  250. @    @
  251. @    @
  252.  @@@@
  253. ",
  254.    v => "
  255. @     @
  256. @     @
  257. @   @
  258. @   @
  259. @   @
  260.  @ @  
  261.  @ @  
  262.   @  
  263.   @  
  264. ",
  265.    W => "
  266. @         @
  267. @         @
  268. @   @   @
  269. @   @   @
  270. @   @   @
  271.  @ @ @ @  
  272.  @ @ @ @  
  273.   @   @  
  274.   @   @  
  275. ",
  276.    x => "
  277. @     @
  278. @     @
  279. @   @
  280.  @ @  
  281.   @  
  282.  @ @  
  283. @   @
  284. @     @
  285. @     @
  286. ",
  287.    y => "
  288. @     @
  289. @     @
  290. @   @
  291.  @ @  
  292.   @  
  293.   @  
  294.   @  
  295.   @  
  296.   @  
  297. ",
  298.    z => "
  299. @@@@@@@
  300.      @
  301.     @
  302.    @  
  303.   @  
  304.  @    
  305. @    
  306. @      
  307. @@@@@@@
  308. "
  309.  
  310. );
  311.  
  312. my $color_fondo = "black";
  313. my $color_texto = "green";
  314.  
  315. my $ven =
  316.  MainWindow->new( -background => $color_fondo, -foreground => $color_texto );
  317. $ven->title("ASCII Art 0.1 || Written By Doddy H");
  318. $ven->geometry("555x300+20+20");
  319. $ven->resizable( 0, 0 );
  320.  
  321. my $fondo = $ven->Text(
  322.    -width      => 75,
  323.    -heigh      => 15,
  324.    -background => $color_fondo,
  325.    -foreground => $color_texto
  326. )->place( -x => 15, -y => 10 );
  327. $ven->Label(
  328.    -text       => "Text : ",
  329.    -font       => "Impact1",
  330.    -background => $color_fondo,
  331.    -foreground => $color_texto
  332. )->place( -x => 20, -y => 250 );
  333. my $tengo = $ven->Entry(
  334.    -width      => 40,
  335.    -background => $color_fondo,
  336.    -foreground => $color_texto
  337. )->place( -x => 66, -y => 254 );
  338. $ven->Button(
  339.    -command          => \&now,
  340.    -text             => "Now!",
  341.    -width            => 10,
  342.    -background       => $color_fondo,
  343.    -foreground       => $color_texto,
  344.    -activebackground => $color_texto
  345. )->place( -x => 320, -y => 252 );
  346. $ven->Button(
  347.    -command          => \&about,
  348.    -text             => "About",
  349.    -width            => 10,
  350.    -background       => $color_fondo,
  351.    -foreground       => $color_texto,
  352.    -activebackground => $color_texto
  353. )->place( -x => 395, -y => 252 );
  354. $ven->Button(
  355.    -command          => \&exitnow,
  356.    -text             => "Exit",
  357.    -width            => 10,
  358.    -background       => $color_fondo,
  359.    -foreground       => $color_texto,
  360.    -activebackground => $color_texto
  361. )->place( -x => 470, -y => 252 );
  362.  
  363. MainLoop;
  364.  
  365. sub about {
  366.    $ven->Dialog(
  367.        -title            => "About",
  368.        -buttons          => ["OK"],
  369.        -text             => "Coded By Doddy H",
  370.        -background       => $color_fondo,
  371.        -foreground       => $color_texto,
  372.        -activebackground => $color_texto
  373.    )->Show();
  374. }
  375.  
  376. sub exitnow {
  377.    exit(1);
  378. }
  379.  
  380. sub now {
  381.  
  382.    $fondo->delete( "0.1", "end" );
  383.  
  384.    my $now  = $tengo->get;
  385.    my $code = artnow($now);
  386.  
  387.    $fondo->insert( "end", $code );
  388.  
  389. }
  390.  
  391. sub artnow {
  392.  
  393.    my $target = shift;
  394.  
  395.    my $fondo   = " ";
  396.    my $espacio = 0;
  397.  
  398.    my $lugar;
  399.    my @lotengo;
  400.  
  401.    my $tipox = $letras{"a"};
  402.    my @lineas = split /\n/, $tipox;
  403.    $altura = @lineas + 1;
  404.  
  405.    $anchura = max map { length $_ } @lineas;
  406.  
  407.    for ( 1 .. $altura ) {
  408.        push @lotengo, $fondo x ( ( $anchura + $espacio ) * length $target );
  409.    }
  410.  
  411.    for my $letra ( split //, $target ) {
  412.        my @lineas = split /\n/, $letras{$letra};
  413.  
  414.        for my $i ( 0 .. $altura - 1 ) {
  415.            ( my $plan = $lineas[$i] ) =~ s/ /$fondo/g;
  416.  
  417.            $plan = $fondo x $anchura if not $plan;
  418.  
  419.            substr( $lotengo[$i], $lugar, length $plan ) = $plan;
  420.        }
  421.  
  422.        $lugar += $anchura + $espacio;
  423.    }
  424.  
  425.    return ( join "\n", @lotengo );
  426.  
  427. }
  428.  
  429. #The End ?
  430.  

Una imagen



En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.822



Ver Perfil
Re: [Perl Tk] ASCII Art 0.1
« Respuesta #1 en: 3 Octubre 2012, 01:28 am »

+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?
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  ;-)


En línea

BigBear


Desconectado Desconectado

Mensajes: 545



Ver Perfil
Re: [Perl Tk] ASCII Art 0.1
« Respuesta #2 en: 3 Octubre 2012, 01:44 am »

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.
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Libros de Perl online [PERL]
Scripting
madpitbull_99 0 3,835 Último mensaje 18 Mayo 2011, 21:49 pm
por madpitbull_99
[Python] Ascii To Hex y Hex to Ascii
Scripting
Runex 0 3,099 Último mensaje 8 Abril 2012, 15:09 pm
por Runex
[Perl] ASCII Art 0.1
Scripting
BigBear 0 1,420 Último mensaje 3 Octubre 2012, 01:14 am
por BigBear
[Perl] ASCII Art 0.2
Scripting
BigBear 0 1,502 Último mensaje 5 Octubre 2012, 00:29 am
por BigBear
[Perl Tk] ASCII Art 0.2
Scripting
BigBear 0 1,698 Último mensaje 5 Octubre 2012, 00:30 am
por BigBear
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines