File indexing completed on 2024-12-22 05:36:54
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Pdf 0017 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0018 * @license http://framework.zend.com/license/new-bsd New BSD License 0019 * @version $Id$ 0020 */ 0021 0022 /** Internally used classes */ 0023 // require_once 'Zend/Pdf/Element/Numeric.php'; 0024 0025 0026 /** Zend_Pdf_Color */ 0027 // require_once 'Zend/Pdf/Color.php'; 0028 0029 /** 0030 * CMYK color implementation 0031 * 0032 * @category Zend 0033 * @package Zend_Pdf 0034 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0035 * @license http://framework.zend.com/license/new-bsd New BSD License 0036 */ 0037 class Zend_Pdf_Color_Cmyk extends Zend_Pdf_Color 0038 { 0039 /** 0040 * Cyan level. 0041 * 0.0 (zero concentration) - 1.0 (maximum concentration) 0042 * 0043 * @var Zend_Pdf_Element_Numeric 0044 */ 0045 private $_c; 0046 0047 /** 0048 * Magenta level. 0049 * 0.0 (zero concentration) - 1.0 (maximum concentration) 0050 * 0051 * @var Zend_Pdf_Element_Numeric 0052 */ 0053 private $_m; 0054 0055 /** 0056 * Yellow level. 0057 * 0.0 (zero concentration) - 1.0 (maximum concentration) 0058 * 0059 * @var Zend_Pdf_Element_Numeric 0060 */ 0061 private $_y; 0062 0063 /** 0064 * Key (BlacK) level. 0065 * 0.0 (zero concentration) - 1.0 (maximum concentration) 0066 * 0067 * @var Zend_Pdf_Element_Numeric 0068 */ 0069 private $_k; 0070 0071 0072 /** 0073 * Object constructor 0074 * 0075 * @param float $c 0076 * @param float $m 0077 * @param float $y 0078 * @param float $k 0079 */ 0080 public function __construct($c, $m, $y, $k) 0081 { 0082 if ($c < 0) { $c = 0; } 0083 if ($c > 1) { $c = 1; } 0084 0085 if ($m < 0) { $m = 0; } 0086 if ($m > 1) { $m = 1; } 0087 0088 if ($y < 0) { $y = 0; } 0089 if ($y > 1) { $y = 1; } 0090 0091 if ($k < 0) { $k = 0; } 0092 if ($k > 1) { $k = 1; } 0093 0094 $this->_c = new Zend_Pdf_Element_Numeric($c); 0095 $this->_m = new Zend_Pdf_Element_Numeric($m); 0096 $this->_y = new Zend_Pdf_Element_Numeric($y); 0097 $this->_k = new Zend_Pdf_Element_Numeric($k); 0098 } 0099 0100 /** 0101 * Instructions, which can be directly inserted into content stream 0102 * to switch color. 0103 * Color set instructions differ for stroking and nonstroking operations. 0104 * 0105 * @param boolean $stroking 0106 * @return string 0107 */ 0108 public function instructions($stroking) 0109 { 0110 return $this->_c->toString() . ' ' 0111 . $this->_m->toString() . ' ' 0112 . $this->_y->toString() . ' ' 0113 . $this->_k->toString() . ($stroking? " K\n" : " k\n"); 0114 } 0115 0116 /** 0117 * Get color components (color space dependent) 0118 * 0119 * @return array 0120 */ 0121 public function getComponents() 0122 { 0123 return array($this->_c->value, $this->_m->value, $this->_y->value, $this->_k->value); 0124 } 0125 } 0126