Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Made Write a subclass of DrawBorderThenFill, as it should be

Grant Sanderson7f3b1e624d90
diff --git a/animation/creation.py b/animation/creation.py
index fb551ac8c..ffa0a2180 100644
--- a/animation/creation.py
+++ b/animation/creation.py
@@ -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
diff --git a/mobject/svg/tex_mobject.py b/mobject/svg/tex_mobject.py
index eea067f1d..e1849d382 100644
--- a/mobject/svg/tex_mobject.py
+++ b/mobject/svg/tex_mobject.py
@@ -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):