ManimCommunity / manim

A community-maintained Python framework for creating mathematical animations.
https://www.manim.community
MIT License
21.05k stars 1.53k forks source link

Adding new example to documentation of `MovingCamera` and `MovingCameraScene` #3098

Open MrDiver opened 1 year ago

MrDiver commented 1 year ago

I don't think we have a good example for how to use MovingCameraScene in the actual documentation for either MovingCamera or MovingCameraScene.

class Test(MovingCameraScene):
  def construct(self):
    def create_scene(number):
      frame = Rectangle(width=16,height=9)
      circ = Circle().shift(LEFT)
      text = Tex(f"This is Scene {str(number)}").next_to(circ, RIGHT)
      frame.add(circ,text)
      return frame

    group = VGroup(*(create_scene(i) for i in range(4))).arrange_in_grid(buff=4)
    self.add(group)
    self.camera.auto_zoom(group[0], animate=False)
    for scene in group:
      self.play(self.camera.auto_zoom(scene))
      self.wait()

    self.play(self.camera.auto_zoom(group, margin=2))

Here is a little example

https://user-images.githubusercontent.com/17803932/209752651-b93e91c0-e254-47e3-9300-473ca5e8e6fb.mp4

solomonsanderson commented 1 year ago

Would you like the documentation for the mentioned classes to be similar to that for moving_camera_scene which has plenty of examples? I would be happy to take on this task if so.

MrDiver commented 1 year ago

I actually missed that there is Documentation on the Module, it is sometimes unclear which parts are documented. The documentation should either be referenced in MovingCameraScene or some parts should be moved over there.

I think referencing on this page https://docs.manim.community/en/stable/reference/manim.camera.moving_camera.MovingCamera.html#manim.camera.moving_camera.MovingCamera should be good, to find the documentation

pranav-ravuri commented 1 year ago

Hi, is this issue still open, if so I would like to help.

MrDiver commented 1 year ago

Seems to still be open, you are free to change the docs if you want @pranav-ravuri i would just reference the moving_camera_scene in the docs mentioned above. They're already mentioned here https://docs.manim.community/en/stable/reference/manim.camera.moving_camera.html but i am not quite sure if many people walk over that, so expanding the other reference would be great.

pranav-ravuri commented 1 year ago

Okay, can you assign this task to me?

pranav-ravuri commented 1 year ago

Hi, @MrDiver sorry for the delay, I needed time to look into the source code a little bit to understand what is happening. So, my understanding is that there is camera_class attribute base Scene class which holds the camera class to be used. The default Scene class initializes Camera into the camera_class and this class does not allow any camera movement. On the other hand, MovingCameraScene initializes MovingCamera class instead of standard Camera class along with modifying the existing get_moving_mobjects method . This change allows us to render the movement of camera in a scene as the name suggests.

So, it does not seem like class MovingCamera in itself is not intended to be used as is but rather to be used by indirectly by importing the necessary Scene class like MovingCameraScene.

Finally the documentation of MovingCameraScene has been already linked in the documentation of moving_camera and MovingCamera as a "see also" info card. So, do you thing paraphrasing the my first paragraph and adding it to the documentation of MovingCamera would make it clear?

MrDiver commented 1 year ago

The problem is that MovingCameraScene does not really have documentation. Rather the module moving_camera_scene has the documentation. Just linking to the module too would help find the documentation a little bit more easily. moving_camera_scene has a lot of documentation which is not easily found by serching because people will most likely click on the classes and not on the modules.

grafik

Which is also not helped by the fact that you can't just search moving camera and find the documentation you want, because the first useful result is the MovingCameraScene which doesn't have such extensive documentation.

pranav-ravuri commented 1 year ago

Okayyy so, should I just link the documentation of moving_camera_scene (the module) documentation in the documentation of the MovingCameraScene (the class). It would appear in the see also info box (marked in red in the below image) next to the MovingCamera link which is already present.

image

I am thinking to add the new moving_camera_scene (the module) documentation as the first link and then the documentation of MovingCamera (which is already there) as the second link in the order.