Changeset 309 for cleversvg

Show
Ignore:
Timestamp:
02/26/08 10:39:52 (4 years ago)
Author:
ndory
Message:

Quick Example with comments

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • cleversvg/cleversvg/quick_examples.php

    r308 r309  
    44 
    55//Instanciate a SVG document, specifying its width and height 
    6 $doc = new csDocument(550, 300, 'Un document SVG de test'); 
     6$doc = new csDocument(1000, 700, 'Un document SVG de test'); 
    77 
    8 //Then, you can define as many shapes objects as you want and add them to the document 
    9 $rect = new csRect(60, 60, 40, 40); 
    10 $rect->setFill('red'); 
    11 $rect->setStroke('yellow'); 
    12 $rect->setStrokeWidth('4'); 
     8$gradient = new csLinearGradient(0, 0, '100%', '100%'); 
     9$gradient->addStop('0%', 'yellow'); 
     10$gradient->addStop('100%', 'red'); 
     11$doc->addAsDefinition($gradient, 'myLinearGradient'); 
    1312 
    14 $doc->addElement($rect); 
     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); 
     28 
     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 
    1547 
    1648//Never forget to send image/svg+xml headers before outputing