| 1 | <?php | 
| 2 | /** | 
| 3 | * Another example of how to build an | 
| 4 | * SVG Image with phpHtmlLib. | 
| 5 | * SVG = Scalable Vector Graphics. | 
| 6 | * that phpHtmlLib provides. | 
| 7 | * | 
| 8 | * | 
| 9 | * $Id: example7.php,v 1.3 2003/06/05 18:25:45 hemna Exp $ | 
| 10 | * | 
| 11 | * @author Walter A. Boring IV <waboring@buildabetterweb.com> | 
| 12 | * @package phpHtmlLib | 
| 13 | * @subpackage examples | 
| 14 | * @version 2.0.0 | 
| 15 | * | 
| 16 | */ | 
| 17 |  | 
| 18 | /** | 
| 19 | * Include the phphtmllib libraries | 
| 20 | */ | 
| 21 | include_once("includes.inc"); | 
| 22 | include_once($phphtmllib."/widgets/svg/SVGDocumentClass.inc"); | 
| 23 |  | 
| 24 | //build the SVG Document object and set the | 
| 25 | //width=400, height=200 attributes on the 'svg' root | 
| 26 | //xml tag; | 
| 27 | $svgdoc = new SVGDocumentClass(400,200); | 
| 28 |  | 
| 29 | //build and add a css class | 
| 30 | $style = svg_style("text/css", "/*this is a test*/"); | 
| 31 | $style->add( ".mylink {\n color: #000000;\n". | 
| 32 | "text-decoration:underline;\n". | 
| 33 | "font-size:20;\n }"); | 
| 34 | $svgdoc->add( $style ); | 
| 35 |  | 
| 36 | //add a nice line around it all | 
| 37 | $rect = svg_rect(0,0,400,200,"none","black",1); | 
| 38 | $svgdoc->add( $rect ); | 
| 39 |  | 
| 40 | //build the circle | 
| 41 | $g = svg_g("stroke:black", "translate(190 80)"); | 
| 42 | $circle = svg_circle(0,0,50,"blue", "black", 2); | 
| 43 |  | 
| 44 | //add a neat mouseover to the circle | 
| 45 | $circle->set_tag_attribute("onmouseover", "evt.target.setAttribute('style', 'stroke:red; stroke-width:2');"); | 
| 46 | $circle->set_tag_attribute("onmouseout", "evt.target.setAttribute('style', '');"); | 
| 47 | $g->add( $circle ); | 
| 48 | //add it to the image | 
| 49 | $svgdoc->add( $g ); | 
| 50 |  | 
| 51 | $g2 = svg_g("stroke:black", "translate(100 80)"); | 
| 52 | $text = svg_text(0,80,NULL,NULL, "SVG built by"); | 
| 53 | $text->set_style("font-size:20;"); | 
| 54 | $text->set_collapse(); | 
| 55 | $linktext = svg_text(114,80,NULL,"mylink","phpHtmlLib"); | 
| 56 |  | 
| 57 | //$linktext->set_style("font-size:20;color:#FF0000;text-decoration:underline;"); | 
| 58 |  | 
| 59 | $link = svg_a("http://phphtmllib.newsblob.com", $linktext); | 
| 60 | $g2->add( $text, $link ); | 
| 61 | $svgdoc->add( $g2 ); | 
| 62 |  | 
| 63 | print $svgdoc->render(); | 
| 64 | ?> |