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/elements/csPath.class.php

    r318 r336  
    22/** 
    33 * SVG Path class 
    4  *  
     4 * 
    55 * @author     Nicolas Perriault <nperriault@gmail.com> 
    66 * @package    cleversvg 
     
    1010{ 
    1111 
    12   protected  
     12  protected 
    1313    $xml_node_name = 'path', 
    1414    $path_array    = array(); 
     
    1616  /** 
    1717   * Class constructor 
    18    *  
     18   * 
    1919   */ 
    20   public function __construct($path_data=array(), $attrs=array()) 
     20  public function __construct($path_data = array(), $attrs = array()) 
    2121  { 
    2222    $this->setPathDataArray($path_data); 
     
    2424    $this->attributes = array_merge($attrs, $this->attributes); 
    2525  } 
    26    
     26 
    2727  /** 
    2828   * Compute current path data array 
    29    *  
     29   * 
    3030   */ 
    3131  protected function computePath() 
     
    3636      if (isset($move[1])) 
    3737      { 
    38         $path_string .= sprintf('%s %s',  
     38        $path_string .= sprintf('%s %s', 
    3939                                $move[0], 
    4040                                implode(' ', $move[1])); 
     
    4747    $this->setPathDataString(trim($path_string)); 
    4848  } 
    49    
     49 
    5050  /** 
    5151   * Sets the path data from an array 
    52    *  
     52   * 
     53   * @param  array 
    5354   */ 
    5455  public function setPathDataArray($path_data_array) 
     
    5758    $this->computePath(); 
    5859  } 
    59    
     60 
    6061  /** 
    6162   * Sets the path string 
    62    *  
     63   * 
     64   * @param  string 
    6365   */ 
    6466  public function setPathDataString($path_data_string) 
     
    7173    $this->setAttribute('d', $path_data_string); 
    7274  } 
    73    
     75 
    7476  /** 
    7577   * Init path data array and ready to receive path building directions 
    76    *  
     78   * 
    7779   */ 
    7880  public function begin() 
     
    8082    $this->path_data_array = array(); 
    8183  } 
    82    
     84 
    8385  public function end() 
    8486  { 
     
    8688    $this->computePath(); 
    8789  } 
    88    
     90 
    8991  /** 
    9092   * Move to a point 
    91    *  
     93   * 
     94   * @param  int  $x 
     95   * @param  int  $y 
    9296   */ 
    9397  public function moveTo($x, $y) 
     
    9599    $this->path_data_array[] = array('M', array($x, $y)); 
    96100  } 
    97    
     101 
    98102  /** 
    99103   * Draws a line moving to a point 
    100    *  
     104   * 
     105   * @param  int  $x 
     106   * @param  int  $y 
    101107   */ 
    102108  public function lineTo($x, $y) 
     
    104110    $this->path_data_array[] = array('L', array($x, $y)); 
    105111  } 
    106    
     112 
    107113  /** 
    108114   * Draws a horizontal line moving to a point 
    109    *  
     115   * 
     116   * @param  int  $x 
    110117   */ 
    111118  public function hLineTo($x) 
     
    113120    $this->path_data_array[] = array('H', array($x)); 
    114121  } 
    115    
     122 
    116123  /** 
    117124   * Draws a vertical line moving to a point 
    118    *  
     125   * 
     126   * @param  int  $y 
    119127   */ 
    120128  public function vLineTo($y) 
     
    122130    $this->path_data_array[] = array('V', array($y)); 
    123131  } 
    124    
     132 
    125133  /** 
    126134   * Draws a curve moving to a point 
    127    *  
     135   * 
    128136   */ 
    129137  public function curveTo($x, $y, $x1, $y1, $x2, $y2) 
     
    131139    $this->path_data_array[] = array('C', array($x, $y, $x1, $y1, $x2, $y2)); 
    132140  } 
    133    
     141 
    134142  /** 
    135143   * Draws a smooth curve moving to a point 
    136    *  
     144   * 
    137145   */ 
    138146  public function smoothCurveTo($x, $y, $x2, $y2) 
     
    140148    $this->path_data_array[] = array('S', array($x, $y, $x2, $y2)); 
    141149  } 
    142    
     150 
    143151  /** 
    144152   * The x-axis coordinate of one corner of the rectangular region into which an 
    145153   * embedded 'svg' element is placed. 
    146    *  
     154   * 
     155   * @param  int 
    147156   */ 
    148157  public function setX($x) 
     
    150159    $this->setAttribute('x', $x); 
    151160  } 
    152    
     161 
    153162  /** 
    154163   * The y-axis coordinate of one corner of the rectangular region into which an 
    155164   * embedded 'svg' element is placed. 
    156    *  
     165   * 
     166   * @param  int 
    157167   */ 
    158168  public function setY($y) 
     
    160170    $this->setAttribute('y', $y); 
    161171  } 
    162    
    163    
     172 
     173 
    164174}