• Publicidad

ASCII Art 0.1 (Version TK)

¿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 (Version TK)

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

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

El código

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


Una imagen

[center]Imagen[/center]
BigBear
Perlero frecuente
Perlero frecuente
 
Mensajes: 981
Registrado: 2009-03-01 18:39 @818

Publicidad

Volver a Proyectos

¿Quién está conectado?

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

cron