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

Method replace

manimlib/mobject/mobject.py:1258–1272  ·  view source on GitHub ↗
(self, mobject: Mobject, dim_to_match: int = 0, stretch: bool = False)

Source from the content-addressed store, hash-verified

1256 return self
1257
1258 def replace(self, mobject: Mobject, dim_to_match: int = 0, stretch: bool = False) -> Self:
1259 if not mobject.get_num_points() and not mobject.submobjects:
1260 self.scale(0)
1261 return self
1262 if stretch:
1263 for i in range(self.dim):
1264 self.rescale_to_fit(mobject.length_over_dim(i), i, stretch=True)
1265 else:
1266 self.rescale_to_fit(
1267 mobject.length_over_dim(dim_to_match),
1268 dim_to_match,
1269 stretch=False
1270 )
1271 self.shift(mobject.get_center() - self.get_center())
1272 return self
1273
1274 def surround(
1275 self,

Callers 11

surroundMethod · 0.95
set_color_by_xyz_funcMethod · 0.45
get_num_stringMethod · 0.45
surroundMethod · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 6

scaleMethod · 0.95
rescale_to_fitMethod · 0.95
shiftMethod · 0.95
get_centerMethod · 0.95
get_num_pointsMethod · 0.80
length_over_dimMethod · 0.80

Tested by

no test coverage detected