Your IP : 216.73.216.240


Current Path : /home/juvelize/saulnois/tmp/install_695d2cf0b4957/src/View/Html/
Upload File :
Current File : /home/juvelize/saulnois/tmp/install_695d2cf0b4957/src/View/Html/TSvg.php

<?php
/*
* @package		Tech Fry Library
* @license		https://www.gnu.org/licenses/gpl-3.0.en.html
*/

namespace TechFry\Library\View\Html;

defined('_JEXEC') or die;

// https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorials/SVG_from_scratch
class TSvg
{
	public $width;

    public $height;

    // Styling
    public $stroke;
    public $stroke_width;
    public $stroke_linecap; // butt, square, round
    public $fill;

    public $elements = [];

    // circle, rect, ellipse, line, polygon, polyline, text, path

    public function __construct($width = 100, $height = 100)
    {
        $this->width = $width;

        $this->height = $height;
    }

    // 1. Line joining two points - x1, y1 and x2, y2
    public function line($x1, $y1, $x2, $y2) 
    {
        $line = '<line x1="' . $x1 . '" y1="' . $y1 . '" x2="' . $x2 . '" y2="' . $y2 . '" />';
        
        $this->elements[] = $line;
    }

    // 2. Rectangle - x, y are top left corner
    public function rectangle($x, $y, $width, $height)
    {
        $rect = '<rect x="' . $x . '" y="' . $y . ' width="' . $width  . '" height="' . $height . '" fill="' . $this->fill . '" />';
        
        $this->elements[] = $rect;
    }

    // 3. Circle - center and radius
    public function circle($cx, $cy, $r)
    {
        $circle = '<circle cx="' . $cx . '" cy="' . $cy . '" r="' . $r . '" />';
        
        $this->elements[] = $circle;
    }

    // 4. Ellipse - center and two radius
    public function ellipse($cx, $cy, $rx, $ry)
    {
        $ellipse = '<ellipse cx="' . $cx . '" cy="' . $cy . '" rx="' . $rx . '" ry="' . $ry . '" />';

        $this->elements[] = $ellipse;
    }

    // Text
    public function text($content)
    {


    }
}

/*
Top left corner is origin point (0,0)

path (<path d="M10 10" />)
    Move To - M x y (or) m dx dy
    Line To - L x y (or) l dx dy
    Quadratic Curve - Q x1 y1, x y (or) q dx1 dy1, dx dy
    Cubic Curve - C

transform
    translate() - transform="translate(30,40)"
    rotate() - transform="rotate(45)"
    skewX() 
    skewY()
    scale()
*/