Made Write a subclass of DrawBorderThenFill, as it should be

This commit is contained in:
Grant Sanderson 2018-08-12 12:47:16 -07:00
parent 3f6376af39
commit 7f3b1e624d
2 changed files with 34 additions and 45 deletions

View file

@ -44,36 +44,6 @@ class Uncreate(ShowCreation):
}
class Write(ShowCreation):
CONFIG = {
"rate_func": None,
"submobject_mode": "lagged_start",
}
def __init__(self, mob_or_text, **kwargs):
digest_config(self, kwargs)
if isinstance(mob_or_text, str):
mobject = TextMobject(mob_or_text)
else:
mobject = mob_or_text
if "run_time" not in kwargs:
self.establish_run_time(mobject)
if "lag_factor" not in kwargs:
if len(mobject.family_members_with_points()) < 4:
min_lag_factor = 1
else:
min_lag_factor = 2
self.lag_factor = max(self.run_time - 1, min_lag_factor)
ShowCreation.__init__(self, mobject, **kwargs)
def establish_run_time(self, mobject):
num_subs = len(mobject.family_members_with_points())
if num_subs < 15:
self.run_time = 1
else:
self.run_time = 2
class DrawBorderThenFill(Animation):
CONFIG = {
"run_time": 2,
@ -115,6 +85,36 @@ class DrawBorderThenFill(Animation):
submobject.set_stroke(width=width)
submobject.set_fill(opacity=opacity)
class Write(DrawBorderThenFill):
CONFIG = {
"rate_func": None,
"submobject_mode": "lagged_start",
}
def __init__(self, mob_or_text, **kwargs):
digest_config(self, kwargs)
if isinstance(mob_or_text, str):
mobject = TextMobject(mob_or_text)
else:
mobject = mob_or_text
if "run_time" not in kwargs:
self.establish_run_time(mobject)
if "lag_factor" not in kwargs:
if len(mobject.family_members_with_points()) < 4:
min_lag_factor = 1
else:
min_lag_factor = 2
self.lag_factor = max(self.run_time - 1, min_lag_factor)
DrawBorderThenFill.__init__(self, mobject, **kwargs)
def establish_run_time(self, mobject):
num_subs = len(mobject.family_members_with_points())
if num_subs < 15:
self.run_time = 1
else:
self.run_time = 2
# Fading

View file

@ -17,21 +17,10 @@ TEX_MOB_SCALE_FACTOR = 0.05
class TexSymbol(VMobjectFromSVGPathstring):
def pointwise_become_partial(self, mobject, a, b):
# TODO, this assumes a = 0
if b < 0.5:
b = 2 * b
added_width = 1
opacity = 0
else:
added_width = 2 - 2 * b
opacity = 2 * b - 1
b = 1
VMobjectFromSVGPathstring.pointwise_become_partial(
self, mobject, 0, b
)
self.set_stroke(width=added_width + mobject.get_stroke_width())
self.set_fill(opacity=opacity)
"""
Purely a renaming of VMobjectFromSVGPathstring
"""
pass
class SingleStringTexMobject(SVGMobject):