PHP code example of stratadox / ascii-renderer

1. Go to this page and download the library: Download stratadox/ascii-renderer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

stratadox / ascii-renderer example snippets


use Stratadox\AsciiRenderer\FileLoader;
use Stratadox\AsciiRenderer\ImageFactory;
use Stratadox\AsciiRenderer\MaskFactory;

$loader = new FileLoader(new MaskFactory(), new ImageFactory());
$animation = $loader->load('file/name.ext');

use Stratadox\AsciiRenderer\AnimationCombiner;
use Stratadox\AsciiRenderer\Combiner;
use Stratadox\AsciiRenderer\FileLoader;
use Stratadox\AsciiRenderer\ImageFactory;
use Stratadox\AsciiRenderer\MaskFactory;

$loader = new FileLoader(new MaskFactory(), new ImageFactory());
$combiner = new AnimationCombiner(new Combiner());

$animation = $combiner->combine(
    [
        'item2' => $this->loader->load('/Asset/item/kite-shield-back.txt'),
        'body' => $this->loader->load('/Asset/body/leather-jacket-walk.txt'),
        'head' => $this->loader->load('/Asset/head/default.txt'),
        'headgear' => $this->loader->load('/Asset/headgear/cap.txt'),
        'item1' => $this->loader->load('/Asset/item/axe.txt'),
    ],
    'body'
);

assert(8 === $animation->length())
assert((string) $animation->frame(0)) === <<<'EOT'
  ____       
 /   _}      
 \__/*}  ./\ 
 /~^~\--<)+))
 |(  V___|\/ 
 \\_____(| ) 
 /~~~\   |/  
 (   \   o   
  \\  ) /    
  ) \ |/     
 / /| |      
[__b[__b     
EOT
);