PHP Classes

File: example/pathBox.php

Recommend this page to a friend!
  Classes of Edgar Asatryan   PHP SVG Magick Library   example/pathBox.php   Download  
File: example/pathBox.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP SVG Magick Library
Compose vectorial graphics in SVG format
Author: By
Last change: Remove duplicate method.
Clean up example.
Date: 6 years ago
Size: 1,026 bytes
 

Contents

Class file image Download
<?php

use nstdio\svg\container\SVG;
use
nstdio\svg\shape\Circle;
use
nstdio\svg\shape\Path;
use
nstdio\svg\shape\Rect;

require_once
__DIR__ . '/../vendor/autoload.php';

$svg = new SVG();

$path = Path::create($svg, 10, 10)
    ->
apply(['fill' => 'none', 'stroke' => 'red', 'stoke-width' => 0.2]);

$path
   
->hLineTo(90, false)
    ->
vLineTo(90, false)
    ->
hLineTo(90, false);

Circle::create($svg, 10, 10, 3)->apply(['fill' => 'green']);
Circle::create($svg, 100, 10, 3)->apply(['fill' => 'green']);
Circle::create($svg, 100, 100, 3)->apply(['fill' => 'green']);
Circle::create($svg, 190, 100, 3)->apply(['fill' => 'green']);

drawBBox($svg, $path->getBoundingBox());

Rect::create($svg, 478, 638, 1, 1)->apply(['fill' => 'none', 'stroke' => 'blue', 'stroke-width' => '1']);

echo
$svg;

function
drawBBox($parent, $box)
{
    (new
Rect($parent, $box['height'], $box['width'], $box['x'], $box['y']))->apply([
       
'fill' => 'none',
       
'stroke' => 'green',
       
'stroke-width' => 0.3,
    ]);
}