svg can handle ellipse

This commit is contained in:
mirefek
2018-01-28 14:55:17 +01:00
parent 5718db026e
commit fd1f92b705

View File

@ -76,6 +76,8 @@ class SVGMobject(VMobject):
result.append(self.rect_to_mobject(element))
elif element.tagName == 'circle':
result.append(self.circle_to_mobject(element))
elif element.tagName == 'ellipse':
result.append(self.ellipse_to_mobject(element))
elif element.tagName in ['polygon', 'polyline']:
result.append(self.polygon_to_mobject(element))
else:
@ -122,6 +124,15 @@ class SVGMobject(VMobject):
]
return Circle(radius = r).shift(x*RIGHT+y*DOWN)
def ellipse_to_mobject(self, circle_element):
x, y, rx, ry = [
float(circle_element.getAttribute(key))
if circle_element.hasAttribute(key)
else 0.0
for key in "cx", "cy", "rx", "ry"
]
return Circle().scale(rx*RIGHT + ry*UP).shift(x*RIGHT+y*DOWN)
def rect_to_mobject(self, rect_element):
if rect_element.hasAttribute("fill"):
if Color(str(rect_element.getAttribute("fill"))) == Color(WHITE):