public function testFactoryColorFromIntegerArray() { $color = ezcGraphColor::fromIntegerArray(array(5, 23, 42)); $this->assertEquals($color->red, 5, 'Wrong red color value'); $this->assertEquals($color->green, 23, 'Wrong green color value'); $this->assertEquals($color->blue, 42, 'Wrong blue color value'); $this->assertEquals($color->alpha, 0, 'Wrong alpha color value'); }
/** * Tries to detect type of color color definition and returns an * ezcGraphColor object * * @param mixed $color Some kind of color definition * @return ezcGraphColor */ public static function create($color) { if ($color instanceof ezcGraphColor) { return $color; } elseif (is_string($color)) { return ezcGraphColor::fromHex($color); } elseif (is_array($color)) { $testElement = reset($color); if (is_int($testElement)) { return ezcGraphColor::fromIntegerArray($color); } else { return ezcGraphColor::fromFloatArray($color); } } else { throw new ezcGraphUnknownColorDefinitionException($color); } }