Show
Ignore:
Timestamp:
03/07/08 08:33:04 (4 years ago)
Author:
nperriault
Message:

Clever Svg:

  • refs #40: more elements tests
  • Removed depth management, as svg handle it natively

Warning: breaks BC from 0.5.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • cleversvg/trunk/quick_examples.php

    r323 r336  
    11<?php 
    2 //First, require the library call script 
    32require_once('cleversvg.php'); 
    4  
    5 //Instanciate a SVG document, specifying its width and height 
    6 $doc = new csDocument(1000, 700, 'Un document SVG de test'); 
     3$doc = new csDocument(550, 400, 'SVG test document'); 
    74 
    85$gradient = new csLinearGradient(0, 0, '100%', '100%'); 
    96$gradient->addStop('0%', 'yellow'); 
    107$gradient->addStop('100%', 'red'); 
    11 $doc->addAsDefinition($gradient, 'myLinearGradient'); 
     8$doc->addAsDefinition($gradient, 'gradient'); 
    129 
    13 $polygon = new csPolygon(); 
    14 $polygon->setPointsArray(array(array(350,75), 
    15                             array(379,161), 
    16                             array(469,161), 
    17                             array(397,215), 
    18                             array(423,301), 
    19                             array(350,250), 
    20                             array(277,301), 
    21                             array(303,215), 
    22                             array(231,161), 
    23                             array(321,161))); 
    24 $polygon->setStroke('blue'); 
    25 $polygon->setFill('url(#myLinearGradient)'); 
    26 $polygon->setStrokeWidth(3); 
    27 $doc->addElement($polygon); 
     10$star = new csPolygon(); 
     11$star->setPointsArray(array(array(350,75),  array(379,161), 
     12                            array(469,161), array(397,215), 
     13                            array(423,301), array(350,250), 
     14                            array(277,301), array(303,215), 
     15                            array(231,161), array(321,161))); 
     16$star->setStroke('blue'); 
     17$star->setFill('url(#gradient)'); 
     18$star->setStrokeWidth(4); 
     19$linkedstar = new csLink(); 
     20$linkedstar->setHref('http://prendreuncafe.com/blog/'); 
     21$linkedstar->addElement($star); 
     22$doc->addElement($linkedstar); 
    2823 
    29  
    30  
    31 $gradient = new csRadialGradient('50%', '50%', '30%', '30%', '50%'); 
    32 $gradient->addStop('15%', 'lightblue', 0.5); 
    33 $gradient->addStop('100%', 'darkblue'); 
    34 $doc->addAsDefinition($gradient, 'myRadialGradient'); 
    35  
    36 $path = new csPath(); 
    37 $path->begin(); 
    38 $path->moveTo(600, 25); 
    39 $path->lineTo(120, 25); 
    40 $path->lineTo(350, 500); 
    41 $path->end(); 
    42 $path->setStroke('orange'); 
    43 $path->setStrokeWidth(3); 
    44 $path->setFill('url(#myRadialGradient)'); 
    45 $doc->addElement($path); 
    46  
    47  
    48 //Never forget to send image/svg+xml headers before outputing 
    4924header("Content-type: image/svg+xml"); 
    50  
    51 //When you're done, render the document as a standalone one 
    52 echo $doc->toXML(true); 
    53  
    54 //Or an embedded one : 
    55 //echo $doc->toXML(true); 
    56 ?> 
     25echo $doc->toXML();