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