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:
Name | Type | Description |
---|---|---|
position | PhpTui\Tui\Position\FloatPosition | Position to draw the rectangle (bottom left corner) |
width | int | Width of the rectangle |
height | int | Height of the rectangle |
color | PhpTui\Tui\Color\Color | Color of the rectangle |