/** * Test Alpha */ public function testAlpha() { $object = new Color(); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setARGB()); $this->assertEquals(100, $object->getAlpha()); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setARGB(Color::COLOR_BLUE)); $this->assertEquals(100, $object->getAlpha()); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setARGB('AA0000FF')); $this->assertEquals(66.67, $object->getAlpha()); }
/** * @param XMLWriter $objWriter * @param Color $color * @param int|null $alpha */ protected function writeColor(XMLWriter $objWriter, Color $color, $alpha = null) { if (is_null($alpha)) { $alpha = $color->getAlpha(); } // a:srgbClr $objWriter->startElement('a:srgbClr'); $objWriter->writeAttribute('val', $color->getRGB()); // a:alpha $objWriter->startElement('a:alpha'); $objWriter->writeAttribute('val', $alpha * 1000); $objWriter->endElement(); $objWriter->endElement(); }