first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
File diff suppressed because it is too large Load Diff
+94
View File
@@ -0,0 +1,94 @@
<?php namespace RedeyeVentures\GeoPattern;
use RedeyeVentures\GeoPattern\SVGElements\Group;
use RedeyeVentures\GeoPattern\SVGElements\Polyline;
use RedeyeVentures\GeoPattern\SVGElements\Rectangle;
use RedeyeVentures\GeoPattern\SVGElements\Circle;
use RedeyeVentures\GeoPattern\SVGElements\Path;
class SVG {
protected $width;
protected $height;
protected $svgString;
function __construct($options=array())
{
$this->width = 100;
$this->height = 100;
$this->svgString = '';
}
public function setWidth($width)
{
$this->width = floor($width);
return $this;
}
public function setHeight($height)
{
$this->height = floor($height);
return $this;
}
protected function getSvgHeader()
{
return "<?xml version=\"1.0\"?><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"{$this->width}\" height=\"{$this->height}\">";
}
protected function getSvgFooter()
{
return '</svg>';
}
public function addRectangle($x, $y, $width, $height, $args=array())
{
$rectangle = new Rectangle($x, $y, $width, $height, $args);
$this->svgString .= $rectangle;
return $this;
}
public function addCircle($cx, $cy, $r, $args=array())
{
$circle = new Circle($cx, $cy, $r, $args);
$this->svgString .= $circle;
return $this;
}
public function addPath($d, $args=array())
{
$path = new Path($d, $args);
$this->svgString .= $path;
return $this;
}
public function addPolyline($points, $args=array())
{
$polyline = new Polyline($points, $args);
$this->svgString .= $polyline;
return $this;
}
public function addGroup($group, $args=array())
{
if ($group instanceof Group)
{
$group->setArgs($args);
$this->svgString .= $group;
return $this;
}
throw new \InvalidArgumentException("The group provided is not a valid instance of Group.");
}
public function getString()
{
return $this->getSvgHeader().$this->svgString.$this->getSvgFooter();
}
public function __toString()
{
return $this->getString();
}
}
@@ -0,0 +1,55 @@
<?php namespace RedeyeVentures\GeoPattern\SVGElements;
abstract class Base
{
protected $tag;
protected $elements;
protected $args;
function __construct($args)
{
$this->args = $args;
}
public function elementsToString()
{
$string = ' ';
foreach ($this->elements as $key => $value)
{
$string .= "$key=\"$value\" ";
}
return $string;
}
public function argsToString()
{
$string = '';
foreach ($this->args as $key => $value)
{
if (is_array($value))
{
$string .= "$key=\"";
foreach ($value as $k => $v)
{
$string .= "$k:$v;";
}
$string .= '" ';
}
else
{
$string .= "$key=\"$value\" ";
}
}
return $string;
}
public function getString()
{
return "<{$this->tag}{$this->elementsToString()}{$this->argsToString()}/>";
}
function __toString()
{
return $this->getString();
}
}
@@ -0,0 +1,16 @@
<?php namespace RedeyeVentures\GeoPattern\SVGElements;
class Circle extends Base
{
protected $tag = 'circle';
function __construct($cx, $cy, $r, $args=array())
{
$this->elements = [
'cx' => $cx,
'cy' => $cy,
'r' => $r,
];
parent::__construct($args);
}
}
@@ -0,0 +1,38 @@
<?php namespace RedeyeVentures\GeoPattern\SVGElements;
class Group extends Base
{
protected $tag = 'g';
protected $items;
function __construct($items=array(), $args=array())
{
$this->items = $items;
$this->args = $args;
}
function addItem($item)
{
$this->items[] = $item;
return $this;
}
function setArgs($args)
{
$this->args = $args;
return $this;
}
function getString()
{
$svgString = '';
$svgString .= "<{$this->tag} {$this->argsToString($this->args)}>";
foreach ($this->items as $item)
{
$svgString .= $item;
}
$svgString .= "</{$this->tag}>";
return $svgString;
}
}
@@ -0,0 +1,14 @@
<?php namespace RedeyeVentures\GeoPattern\SVGElements;
class Path extends Base
{
protected $tag = 'path';
function __construct($d, $args=array())
{
$this->elements = [
'd' => $d,
];
parent::__construct($args);
}
}
@@ -0,0 +1,14 @@
<?php namespace RedeyeVentures\GeoPattern\SVGElements;
class Polyline extends Base
{
protected $tag = 'polyline';
function __construct($points, $args=array())
{
$this->elements = [
'points' => $points,
];
parent::__construct($args);
}
}
@@ -0,0 +1,17 @@
<?php namespace RedeyeVentures\GeoPattern\SVGElements;
class Rectangle extends Base
{
protected $tag = 'rect';
function __construct($x, $y, $width, $height, $args=array())
{
$this->elements = [
'x' => $x,
'y' => $y,
'width' => $width,
'height' => $height,
];
parent::__construct($args);
}
}