diff -r 000000000000 -r 4eba9c11703f web/Zend/Pdf/Resource/GraphicsState.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/Zend/Pdf/Resource/GraphicsState.php Mon Dec 13 18:29:26 2010 +0100 @@ -0,0 +1,109 @@ +Type = new Zend_Pdf_Element_Name('ExtGState'); + + $extGStateObject = $factory->newObject($gsDictionary); + } + + if ($extGStateObject->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) { + require_once 'Zend/Pdf/Exception.php'; + throw new Zend_Pdf_Exception('Graphics state PDF object must be a dictionary'); + } + + parent::__construct($gsDictionary); + } + + /** + * Set the transparancy + * + * $alpha == 0 - transparent + * $alpha == 1 - opaque + * + * Transparency modes, supported by PDF: + * Normal (default), Multiply, Screen, Overlay, Darken, Lighten, ColorDodge, ColorBurn, HardLight, + * SoftLight, Difference, Exclusion + * + * @param float $alpha + * @param string $mode + * @throws Zend_Pdf_Exception + * @return Zend_Pdf_Canvas_Interface + */ + public function setAlpha($alpha, $mode = 'Normal') + { + if (!in_array($mode, array('Normal', 'Multiply', 'Screen', 'Overlay', 'Darken', 'Lighten', 'ColorDodge', + 'ColorBurn', 'HardLight', 'SoftLight', 'Difference', 'Exclusion'))) { + require_once 'Zend/Pdf/Exception.php'; + throw new Zend_Pdf_Exception('Unsupported transparency mode.'); + } + if (!is_numeric($alpha) || $alpha < 0 || $alpha > 1) { + require_once 'Zend/Pdf/Exception.php'; + throw new Zend_Pdf_Exception('Alpha value must be numeric between 0 (transparent) and 1 (opaque).'); + } + + $this->_resource->BM = new Zend_Pdf_Element_Name($mode); + $this->_resource->CA = new Zend_Pdf_Element_Numeric($alpha); + $this->_resource->ca = new Zend_Pdf_Element_Numeric($alpha); + } + + + /** @todo add other Graphics State features support */ +} +