Download the PHP package wazum/stipple without Composer

On this page you can find all versions of the php package wazum/stipple. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package stipple

stipple

Packagist Version PHP Version Support CI PHPStan

Render small SVG icons as monochrome ANSI in the terminal — pure PHP, zero system dependencies.

Use it in any PHP command line tool that wants real icons next to its menu items. The result is a plain string, so echo, Symfony TUI, Symfony Console and Laravel Prompts all work. Two samplers are included: Braille for more detail, half-block for wider terminal support.

Preview

One icon from TYPO3.Icons (MIT licence): the original SVG, then Braille output at heights 4, 6 and 8.

Source SVG (16×16) Braille, height(4) Braille, height(6) Braille, height(8)

The same icon with the half-block sampler. Less detail, but it works in any terminal and font.

All example icons, drawn by stipple itself. GALLERY.md has more sizes and both samplers.

Will my icons work?

Icons from Works?
Material Icons and Symbols, Font Awesome, Heroicons, Bootstrap Icons, Feather, TYPO3.Icons Yes, also black and unfilled icons
A CDN, in minified form Yes
Sprite sheets (<use> and <symbol>) Yes
Figma or Illustrator export Yes
Files with gradients or patterns Yes, drawn as one solid colour
Files that need real clipping or a mask No. You get an error, not a wrong picture.
Files with <text> No. Convert the text to paths first.
Colourful illustrations Not really. The output has one colour.

The rule everywhere: when stipple cannot draw something correctly, it throws an error. It never returns an empty or wrong picture and calls it success.

Install

Needs PHP 8.2 or newer with ext-gd, ext-mbstring, ext-dom, ext-libxml and ext-simplexml. No extra programs to install: the drawing is done in PHP by meyfa/php-svg.

Try it on your own icon

Installing also gives you a stipple command. Use it to look at one of your icons before you write any code:

vendor/bin/stipple --help lists all options. On failure it writes to stderr and returns a non-zero exit code.

Usage

Every row ends with \n.

Using it with a framework

No bridge package is needed. All of these take a plain string.

Symfony Console — pass isDecorated(), so a pipe or --no-ansi gets clean text. Console removes its own <info> tags in that case, but not colour codes from somewhere else, so without this you would find escape codes in your log file:

Laravel Prompts — note() takes the string as it is:

Symfony TUI — put the rows in a TextWidget. Its layout counts visible columns and ignores colour codes, so the rows keep their width.

Two things to know about Symfony TUI: it needs PHP 8.4 and is still marked experimental, while stipple stays on PHP 8.2. And if your terminal speaks the Kitty graphics protocol, Symfony TUI can show the SVG as a real image with its own ImageWidget, which always looks better. stipple is for the terminals that cannot do that.

Icons side by side

toString() returns one string. To put an icon next to something else, use toIcon() and get the rows separately:

Measure a row with widthCells, not strlen(). Rows with content hold colour codes, empty rows do not, so equally wide rows have different string lengths.

row() fills a missing row with the sampler's own empty cell, so icons of different height stay in line.

Ink mode

The output has one colour, so what counts is which pixels are covered, not which colour they are. That is the default.

Mode A pixel counts when Use it for
Coverage (default) it is solid enough, whatever its colour normal icons, also black or unfilled ones
Luminance it is bright enough light drawings on a dark background

threshold() sets the cut-off for the mode you picked.

With Luminance a black icon shows nothing, because black is not bright. That is why Coverage is the default.

Samplers

Sampler Pixels per cell Glyphs Notes
BrailleSampler (default) 2×4 U+2800–U+28FF More detail. Needs a font with Braille signs: JetBrains Mono, Cascadia, DejaVu and Iosevka all have them.
HalfBlockSampler 1×2 ▀ ▄ █ Less detail, but works in every terminal and font.

Empty Braille cells use U+2800 instead of a space, so icons next to each other keep their columns. The half-block sampler uses spaces, which can shift by one column in some fonts.

Extending

Use a different drawing library with RasterizerInterface:

Write your own sampler with SamplerInterface. AbstractSampler already has the helpers for reading pixels and writing colour codes:

SamplerOptions holds the colour, threshold and ink mode, and checks all three when it is created, so a sampler never has to. color(), threshold() and inkMode() build one for you, or pass one yourself:

Public API

These follow semantic versioning: Stipple, RenderedIcon, SamplerInterface, SamplerOptions, InkMode, BrailleSampler, HalfBlockSampler, AbstractSampler, RasterizerInterface, PhpSvgRasterizer and the classes under Exception\. How the stipple command behaves is included.

SvgPreprocessor, PreprocessedSvg and Console\StippleCommand are marked @internal. They can change in any release.

Security

The SVG is checked before it is drawn:

Every problem becomes a Wazum\Stipple\Exception\StippleException, so catch (StippleException) is enough.

SVG support

Handled for you:

Refused with an error, so you never get a wrong picture:

Drawn, but not exactly like a browser:

Everything else is passed on unchanged.

License

MIT — see LICENSE. Bundled demo icons (examples/icons/) are MIT-licensed by the TYPO3.Icons project — see THIRD_PARTY_NOTICES.md.


All versions of stipple with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-dom Version *
ext-gd Version *
ext-libxml Version *
ext-mbstring Version *
ext-simplexml Version *
meyfa/php-svg Version ^0.16
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package wazum/stipple contains the following files

Loading the files please wait ...