/** * Sets the current color space and color * * @param string $fstype 'fill', 'stroke', or 'both' * @param string $colorspace 'rgb' or 'cymk' * @param float $c1 red or cyan value * @param float $c2 green or yellow value * @param float $c3 blue or magenta value * @param float $c4 key value ('cymk' only) * @return boolean TRUE on success or FALSE on failure. */ public function setcolor($fstype, $colorspace, $c1, $c2, $c3, $c4 = 0) { if (in_array($fstype, array(self::FILL_STYLE_STROCK, self::FILL_STYLE_FILL, self::FILL_STYLE_BOTH))) { $this->_errmsg = "Unknown fill type '{$fstype}'"; return false; } if (self::COLOR_SPACE_RGB) { $color = new Zend_Pdf_Color_Rgb($c1, $c2, $c3); } elseif (self::COLOR_SPACE_CMYK) { $color = new Zend_Pdf_Color_Cymk($c1, $c2, $c3, $c4); } else { $this->_errmsg = "Unknown color space '{$colorspace}'"; return false; } if (in_array($fstype, array(self::FILL_STYLE_FILL, self::FILL_STYLE_BOTH))) { $this->_page->setFillColor($color); } if (in_array($fstype, array(self::FILL_STYLE_FILL, self::FILL_STYLE_STROCK))) { $this->_page->setLineColor($color); } return true; }
/** * @param ZendPage $page * @param StrokeStyle $strokeStyle * @param float|null $opacity */ private function setLineStyle(ZendPage $page, StrokeStyle $strokeStyle, $opacity = null) { $page->setLineWidth($strokeStyle->getWidth()); $page->setLineColor($this->getZendColor($strokeStyle->getColor())); if ($opacity !== null) { $page->setAlpha($opacity * $strokeStyle->getOpacity()); } }