diff -r 000000000000 -r 4eba9c11703f web/Zend/Pdf/Color/Rgb.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/Zend/Pdf/Color/Rgb.php Mon Dec 13 18:29:26 2010 +0100 @@ -0,0 +1,114 @@ + 1) { $r = 1; } + + if ($g < 0) { $g = 0; } + if ($g > 1) { $g = 1; } + + if ($b < 0) { $b = 0; } + if ($b > 1) { $b = 1; } + + $this->_r = new Zend_Pdf_Element_Numeric($r); + $this->_g = new Zend_Pdf_Element_Numeric($g); + $this->_b = new Zend_Pdf_Element_Numeric($b); + } + + /** + * Instructions, which can be directly inserted into content stream + * to switch color. + * Color set instructions differ for stroking and nonstroking operations. + * + * @param boolean $stroking + * @return string + */ + public function instructions($stroking) + { + return $this->_r->toString() . ' ' + . $this->_g->toString() . ' ' + . $this->_b->toString() . ($stroking? " RG\n" : " rg\n"); + } + + /** + * Get color components (color space dependent) + * + * @return array + */ + public function getComponents() + { + return array($this->_r->value, $this->_g->value, $this->_b->value); + } +} +