Skip to content

Commit

Permalink
Merge pull request BachiLi#22 from Vrroom/master
Browse files Browse the repository at this point in the history
Parse named colors
  • Loading branch information
BachiLi authored May 13, 2021
2 parents fd38f71 + b4639e5 commit 465e1a7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pydiffvg/parse_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import warnings
import cssutils
import logging
import matplotlib.colors
cssutils.log.setLevel(logging.ERROR)

def remove_namespaces(s):
Expand Down Expand Up @@ -70,7 +71,11 @@ def parse_color(s, defs):
elif s == 'none':
return None
else:
warnings.warn('Unknown color command ' + s)
try :
rgba = matplotlib.colors.to_rgba(s)
color = torch.tensor(rgba)
except ValueError :
warnings.warn('Unknown color command ' + s)
return color

# https://github.com/mathandy/svgpathtools/blob/7ebc56a831357379ff22216bec07e2c12e8c5bc6/svgpathtools/parser.py
Expand Down

0 comments on commit 465e1a7

Please sign in to comment.