/** * Test get/set RGB */ public function testSetGetRGB() { $object = new Color(); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setRGB()); $this->assertEquals('000000', $object->getRGB()); $this->assertEquals('FF000000', $object->getARGB()); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setRGB('')); $this->assertEquals('000000', $object->getRGB()); $this->assertEquals('FF000000', $object->getARGB()); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setRGB('555')); $this->assertEquals('555', $object->getRGB()); $this->assertEquals('FF555', $object->getARGB()); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setRGB('6666')); $this->assertEquals('FF6666', $object->getRGB()); $this->assertEquals('FF6666', $object->getARGB()); }
/** * @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(); }