Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the elliptical arc command for SVGMobject #1598

Merged
merged 1 commit into from
Aug 9, 2021
Merged

Support the elliptical arc command for SVGMobject #1598

merged 1 commit into from
Aug 9, 2021

Conversation

YishiMichael
Copy link
Contributor

Motivation

Support the elliptical arc command for SVGMobject. Now all the commands of svg path can be implemented.

Proposed changes

This is reached through approximating elliptical arcs with quadratic bezier curves, which is almost the same way to form a circular arc in Arc class. The key is to figure out the center of the ellipse, requiring us to solve simultaneous equations. I've built a function add_elliptical_arc_to(self, rx, ry, x_axis_rotation, large_arc_flag, sweep_flag, point), inside which a bunch of functions were defined just to do those calculations. I guess it might be better to transfer them into the file utils\space_ops.py, but I daren't make too much changes across files in my first pull request.
Detailed annotations are left in the code. I deduced all those stuff by hand today .(:з」∠).

Test

Code:

class Test(Scene):
    def construct(self):
        self.add(SVGMobject("test"))
<svg width="320px" height="320px" version="1.1" xmlns="http://www.w3.org/2000/svg">
  <path d="M10 315
           L 110 215
           A 30 50 0 0 1 162.55 162.45
           L 172.55 152.45
           A 30 50 -45 0 1 215.1 109.9
           L 315 10"/>
</svg>

Result:
result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants