PHP Class Pop\Image\Svg

Author: Nick Sagona, III ([email protected])
Inheritance: extends AbstractImage
Show file Open project: nicksagona/PopPHP Class Usage Examples

Protected Properties

Property Type Description
$allowed array Array of allowed file types.
$allowedUnits array Array of allowed units.
$backgroundColor mixed SVG image background color
$clippingPaths array SVG image available clipping paths
$curClippingPath integer Current clipping path to use.
$curGradient integer Current gradient to use.
$fillColor mixed SVG image fill color
$gradients array SVG image available gradients
$height integer SVG image height
$opacity float SVG image color opacity
$resource SimpleXMLElement SVG image resource
$strokeColor mixed SVG image stroke color
$strokeDashGap integer Stroke dash gap
$strokeDashLength integer Stroke dash length
$strokeWidth array SVG image stroke width
$units string SVG image units
$width integer SVG image width

Public Methods

Method Description
__construct ( string $svg, integer | string $w = null, integer | string $h = null, Pop\Color\Space\ColorInterface $color = null ) : Svg Constructor
__toString ( ) : string To string method to output the image
addGradient ( Pop\Color\Space\ColorInterface $color1, Pop\Color\Space\ColorInterface $color2, integer $type = Svg::HORIZONTAL ) : Svg Add a gradient.
border ( integer $w ) : Svg Method to add a border to the image.
drawArc ( integer $x, integer $y, integer $start, integer $end, integer $w, integer $h = null ) : Svg Method to add an arc to the image.
drawCircle ( integer $x, integer $y, integer $w ) : Svg Method to add a circle to the image.
drawClippingCircle ( integer $x, integer $y, integer $w ) : Svg Add a clipping circle.
drawClippingEllipse ( integer $x, integer $y, integer $w, integer $h = null ) : Svg Add a clipping ellipse.
drawClippingPolygon ( array $points ) : Svg Add a clipping polygon.
drawClippingRectangle ( integer $x, integer $y, integer $w, integer $h = null ) : Svg Add a clipping rectangle.
drawClippingSquare ( integer $x, integer $y, integer $w ) : Svg Add a clipping square.
drawEllipse ( integer $x, integer $y, integer $w, integer $h = null ) : Svg Method to add an ellipse to the image.
drawLine ( integer $x1, integer $y1, integer $x2, integer $y2 ) : void Method to add a line to the image.
drawPolygon ( array $points ) : Svg Method to add a polygon to the image.
drawRectangle ( integer $x, integer $y, integer $w, integer $h = null ) : void Method to add a rectangle to the image.
drawSquare ( integer $x, integer $y, integer $w ) : Svg Method to add a square to the image.
getHeight ( ) : integer Get the SVG image height.
getUnits ( ) : string Get the SVG image units.
getWidth ( ) : integer Get the SVG image width.
output ( boolean $download = false ) : void Method to output the SVG image.
setBackgroundColor ( Pop\Color\Space\ColorInterface $color = null ) : Svg Set the background color.
setClippingPath ( integer $index = null ) : Svg Set the clipping path to use.
setFillColor ( Pop\Color\Space\ColorInterface $color = null ) : Svg Set the fill color.
setGradient ( integer $index = null ) : Svg Set the gradient to use.
setOpacity ( float $opac ) : Svg Set the opacity.
setStrokeColor ( Pop\Color\Space\ColorInterface $color = null ) : Svg Set the stroke color.
setStrokeWidth ( integer $wid = null, integer $dash_len = null, integer $dash_gap = null ) : Svg Set the stroke width.
text ( string $str, integer | string $size, integer | string $x, integer | string $y, string $font = 'Arial', integer | string $rotate = null, boolean $bold = false ) : Svg Create text within the an SVG image object.

Protected Methods

Method Description
getQuadrant ( array $point, array $center ) : integer Method to calculate which quadrant a point is in.
setStyles ( SimpleXMLElement $obj ) : SimpleXMLElement Method to set the styles.

Method Details

__construct() public method

Instantiate an SVG image object based on either a pre-existing SVG image file on disk, or a new SVG image file.
public __construct ( string $svg, integer | string $w = null, integer | string $h = null, Pop\Color\Space\ColorInterface $color = null ) : Svg
$svg string
$w integer | string
$h integer | string
$color Pop\Color\Space\ColorInterface
return Svg

__toString() public method

To string method to output the image
public __toString ( ) : string
return string

addGradient() public method

Add a gradient.
public addGradient ( Pop\Color\Space\ColorInterface $color1, Pop\Color\Space\ColorInterface $color2, integer $type = Svg::HORIZONTAL ) : Svg
$color1 Pop\Color\Space\ColorInterface
$color2 Pop\Color\Space\ColorInterface
$type integer
return Svg

border() public method

Method to add a border to the image.
public border ( integer $w ) : Svg
$w integer
return Svg

drawArc() public method

Method to add an arc to the image.
public drawArc ( integer $x, integer $y, integer $start, integer $end, integer $w, integer $h = null ) : Svg
$x integer
$y integer
$start integer
$end integer
$w integer
$h integer
return Svg

drawCircle() public method

Method to add a circle to the image.
public drawCircle ( integer $x, integer $y, integer $w ) : Svg
$x integer
$y integer
$w integer
return Svg

drawClippingCircle() public method

Add a clipping circle.
public drawClippingCircle ( integer $x, integer $y, integer $w ) : Svg
$x integer
$y integer
$w integer
return Svg

drawClippingEllipse() public method

Add a clipping ellipse.
public drawClippingEllipse ( integer $x, integer $y, integer $w, integer $h = null ) : Svg
$x integer
$y integer
$w integer
$h integer
return Svg

drawClippingPolygon() public method

Add a clipping polygon.
public drawClippingPolygon ( array $points ) : Svg
$points array
return Svg

drawClippingRectangle() public method

Add a clipping rectangle.
public drawClippingRectangle ( integer $x, integer $y, integer $w, integer $h = null ) : Svg
$x integer
$y integer
$w integer
$h integer
return Svg

drawClippingSquare() public method

Add a clipping square.
public drawClippingSquare ( integer $x, integer $y, integer $w ) : Svg
$x integer
$y integer
$w integer
return Svg

drawEllipse() public method

Method to add an ellipse to the image.
public drawEllipse ( integer $x, integer $y, integer $w, integer $h = null ) : Svg
$x integer
$y integer
$w integer
$h integer
return Svg

drawLine() public method

Method to add a line to the image.
public drawLine ( integer $x1, integer $y1, integer $x2, integer $y2 ) : void
$x1 integer
$y1 integer
$x2 integer
$y2 integer
return void

drawPolygon() public method

Method to add a polygon to the image.
public drawPolygon ( array $points ) : Svg
$points array
return Svg

drawRectangle() public method

Method to add a rectangle to the image.
public drawRectangle ( integer $x, integer $y, integer $w, integer $h = null ) : void
$x integer
$y integer
$w integer
$h integer
return void

drawSquare() public method

Method to add a square to the image.
public drawSquare ( integer $x, integer $y, integer $w ) : Svg
$x integer
$y integer
$w integer
return Svg

getHeight() public method

Get the SVG image height.
public getHeight ( ) : integer
return integer

getQuadrant() protected method

Method to calculate which quadrant a point is in.
protected getQuadrant ( array $point, array $center ) : integer
$point array
$center array
return integer

getUnits() public method

Get the SVG image units.
public getUnits ( ) : string
return string

getWidth() public method

Get the SVG image width.
public getWidth ( ) : integer
return integer

output() public method

Method to output the SVG image.
public output ( boolean $download = false ) : void
$download boolean
return void

setBackgroundColor() public method

Set the background color.
public setBackgroundColor ( Pop\Color\Space\ColorInterface $color = null ) : Svg
$color Pop\Color\Space\ColorInterface
return Svg

setClippingPath() public method

Set the clipping path to use.
public setClippingPath ( integer $index = null ) : Svg
$index integer
return Svg

setFillColor() public method

Set the fill color.
public setFillColor ( Pop\Color\Space\ColorInterface $color = null ) : Svg
$color Pop\Color\Space\ColorInterface
return Svg

setGradient() public method

Set the gradient to use.
public setGradient ( integer $index = null ) : Svg
$index integer
return Svg

setOpacity() public method

Set the opacity.
public setOpacity ( float $opac ) : Svg
$opac float
return Svg

setStrokeColor() public method

Set the stroke color.
public setStrokeColor ( Pop\Color\Space\ColorInterface $color = null ) : Svg
$color Pop\Color\Space\ColorInterface
return Svg

setStrokeWidth() public method

Set the stroke width.
public setStrokeWidth ( integer $wid = null, integer $dash_len = null, integer $dash_gap = null ) : Svg
$wid integer
$dash_len integer
$dash_gap integer
return Svg

setStyles() protected method

Method to set the styles.
protected setStyles ( SimpleXMLElement $obj ) : SimpleXMLElement
$obj SimpleXMLElement
return SimpleXMLElement

text() public method

Create text within the an SVG image object.
public text ( string $str, integer | string $size, integer | string $x, integer | string $y, string $font = 'Arial', integer | string $rotate = null, boolean $bold = false ) : Svg
$str string
$size integer | string
$x integer | string
$y integer | string
$font string
$rotate integer | string
$bold boolean
return Svg

Property Details

$allowed protected property

Array of allowed file types.
protected array $allowed
return array

$allowedUnits protected property

Array of allowed units.
protected array $allowedUnits
return array

$backgroundColor protected property

SVG image background color
protected mixed $backgroundColor
return mixed

$clippingPaths protected property

SVG image available clipping paths
protected array $clippingPaths
return array

$curClippingPath protected property

Current clipping path to use.
protected int $curClippingPath
return integer

$curGradient protected property

Current gradient to use.
protected int $curGradient
return integer

$fillColor protected property

SVG image fill color
protected mixed $fillColor
return mixed

$gradients protected property

SVG image available gradients
protected array $gradients
return array

$height protected property

SVG image height
protected int $height
return integer

$opacity protected property

SVG image color opacity
protected float $opacity
return float

$resource protected property

SVG image resource
protected SimpleXMLElement $resource
return SimpleXMLElement

$strokeColor protected property

SVG image stroke color
protected mixed $strokeColor
return mixed

$strokeDashGap protected property

Stroke dash gap
protected int $strokeDashGap
return integer

$strokeDashLength protected property

Stroke dash length
protected int $strokeDashLength
return integer

$strokeWidth protected property

SVG image stroke width
protected array $strokeWidth
return array

$units protected property

SVG image units
protected string $units
return string

$width protected property

SVG image width
protected int $width
return integer