Skip to content

Commit

Permalink
Add support for transparent color keyword
Browse files Browse the repository at this point in the history
fixes #103
  • Loading branch information
bsweeney committed Feb 23, 2024
1 parent 4350dce commit e4b2dce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Svg/Style.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ static function parseColor($color)
return "currentcolor";
}

if ($color === "transparent") {
return [0,0,0,0];
}

// SVG color name
if (isset(self::$colorNames[$color])) {
return self::parseHexColor(self::$colorNames[$color]);
Expand Down
1 change: 1 addition & 0 deletions tests/Svg/StyleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public function test_parseColor()
{
$this->assertEquals("none", Style::parseColor("none"));
$this->assertEquals("currentcolor", Style::parseColor("currentcolor"));
$this->assertEquals(array(0, 0, 0, 0), Style::parseColor("transparent"));
$this->assertEquals(array(255, 0, 0, 1), Style::parseColor("RED"));
$this->assertEquals(array(0, 0, 255, 1), Style::parseColor("blue"));
$this->assertEquals(array(0, 0, 0, 1), Style::parseColor("black"));
Expand Down

0 comments on commit e4b2dce

Please sign in to comment.