mirror of
https://github.com/3b1b/manim.git
synced 2025-07-30 21:44:19 +08:00
svg can handle ellipse
This commit is contained in:
@ -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):
|
||||
|
Reference in New Issue
Block a user