mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Added PiCreature.get_mode, along with other changes to keep it working
This commit is contained in:
parent
d8ed9d188b
commit
1c71a00073
1 changed files with 14 additions and 2 deletions
|
@ -47,6 +47,7 @@ class PiCreature(SVGMobject):
|
||||||
|
|
||||||
def __init__(self, mode="plain", **kwargs):
|
def __init__(self, mode="plain", **kwargs):
|
||||||
digest_config(self, kwargs)
|
digest_config(self, kwargs)
|
||||||
|
self.mode = mode
|
||||||
self.parts_named = False
|
self.parts_named = False
|
||||||
try:
|
try:
|
||||||
svg_file = os.path.join(
|
svg_file = os.path.join(
|
||||||
|
@ -68,6 +69,13 @@ class PiCreature(SVGMobject):
|
||||||
if self.start_corner is not None:
|
if self.start_corner is not None:
|
||||||
self.to_corner(self.start_corner)
|
self.to_corner(self.start_corner)
|
||||||
|
|
||||||
|
def align_data(self, mobject):
|
||||||
|
# This ensures that after a transform into a different mode,
|
||||||
|
# the pi creatures mode will be updated appropriately
|
||||||
|
SVGMobject.align_data(self, mobject)
|
||||||
|
if isinstance(mobject, PiCreature):
|
||||||
|
self.mode = mobject.get_mode()
|
||||||
|
|
||||||
def name_parts(self):
|
def name_parts(self):
|
||||||
self.mouth = self.submobjects[MOUTH_INDEX]
|
self.mouth = self.submobjects[MOUTH_INDEX]
|
||||||
self.body = self.submobjects[BODY_INDEX]
|
self.body = self.submobjects[BODY_INDEX]
|
||||||
|
@ -108,14 +116,18 @@ class PiCreature(SVGMobject):
|
||||||
)
|
)
|
||||||
new_self.match_style(self)
|
new_self.match_style(self)
|
||||||
new_self.match_height(self)
|
new_self.match_height(self)
|
||||||
if self.is_flipped() ^ new_self.is_flipped():
|
if self.is_flipped() != new_self.is_flipped():
|
||||||
new_self.flip()
|
new_self.flip()
|
||||||
new_self.shift(self.eyes.get_center() - new_self.eyes.get_center())
|
new_self.shift(self.eyes.get_center() - new_self.eyes.get_center())
|
||||||
if hasattr(self, "purposeful_looking_direction"):
|
if hasattr(self, "purposeful_looking_direction"):
|
||||||
new_self.look(self.purposeful_looking_direction)
|
new_self.look(self.purposeful_looking_direction)
|
||||||
Transform(self, new_self).update(1)
|
Transform(self, new_self).update(1)
|
||||||
|
self.mode = mode
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
def get_mode(self):
|
||||||
|
return self.mode
|
||||||
|
|
||||||
def look(self, direction):
|
def look(self, direction):
|
||||||
norm = np.linalg.norm(direction)
|
norm = np.linalg.norm(direction)
|
||||||
if norm == 0:
|
if norm == 0:
|
||||||
|
|
Loading…
Add table
Reference in a new issue