From 944a20fbdcdfcac5bedb216667f42410384a6a9e Mon Sep 17 00:00:00 2001 From: kolibril13 <44469195+kolibril13@users.noreply.github.com> Date: Sat, 2 Jan 2021 13:07:07 +0100 Subject: [PATCH] Simplifiying template (#1) * Update custom_mobject.py * Update src/manim_plugintemplate/custom_mobject.py Co-authored-by: Naveen M K * Update custom_mobject.py * suggested fixes Updated mobjects subpackage init.py Co-authored-by: Naveen M K Co-authored-by: Jason G. Villanueva --- src/manim_plugintemplate/__init__.py | 2 +- src/manim_plugintemplate/custom_mobject.py | 58 ------------------- src/manim_plugintemplate/mobjects/__init__.py | 1 + src/manim_plugintemplate/mobjects/dotgrid.py | 14 +++++ 4 files changed, 16 insertions(+), 59 deletions(-) delete mode 100644 src/manim_plugintemplate/custom_mobject.py create mode 100644 src/manim_plugintemplate/mobjects/__init__.py create mode 100644 src/manim_plugintemplate/mobjects/dotgrid.py diff --git a/src/manim_plugintemplate/__init__.py b/src/manim_plugintemplate/__init__.py index 960d800..5e9b722 100644 --- a/src/manim_plugintemplate/__init__.py +++ b/src/manim_plugintemplate/__init__.py @@ -1,2 +1,2 @@ __version__ = "0.1.3" -from .custom_mobject import * +from .mobjects.dotgrid import * diff --git a/src/manim_plugintemplate/custom_mobject.py b/src/manim_plugintemplate/custom_mobject.py deleted file mode 100644 index 56358ae..0000000 --- a/src/manim_plugintemplate/custom_mobject.py +++ /dev/null @@ -1,58 +0,0 @@ -from manim import * - -__all__ = [ - "EmitWaveAtPoint", - "EmitWaves", -] - - -class EmitWaveAtPoint(Animation): - CONFIG = { - "small_radius": 0.0, - "big_radius": 5, - "start_stroke_width": 8, - "color": BLUE, - "lag_ratio": 0.1, - "rate_func": linear, - } - - def __init__(self, source, **kwargs): - digest_config(self, kwargs) - self.source = source - self.mobject = Circle( - radius=self.big_radius, - stroke_color=self.color, - stroke_width=self.start_stroke_width, - ) - self.mobject.move_to(source) - - def spawn_at_point(mobj, dt): - mobj.move_to(self.source) - # self.mobject.clear_updaters() - - self.mobject.add_updater(spawn_at_point) - - def interpolate_mobject(self, alpha): - self.mobject.become(self.starting_mobject) - self.mobject.set_width(alpha * self.big_radius) - self.mobject.set_stroke(width=(1 - alpha) * self.start_stroke_width) - - -class EmitWaves(LaggedStart): - CONFIG = { - "small_radius": 0.0, - "big_radius": 5, - "n_circles": 2, - "start_stroke_width": 8, - "color": WHITE, - "remover": True, - "lag_ratio": 0.6, - "run_time": 1, - "remover": True, - } - - def __init__(self, focal_point, **kwargs): - digest_config(self, kwargs) - self.focal_point = focal_point - animations = [EmitWaveAtPoint(focal_point) for x in range(self.n_circles)] - super().__init__(*animations, **kwargs) diff --git a/src/manim_plugintemplate/mobjects/__init__.py b/src/manim_plugintemplate/mobjects/__init__.py new file mode 100644 index 0000000..e15fc02 --- /dev/null +++ b/src/manim_plugintemplate/mobjects/__init__.py @@ -0,0 +1 @@ +from .dotgrid import * \ No newline at end of file diff --git a/src/manim_plugintemplate/mobjects/dotgrid.py b/src/manim_plugintemplate/mobjects/dotgrid.py new file mode 100644 index 0000000..c47ba2b --- /dev/null +++ b/src/manim_plugintemplate/mobjects/dotgrid.py @@ -0,0 +1,14 @@ +from manim import * + +__all__ = ["DotGrid"] +class DotGrid(VMobject): + def __init__(self): + super().__init__() + dot1 = Dot(fill_color=GREEN).shift(LEFT) + dot2 = Dot(fill_color=BLUE) + dot3 = Dot(fill_color=RED).shift(RIGHT) + self.dotgrid = VGroup(dot1, dot2, dot3) + self.add(self.dotgrid) + + def update_dot(self): + self.dotgrid.become(self.dotgrid.shift(UP))