13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Barcode |
16 * @package Zend_Barcode |
17 * @subpackage Renderer |
17 * @subpackage Renderer |
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
20 * @version $Id: Image.php 20366 2010-01-18 03:56:52Z ralph $ |
20 * @version $Id: Image.php 20366 2010-01-18 03:56:52Z ralph $ |
21 */ |
21 */ |
22 |
22 |
23 /** @see Zend_Barcode_Renderer_RendererAbstract*/ |
23 /** @see Zend_Barcode_Renderer_RendererAbstract*/ |
26 /** |
26 /** |
27 * Class for rendering the barcode as svg |
27 * Class for rendering the barcode as svg |
28 * |
28 * |
29 * @category Zend |
29 * @category Zend |
30 * @package Zend_Barcode |
30 * @package Zend_Barcode |
31 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
31 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
32 * @license http://framework.zend.com/license/new-bsd New BSD License |
32 * @license http://framework.zend.com/license/new-bsd New BSD License |
33 */ |
33 */ |
34 class Zend_Barcode_Renderer_Svg extends Zend_Barcode_Renderer_RendererAbstract |
34 class Zend_Barcode_Renderer_Svg extends Zend_Barcode_Renderer_RendererAbstract |
35 { |
35 { |
36 |
36 |
58 */ |
58 */ |
59 protected $_userWidth = 0; |
59 protected $_userWidth = 0; |
60 |
60 |
61 /** |
61 /** |
62 * Set height of the result image |
62 * Set height of the result image |
|
63 * |
63 * @param null|integer $value |
64 * @param null|integer $value |
64 * @return Zend_Image_Barcode_Abstract |
65 * @return Zend_Image_Barcode_Abstract |
65 * @throw Zend_Image_Barcode_Exception |
66 * @throws Zend_Barcode_Renderer_Exception |
66 */ |
67 */ |
67 public function setHeight($value) |
68 public function setHeight($value) |
68 { |
69 { |
69 if (!is_numeric($value) || intval($value) < 0) { |
70 if (!is_numeric($value) || intval($value) < 0) { |
70 require_once 'Zend/Barcode/Renderer/Exception.php'; |
71 require_once 'Zend/Barcode/Renderer/Exception.php'; |
115 } |
117 } |
116 |
118 |
117 /** |
119 /** |
118 * Set an image resource to draw the barcode inside |
120 * Set an image resource to draw the barcode inside |
119 * |
121 * |
120 * @param DOMDocument $value |
122 * @param $svg |
121 * @return Zend_Barcode_Renderer |
123 * @return Zend_Barcode_Renderer |
122 * @throw Zend_Barcode_Renderer_Exception |
124 * @throws Zend_Barcode_Renderer_Exception |
123 */ |
125 */ |
124 public function setResource($svg) |
126 public function setResource($svg) |
125 { |
127 { |
126 if (!$svg instanceof DOMDocument) { |
128 if (!$svg instanceof DOMDocument) { |
127 require_once 'Zend/Barcode/Renderer/Exception.php'; |
129 require_once 'Zend/Barcode/Renderer/Exception.php'; |
339 } |
342 } |
340 |
343 |
341 /** |
344 /** |
342 * Draw a polygon in the svg resource |
345 * Draw a polygon in the svg resource |
343 * |
346 * |
344 * @param string $text |
347 * @param string $text |
345 * @param float $size |
348 * @param float $size |
346 * @param array $position |
349 * @param array $position |
347 * @param string $font |
350 * @param string $font |
348 * @param integer $color |
351 * @param integer $color |
349 * @param string $alignment |
352 * @param string $alignment |
350 * @param float $orientation |
353 * @param float|int $orientation |
351 */ |
354 */ |
352 protected function _drawText($text, $size, $position, $font, $color, $alignment = 'center', $orientation = 0) |
355 protected function _drawText($text, $size, $position, $font, $color, $alignment = 'center', $orientation = 0) |
353 { |
356 { |
354 $color = 'rgb(' . implode(', ', array(($color & 0xFF0000) >> 16, |
357 $color = 'rgb(' . implode(', ', array(($color & 0xFF0000) >> 16, |
355 ($color & 0x00FF00) >> 8, |
358 ($color & 0x00FF00) >> 8, |