Line #
PhpTui\Tui\Extension\Core\Shape\LineShape
Draw a straight line from one point to another.
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\LineShape;
use PhpTui\Tui\Extension\Core\Widget\CanvasWidget;
require 'vendor/autoload.php';
$display = DisplayBuilder::default()->build();
$display->draw(
CanvasWidget::fromIntBounds(0, 20, 0, 20)
->marker(Marker::Dot)
->draw(LineShape::fromScalars(
0, // x1
0, // y1
20, // x2
20, // y2
)->color(AnsiColor::Green))
);
Parameters #
Configure the shape using the builder methods named as follows:
Name | Type | Description |
---|---|---|
point1 | PhpTui\Tui\Position\FloatPosition | Draw from this point |
point2 | PhpTui\Tui\Position\FloatPosition | Draw to this point |
color | PhpTui\Tui\Color\Color | Color of the line |