Fix bug with pi creature

This commit is contained in:
Grant Sanderson 2020-02-20 15:51:04 -08:00
parent c88bcc1a3c
commit 16ea2a0104
3 changed files with 17 additions and 13 deletions

View file

@ -149,9 +149,7 @@ class PiCreature(SVGMobject):
return self return self
def change_mode(self, mode): def change_mode(self, mode):
new_self = self.__class__( new_self = self.__class__(mode=mode)
mode=mode,
)
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():
@ -211,10 +209,11 @@ class PiCreature(SVGMobject):
def blink(self): def blink(self):
eye_parts = self.eye_parts eye_parts = self.eye_parts
eye_bottom_y = eye_parts.get_bottom()[1] eye_bottom_y = eye_parts.get_y(DOWN)
eye_parts.apply_function(
lambda p: [p[0], eye_bottom_y, p[2]] for eye_part in eye_parts:
) eye_part.points[:, 1] = eye_bottom_y
return self return self
def to_corner(self, vect=None, **kwargs): def to_corner(self, vect=None, **kwargs):

View file

@ -322,6 +322,11 @@ class SVGMobject(VMobject):
class VMobjectFromSVGPathstring(VMobject): class VMobjectFromSVGPathstring(VMobject):
CONFIG = {
"long_lines": True,
"subdivide_sharp_curves": False,
}
def __init__(self, path_string, **kwargs): def __init__(self, path_string, **kwargs):
self.path_string = path_string self.path_string = path_string
VMobject.__init__(self, **kwargs) VMobject.__init__(self, **kwargs)
@ -345,6 +350,7 @@ class VMobjectFromSVGPathstring(VMobject):
for command, coord_string in self.get_commands_and_coord_strings(): for command, coord_string in self.get_commands_and_coord_strings():
new_points = self.string_to_points(command, coord_string) new_points = self.string_to_points(command, coord_string)
self.handle_command(command, new_points) self.handle_command(command, new_points)
if self.subdivide_sharp_curves:
# For a healthy triangulation later # For a healthy triangulation later
self.subdivide_sharp_curves() self.subdivide_sharp_curves()
# SVG treats y-coordinate differently # SVG treats y-coordinate differently

View file

@ -16,10 +16,9 @@ TEX_MOB_SCALE_FACTOR = 0.05
class TexSymbol(VMobjectFromSVGPathstring): class TexSymbol(VMobjectFromSVGPathstring):
""" CONFIG = {
Purely a renaming of VMobjectFromSVGPathstring "subdivide_sharp_curves": True,
""" }
pass
class SingleStringTexMobject(SVGMobject): class SingleStringTexMobject(SVGMobject):