• Publicidad

ASCII Art 0.1

¿Estás desarrollando un proyecto, o piensas hacerlo? Pon aquí tu propuesta, lo más seguro es que alguien esté interesado en ayudarte.

ASCII Art 0.1

Notapor BigBear » 2012-10-02 18:16 @803

Sin mucho que decir dejo este simple script para hacer ASCII Art desde una palabra.

El código

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


Ejemplo de uso

Código: Seleccionar todo

r00t ~ # art.pl



#=============================================#
#            ASCII Art 0.1                    #
#---------------------------------------------#
# Written By Doddy H                          #
# Email: lepuke[at]hotmail[com]               #
# Website: doddyhackman.webcindario.com       #
#---------------------------------------------#
# Thanks to : reLlene,MARKO,explorer          #
# The End ?                                   #
#=============================================#


[+] Text : kacked



 @   @      @       @@@@    @   @    @@@@@    @@@@
 @  @       @      @    @   @  @     @        @   @
 @ @       @ @     @        @ @      @        @    @
 @@        @ @     @        @@       @        @    @
 @@       @   @    @        @@       @@@@     @    @
 @ @      @   @    @        @ @      @        @    @
 @  @     @@@@@    @        @  @     @        @    @
 @   @   @     @   @    @   @   @    @        @   @
 @    @  @     @    @@@@    @    @   @@@@@    @@@@



-- == (C) Doddy Hackman 2012 == --

BigBear
Perlero frecuente
Perlero frecuente
 
Mensajes: 981
Registrado: 2009-03-01 18:39 @818

Publicidad

Re: ASCII Art 0.1

Notapor explorer » 2012-10-02 19:51 @869

El ASCII Art no consiste solamente en sacar letras de gran tamaño, aclaro ;)
JF^D Perl programming & Raku programming. Grupo en Telegram: https://t.me/Perl_ES
Avatar de Usuario
explorer
Administrador
Administrador
 
Mensajes: 14476
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España

Re: ASCII Art 0.1

Notapor BigBear » 2012-10-03 08:26 @393

Eso ya lo sé. Sólo a esto pude llegar :)

En la versión 0.2 voy a usar este módulo que me habías recomendado para evitar ese hash infernal.
BigBear
Perlero frecuente
Perlero frecuente
 
Mensajes: 981
Registrado: 2009-03-01 18:39 @818


Volver a Proyectos

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 2 invitados

cron