Changeset 336 for cleversvg/trunk/elements/csPath.class.php
- Timestamp:
- 03/07/08 08:33:04 (4 years ago)
- Files:
-
- 1 modified
-
cleversvg/trunk/elements/csPath.class.php (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cleversvg/trunk/elements/csPath.class.php
r318 r336 2 2 /** 3 3 * SVG Path class 4 * 4 * 5 5 * @author Nicolas Perriault <nperriault@gmail.com> 6 6 * @package cleversvg … … 10 10 { 11 11 12 protected 12 protected 13 13 $xml_node_name = 'path', 14 14 $path_array = array(); … … 16 16 /** 17 17 * Class constructor 18 * 18 * 19 19 */ 20 public function __construct($path_data =array(), $attrs=array())20 public function __construct($path_data = array(), $attrs = array()) 21 21 { 22 22 $this->setPathDataArray($path_data); … … 24 24 $this->attributes = array_merge($attrs, $this->attributes); 25 25 } 26 26 27 27 /** 28 28 * Compute current path data array 29 * 29 * 30 30 */ 31 31 protected function computePath() … … 36 36 if (isset($move[1])) 37 37 { 38 $path_string .= sprintf('%s %s', 38 $path_string .= sprintf('%s %s', 39 39 $move[0], 40 40 implode(' ', $move[1])); … … 47 47 $this->setPathDataString(trim($path_string)); 48 48 } 49 49 50 50 /** 51 51 * Sets the path data from an array 52 * 52 * 53 * @param array 53 54 */ 54 55 public function setPathDataArray($path_data_array) … … 57 58 $this->computePath(); 58 59 } 59 60 60 61 /** 61 62 * Sets the path string 62 * 63 * 64 * @param string 63 65 */ 64 66 public function setPathDataString($path_data_string) … … 71 73 $this->setAttribute('d', $path_data_string); 72 74 } 73 75 74 76 /** 75 77 * Init path data array and ready to receive path building directions 76 * 78 * 77 79 */ 78 80 public function begin() … … 80 82 $this->path_data_array = array(); 81 83 } 82 84 83 85 public function end() 84 86 { … … 86 88 $this->computePath(); 87 89 } 88 90 89 91 /** 90 92 * Move to a point 91 * 93 * 94 * @param int $x 95 * @param int $y 92 96 */ 93 97 public function moveTo($x, $y) … … 95 99 $this->path_data_array[] = array('M', array($x, $y)); 96 100 } 97 101 98 102 /** 99 103 * Draws a line moving to a point 100 * 104 * 105 * @param int $x 106 * @param int $y 101 107 */ 102 108 public function lineTo($x, $y) … … 104 110 $this->path_data_array[] = array('L', array($x, $y)); 105 111 } 106 112 107 113 /** 108 114 * Draws a horizontal line moving to a point 109 * 115 * 116 * @param int $x 110 117 */ 111 118 public function hLineTo($x) … … 113 120 $this->path_data_array[] = array('H', array($x)); 114 121 } 115 122 116 123 /** 117 124 * Draws a vertical line moving to a point 118 * 125 * 126 * @param int $y 119 127 */ 120 128 public function vLineTo($y) … … 122 130 $this->path_data_array[] = array('V', array($y)); 123 131 } 124 132 125 133 /** 126 134 * Draws a curve moving to a point 127 * 135 * 128 136 */ 129 137 public function curveTo($x, $y, $x1, $y1, $x2, $y2) … … 131 139 $this->path_data_array[] = array('C', array($x, $y, $x1, $y1, $x2, $y2)); 132 140 } 133 141 134 142 /** 135 143 * Draws a smooth curve moving to a point 136 * 144 * 137 145 */ 138 146 public function smoothCurveTo($x, $y, $x2, $y2) … … 140 148 $this->path_data_array[] = array('S', array($x, $y, $x2, $y2)); 141 149 } 142 150 143 151 /** 144 152 * The x-axis coordinate of one corner of the rectangular region into which an 145 153 * embedded 'svg' element is placed. 146 * 154 * 155 * @param int 147 156 */ 148 157 public function setX($x) … … 150 159 $this->setAttribute('x', $x); 151 160 } 152 161 153 162 /** 154 163 * The y-axis coordinate of one corner of the rectangular region into which an 155 164 * embedded 'svg' element is placed. 156 * 165 * 166 * @param int 157 167 */ 158 168 public function setY($y) … … 160 170 $this->setAttribute('y', $y); 161 171 } 162 163 172 173 164 174 }
