Source for file svg.php

Documentation is available at svg.php

  1. <?php
  2. /**
  3.  * Using QueryPath to Generate a Scalable Vector Graphic (SVG).
  4.  *
  5.  * This file contains an example of how QueryPath can be used
  6.  * to generate an SVG image. SVG (Scalable Vector Graphics) is a W3C standard
  7.  * XML format for creating graphics. You can find out more about it
  8.  * here: {@link http://www.w3.org/TR/SVG11/}.
  9.  *
  10.  * If you would like to view the SVG file that is created, the file is available
  11.  * at {@link http://querypath.org/svg.php}. (That URL actually runs the script displayed
  12.  * here.)
  13.  *
  14.  * @package Examples
  15.  * @author M Butcher <matt@aleph-null.tv>
  16.  * @license LGPL The GNU Lesser GPL (LGPL) or an MIT-like license.
  17.  */
  18.  
  19. require_once '../src/QueryPath/QueryPath.php';
  20.  
  21. // Let's stub out a basic SVG document.
  22. $svg_stub '<?xml version="1.0"?>
  23. <svg
  24.    xmlns:svg="http://www.w3.org/2000/svg"
  25.    xmlns="http://www.w3.org/2000/svg"
  26.    xmlns:xlink="http://www.w3.org/1999/xlink"
  27.    version="1.0"
  28.    width="800"
  29.    height="600"
  30.    id="test">
  31.   <desc>Created by QueryPath.</desc>
  32. </svg>';
  33.  
  34. qp($svg_stub)
  35.   ->attr(array('width' => 800'height' => 600))
  36.   ->append('<rect id="first"/><rect id="second"/>')
  37.   ->find('#second')
  38.   ->attr(array('x' => 15'y' => 4'width' => 40'height' => 60'fill' => 'red'))
  39.   ->prev()
  40.   ->attr(array('x' => 2'y' => 2'width' => 40'height' => 60'fill' => 'navy'))
  41.   ->writeXML();

Documentation generated on Sun, 25 Jul 2010 16:09:12 -0500 by phpDocumentor 1.4.3