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.
17 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
18 * @license http://framework.zend.com/license/new-bsd New BSD License
19 * @version $Id: Cmyk.php 16978 2009-07-22 19:59:40Z alexander $
23 require_once 'Zend/Pdf/Color.php';
25 /** Zend_Pdf_Element_Numeric */
26 require_once 'Zend/Pdf/Element/Numeric.php';
29 * CMYK color implementation
33 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
34 * @license http://framework.zend.com/license/new-bsd New BSD License
36 class Zend_Pdf_Color_Cmyk
extends Zend_Pdf_Color
40 * 0.0 (zero concentration) - 1.0 (maximum concentration)
42 * @var Zend_Pdf_Element_Numeric
48 * 0.0 (zero concentration) - 1.0 (maximum concentration)
50 * @var Zend_Pdf_Element_Numeric
56 * 0.0 (zero concentration) - 1.0 (maximum concentration)
58 * @var Zend_Pdf_Element_Numeric
64 * 0.0 (zero concentration) - 1.0 (maximum concentration)
66 * @var Zend_Pdf_Element_Numeric
79 public function __construct($c, $m, $y, $k)
81 if ($c < 0) { $c = 0; }
82 if ($c > 1) { $c = 1; }
84 if ($m < 0) { $m = 0; }
85 if ($m > 1) { $m = 1; }
87 if ($y < 0) { $y = 0; }
88 if ($y > 1) { $y = 1; }
90 if ($k < 0) { $k = 0; }
91 if ($k > 1) { $k = 1; }
93 $this->_c
= new Zend_Pdf_Element_Numeric($c);
94 $this->_m
= new Zend_Pdf_Element_Numeric($m);
95 $this->_y
= new Zend_Pdf_Element_Numeric($y);
96 $this->_k
= new Zend_Pdf_Element_Numeric($k);
100 * Instructions, which can be directly inserted into content stream
102 * Color set instructions differ for stroking and nonstroking operations.
104 * @param boolean $stroking
107 public function instructions($stroking)
109 return $this->_c
->toString() . ' '
110 . $this->_m
->toString() . ' '
111 . $this->_y
->toString() . ' '
112 . $this->_k
->toString() . ($stroking?
" K\n" : " k\n");
116 * Get color components (color space dependent)
120 public function getComponents()
122 return array($this->_c
->value
, $this->_m
->value
, $this->_y
->value
, $this->_k
->value
);