vitkutny/ascii

There is no license information available for the latest version (v1.0.0) of this package.

v1.0.0 2014-08-22 11:51 UTC

This package is not auto-updated.

Last update: 2024-04-08 23:19:37 UTC


README

   _|_|       _|_|_|     _|_|_|   _|_|_|   _|_|_|  
 _|    _|   _|         _|           _|       _|    
 _|_|_|_|     _|_|     _|           _|       _|    
 _|    _|         _|   _|           _|       _|    
 _|    _|   _|_|_|       _|_|_|   _|_|_|   _|_|_|  
 
 _|_   _       _|_      ,_    _          _|    _   ,_    _   ,_  
  |   |/  /\/   |      /  |  |/  /|/|   / |   |/  /  |  |/  /  | 
  |_/ |_/  /\/  |_/       |/ |_/  | |_/ \/|_/ |_/    |/ |_/    |/

Usage

use VitKutny\Ascii\Text;

$text = new Text\Renderer('Hello world!');
$text->setFont(new Text\Font\Figlet(__DIR__ . '/fonts/figlet-font.flf');
$text->render(); //or echo $text;

Now this will work fine only in console. Because no lineBreakWrapper and stringWrapper are set.

Wrappers

Basic render in HTML tag <pre>:

$text->setStringWrapper(Text\Wrapper::el('pre'));
$text->setLineBreak(Text\Wrapper::el('br'));

Render ASCII text in table:

$text->setStringWrapper(Text\Wrapper::el('table'));
$text->setLineWrapper(Text\Wrapper::el('tr'));
$text->setPixelWrapper(Text\Wrapper::el('td'));

Using wrappers output will have some usefull classes e.g. for styling.

<table class="ascii-string ascii-font-figlet-font">
  <tr class="ascii-line">
      <td class="ascii-pixel"></td>
      ...
  </tr>
  ...
</table>

CharacterLineWrapper also has class containing ASCII number of the character, e.g. for letter A:

<span class="ascii-character ascii-character-65">
  ...
</span>

Console

ASCII text renderer works like a charm in console by removing HTML tags and replacing Text\Renderer::$lineBreak by PHP_EOL.