From 67fb9e264c8eb72a908cad073abd2a67e0edd110 Mon Sep 17 00:00:00 2001 From: Joel Day Date: Tue, 15 Mar 2016 15:18:24 +0000 Subject: [PATCH 1/2] do it on the develop branch --- src/PhpPresentation/Style/Color.php | 15 ++++++++++ .../AbstractDecoratorWriter.php | 30 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/PhpPresentation/Style/Color.php b/src/PhpPresentation/Style/Color.php index d962fee08..407a39fa9 100644 --- a/src/PhpPresentation/Style/Color.php +++ b/src/PhpPresentation/Style/Color.php @@ -87,6 +87,21 @@ public function setARGB($pValue = self::COLOR_BLACK) return $this; } + /** + * Get the alpha % of the ARGB + * Will return 100 if no ARGB + * @return integer + */ + public function getAlpha() + { + $alpha = 100; + if (strlen($this->argb) >= 6) { + $dec = hexdec(substr($this->argb,0,2)); + $alpha = number_format(( $dec/255 ) * 100, 2); + } + return $alpha; + } + /** * Get RGB * diff --git a/src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php b/src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php index d8a126442..b0d3a6ae1 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php @@ -155,6 +155,12 @@ protected function writeSolidFill(XMLWriter $objWriter, Fill $pFill) // srgbClr $objWriter->startElement('a:srgbClr'); $objWriter->writeAttribute('val', $pFill->getStartColor()->getRGB()); + + // a:alpha + $objWriter->startElement('a:alpha'); + $objWriter->writeAttribute('val', $pFill->getStartColor()->getAlpha() * 1000); + $objWriter->endElement(); + $objWriter->endElement(); $objWriter->endElement(); @@ -181,6 +187,12 @@ protected function writeGradientFill(XMLWriter $objWriter, Fill $pFill) // srgbClr $objWriter->startElement('a:srgbClr'); $objWriter->writeAttribute('val', $pFill->getStartColor()->getRGB()); + + // a:alpha + $objWriter->startElement('a:alpha'); + $objWriter->writeAttribute('val', $pFill->getStartColor()->getAlpha() * 1000); + $objWriter->endElement(); + $objWriter->endElement(); $objWriter->endElement(); @@ -192,6 +204,12 @@ protected function writeGradientFill(XMLWriter $objWriter, Fill $pFill) // srgbClr $objWriter->startElement('a:srgbClr'); $objWriter->writeAttribute('val', $pFill->getEndColor()->getRGB()); + + // a:alpha + $objWriter->startElement('a:alpha'); + $objWriter->writeAttribute('val', $pFill->getEndColor()->getAlpha() * 1000); + $objWriter->endElement(); + $objWriter->endElement(); $objWriter->endElement(); @@ -225,6 +243,12 @@ protected function writePatternFill(XMLWriter $objWriter, Fill $pFill) // srgbClr $objWriter->startElement('a:srgbClr'); $objWriter->writeAttribute('val', $pFill->getStartColor()->getRGB()); + + // a:alpha + $objWriter->startElement('a:alpha'); + $objWriter->writeAttribute('val', $pFill->getStartColor()->getAlpha() * 1000); + $objWriter->endElement(); + $objWriter->endElement(); $objWriter->endElement(); @@ -235,6 +259,12 @@ protected function writePatternFill(XMLWriter $objWriter, Fill $pFill) // srgbClr $objWriter->startElement('a:srgbClr'); $objWriter->writeAttribute('val', $pFill->getEndColor()->getRGB()); + + // a:alpha + $objWriter->startElement('a:alpha'); + $objWriter->writeAttribute('val', $pFill->getEndColor()->getAlpha() * 1000); + $objWriter->endElement(); + $objWriter->endElement(); $objWriter->endElement(); From 7a84e3bf43e1b9d56619afca15d70de338c2d4dc Mon Sep 17 00:00:00 2001 From: Joel Day Date: Tue, 15 Mar 2016 16:25:04 +0000 Subject: [PATCH 2/2] fix PSR2 --- src/PhpPresentation/Style/Color.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpPresentation/Style/Color.php b/src/PhpPresentation/Style/Color.php index 407a39fa9..c8c53706a 100644 --- a/src/PhpPresentation/Style/Color.php +++ b/src/PhpPresentation/Style/Color.php @@ -96,7 +96,7 @@ public function getAlpha() { $alpha = 100; if (strlen($this->argb) >= 6) { - $dec = hexdec(substr($this->argb,0,2)); + $dec = hexdec(substr($this->argb, 0, 2)); $alpha = number_format(( $dec/255 ) * 100, 2); } return $alpha;