Skip to content

Commit e4b2dce

Browse files
committed
Add support for transparent color keyword
fixes #103
1 parent 4350dce commit e4b2dce

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/Svg/Style.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ static function parseColor($color)
219219
return "currentcolor";
220220
}
221221

222+
if ($color === "transparent") {
223+
return [0,0,0,0];
224+
}
225+
222226
// SVG color name
223227
if (isset(self::$colorNames[$color])) {
224228
return self::parseHexColor(self::$colorNames[$color]);

tests/Svg/StyleTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function test_parseColor()
1818
{
1919
$this->assertEquals("none", Style::parseColor("none"));
2020
$this->assertEquals("currentcolor", Style::parseColor("currentcolor"));
21+
$this->assertEquals(array(0, 0, 0, 0), Style::parseColor("transparent"));
2122
$this->assertEquals(array(255, 0, 0, 1), Style::parseColor("RED"));
2223
$this->assertEquals(array(0, 0, 255, 1), Style::parseColor("blue"));
2324
$this->assertEquals(array(0, 0, 0, 1), Style::parseColor("black"));

0 commit comments

Comments
 (0)