Source for file SVG.php
Documentation is available at SVG.php
* Wrapper class that provides some examples and a few convenience
* $Horde: framework/XML_SVG/SVG.php,v 1.20 2006/01/01 21:10:25 jan Exp $
* Copyright 2002-2006 Chuck Hagenbuch <chuck@horde.org>
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
// Create an instance of XML_SVG_Document. All other objects
// will be added to this instance for printing. Set the height
// and width of the viewport.
// Create an instance of XML_SVG_Group. Set the style,
// transforms for child objects.
'transform' => 'translate(200 100)'));
// Add a parent to the g instance.
// The same results can be accomplished by making g a child of the svg.
// Create and animate a circle.
'style' => 'stroke-width:3'));
'attributeType' => 'XML',
'attributeType' => 'CSS',
// Make the circle a child of g.
// Create and animate some text.
'style' => 'font-size:20;text-anchor:middle;'));
'attributeType' => 'auto',
// Make the text a child of g.
// Send a message to the svg instance to start printing.
* This is the base class for the different SVG Element
* Objects. Extend this class to create a new SVG Element.
foreach ($params as $p => $v) {
* Most SVG elements can contain child elements. This method calls
* the printElement method of any child element added to this
* object by use of the addChild method.
foreach ($this->_elements as $child) {
* This method adds an object reference (or value, if $copy is
* true) to the _elements array.
function addChild(&$element, $copy = false )
$this->_elements[] = &$element->copy ();
$this->_elements[] = &$element;
* This method sends a message to the passed element requesting to
$parent->addChild ($this);
* Print each of the passed parameters, if they are set.
if (isset ($this->$_param)) {
echo ' filter="url(#' . $this->$_param . ')"';
echo ' ' . str_replace('_', '-', $param) . '="' . $this->$_param . '"';
// Set any named attribute of an element to a value.
// Get any named attribute of an element.
if (isset ($this->$attr)) {
// Print out the object for debugging.
echo '<pre>'; var_dump($this); echo '</pre>';
$this->printParams('id', 'width', 'height', 'x', 'y', 'viewBox', 'style');
echo ' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' . "\n";
* This extends the XML_SVG_Fragment class. It wraps the XML_SVG_Frament output
* with a content header, xml definition and doctype.
header('Content-Type: image/svg+xml');
print ('<?xml version="1.0" encoding="iso-8859-1"?>'. "\n");
print ('<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">' . "\n");
$this->printParams('id', 'style', 'transform', 'filter');
$this->printParams('id', 'x', 'y', 'dx', 'dy', 'rotate',
'textLength', 'lengthAdjust', 'style', 'transform');
if (isset ($this->_charset)) {
$this->printParams('id', 'x', 'y', 'dx', 'dy', 'rotate',
'textLength', 'lengthAdjust', 'style', 'transform');
$this->printParams('id', 'cx', 'cy', 'r', 'style', 'transform');
// Print children, start and end tag.
$this->printParams('id', 'x1', 'y1', 'x2', 'y2', 'style');
// Print children, start and end tag.
// Print children, start and end tag.
function setShape($x, $y, $width, $height)
$this->_height = $height;
$this->printParams('id', 'cx', 'cy', 'rx', 'ry', 'style', 'transform');
// Print children, start and end tag.
$this->printParams('id', 'points', 'style', 'transform');
// Print children, start and end tag.
$this->_points = $points;
$this->printParams('id', 'points', 'style', 'transform');
// Print children, start and end tag.
$this->_points = $points;
// Print children, start and end tag.
$this->printParams('id', 'x', 'y', 'width', 'height', 'style');
if (!empty ($this->_href)) {
echo ' xlink:href="' . $this->_href . '"';
// Print children, start and end tag.
function setShape($x, $y, $width, $height)
$this->_height = $height;
$this->printParams('id', 'attributeName', 'attributeType', 'from', 'to',
// Print children, start and end tag.
function setShape($attributeName, $attributeType = '', $from = '',
$to = '', $begin = '', $dur = '', $fill = '')
$this->_attributeName = $attributeName;
$this->_attributeType = $attributeType;
// Print children, start and end tag.
* XML_SVG_FilterPrimitive
var $_primitives = array ('Blend',
$this->_primitive = $primitive;
$name = 'fe' . $this->_primitive;
$this->printParams('id', 'x', 'y', 'dx', 'dy', 'width', 'height', 'in', 'in2',
'result', 'mode', 'type', 'values', 'operator',
'k1', 'k2', 'k3', 'k4', 'surfaceScale', 'stdDeviation',
'diffuseConstant', 'kernelUnitLength',
'flood_color', 'flood_opacity');
// Print children, start and end tag.
* XML_SVG_FilterMergeNode
$this->_symbol = $symbol;
echo '<use xlink:href="#' . $this->_symbol . '"/>';
$this->printParams('id', 'refX', 'refY', 'markerUnits',
'markerWidth', 'markerHeight', 'orient');
if (is_array($this->_elements)) { // Print children, start and end tag.
function setShape($refX = '', $refY = '', $markerUnits = '',
$markerWidth = '', $markerHeight = '', $orient = '')
$this->_markerUnits = $markerUnits;
$this->_markerWidth = $markerWidth;
$this->_markerHeight = $markerHeight;
$this->_orient = $orient;
$this->printParams('id', 'x', 'y', 'dx', 'dy', 'rotate',
'textLength', 'lengthAdjust', 'style');
Documentation generated on Mon, 11 Mar 2019 14:39:04 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|