vitkutny / ascii
此包的最新版本(v1.0.0)没有提供许可证信息。
v1.0.0
2014-08-22 11:51 UTC
Requires
- nette/utils: ~2.2
This package is not auto-updated.
Last update: 2024-09-24 01:46:11 UTC
README
_|_| _|_|_| _|_|_| _|_|_| _|_|_|
_| _| _| _| _| _|
_|_|_|_| _|_| _| _| _|
_| _| _| _| _| _|
_| _| _|_|_| _|_|_| _|_|_| _|_|_|
_|_ _ _|_ ,_ _ _| _ ,_ _ ,_
| |/ /\/ | / | |/ /|/| / | |/ / | |/ / |
|_/ |_/ /\/ |_/ |/ |_/ | |_/ \/|_/ |_/ |/ |_/ |/
使用方法
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;
现在这将在控制台正常工作。因为没有设置 lineBreakWrapper 和 stringWrapper。
包装器
基本在 HTML 标签 <pre> 中的渲染
$text->setStringWrapper(Text\Wrapper::el('pre')); $text->setLineBreak(Text\Wrapper::el('br'));
在表格中渲染 ASCII 文本
$text->setStringWrapper(Text\Wrapper::el('table')); $text->setLineWrapper(Text\Wrapper::el('tr')); $text->setPixelWrapper(Text\Wrapper::el('td'));
使用包装器输出将有一些有用的类,例如用于样式化。
<table class="ascii-string ascii-font-figlet-font"> <tr class="ascii-line"> <td class="ascii-pixel"></td> ... </tr> ... </table>
CharacterLineWrapper 还有一个包含字符 ASCII 码的类,例如字母 A
<span class="ascii-character ascii-character-65"> ... </span>
控制台
ASCII 文本渲染器通过删除 HTML 标签并将 Text\Renderer::$lineBreak 替换为 PHP_EOL,在控制台中表现得非常出色。