Rectangle

Rectangle #

PhpTui\Tui\Extension\Core\Shape\RectangleShape

Draw a rectangle at the given position with the given width and height

Example #

Show code
<?php

declare(strict_types=1);

use PhpTui\Tui\Canvas\Marker;
use PhpTui\Tui\Color\AnsiColor;
use PhpTui\Tui\DisplayBuilder;
use PhpTui\Tui\Extension\Core\Shape\RectangleShape;
use PhpTui\Tui\Extension\Core\Widget\CanvasWidget;

require 'vendor/autoload.php';

$display = DisplayBuilder::default()->build();
$display->draw(
    CanvasWidget::fromIntBounds(0, 10, 0, 10)
        ->marker(Marker::Dot)
        ->draw(
            RectangleShape::fromScalars(
                0,
                0,
                10,
                10,
            )->color(
                AnsiColor::Green
            )
        )
);

Parameters #

Configure the shape using the builder methods named as follows:

NameTypeDescription
positionPhpTui\Tui\Position\FloatPositionPosition to draw the rectangle (bottom left corner)
widthintWidth of the rectangle
heightintHeight of the rectangle
colorPhpTui\Tui\Color\ColorColor of the rectangle