MCPcopy
hub / github.com/3b1b/manim / apply_points_function

Method apply_points_function

manimlib/mobject/mobject.py:279–308  ·  view source on GitHub ↗
(
        self,
        func: Callable[[np.ndarray], np.ndarray],
        about_point: Vect3 | None = None,
        about_edge: Vect3 = ORIGIN,
        works_on_bounding_box: bool = False
    )

Source from the content-addressed store, hash-verified

277
278 @affects_family_data
279 def apply_points_function(
280 self,
281 func: Callable[[np.ndarray], np.ndarray],
282 about_point: Vect3 | None = None,
283 about_edge: Vect3 = ORIGIN,
284 works_on_bounding_box: bool = False
285 ) -> Self:
286 if about_point is None and about_edge is not None:
287 about_point = self.get_bounding_box_point(about_edge)
288
289 for mob in self.get_family():
290 arrs = []
291 if mob.has_points():
292 for key in mob.pointlike_data_keys:
293 arrs.append(mob.data[key])
294 if works_on_bounding_box:
295 arrs.append(mob.get_bounding_box())
296
297 for arr in arrs:
298 if about_point is None:
299 arr[:] = func(arr)
300 else:
301 arr[:] = func(arr - about_point) + about_point
302
303 if not works_on_bounding_box:
304 self.refresh_bounding_box(recurse_down=True)
305 else:
306 for parent in self.parents:
307 parent.refresh_bounding_box()
308 return self
309
310 # Others related to points
311

Callers 6

shiftMethod · 0.95
scaleMethod · 0.95
stretchMethod · 0.95
rotateMethod · 0.95
apply_functionMethod · 0.95
apply_matrixMethod · 0.95

Calls 6

get_familyMethod · 0.95
refresh_bounding_boxMethod · 0.95
has_pointsMethod · 0.80
get_bounding_boxMethod · 0.80
funcFunction · 0.70

Tested by

no test coverage detected