⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 svg.php

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/** * XML_SVG * * Wrapper class that provides some examples and a few convenience * methods. * * $Horde: framework/XML_SVG/SVG.php,v 1.18 2005/01/03 13:09:24 jan Exp $ * * Copyright 2002-2005 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. * * @package XML_SVG */class XML_SVG {    function example()    {        // 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.        $svg = &new XML_SVG_Document(array('width' => 400,                                           'height' => 200));        // Create an instance of XML_SVG_Group. Set the style,        // transforms for child objects.        $g = &new XML_SVG_Group(array('style' => 'stroke:black',                                      'transform' => 'translate(200 100)'));        // Add a parent to the g instance.        $g->addParent($svg);        // The same results can be accomplished by making g a child of the svg.        // $svg->addChild($g);        // Create and animate a circle.        $circle = &new XML_SVG_Circle(array('cx' => 0,                                           'cy' => 0,                                           'r' => 100,                                           'style' => 'stroke-width:3'));        $circle->addChild(new XML_SVG_Animate(array('attributeName' => 'r',                                                    'attributeType' => 'XML',                                                    'from' => 0,                                                    'to' => 75,                                                    'dur' => '3s',                                                    'fill' => 'freeze')));        $circle->addChild(new XML_SVG_Animate(array('attributeName' => 'fill',                                                    'attributeType' => 'CSS',                                                    'from' => 'green',                                                    'to' => 'red',                                                    'dur' => '3s',                                                    'fill' => 'freeze')));        // Make the circle a child of g.        $g->addChild($circle);        // Create and animate some text.        $text = &new XML_SVG_Text(array('text' => 'SVG chart!',                                       'x' => 0,                                       'y' => 0,                                       'style' => 'font-size:20;text-anchor:middle;'));        $text->addChild(new XML_SVG_Animate(array('attributeName' => 'font-size',                                                  'attributeType' => 'auto',                                                  'from' => 0,                                                  'to' => 20,                                                  'dur' => '3s',                                                  'fill' => 'freeze')));        // Make the text a child of g.        $g->addChild($text);        // Send a message to the svg instance to start printing.        $svg->printElement();    }}/** * XML_SVG_Element * * This is the base class for the different SVG Element * Objects. Extend this class to create a new SVG Element. * * @package XML_SVG */class XML_SVG_Element {    var $_elements = null;    var $_style = null;    var $_transform = null;    var $_id = null;    function XML_SVG_Element($params = array())    {        foreach ($params as $p => $v) {            $param = '_' . $p;            $this->$param = $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.     */    function printElement()    {        // Loop and call.        if (is_array($this->_elements)) {            foreach ($this->_elements as $child) {                $child->printElement();            }        }    }    /**     * This method adds an object reference (or value, if $copy is     * true) to the _elements array.     */    function addChild(&$element, $copy = false)    {        if ($copy) {            $this->_elements[] = &$element->copy();        } else {            $this->_elements[] = &$element;        }    }    /**     * This method sends a message to the passed element requesting to     * be added as a child.     */    function addParent(&$parent)    {        if (is_subclass_of($parent, 'XML_SVG_Element')) {            $parent->addChild($this);        }    }    function copy()    {        if (version_compare(zend_version(), '2', '>')) {            return clone($this);        } else {            $xml_svg = $this;            return $xml_svg;        }    }    /**     * Print each of the passed parameters, if they are set.     */    function printParams()    {        foreach (func_get_args() as $param) {            $_param = '_' . $param;            if (isset($this->$_param)) {                switch ($param) {                case 'filter':                    echo ' filter="url(#' . $this->$_param . ')"';                    break;                default:                    echo ' ' . str_replace('_', '-', $param) . '="' . $this->$_param . '"';                    break;                }            }        }    }    // Set any named attribute of an element to a value.    function setParam($param, $value)    {        $attr = '_' . $param;        $this->$attr = $value;    }    // Get any named attribute of an element.    function getParam($param)    {        $attr = '_' . $param;        if (isset($this->$attr)) {            return $this->$attr;        } else {            return null;        }    }    // Print out the object for debugging.    function debug()    {        echo '<pre>'; var_dump($this); echo '</pre>';    }}/** * XML_SVG_Fragment * * @package XML_SVG */class XML_SVG_Fragment extends XML_SVG_Element {    var $_width;    var $_height;    var $_viewBox;    var $_x;    var $_y;    function printElement()    {        echo '<svg';        $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";        parent::printElement();        echo "</svg>\n";    }    function bufferObject()    {        ob_start();        $this->printElement();        $output = ob_get_contents();        ob_end_clean();        return $output;    }}/** * XML_SVG_Document * * This extends the XML_SVG_Fragment class. It wraps the XML_SVG_Frament output * with a content header, xml definition and doctype. * * @package XML_SVG */class XML_SVG_Document extends XML_SVG_Fragment {    function printElement()    {        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");        parent::printElement();    }}/** * XML_SVG_Group * * @package XML_SVG */class XML_SVG_Group extends XML_SVG_Element {    function printElement()    {        echo '<g';        $this->printParams('id', 'style', 'transform', 'filter');        print(">\n");        parent::printElement();        print("</g>\n");    }}/** * XML_SVG_Textpath * * @package XML_SVG */class XML_SVG_Textpath extends XML_SVG_Element {    var $_text;    var $_x;    var $_y;    var $_dx;    var $_dy;    var $_rotate;    var $_textLength;    var $_lengthAdjust;    function printElement($element = 'textpath')    {        echo '<' . $element;        $this->printParams('id', 'x', 'y', 'dx', 'dy', 'rotate',                           'textLength', 'lengthAdjust', 'style', 'transform');        echo '>' . htmlentities($this->_text);        parent::printElement();        echo "</$element>\n";    }    function setShape($x, $y, $text)    {        $this->_x = $x;        $this->_y = $y;        $this->_text = $text;    }}/** * XML_SVG_Text * * @package XML_SVG */class XML_SVG_Text extends XML_SVG_Textpath {    function printElement()    {        parent::printElement('text');    }    function setShape($x, $y, $text)    {        $this->_x = $x;        $this->_y = $y;        $this->_text = $text;    }}/** * XML_SVG_Tspan * * @package XML_SVG */class XML_SVG_Tspan extends XML_SVG_Element {    var $_text;    var $_x;    var $_y;    var $_dx;    var $_dy;    var $_rotate;    var $_textLength;    var $_lengthAdjust;    function printElement()    {        echo '<tspan';        $this->printParams('id', 'x', 'y', 'dx', 'dy', 'rotate',                           'textLength', 'lengthAdjust', 'style', 'transform');        echo '>' . $this->_text;        if (is_array($this->_elements)) {            parent::printElement();        }        echo "</tspan>\n";    }    function setShape($x, $y, $text)    {        $this->_x = $x;        $this->_y = $y;        $this->_text  = $text;    }}/** * XML_SVG_Circle * * @package XML_SVG */class XML_SVG_Circle extends XML_SVG_Element {    var $_cx;    var $_cy;    var $_r;    function printElement()    {        echo '<circle';        $this->printParams('id', 'cx', 'cy', 'r', 'style', 'transform');        if (is_array($this->_elements)) {            // Print children, start and end tag.            echo ">\n";            parent::printElement();            echo "</circle>\n";        } else {            // Print short tag.            echo "/>\n";        }    }    function setShape($cx, $cy, $r)    {        $this->_cx = $cx;        $this->_cy = $cy;        $this->_r  = $r;    }}/** * XML_SVG_Line * * @package XML_SVG */class XML_SVG_Line extends XML_SVG_Element {    var $_x1;    var $_y1;    var $_x2;    var $_y2;    function printElement()    {        echo '<line';        $this->printParams('id', 'x1', 'y1', 'x2', 'y2', 'style');        if (is_array($this->_elements)) {            // Print children, start and end tag.            print(">\n");            parent::printElement();            print("</line>\n");        } else {            // Print short tag.            print("/>\n");        }    }    function setShape($x1, $y1, $x2, $y2)    {        $this->_x1 = $x1;        $this->_y1 = $y1;        $this->_x2  = $x2;        $this->_y2  = $y2;    }}/** * XML_SVG_Rect * * @package XML_SVG */class XML_SVG_Rect extends XML_SVG_Element {    var $_x;    var $_y;    var $_width;    var $_height;    var $_rx;    var $_ry;    function printElement()    {        echo '<rect';        $this->printParams('id', 'x', 'y', 'width', 'height',                           'rx', 'ry', 'style');        if (is_array($this->_elements)) {            // Print children, start and end tag.            print(">\n");            parent::printElement();            print("</rect>\n");        } else {            // Print short tag.            print("/>\n");        }    }    function setShape($x, $y, $width, $height)    {        $this->_x = $x;        $this->_y = $y;        $this->_width  = $width;        $this->_height  = $height;    }}/** * XML_SVG_Ellipse * * @package XML_SVG */class XML_SVG_Ellipse extends XML_SVG_Element {    var $_cx;    var $_cy;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -