Skip to content

Commit e8a3996

Browse files
authored
Merge pull request #35 from Aathish04/docs
Added DocStrings for Camera type objects, and updated DocStrings for Scene type objects.
2 parents e7ec719 + 92ac8ea commit e8a3996

File tree

12 files changed

+1350
-425
lines changed

12 files changed

+1350
-425
lines changed

manimlib/camera/camera.py

Lines changed: 626 additions & 7 deletions
Large diffs are not rendered by default.

manimlib/camera/mapping_camera.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111

1212
class MappingCamera(Camera):
13+
"""Camera object that allows mapping
14+
between objects.
15+
"""
1316
CONFIG = {
1417
"mapping_func": lambda p: p,
1518
"min_num_curves": 50,

manimlib/camera/moving_camera.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,65 @@ def __init__(self, frame=None, **kwargs):
4848

4949
# TODO, make these work for a rotated frame
5050
def get_frame_height(self):
51+
"""Returns the height of the frame.
52+
53+
Returns
54+
-------
55+
float
56+
The height of the frame.
57+
"""
5158
return self.frame.get_height()
5259

5360
def get_frame_width(self):
61+
"""Returns the width of the frame
62+
63+
Returns
64+
-------
65+
float
66+
The width of the frame.
67+
"""
5468
return self.frame.get_width()
5569

5670
def get_frame_center(self):
71+
"""Returns the centerpoint of the frame in cartesian coordinates.
72+
73+
Returns
74+
-------
75+
np.array
76+
The cartesian coordinates of the center of the frame.
77+
"""
5778
return self.frame.get_center()
5879

5980
def set_frame_height(self, frame_height):
81+
"""Sets the height of the frame in MUnits.
82+
83+
Parameters
84+
----------
85+
frame_height : int, float
86+
The new frame_height.
87+
"""
6088
self.frame.stretch_to_fit_height(frame_height)
6189

6290
def set_frame_width(self, frame_width):
91+
"""Sets the width of the frame in MUnits.
92+
93+
Parameters
94+
----------
95+
frame_width : int, float
96+
The new frame_width.
97+
"""
6398
self.frame.stretch_to_fit_width(frame_width)
6499

65100
def set_frame_center(self, frame_center):
101+
"""Sets the centerpoint of the frame.
102+
103+
Parameters
104+
----------
105+
frame_center : np.array, list, tuple, Mobject
106+
The point to which the frame must be moved.
107+
If is of type mobject, the frame will be moved to
108+
the center of that mobject.
109+
"""
66110
self.frame.move_to(frame_center)
67111

68112
def capture_mobjects(self, mobjects, **kwargs):
@@ -74,9 +118,19 @@ def capture_mobjects(self, mobjects, **kwargs):
74118
# context used for updating should be regenerated
75119
# at each frame. So no caching.
76120
def get_cached_cairo_context(self, pixel_array):
121+
"""
122+
Since the frame can be moving around, the cairo
123+
context used for updating should be regenerated
124+
at each frame. So no caching.
125+
"""
77126
return None
78127

79128
def cache_cairo_context(self, pixel_array, ctx):
129+
"""
130+
Since the frame can be moving around, the cairo
131+
context used for updating should be regenerated
132+
at each frame. So no caching.
133+
"""
80134
pass
81135

82136
# def reset_frame_center(self):
@@ -94,5 +148,9 @@ def get_mobjects_indicating_movement(self):
94148
"""
95149
Returns all mobjets whose movement implies that the camera
96150
should think of all other mobjects on the screen as moving
151+
152+
Returns
153+
-------
154+
list
97155
"""
98156
return [self.frame]

manimlib/camera/multi_camera.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,36 @@
33

44

55
class MultiCamera(MovingCamera):
6+
"""Camera Object that allows for multiple perspectives.
7+
"""
68
CONFIG = {
79
"allow_cameras_to_capture_their_own_display": False,
810
}
911

1012
def __init__(self, *image_mobjects_from_cameras, **kwargs):
13+
"""Initalises the MultiCamera
14+
15+
Parameters:
16+
-----------
17+
*image_mobjects_from_cameras : ImageMobject
18+
19+
**kwargs
20+
Any valid keyword arguments of MovingCamera.
21+
"""
1122
self.image_mobjects_from_cameras = []
1223
for imfc in image_mobjects_from_cameras:
1324
self.add_image_mobject_from_camera(imfc)
1425
MovingCamera.__init__(self, **kwargs)
1526

1627
def add_image_mobject_from_camera(self, image_mobject_from_camera):
28+
"""Adds an ImageMobject that's been obtained from the camera
29+
into the list `self.image_mobject_from_cameras`
30+
31+
Parameters
32+
----------
33+
image_mobject_from_camera : ImageMobject
34+
The ImageMobject to add to self.image_mobject_from_cameras
35+
"""
1736
# A silly method to have right now, but maybe there are things
1837
# we want to guarantee about any imfc's added later.
1938
imfc = image_mobject_from_camera
@@ -34,6 +53,13 @@ def update_sub_cameras(self):
3453
)
3554

3655
def reset(self):
56+
"""Resets the MultiCamera.
57+
58+
Returns
59+
-------
60+
MultiCamera
61+
The reset MultiCamera
62+
"""
3763
for imfc in self.image_mobjects_from_cameras:
3864
imfc.camera.reset()
3965
MovingCamera.reset(self)
@@ -51,6 +77,13 @@ def capture_mobjects(self, mobjects, **kwargs):
5177
MovingCamera.capture_mobjects(self, mobjects, **kwargs)
5278

5379
def get_mobjects_indicating_movement(self):
80+
"""Returns all mobjets whose movement implies that the camera
81+
should think of all other mobjects on the screen as moving
82+
83+
Returns
84+
-------
85+
list
86+
"""
5487
return [self.frame] + [
5588
imfc.camera.frame
5689
for imfc in self.image_mobjects_from_cameras

0 commit comments

Comments
 (0)