Added TauCreatures

This commit is contained in:
Grant Sanderson 2018-03-12 15:51:31 -07:00
parent c713ef4d2f
commit edad6fb77b

View file

@ -29,6 +29,7 @@ MOUTH_INDEX = 5
class PiCreature(SVGMobject): class PiCreature(SVGMobject):
CONFIG = { CONFIG = {
"color" : BLUE_E, "color" : BLUE_E,
"file_name_prefix" : "PiCreatures",
"stroke_width" : 0, "stroke_width" : 0,
"stroke_color" : BLACK, "stroke_color" : BLACK,
"fill_opacity" : 1.0, "fill_opacity" : 1.0,
@ -43,20 +44,21 @@ class PiCreature(SVGMobject):
"left_arm_range" : [.34, .462], "left_arm_range" : [.34, .462],
} }
def __init__(self, mode = "plain", **kwargs): def __init__(self, mode = "plain", **kwargs):
digest_config(self, kwargs)
self.parts_named = False self.parts_named = False
try: # try:
svg_file = os.path.join( svg_file = os.path.join(
PI_CREATURE_DIR, PI_CREATURE_DIR,
"PiCreatures_%s.svg"%mode "%s_%s.svg"%(self.file_name_prefix, mode)
) )
SVGMobject.__init__(self, file_name = svg_file, **kwargs) SVGMobject.__init__(self, file_name = svg_file, **kwargs)
except: # except:
warnings.warn("No PiCreature design with mode %s"%mode) # warnings.warn("No %s design with mode %s"%(self.file_name_prefix, mode))
svg_file = os.path.join( # svg_file = os.path.join(
FILE_DIR, # FILE_DIR,
"PiCreatures_plain.svg" # "PiCreatures_plain.svg",
) # )
SVGMobject.__init__(self, file_name = svg_file, **kwargs) # SVGMobject.__init__(self, file_name = svg_file, **kwargs)
if self.flip_at_start: if self.flip_at_start:
self.flip() self.flip()
@ -210,7 +212,7 @@ class PiCreature(SVGMobject):
def get_all_pi_creature_modes(): def get_all_pi_creature_modes():
result = [] result = []
prefix = "PiCreatures_" prefix = "%s_"%PiCreature.CONFIG["file_name_prefix"]
suffix = ".svg" suffix = ".svg"
for file in os.listdir(PI_CREATURE_DIR): for file in os.listdir(PI_CREATURE_DIR):
if file.startswith(prefix) and file.endswith(suffix): if file.startswith(prefix) and file.endswith(suffix):
@ -253,6 +255,12 @@ class BabyPiCreature(PiCreature):
pupil.scale_in_place(self.pupil_scale_factor) pupil.scale_in_place(self.pupil_scale_factor)
self.look(looking_direction) self.look(looking_direction)
class TauCreature(PiCreature):
CONFIG = {
"file_name_prefix" : "TauCreatures"
}
class Blink(ApplyMethod): class Blink(ApplyMethod):
CONFIG = { CONFIG = {
"rate_func" : squish_rate_func(there_and_back) "rate_func" : squish_rate_func(there_and_back)