Código PHP:
Ver original<?php
abstract class Char
{
private $charMap;
private $map;
public function __construct($map)
{
$this->map = $map;
0 => ' ',
1 => '_',
2 => '|',
3 => "'",
4 => '"',
5 => '/',
6 => '\\',
7 => 'U',
8 => '(',
9 => ')',
10 => '>',
11 => '<',
12 => '.',
13 => '-',
14 => ','
);
}
final protected function getChar($index)
{
return $this->charMap[$index];
}
final public function getTotalLines()
{
return count($this->map); }
final public function getLine($index)
{
$str = '';
foreach ($this->map[$index] as $character) {
$str .= $this->getChar($character);
}
return $str;
}
}
class CharSpace extends Char
{
public function __construct()
{
parent
::__construct
(array( array( 0, 0, 0, 0, 0, 0, 0), array( 0, 0, 0, 0, 0, 0, 0), array( 0, 0, 0, 0, 0, 0, 0), array( 0, 0, 0, 0, 0, 0, 0), array( 0, 0, 0, 0, 0, 0, 0), array( 0, 0, 0, 0, 0, 0, 0), array( 0, 0, 0, 0, 0, 0, 0) ));
}
}
class CharH extends Char
{
public function __construct()
{
parent
::__construct
(array( array( 0, 0, 1, 0, 0, 0, 1, 0, 0), array( 0, 2, 3, 2, 0, 2, 3, 2, 0), array( 5, 2, 0, 2, 1, 2, 0, 2, 6), array( 7, 2, 0, 0, 1, 0, 0, 2, 7), array( 0, 2, 1, 2, 0, 2, 1, 2, 0), array( 0, 5, 5, 0, 0, 0, 6, 6, 0), array( 8, 1, 4, 9, 0, 8, 4, 1, 9) ));
}
}
class CharO extends Char
{
public function __construct()
{
parent
::__construct
(array( array( 0, 0, 0, 7, 0, 0, 1, 1, 1, 0, 7), array( 0, 0, 0, 0, 6, 5, 4, 0, 0, 6, 5), array( 0, 0, 0, 0, 2, 0, 2, 0, 2, 0, 2), array(12,13,14, 1, 2, 0, 2, 1, 2, 0, 2), array( 0, 6, 1, 9,13, 6, 1, 1, 1, 5, 0), array( 0, 0, 0, 0, 0, 0, 6, 6, 0, 0, 0), array( 0, 0, 0, 0, 0, 8, 4, 1, 9, 0, 0) ));
}
}
class CharL extends Char
{
public function __construct()
{
parent
::__construct
(array( array( 0, 0, 0, 1, 0, 0, 0, 0, 0), array( 0, 0, 2, 4, 2, 0, 0, 0, 0), array( 7, 0, 2, 0, 2, 0, 7, 0, 0), array( 0, 6, 2, 0, 2, 5, 1, 1, 0), array( 0, 0, 2, 1, 1, 1, 1, 1, 2), array( 0, 0, 5, 5, 0, 0, 6, 6, 0), array( 0, 8, 1, 4, 9, 8, 4, 1, 9) ));
}
}
class CharA extends Char
{
public function __construct()
{
parent
::__construct
(array( array( 0, 0, 0, 0, 1, 0, 0, 0, 0, 0), array( 7, 0, 0, 5, 4, 6, 0, 0, 7, 0), array( 0, 6, 5, 0, 1, 0, 6, 5, 0, 0), array( 0, 5, 0, 1, 1, 1, 0, 6, 0, 0), array( 5, 1, 5, 0, 0, 0, 6, 1, 6, 0), array( 0, 6, 6, 0, 0, 0, 0, 6, 6, 0), array( 8, 4, 1, 9, 0, 0, 8, 4, 1, 9) ));
}
}
class CharM extends Char
{
public function __construct()
{
parent
::__construct
(array( array( 0, 0, 1, 1, 0, 0, 1, 1, 0, 0), array( 7, 2, 3, 0, 6, 5, 0, 3, 2, 7), array( 6, 2, 0, 2, 6, 5, 2, 0, 2, 5), array( 0, 2, 0, 2, 0, 0, 2, 0, 2, 0), array( 0, 2, 1, 2, 0, 0, 2, 2, 2, 0), array( 0,11,11, 0, 0, 0, 0,10,10, 0), array( 0, 8,12, 5, 0, 0, 6,12, 9, 0) ));
}
}
class CharU extends Char
{
public function __construct()
{
parent
::__construct
(array( array( 0, 0, 0, 1, 0, 0, 0, 1, 0), array( 7, 0, 2, 4, 2, 7, 2, 0, 2), array( 0, 6, 2, 0, 2, 6, 2, 0, 2), array( 0, 0, 2, 0, 2, 1, 2, 0, 2), array( 0,11,11, 6, 1, 1, 1, 5, 0), array( 0, 8, 1, 1, 9, 2, 2, 0, 0), array( 0, 0, 0, 0, 8, 1, 1, 9, 0) ));
}
}
class CharN extends Char
{
public function __construct()
{
parent
::__construct
(array( array( 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0), array( 0, 2, 0, 6, 0, 2, 4, 2, 0, 0, 0), array(11, 2, 0, 0, 6, 2, 0, 2,10, 0, 0), array( 7, 2, 0, 2, 6, 0, 0, 2, 7, 0, 0), array( 0, 2, 1, 2, 0, 6, 1, 2, 0, 0, 0), array( 0, 2, 2, 0, 0, 0, 6, 6,14,13,12), array( 0, 8, 1, 4, 9, 0, 0, 8, 1, 5, 0) ));
}
}
class CharD extends Char
{
public function __construct()
{
parent
::__construct
(array( array( 0, 0, 1, 1, 1, 1, 0, 0, 0), array( 0, 2, 0, 0, 1, 4, 6, 0, 0), array( 5, 2, 0, 2, 0, 2, 0, 2, 0), array( 7, 2, 0, 2, 1, 2, 0, 2, 6), array( 0, 2, 1, 1, 1, 1, 5, 0, 7), array( 0, 0, 2, 2, 2, 1, 0, 0, 0), array( 0, 8, 1, 1, 9, 1, 9, 0, 0) ));
}
}
class CharCollection
{
private $list;
public function __construct()
{
}
public function add(Char $character)
{
$this->list[] = $character; }
public function toArrayString()
{
}
for ($i = 0, $n = $this->list[0]->getTotalLines(); $i < $n; $i++) { $str = '';
foreach ($this->list as $character) { $str .= $character->getLine($i) . ' ';
}
$strArr[] = $str;
}
return $strArr;
}
public function toImage()
{
$arr = $this->toArrayString();
$w = 1050;
$h = 140;
foreach ($arr as $i => $line) {
}
return $img;
}
}
$hm = new CharCollection();
$hm->add(new CharH());
$hm->add(new CharO());
$hm->add(new CharL());
$hm->add(new CharA());
$hm->add(new CharSpace());
$hm->add(new CharM());
$hm->add(new CharU());
$hm->add(new CharN());
$hm->add(new CharD());
$hm->add(new CharO());
$img = $hm->toImage();
header('Content-Type: image/png');