Image

Image #

PhpTui\Tui\Extension\ImageMagick\Shape\ImageShape

Renders an image on the canvas.

Example #

Show code
<?php

declare(strict_types=1);

use PhpTui\Tui\Canvas\Marker;
use PhpTui\Tui\DisplayBuilder;
use PhpTui\Tui\Extension\Core\Widget\CanvasWidget;
use PhpTui\Tui\Extension\ImageMagick\ImageMagickExtension;
use PhpTui\Tui\Extension\ImageMagick\Shape\ImageShape;

require 'vendor/autoload.php';

$display = DisplayBuilder::default()
    ->addExtension(new ImageMagickExtension())
    ->build();
$display->draw(
    CanvasWidget::fromIntBounds(0, 320, 0, 240)
        ->marker(Marker::HalfBlock)
        ->draw(
            ImageShape::fromPath(__DIR__ . '/example.jpg')
        )
);

Parameters #

Configure the shape using the builder methods named as follows:

NameTypeDescription
pathstringAbsolute path to the image
positionPhpTui\Tui\Position\FloatPositionPosition to render at (bottom left)