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

Added Auto Zoom functionality to scene.py #1865

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HadiSDev
Copy link

@HadiSDev HadiSDev commented Sep 14, 2022

Motivation

I wanted to add the Auto Zoom functionality back to manim as it is very useful :) And saves a lot of time

Credits to @benjaminolsen12 for doing the conversion

Proposed changes

  • scene.py
    I Basically copied the old implementation

Test

Code:

class SquareToCircle(Scene):
    def construct(self):
        circle = Circle()
        circle.set_fill(BLUE, opacity=0.5)
        circle.set_stroke(BLUE_E, width=4)
        square = Square()

        self.play(ShowCreation(square))
        self.wait()
        self.play(ReplacementTransform(square, circle))
        self.wait()
        square = Square().move_to(LEFT)
        self.play(ShowCreation(square))
        self.play(self.auto_zoom([square]))

Result:
image

@3b1b
Copy link
Owner

3b1b commented Nov 3, 2022

Thanks for contributing! A few comments:

  • I think a lot of the implementation computes what you would get with the simpler line Group(*mobjects).get_bounding_box()
  • I wonder if it would be better to just make this a method of CameraFrame, so that one might call self.play(frame.animate.zoom_to(square)), or something like that.

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.

None yet

2 participants