1. Go to this page and download the library: Download wazum/stipple 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/ */
wazum / stipple example snippets
use Wazum\Stipple\Sampler\InkMode;
use Wazum\Stipple\Stipple;
// One-shot, defaults: height 8 cells, terminal default fg, Braille sampler.
echo Stipple::render('/path/to/icon.svg');
echo Stipple::renderFromString('<svg ...>');
// Fluent
echo Stipple::make('/path/to/icon.svg')
->height(4) // cells; valid 1..256
->color('#00ffff') // optional, 6-digit hex; null → terminal default fg
->accent('#ff8700') // overrides the fallback in any var(--icon-color-accent, …) call in the SVG
->threshold(0.5) // cutoff in [0.0, 1.0] for whatever the ink mode measures
->inkMode(InkMode::Coverage) // Coverage (default) or Luminance — see below
->decorated(true) // false writes no colour codes, for a file or a pipe
->maxRasterDimension(2048) // safety cap on the intermediate raster (default 4096 px)
->toString();
// __toString delegates to toString(), so casting works too:
echo (string) Stipple::make('/path/to/icon.svg')->height(4);
use Wazum\Stipple\RenderedIcon;
$icon = Stipple::make('/path/to/icon.svg')->height(4)->toIcon();
$icon->rows; // one string per row
$icon->widthCells; // width in terminal cells
$icon->heightCells; // same as count($icon->rows)
$icon->row(9); // one row, or an empty row if it does not exist
$icon->blankRow(); // an empty row
echo $icon; // same as toString()
use Wazum\Stipple\Sampler\InkMode;
Stipple::make($path)->toString(); // Coverage (default)
Stipple::make($path)->inkMode(InkMode::Luminance)->toString();
use Wazum\Stipple\Sampler\HalfBlockSampler;
Stipple::make($path)->sampler(new HalfBlockSampler())->toString();
use Wazum\Stipple\Rasterizer\RasterizerInterface;
final class MyRasterizer implements RasterizerInterface
{
public function rasterize(string $svg, int $widthPx, int $heightPx): \GdImage { /* … */ }
}
Stipple::make($path)->rasterizer(new MyRasterizer())->toString();
public function sample(\GdImage $image, SamplerOptions $options): string
use Wazum\Stipple\Sampler\SamplerOptions;
Stipple::make($path)->samplerOptions(new SamplerOptions('#00ffff', 0.4))->toString();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.