|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
7 * This source file is subject to the new BSD license that is bundled |
|
8 * with this package in the file LICENSE.txt. |
|
9 * It is also available through the world-wide-web at this URL: |
|
10 * http://framework.zend.com/license/new-bsd |
|
11 * If you did not receive a copy of the license and are unable to |
|
12 * obtain it through the world-wide-web, please send an email |
|
13 * to license@zend.com so we can send you a copy immediately. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_Pdf |
|
17 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
19 * @version $Id: GrayScale.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
20 */ |
|
21 |
|
22 |
|
23 /** Internally used classes */ |
|
24 require_once 'Zend/Pdf/Element/Numeric.php'; |
|
25 |
|
26 |
|
27 /** Zend_Pdf_Color */ |
|
28 require_once 'Zend/Pdf/Color.php'; |
|
29 |
|
30 /** |
|
31 * GrayScale color implementation |
|
32 * |
|
33 * @category Zend |
|
34 * @package Zend_Pdf |
|
35 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
36 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
37 */ |
|
38 class Zend_Pdf_Color_GrayScale extends Zend_Pdf_Color |
|
39 { |
|
40 /** |
|
41 * GrayLevel. |
|
42 * 0.0 (black) - 1.0 (white) |
|
43 * |
|
44 * @var Zend_Pdf_Element_Numeric |
|
45 */ |
|
46 private $_grayLevel; |
|
47 |
|
48 /** |
|
49 * Object constructor |
|
50 * |
|
51 * @param float $grayLevel |
|
52 */ |
|
53 public function __construct($grayLevel) |
|
54 { |
|
55 if ($grayLevel < 0) { $grayLevel = 0; } |
|
56 if ($grayLevel > 1) { $grayLevel = 1; } |
|
57 |
|
58 $this->_grayLevel = new Zend_Pdf_Element_Numeric($grayLevel); |
|
59 } |
|
60 |
|
61 /** |
|
62 * Instructions, which can be directly inserted into content stream |
|
63 * to switch color. |
|
64 * Color set instructions differ for stroking and nonstroking operations. |
|
65 * |
|
66 * @param boolean $stroking |
|
67 * @return string |
|
68 */ |
|
69 public function instructions($stroking) |
|
70 { |
|
71 return $this->_grayLevel->toString() . ($stroking? " G\n" : " g\n"); |
|
72 } |
|
73 |
|
74 /** |
|
75 * Get color components (color space dependent) |
|
76 * |
|
77 * @return array |
|
78 */ |
|
79 public function getComponents() |
|
80 { |
|
81 return array($this->_grayLevel->value); |
|
82 } |
|
83 } |
|
84 |