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); } }