PHP code example of atelier / layout

1. Go to this page and download the library: Download atelier/layout library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

atelier / layout example snippets


$result = Grid::tracks('row', [TrackSize::fixed(48), TrackSize::fr(), TrackSize::fixed(48)])
    ->gap(8)
    ->add(Frame::fixed('left', 32, 32))
    ->add(Frame::stretch('middle'))
    ->add(Frame::fixed('right', 32, 32))
    ->solve(new LayoutContext(), Rect::fromSize(240, 48));

$result->frameOf('middle');   // Rect(56, 0, 128, 48)

use Atelier\Layout\Alignment;
use Atelier\Layout\Element\TextBlock;
use Atelier\Layout\Geometry\Rect;
use Atelier\Layout\LayoutContext;

$text = TextBlock::of('caption', 'A label that wraps', 12)
    ->align(Alignment::Center, Alignment::End)
    ->layout(new LayoutContext(), new Rect(0, 0, 90, 48));

$text->lines;          // one frame and one baseline per line
$text->hasOverflow();  // reported, never hidden

use Atelier\Layout\Connection\OrthogonalConnector;

$connection = (new OrthogonalConnector())->connect($from, $to);

$connection->points;      // 100,40 -> 140,40 -> 140,80 -> 180,80
$connection->labelPoint;  // where an edge label belongs
$connection->tipTangent;  // the final direction, for an arrowhead