@@ -108,92 +108,6 @@ def reset_pixel_shape(self, new_height, new_width):
108108 self .resize_frame_shape ()
109109 self .reset ()
110110
111- def get_pixel_height (self ):
112- """Returns the height of the scene in
113- pixel at that moment.
114-
115- Returns
116- -------
117- int
118- The height of the scene in pixels.
119- """
120- return self .pixel_height
121-
122- def get_pixel_width (self ):
123- """Returns the width of the scene in
124- pixels at that moment.
125-
126- Returns
127- -------
128- int
129- The width of the scene in pixels.
130- """
131- return self .pixel_width
132-
133- def get_frame_height (self ):
134- """Returns the height of the frame
135- in MUnits. Default is 8.0
136-
137- Returns
138- -------
139- float
140- The frame height
141- """
142- return self .frame_height
143-
144- def get_frame_width (self ):
145- """Returns the width of the frame
146- in MUnits.
147-
148- Returns
149- -------
150- float
151- The frame width
152- """
153- return self .frame_width
154-
155- def get_frame_center (self ):
156- """Returns the absolute center of the frame as Cartesian
157- Coordinates with the unit MUnits.
158-
159- Returns
160- -------
161- np.array
162- The array of x,y,z coordinates.
163- """
164- return self .frame_center
165-
166- def set_frame_height (self , frame_height ):
167- """Sets the frame height to the passed value.
168-
169- Parameters
170- ----------
171- frame_height : int, float
172- The frame_height in MUnits.
173- """
174- self .frame_height = frame_height
175-
176- def set_frame_width (self , frame_width ):
177- """Sets the frame width to the passed value.
178-
179- Parameters
180- ----------
181- frame_width : int, float
182- The frame_width in MUnits.
183- """
184- self .frame_width = frame_width
185-
186- def set_frame_center (self , frame_center ):
187- """Sets the center of the frame to the passed
188- cartesian coordinates.
189-
190- Parameters
191- ----------
192- frame_center : np.array
193- The center of the frame.
194- """
195- self .frame_center = frame_center
196-
197111 def resize_frame_shape (self , fixed_dimension = 0 ):
198112 """
199113 Changes frame_shape to match the aspect ratio
@@ -207,26 +121,26 @@ def resize_frame_shape(self, fixed_dimension=0):
207121 If 0, height is scaled with respect to width
208122 else, width is scaled with respect to height.
209123 """
210- pixel_height = self .get_pixel_height ()
211- pixel_width = self .get_pixel_width ()
212- frame_height = self .get_frame_height ()
213- frame_width = self .get_frame_width ()
124+ pixel_height = self .pixel_height
125+ pixel_width = self .pixel_width
126+ frame_height = self .frame_height
127+ frame_width = self .frame_width
214128 aspect_ratio = fdiv (pixel_width , pixel_height )
215129 if fixed_dimension == 0 :
216130 frame_height = frame_width / aspect_ratio
217131 else :
218132 frame_width = aspect_ratio * frame_height
219- self .set_frame_height ( frame_height )
220- self .set_frame_width ( frame_width )
133+ self .frame_height = frame_height
134+ self .frame_width = frame_width
221135
222136 def init_background (self ):
223137 """Initialize the background.
224138 If self.background_image is the path of an image
225139 the image is set as background; else, the default
226140 background color fills the background.
227141 """
228- height = self .get_pixel_height ()
229- width = self .get_pixel_width ()
142+ height = self .pixel_height
143+ width = self .pixel_width
230144 if self .background_image is not None :
231145 path = get_full_raster_image_path (self .background_image )
232146 image = Image .open (path ).convert (self .image_mode )
@@ -262,17 +176,6 @@ def get_image(self, pixel_array=None):
262176 pixel_array = self .pixel_array
263177 return Image .fromarray (pixel_array , mode = self .image_mode )
264178
265- def get_pixel_array (self ):
266- """Returns the pixel array
267- of the current frame.
268-
269- Returns
270- -------
271- np.array
272- The array of RGB values of each pixel.
273- """
274- return self .pixel_array
275-
276179 def convert_pixel_array (self , pixel_array , convert_from_floats = False ):
277180 """Converts a pixel array from values that have floats in then
278181 to proper RGB values.
@@ -460,9 +363,9 @@ def is_in_frame(self, mobject):
460363 bool
461364 True if in frame, False otherwise.
462365 """
463- fc = self .get_frame_center ()
464- fh = self .get_frame_height ()
465- fw = self .get_frame_width ()
366+ fc = self .frame_center
367+ fh = self .frame_height
368+ fw = self .frame_width
466369 return not reduce (
467370 op .or_ ,
468371 [
@@ -559,11 +462,11 @@ def get_cairo_context(self, pixel_array):
559462 cached_ctx = self .get_cached_cairo_context (pixel_array )
560463 if cached_ctx :
561464 return cached_ctx
562- pw = self .get_pixel_width ()
563- ph = self .get_pixel_height ()
564- fw = self .get_frame_width ()
565- fh = self .get_frame_height ()
566- fc = self .get_frame_center ()
465+ pw = self .pixel_width
466+ ph = self .pixel_height
467+ fw = self .frame_width
468+ fh = self .frame_height
469+ fc = self .frame_center
567470 surface = cairo .ImageSurface .create_for_data (
568471 pixel_array , cairo .FORMAT_ARGB32 , pw , ph
569472 )
@@ -756,7 +659,7 @@ def apply_stroke(self, ctx, vmobject, background=False):
756659 *
757660 # This ensures lines have constant width
758661 # as you zoom in on them.
759- (self .get_frame_width () / self .frame_width )
662+ (self .frame_width / self .frame_width )
760663 )
761664 ctx .stroke_preserve ()
762665 return self
@@ -886,8 +789,8 @@ def display_point_cloud(self, pmobject, points, rgbas, thickness, pixel_array):
886789 pixel_coords = pixel_coords [on_screen_indices ]
887790 rgbas = rgbas [on_screen_indices ]
888791
889- ph = self .get_pixel_height ()
890- pw = self .get_pixel_width ()
792+ ph = self .pixel_height
793+ pw = self .pixel_width
891794
892795 flattener = np .array ([1 , pw ], dtype = "int" )
893796 flattener = flattener .reshape ((2 , 1 ))
@@ -948,7 +851,7 @@ def display_image_mobject(self, image_mobject, pixel_array):
948851
949852 # Paste into an image as large as the camear's pixel array
950853 full_image = Image .fromarray (
951- np .zeros ((self .get_pixel_height () , self .get_pixel_width () )), mode = "RGBA"
854+ np .zeros ((self .pixel_height , self .pixel_width )), mode = "RGBA"
952855 )
953856 new_ul_coords = center_coords - np .array (sub_image .size ) / 2
954857 new_ul_coords = new_ul_coords .astype (int )
@@ -1034,13 +937,13 @@ def points_to_pixel_coords(
1034937 self , mobject , points
1035938 ): # TODO: Write more detailed docstrings for this method.
1036939 points = self .transform_points_pre_display (mobject , points )
1037- shifted_points = points - self .get_frame_center ()
940+ shifted_points = points - self .frame_center
1038941
1039942 result = np .zeros ((len (points ), 2 ))
1040- pixel_height = self .get_pixel_height ()
1041- pixel_width = self .get_pixel_width ()
1042- frame_height = self .get_frame_height ()
1043- frame_width = self .get_frame_width ()
943+ pixel_height = self .pixel_height
944+ pixel_width = self .pixel_width
945+ frame_height = self .frame_height
946+ frame_width = self .frame_width
1044947 width_mult = pixel_width / frame_width
1045948 width_add = pixel_width / 2
1046949 height_mult = pixel_height / frame_height
@@ -1070,9 +973,9 @@ def on_screen_pixels(self, pixel_coords):
1070973 op .and_ ,
1071974 [
1072975 pixel_coords [:, 0 ] >= 0 ,
1073- pixel_coords [:, 0 ] < self .get_pixel_width () ,
976+ pixel_coords [:, 0 ] < self .pixel_width ,
1074977 pixel_coords [:, 1 ] >= 0 ,
1075- pixel_coords [:, 1 ] < self .get_pixel_height () ,
978+ pixel_coords [:, 1 ] < self .pixel_height ,
1076979 ],
1077980 )
1078981
@@ -1092,7 +995,7 @@ def adjusted_thickness(self, thickness):
1092995 big_sum = op .add (
1093996 camera_config ["default_pixel_height" ], camera_config ["default_pixel_width" ]
1094997 )
1095- this_sum = op .add (self .get_pixel_height () , self .get_pixel_width () )
998+ this_sum = op .add (self .pixel_height , self .pixel_width )
1096999 factor = fdiv (big_sum , this_sum )
10971000 return 1 + (thickness - 1 ) / factor
10981001
@@ -1143,14 +1046,14 @@ def get_coords_of_all_pixels(self):
11431046 The array of cartesian coordinates.
11441047 """
11451048 # These are in x, y order, to help me keep things straight
1146- full_space_dims = np .array ([self .get_frame_width () , self .get_frame_height () ])
1147- full_pixel_dims = np .array ([self .get_pixel_width () , self .get_pixel_height () ])
1049+ full_space_dims = np .array ([self .frame_width , self .frame_height ])
1050+ full_pixel_dims = np .array ([self .pixel_width , self .pixel_height ])
11481051
11491052 # These are addressed in the same y, x order as in pixel_array, but the values in them
11501053 # are listed in x, y order
1151- uncentered_pixel_coords = np .indices (
1152- [ self . get_pixel_height (), self . get_pixel_width ()]
1153- )[:: - 1 ].transpose (1 , 2 , 0 )
1054+ uncentered_pixel_coords = np .indices ([ self . pixel_height , self . pixel_width ])[
1055+ :: - 1
1056+ ].transpose (1 , 2 , 0 )
11541057 uncentered_space_coords = fdiv (
11551058 uncentered_pixel_coords * full_space_dims , full_pixel_dims
11561059 )
@@ -1180,7 +1083,7 @@ def __init__(self, camera):
11801083 """
11811084 self .camera = camera
11821085 self .file_name_to_pixel_array_map = {}
1183- self .pixel_array = np .array (camera .get_pixel_array () )
1086+ self .pixel_array = np .array (camera .pixel_array )
11841087 self .reset_pixel_array ()
11851088
11861089 def reset_pixel_array (self ):
0 commit comments