More maintainable script

This commit is contained in:
Mattia Basaglia 2013-11-06 16:40:27 +01:00
parent 49c41cb928
commit 5d5d17a534
7 changed files with 187 additions and 0 deletions

11
Twilight/colors/30;1 Normal file
View file

@ -0,0 +1,11 @@
.-
(WW W
`

29
Twilight/colors/31;22 Normal file
View file

@ -0,0 +1,29 @@
\|/
/|\

29
Twilight/colors/34;22 Normal file
View file

@ -0,0 +1,29 @@
_ __
__..--"" "
`.
) `;. \
/___/ j_ )
' ``::' |
| -,|
.| ( '
..-----, |' ', '
.-` `, ._:7
,' \ | \
.' :. | `"7
/ ,.--''>-' ' /
- | `.
| .' `-_./
.' .'
| |
| '.
| . |
|/| |
` ) '.
\ |
`. |
` |
`-._|

29
Twilight/colors/35;22 Normal file
View file

@ -0,0 +1,29 @@
__ __ _
/ \ ;-. ,'/
( / \_ `.' /
| | ,' / \
( '. / ) |
\ __ /__'
\_ / -. `
( )
. \ ``-.
..::. |, \__/
.:::'':::. :'. ______.-'
.::' ':: :._______ \ \ /
./:' `.`.._ (
:/:' / `._/ \
:::' | |
||| | |
||| | |
':|| / \ / \__/
||| .--' | /-,_______\ \
||| _/ / | |\ \
'::. / / | | `--, \
||| | | | | / l
||| _/| | | | ( |
::|| | | | | \ |
`- | \ | \ `.___/
\_______) \_______)

29
Twilight/colors/37;1 Normal file
View file

@ -0,0 +1,29 @@
*
*
*
*
*

10
Twilight/colors/37;22 Normal file
View file

@ -0,0 +1,10 @@
_
/ \
( | | |
\ | \ j
\_ _ _|

View file

@ -0,0 +1,50 @@
#!/usr/bin/php
<?php
$dir = dirname(__FILE__);
$dir_files = scandir($dir);
$files = array();
$maxw = 0;
$maxh = 0;
foreach($dir_files as $file)
{
if ( strpos($file,";") !== false )
{
$curr_file = file("$dir/$file",FILE_IGNORE_NEW_LINES);
$files[$file] = $curr_file;
foreach($curr_file as $line)
{
$w = strlen($line);
if ( $w> $maxw )
$maxw = $w;
}
$h = count($curr_file);
if ( $h > $maxh )
$maxh = $h;
}
}
$chars=array_fill(0,$maxh,array_fill(0,$maxw,null));
foreach ( $files as $color => $lines )
for ( $i = 0; $i < $maxh; $i++ )
{
for ( $j = 0, $l = strlen($lines[$i]); $j < $l; $j++ )
{
if ( $lines[$i][$j] != ' ' )
$chars[$i][$j] = array("color"=>$color,"char"=>$lines[$i][$j]);
}
}
foreach($chars as $line)
{
foreach($line as $char)
{
if ( is_null($char) )
echo ' ';
else
echo "\x1b[$char[color]m$char[char]";
}
echo "\n";
}
echo "\x1b[0m\n";