BachiLi / diffvg

Differentiable Vector Graphics Rasterization
https://people.csail.mit.edu/tzumao/diffvg/
Apache License 2.0
923 stars 155 forks source link

Parse named colors #22

Closed Vrroom closed 3 years ago

Vrroom commented 3 years ago

The svg parser will incorrectly parse colors such as 'green' and 'red' to black. This commit fixes that by using the code already written in matplotlib.colors module. For example, on an SVG like:

<svg width="100" height="100">
   <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
</svg> 

The output of the master will be a black circle:

incorrect

With this commit, the correct image will be rendered:

correct

BachiLi commented 3 years ago

thanks!