mathematicator-core/vizualizator

Core logic for elegant graphic visualization. Render to SVG, PNG, JPG and Base64.


README

Integrity check codecov Latest Stable Version Latest Unstable Version License: MIT PHPStan Enabled

Smart engine for creating elegant images and graphic visualizations.

Render to SVG, PNG and JPG. All output is in base64 format valid in HTML document.

Installation

composer require mathematicator-core/vizualizator

Usage

Imagine you can render all your images by simple objective request.

First inject Renderer to your script and create request:

$renderer = new Renderer;
$request = $renderer->createRequest();

Now you can add some lines and more:

$request->addLine(10, 10, 35, 70);
$request->addLine(35, 70, 70, 35);

And render to page (output is valid HTML code, base64 or svg tag):

// Render specific format:

echo $request->render(Renderer::FORMAT_PNG);
echo $request->render(Renderer::FORMAT_JPG);
echo $request->render(Renderer::FORMAT_SVG);

// Or use default renderer and __toString() method

echp $request;

Full simple short example

This example use short fluid-syntax. Final image size is 200x100:

echo (new Renderer)->createRequest(200, 100)
    ->addLine(10, 10, 35, 70, '#aaa')
    ->addLine(35, 70, 70, 35, 'red');

Mathematicator Framework tools structure

The biggest advantage is that you can choose which layer best fits your needs and start build on the top of it, immediately, without the need to create everything by yourself. Our tools are tested for bugs and tuned for performance, so you can save a significant amount of your time, money, and effort.

Framework tend to be modular as much as possible, so you should be able to create an extension on each layer and its sublayers.

Mathematicator framework layers ordered from the most concrete one to the most abstract one:

Third-party packages:

⚠️ Not guaranteed!

Contribution

Tests

All new contributions should have its unit tests in /tests directory.

Before you send a PR, please, check all tests pass.

This package uses Nette Tester. You can run tests via command:

composer test

Before PR, please run complete code check via command:

composer cs:install # only first time
composer fix # otherwise pre-commit hook can fail