mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Reorganized animations folder. Warning: While I tried to be systematic, there is a decent chance this will cause import errors somewhere.
This commit is contained in:
parent
6451f09bd5
commit
0978984541
64 changed files with 999 additions and 900 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,10 +1,8 @@
|
|||
*.pyc
|
||||
.DS_Store
|
||||
homeless.py
|
||||
ka_playgrounds/
|
||||
playground.py
|
||||
special_animations.py
|
||||
prettiness_hall_of_fame.py
|
||||
random_scenes/
|
||||
files/
|
||||
ben_playground.py
|
||||
ben_cairo_test.py
|
||||
|
|
|
@ -8,7 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.composition import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -8,7 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.composition import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -8,7 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.composition import *
|
||||
from animation.playground import *
|
||||
from animation.continual_animation import *
|
||||
from topics.geometry import *
|
||||
|
|
|
@ -8,7 +8,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.composition import *
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
__all__ = [
|
||||
"animation",
|
||||
"simple_animations",
|
||||
"transform"
|
||||
]
|
|
@ -1,54 +1,27 @@
|
|||
import numpy as np
|
||||
from __future__ import absolute_import
|
||||
|
||||
import itertools as it
|
||||
import numpy as np
|
||||
|
||||
from constants import *
|
||||
|
||||
import warnings
|
||||
from mobject.mobject import Mobject, Group
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
from mobject.tex_mobject import TextMobject
|
||||
from .animation import Animation
|
||||
from transform import Transform
|
||||
|
||||
from animation.animation import Animation
|
||||
from mobject.mobject import Group
|
||||
from mobject.mobject import Mobject
|
||||
from utils.bezier import inverse_interpolate
|
||||
from utils.config_ops import digest_config
|
||||
from utils.rate_functions import squish_rate_func
|
||||
|
||||
class LaggedStart(Animation):
|
||||
class EmptyAnimation(Animation):
|
||||
CONFIG = {
|
||||
"run_time" : 2,
|
||||
"lag_ratio" : 0.5,
|
||||
"run_time" : 0,
|
||||
"empty" : True
|
||||
}
|
||||
def __init__(self, AnimationClass, mobject, arg_creator = None, **kwargs):
|
||||
digest_config(self, kwargs)
|
||||
for key in "rate_func", "run_time", "lag_ratio":
|
||||
if key in kwargs:
|
||||
kwargs.pop(key)
|
||||
if arg_creator is None:
|
||||
arg_creator = lambda mobject : (mobject,)
|
||||
self.subanimations = [
|
||||
AnimationClass(
|
||||
*arg_creator(submob),
|
||||
run_time = self.run_time,
|
||||
rate_func = squish_rate_func(
|
||||
self.rate_func, beta, beta + self.lag_ratio
|
||||
),
|
||||
**kwargs
|
||||
)
|
||||
for submob, beta in zip(
|
||||
mobject,
|
||||
np.linspace(0, 1-self.lag_ratio, len(mobject))
|
||||
)
|
||||
]
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
|
||||
def update(self, alpha):
|
||||
for anim in self.subanimations:
|
||||
anim.update(alpha)
|
||||
return self
|
||||
|
||||
def clean_up(self, *args, **kwargs):
|
||||
for anim in self.subanimations:
|
||||
anim.clean_up(*args, **kwargs)
|
||||
def __init__(self, *args, **kwargs):
|
||||
return Animation.__init__(self, Group(), *args, **kwargs)
|
||||
|
||||
class Succession(Animation):
|
||||
CONFIG = {
|
||||
|
@ -231,11 +204,64 @@ class AnimationGroup(Animation):
|
|||
for anim in self.sub_anims:
|
||||
anim.update_config(**kwargs)
|
||||
|
||||
class EmptyAnimation(Animation):
|
||||
CONFIG = {
|
||||
"run_time" : 0,
|
||||
"empty" : True
|
||||
}
|
||||
# Variants on mappin an animation over submobjectsg
|
||||
|
||||
class LaggedStart(Animation):
|
||||
CONFIG = {
|
||||
"run_time" : 2,
|
||||
"lag_ratio" : 0.5,
|
||||
}
|
||||
def __init__(self, AnimationClass, mobject, arg_creator = None, **kwargs):
|
||||
digest_config(self, kwargs)
|
||||
for key in "rate_func", "run_time", "lag_ratio":
|
||||
if key in kwargs:
|
||||
kwargs.pop(key)
|
||||
if arg_creator is None:
|
||||
arg_creator = lambda mobject : (mobject,)
|
||||
self.subanimations = [
|
||||
AnimationClass(
|
||||
*arg_creator(submob),
|
||||
run_time = self.run_time,
|
||||
rate_func = squish_rate_func(
|
||||
self.rate_func, beta, beta + self.lag_ratio
|
||||
),
|
||||
**kwargs
|
||||
)
|
||||
for submob, beta in zip(
|
||||
mobject,
|
||||
np.linspace(0, 1-self.lag_ratio, len(mobject))
|
||||
)
|
||||
]
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
|
||||
def update(self, alpha):
|
||||
for anim in self.subanimations:
|
||||
anim.update(alpha)
|
||||
return self
|
||||
|
||||
def clean_up(self, *args, **kwargs):
|
||||
for anim in self.subanimations:
|
||||
anim.clean_up(*args, **kwargs)
|
||||
|
||||
class ApplyToCenters(Animation):
|
||||
def __init__(self, AnimationClass, mobjects, **kwargs):
|
||||
full_kwargs = AnimationClass.CONFIG
|
||||
full_kwargs.update(kwargs)
|
||||
full_kwargs["mobject"] = Mobject(*[
|
||||
mob.get_point_mobject()
|
||||
for mob in mobjects
|
||||
])
|
||||
self.centers_container = AnimationClass(**full_kwargs)
|
||||
full_kwargs.pop("mobject")
|
||||
Animation.__init__(self, Mobject(*mobjects), **full_kwargs)
|
||||
self.name = str(self) + AnimationClass.__name__
|
||||
|
||||
def update_mobject(self, alpha):
|
||||
self.centers_container.update_mobject(alpha)
|
||||
center_mobs = self.centers_container.mobject.split()
|
||||
mobjects = self.mobject.split()
|
||||
for center_mob, mobject in zip(center_mobs, mobjects):
|
||||
mobject.shift(
|
||||
center_mob.get_center()-mobject.get_center()
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
return Animation.__init__(self, Group(), *args, **kwargs)
|
185
animation/creation.py
Normal file
185
animation/creation.py
Normal file
|
@ -0,0 +1,185 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import numpy as np
|
||||
|
||||
from constants import *
|
||||
|
||||
from animation.animation import Animation
|
||||
from mobject.tex_mobject import TextMobject
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
from mobject.vectorized_mobject import VectorizedPoint
|
||||
from animation.transform import Transform
|
||||
from utils.bezier import interpolate
|
||||
from utils.config_ops import digest_config
|
||||
from utils.paths import counterclockwise_path
|
||||
from utils.rate_functions import double_smooth
|
||||
from utils.rate_functions import smooth
|
||||
|
||||
#Drawing
|
||||
|
||||
class ShowPartial(Animation):
|
||||
def update_submobject(self, submobject, starting_submobject, alpha):
|
||||
submobject.pointwise_become_partial(
|
||||
starting_submobject, *self.get_bounds(alpha)
|
||||
)
|
||||
|
||||
def get_bounds(self, alpha):
|
||||
raise Exception("Not Implemented")
|
||||
|
||||
class ShowCreation(ShowPartial):
|
||||
CONFIG = {
|
||||
"submobject_mode" : "one_at_a_time",
|
||||
}
|
||||
def get_bounds(self, alpha):
|
||||
return (0, alpha)
|
||||
|
||||
class Uncreate(ShowCreation):
|
||||
CONFIG = {
|
||||
"rate_func" : lambda t : smooth(1-t),
|
||||
"remover" : True
|
||||
}
|
||||
|
||||
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,
|
||||
"stroke_width" : 2,
|
||||
"stroke_color" : None,
|
||||
"rate_func" : double_smooth,
|
||||
}
|
||||
def __init__(self, vmobject, **kwargs):
|
||||
if not isinstance(vmobject, VMobject):
|
||||
raise Exception("DrawBorderThenFill only works for VMobjects")
|
||||
self.reached_halfway_point_before = False
|
||||
Animation.__init__(self, vmobject, **kwargs)
|
||||
|
||||
def update_submobject(self, submobject, starting_submobject, alpha):
|
||||
submobject.pointwise_become_partial(
|
||||
starting_submobject, 0, min(2*alpha, 1)
|
||||
)
|
||||
if alpha < 0.5:
|
||||
if self.stroke_color:
|
||||
color = self.stroke_color
|
||||
elif starting_submobject.stroke_width > 0:
|
||||
color = starting_submobject.get_stroke_color()
|
||||
else:
|
||||
color = starting_submobject.get_color()
|
||||
submobject.set_stroke(color, width = self.stroke_width)
|
||||
submobject.set_fill(opacity = 0)
|
||||
else:
|
||||
if not self.reached_halfway_point_before:
|
||||
self.reached_halfway_point_before = True
|
||||
submobject.points = np.array(starting_submobject.points)
|
||||
width, opacity = [
|
||||
interpolate(start, end, 2*alpha - 1)
|
||||
for start, end in [
|
||||
(self.stroke_width, starting_submobject.get_stroke_width()),
|
||||
(0, starting_submobject.get_fill_opacity())
|
||||
]
|
||||
]
|
||||
submobject.set_stroke(width = width)
|
||||
submobject.set_fill(opacity = opacity)
|
||||
|
||||
#Fading
|
||||
|
||||
class FadeOut(Transform):
|
||||
CONFIG = {
|
||||
"remover" : True,
|
||||
}
|
||||
def __init__(self, mobject, **kwargs):
|
||||
target = mobject.copy()
|
||||
target.fade(1)
|
||||
Transform.__init__(self, mobject, target, **kwargs)
|
||||
|
||||
def clean_up(self, surrounding_scene = None):
|
||||
Transform.clean_up(self, surrounding_scene)
|
||||
self.update(0)
|
||||
|
||||
class FadeIn(Transform):
|
||||
def __init__(self, mobject, **kwargs):
|
||||
target = mobject.copy()
|
||||
Transform.__init__(self, mobject, target, **kwargs)
|
||||
self.starting_mobject.fade(1)
|
||||
if isinstance(self.starting_mobject, VMobject):
|
||||
self.starting_mobject.set_stroke(width = 0)
|
||||
self.starting_mobject.set_fill(opacity = 0)
|
||||
|
||||
class FadeInAndShiftFromDirection(Transform):
|
||||
CONFIG = {
|
||||
"direction" : DOWN,
|
||||
}
|
||||
def __init__(self, mobject, **kwargs):
|
||||
digest_config(self, kwargs)
|
||||
target = mobject.copy()
|
||||
mobject.shift(self.direction)
|
||||
mobject.fade(1)
|
||||
Transform.__init__(self, mobject, target, **kwargs)
|
||||
|
||||
class FadeInFromDown(FadeInAndShiftFromDirection):
|
||||
"""
|
||||
Essential a more convenient form of FadeInAndShiftFromDirection
|
||||
"""
|
||||
CONFIG = {
|
||||
"direction" : DOWN,
|
||||
}
|
||||
|
||||
#Growing
|
||||
class GrowFromPoint(Transform):
|
||||
CONFIG = {
|
||||
"point_color" : None,
|
||||
}
|
||||
def __init__(self, mobject, point, **kwargs):
|
||||
digest_config(self, kwargs)
|
||||
target = mobject.copy()
|
||||
point_mob = VectorizedPoint(point)
|
||||
if self.point_color:
|
||||
point_mob.set_color(self.point_color)
|
||||
mobject.replace(point_mob)
|
||||
mobject.set_color(point_mob.get_color())
|
||||
Transform.__init__(self, mobject, target, **kwargs)
|
||||
|
||||
class GrowFromCenter(GrowFromPoint):
|
||||
def __init__(self, mobject, **kwargs):
|
||||
GrowFromPoint.__init__(self, mobject, mobject.get_center(), **kwargs)
|
||||
|
||||
class GrowArrow(GrowFromPoint):
|
||||
def __init__(self, arrow, **kwargs):
|
||||
GrowFromPoint.__init__(self, arrow, arrow.get_start(), **kwargs)
|
||||
|
||||
class SpinInFromNothing(GrowFromCenter):
|
||||
CONFIG = {
|
||||
"path_func" : counterclockwise_path()
|
||||
}
|
||||
|
||||
class ShrinkToCenter(Transform):
|
||||
def __init__(self, mobject, **kwargs):
|
||||
Transform.__init__(
|
||||
self, mobject, mobject.get_point_mobject(), **kwargs
|
||||
)
|
187
animation/indication.py
Normal file
187
animation/indication.py
Normal file
|
@ -0,0 +1,187 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import numpy as np
|
||||
|
||||
from constants import *
|
||||
|
||||
from animation.animation import Animation
|
||||
from animation.movement import Homotopy
|
||||
from animation.creation import ShowPartial
|
||||
from animation.transform import Transform
|
||||
from mobject.mobject import Group
|
||||
from mobject.mobject import Mobject
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
from topics.geometry import Circle
|
||||
from topics.geometry import Dot
|
||||
from utils.config_ops import digest_config
|
||||
from utils.rate_functions import squish_rate_func
|
||||
from utils.rate_functions import there_and_back
|
||||
|
||||
|
||||
class FocusOn(Transform):
|
||||
CONFIG = {
|
||||
"opacity" : 0.2,
|
||||
"color" : GREY,
|
||||
"run_time" : 2,
|
||||
"remover" : True,
|
||||
}
|
||||
def __init__(self, mobject_or_point, **kwargs):
|
||||
digest_config(self, kwargs)
|
||||
big_dot = Dot(
|
||||
radius = FRAME_X_RADIUS+FRAME_Y_RADIUS,
|
||||
stroke_width = 0,
|
||||
fill_color = self.color,
|
||||
fill_opacity = 0,
|
||||
)
|
||||
little_dot = Dot(radius = 0)
|
||||
little_dot.set_fill(self.color, opacity = self.opacity)
|
||||
little_dot.move_to(mobject_or_point)
|
||||
|
||||
Transform.__init__(self, big_dot, little_dot, **kwargs)
|
||||
|
||||
class Indicate(Transform):
|
||||
CONFIG = {
|
||||
"rate_func" : there_and_back,
|
||||
"scale_factor" : 1.2,
|
||||
"color" : YELLOW,
|
||||
}
|
||||
def __init__(self, mobject, **kwargs):
|
||||
digest_config(self, kwargs)
|
||||
target = mobject.copy()
|
||||
target.scale_in_place(self.scale_factor)
|
||||
target.set_color(self.color)
|
||||
Transform.__init__(self, mobject, target, **kwargs)
|
||||
|
||||
class CircleIndicate(Indicate):
|
||||
CONFIG = {
|
||||
"rate_func" : squish_rate_func(there_and_back, 0, 0.8),
|
||||
"remover" : True
|
||||
}
|
||||
def __init__(self, mobject, **kwargs):
|
||||
digest_config(self, kwargs)
|
||||
circle = Circle(color = self.color, **kwargs)
|
||||
circle.surround(mobject)
|
||||
Indicate.__init__(self, circle, **kwargs)
|
||||
|
||||
class ShowPassingFlash(ShowPartial):
|
||||
CONFIG = {
|
||||
"time_width" : 0.1,
|
||||
"remover" : True,
|
||||
}
|
||||
def get_bounds(self, alpha):
|
||||
alpha *= (1+self.time_width)
|
||||
alpha -= self.time_width/2.0
|
||||
lower = max(0, alpha - self.time_width/2.0)
|
||||
upper = min(1, alpha + self.time_width/2.0)
|
||||
return (lower, upper)
|
||||
|
||||
def clean_up(self, *args, **kwargs):
|
||||
ShowPartial.clean_up(self, *args, **kwargs)
|
||||
for submob, start_submob in self.get_all_families_zipped():
|
||||
submob.pointwise_become_partial(start_submob, 0, 1)
|
||||
|
||||
class ShowCreationThenDestruction(ShowPassingFlash):
|
||||
CONFIG = {
|
||||
"time_width" : 2.0,
|
||||
"run_time" : 1,
|
||||
}
|
||||
|
||||
class ApplyWave(Homotopy):
|
||||
CONFIG = {
|
||||
"direction" : DOWN,
|
||||
"amplitude" : 0.2,
|
||||
"run_time" : 1,
|
||||
"apply_function_kwargs" : {
|
||||
"maintain_smoothness" : False,
|
||||
},
|
||||
}
|
||||
def __init__(self, mobject, **kwargs):
|
||||
digest_config(self, kwargs, locals())
|
||||
left_x = mobject.get_left()[0]
|
||||
right_x = mobject.get_right()[0]
|
||||
vect = self.amplitude*self.direction
|
||||
def homotopy(x, y, z, t):
|
||||
start_point = np.array([x, y, z])
|
||||
alpha = (x-left_x)/(right_x-left_x)
|
||||
power = np.exp(2*(alpha-0.5))
|
||||
nudge = there_and_back(t**power)
|
||||
return np.array([x, y, z]) + nudge*vect
|
||||
Homotopy.__init__(self, homotopy, mobject, **kwargs)
|
||||
|
||||
class WiggleOutThenIn(Animation):
|
||||
CONFIG = {
|
||||
"scale_value" : 1.1,
|
||||
"rotation_angle" : 0.01*TAU,
|
||||
"n_wiggles" : 6,
|
||||
"run_time" : 2,
|
||||
"scale_about_point" : None,
|
||||
"rotate_about_point" : None,
|
||||
}
|
||||
def __init__(self, mobject, **kwargs):
|
||||
digest_config(self, kwargs)
|
||||
if self.scale_about_point is None:
|
||||
self.scale_about_point = mobject.get_center()
|
||||
if self.rotate_about_point is None:
|
||||
self.rotate_about_point = mobject.get_center()
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
|
||||
def update_submobject(self, submobject, starting_sumobject, alpha):
|
||||
submobject.points[:,:] = starting_sumobject.points
|
||||
submobject.scale(
|
||||
interpolate(1, self.scale_value, there_and_back(alpha)),
|
||||
about_point = self.scale_about_point
|
||||
)
|
||||
submobject.rotate(
|
||||
wiggle(alpha, self.n_wiggles)*self.rotation_angle,
|
||||
about_point = self.rotate_about_point
|
||||
)
|
||||
|
||||
class Vibrate(Animation):
|
||||
CONFIG = {
|
||||
"spatial_period" : 6,
|
||||
"temporal_period" : 1,
|
||||
"overtones" : 4,
|
||||
"amplitude" : 0.5,
|
||||
"radius" : FRAME_X_RADIUS/2,
|
||||
"run_time" : 3.0,
|
||||
"rate_func" : None
|
||||
}
|
||||
def __init__(self, mobject = None, **kwargs):
|
||||
if mobject is None:
|
||||
mobject = Line(3*LEFT, 3*RIGHT)
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
|
||||
def wave_function(self, x, t):
|
||||
return sum([
|
||||
reduce(op.mul, [
|
||||
self.amplitude/(k**2), #Amplitude
|
||||
np.sin(2*np.pi*(k**1.5)*t/self.temporal_period), #Frequency
|
||||
np.sin(2*np.pi*k*x/self.spatial_period) #Number of waves
|
||||
])
|
||||
for k in range(1, self.overtones+1)
|
||||
])
|
||||
|
||||
|
||||
def update_mobject(self, alpha):
|
||||
time = alpha*self.run_time
|
||||
families = map(
|
||||
Mobject.submobject_family,
|
||||
[self.mobject, self.starting_mobject]
|
||||
)
|
||||
for mob, start in zip(*families):
|
||||
mob.points = np.apply_along_axis(
|
||||
lambda (x, y, z) : (x, y + self.wave_function(x, time), z),
|
||||
1, start.points
|
||||
)
|
||||
|
||||
class TurnInsideOut(Transform):
|
||||
CONFIG = {
|
||||
"path_arc" : TAU/4,
|
||||
}
|
||||
def __init__(self, mobject, **kwargs):
|
||||
mobject.sort_points(np.linalg.norm)
|
||||
mob_copy = mobject.copy()
|
||||
mob_copy.sort_points(lambda p : -np.linalg.norm(p))
|
||||
Transform.__init__(self, mobject, mob_copy, **kwargs)
|
||||
|
||||
|
62
animation/movement.py
Normal file
62
animation/movement.py
Normal file
|
@ -0,0 +1,62 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from constants import *
|
||||
|
||||
import warnings
|
||||
|
||||
from animation.animation import Animation
|
||||
from utils.config_ops import digest_config
|
||||
|
||||
class Homotopy(Animation):
|
||||
CONFIG = {
|
||||
"run_time" : 3,
|
||||
"apply_function_kwargs" : {},
|
||||
}
|
||||
def __init__(self, homotopy, mobject, **kwargs):
|
||||
"""
|
||||
Homotopy a function from (x, y, z, t) to (x', y', z')
|
||||
"""
|
||||
def function_at_time_t(t):
|
||||
return lambda p : homotopy(p[0], p[1], p[2], t)
|
||||
self.function_at_time_t = function_at_time_t
|
||||
digest_config(self, kwargs)
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
|
||||
def update_submobject(self, submob, start, alpha):
|
||||
submob.points = start.points
|
||||
submob.apply_function(
|
||||
self.function_at_time_t(alpha),
|
||||
**self.apply_function_kwargs
|
||||
)
|
||||
|
||||
class SmoothedVectorizedHomotopy(Homotopy):
|
||||
def update_submobject(self, submob, start, alpha):
|
||||
Homotopy.update_submobject(self, submob, start, alpha)
|
||||
submob.make_smooth()
|
||||
|
||||
class PhaseFlow(Animation):
|
||||
CONFIG = {
|
||||
"virtual_time" : 1,
|
||||
"rate_func" : None,
|
||||
}
|
||||
def __init__(self, function, mobject, **kwargs):
|
||||
digest_config(self, kwargs, locals())
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
|
||||
def update_mobject(self, alpha):
|
||||
if hasattr(self, "last_alpha"):
|
||||
dt = self.virtual_time*(alpha-self.last_alpha)
|
||||
self.mobject.apply_function(
|
||||
lambda p : p + dt*self.function(p)
|
||||
)
|
||||
self.last_alpha = alpha
|
||||
|
||||
class MoveAlongPath(Animation):
|
||||
def __init__(self, mobject, path, **kwargs):
|
||||
digest_config(self, kwargs, locals())
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
|
||||
def update_mobject(self, alpha):
|
||||
point = self.path.point_from_proportion(alpha)
|
||||
self.mobject.move_to(point)
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
import numpy as np
|
||||
import operator as op
|
||||
|
||||
from .animation import Animation
|
||||
from transform import Transform
|
||||
from mobject.mobject import Mobject
|
||||
from mobject.point_cloud_mobject import Mobject1D
|
||||
from topics.geometry import Line
|
||||
from utils.paths import path_along_arc
|
||||
|
||||
from constants import *
|
||||
|
||||
class Vibrate(Animation):
|
||||
CONFIG = {
|
||||
"spatial_period" : 6,
|
||||
"temporal_period" : 1,
|
||||
"overtones" : 4,
|
||||
"amplitude" : 0.5,
|
||||
"radius" : FRAME_X_RADIUS/2,
|
||||
"run_time" : 3.0,
|
||||
"rate_func" : None
|
||||
}
|
||||
def __init__(self, mobject = None, **kwargs):
|
||||
if mobject is None:
|
||||
mobject = Line(3*LEFT, 3*RIGHT)
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
|
||||
def wave_function(self, x, t):
|
||||
return sum([
|
||||
reduce(op.mul, [
|
||||
self.amplitude/(k**2), #Amplitude
|
||||
np.sin(2*np.pi*(k**1.5)*t/self.temporal_period), #Frequency
|
||||
np.sin(2*np.pi*k*x/self.spatial_period) #Number of waves
|
||||
])
|
||||
for k in range(1, self.overtones+1)
|
||||
])
|
||||
|
||||
|
||||
def update_mobject(self, alpha):
|
||||
time = alpha*self.run_time
|
||||
families = map(
|
||||
Mobject.submobject_family,
|
||||
[self.mobject, self.starting_mobject]
|
||||
)
|
||||
for mob, start in zip(*families):
|
||||
mob.points = np.apply_along_axis(
|
||||
lambda (x, y, z) : (x, y + self.wave_function(x, time), z),
|
||||
1, start.points
|
||||
)
|
||||
|
||||
|
||||
class TurnInsideOut(Transform):
|
||||
CONFIG = {
|
||||
"path_func" : path_along_arc(np.pi/2)
|
||||
}
|
||||
def __init__(self, mobject, **kwargs):
|
||||
mobject.sort_points(np.linalg.norm)
|
||||
mob_copy = mobject.copy()
|
||||
mob_copy.sort_points(lambda p : -np.linalg.norm(p))
|
||||
Transform.__init__(self, mobject, mob_copy, **kwargs)
|
||||
|
||||
|
61
animation/rotation.py
Normal file
61
animation/rotation.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import itertools as it
|
||||
import numpy as np
|
||||
|
||||
from constants import *
|
||||
|
||||
import warnings
|
||||
|
||||
from animation.animation import Animation
|
||||
from animation.transform import Transform
|
||||
from utils.config_ops import digest_config
|
||||
|
||||
class Rotating(Animation):
|
||||
CONFIG = {
|
||||
"axis" : OUT,
|
||||
"radians" : 2*np.pi,
|
||||
"run_time" : 5,
|
||||
"rate_func" : None,
|
||||
"in_place" : True,
|
||||
"about_point" : None,
|
||||
"about_edge" : None,
|
||||
}
|
||||
def update_submobject(self, submobject, starting_submobject, alpha):
|
||||
submobject.points = np.array(starting_submobject.points)
|
||||
|
||||
def update_mobject(self, alpha):
|
||||
Animation.update_mobject(self, alpha)
|
||||
about_point = None
|
||||
if self.about_point is not None:
|
||||
about_point = self.about_point
|
||||
elif self.in_place: #This is superseeded
|
||||
self.about_point = self.mobject.get_center()
|
||||
self.mobject.rotate(
|
||||
alpha*self.radians,
|
||||
axis = self.axis,
|
||||
about_point = self.about_point,
|
||||
about_edge = self.about_edge,
|
||||
)
|
||||
|
||||
class Rotate(Transform):
|
||||
CONFIG = {
|
||||
"in_place" : False,
|
||||
"about_point" : None,
|
||||
}
|
||||
def __init__(self, mobject, angle = np.pi, axis = OUT, **kwargs):
|
||||
if "path_arc" not in kwargs:
|
||||
kwargs["path_arc"] = angle
|
||||
if "path_arc_axis" not in kwargs:
|
||||
kwargs["path_arc_axis"] = axis
|
||||
digest_config(self, kwargs, locals())
|
||||
target = mobject.copy()
|
||||
if self.in_place:
|
||||
self.about_point = mobject.get_center()
|
||||
target.rotate(
|
||||
angle,
|
||||
axis = axis,
|
||||
about_point = self.about_point,
|
||||
)
|
||||
Transform.__init__(self, mobject, target, **kwargs)
|
||||
|
|
@ -1,336 +0,0 @@
|
|||
import numpy as np
|
||||
import itertools as it
|
||||
|
||||
from constants import *
|
||||
|
||||
import warnings
|
||||
from mobject.mobject import Mobject, Group
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
from mobject.tex_mobject import TextMobject
|
||||
from .animation import Animation
|
||||
from transform import Transform
|
||||
from utils.bezier import interpolate
|
||||
from utils.config_ops import digest_config
|
||||
from utils.rate_functions import smooth, double_smooth, there_and_back, wiggle
|
||||
|
||||
class Rotating(Animation):
|
||||
CONFIG = {
|
||||
"axis" : OUT,
|
||||
"radians" : 2*np.pi,
|
||||
"run_time" : 5,
|
||||
"rate_func" : None,
|
||||
"in_place" : True,
|
||||
"about_point" : None,
|
||||
"about_edge" : None,
|
||||
}
|
||||
def update_submobject(self, submobject, starting_submobject, alpha):
|
||||
submobject.points = np.array(starting_submobject.points)
|
||||
|
||||
def update_mobject(self, alpha):
|
||||
Animation.update_mobject(self, alpha)
|
||||
about_point = None
|
||||
if self.about_point is not None:
|
||||
about_point = self.about_point
|
||||
elif self.in_place: #This is superseeded
|
||||
self.about_point = self.mobject.get_center()
|
||||
self.mobject.rotate(
|
||||
alpha*self.radians,
|
||||
axis = self.axis,
|
||||
about_point = self.about_point,
|
||||
about_edge = self.about_edge,
|
||||
)
|
||||
|
||||
class ShowPartial(Animation):
|
||||
def update_submobject(self, submobject, starting_submobject, alpha):
|
||||
submobject.pointwise_become_partial(
|
||||
starting_submobject, *self.get_bounds(alpha)
|
||||
)
|
||||
|
||||
def get_bounds(self, alpha):
|
||||
raise Exception("Not Implemented")
|
||||
|
||||
class ShowCreation(ShowPartial):
|
||||
CONFIG = {
|
||||
"submobject_mode" : "one_at_a_time",
|
||||
}
|
||||
def get_bounds(self, alpha):
|
||||
return (0, alpha)
|
||||
|
||||
class Uncreate(ShowCreation):
|
||||
CONFIG = {
|
||||
"rate_func" : lambda t : smooth(1-t),
|
||||
"remover" : True
|
||||
}
|
||||
|
||||
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,
|
||||
"stroke_width" : 2,
|
||||
"stroke_color" : None,
|
||||
"rate_func" : double_smooth,
|
||||
}
|
||||
def __init__(self, vmobject, **kwargs):
|
||||
if not isinstance(vmobject, VMobject):
|
||||
raise Exception("DrawBorderThenFill only works for VMobjects")
|
||||
self.reached_halfway_point_before = False
|
||||
Animation.__init__(self, vmobject, **kwargs)
|
||||
|
||||
def update_submobject(self, submobject, starting_submobject, alpha):
|
||||
submobject.pointwise_become_partial(
|
||||
starting_submobject, 0, min(2*alpha, 1)
|
||||
)
|
||||
if alpha < 0.5:
|
||||
if self.stroke_color:
|
||||
color = self.stroke_color
|
||||
elif starting_submobject.stroke_width > 0:
|
||||
color = starting_submobject.get_stroke_color()
|
||||
else:
|
||||
color = starting_submobject.get_color()
|
||||
submobject.set_stroke(color, width = self.stroke_width)
|
||||
submobject.set_fill(opacity = 0)
|
||||
else:
|
||||
if not self.reached_halfway_point_before:
|
||||
self.reached_halfway_point_before = True
|
||||
submobject.points = np.array(starting_submobject.points)
|
||||
width, opacity = [
|
||||
interpolate(start, end, 2*alpha - 1)
|
||||
for start, end in [
|
||||
(self.stroke_width, starting_submobject.get_stroke_width()),
|
||||
(0, starting_submobject.get_fill_opacity())
|
||||
]
|
||||
]
|
||||
submobject.set_stroke(width = width)
|
||||
submobject.set_fill(opacity = opacity)
|
||||
|
||||
class ShowPassingFlash(ShowPartial):
|
||||
CONFIG = {
|
||||
"time_width" : 0.1,
|
||||
"remover" : True,
|
||||
}
|
||||
def get_bounds(self, alpha):
|
||||
alpha *= (1+self.time_width)
|
||||
alpha -= self.time_width/2.0
|
||||
lower = max(0, alpha - self.time_width/2.0)
|
||||
upper = min(1, alpha + self.time_width/2.0)
|
||||
return (lower, upper)
|
||||
|
||||
def clean_up(self, *args, **kwargs):
|
||||
ShowPartial.clean_up(self, *args, **kwargs)
|
||||
for submob, start_submob in self.get_all_families_zipped():
|
||||
submob.pointwise_become_partial(start_submob, 0, 1)
|
||||
|
||||
class ShowCreationThenDestruction(ShowPassingFlash):
|
||||
CONFIG = {
|
||||
"time_width" : 2.0,
|
||||
"run_time" : 1,
|
||||
}
|
||||
|
||||
class Homotopy(Animation):
|
||||
CONFIG = {
|
||||
"run_time" : 3,
|
||||
"apply_function_kwargs" : {},
|
||||
}
|
||||
def __init__(self, homotopy, mobject, **kwargs):
|
||||
"""
|
||||
Homotopy a function from (x, y, z, t) to (x', y', z')
|
||||
"""
|
||||
def function_at_time_t(t):
|
||||
return lambda p : homotopy(p[0], p[1], p[2], t)
|
||||
self.function_at_time_t = function_at_time_t
|
||||
digest_config(self, kwargs)
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
|
||||
def update_submobject(self, submob, start, alpha):
|
||||
submob.points = start.points
|
||||
submob.apply_function(
|
||||
self.function_at_time_t(alpha),
|
||||
**self.apply_function_kwargs
|
||||
)
|
||||
|
||||
class SmoothedVectorizedHomotopy(Homotopy):
|
||||
def update_submobject(self, submob, start, alpha):
|
||||
Homotopy.update_submobject(self, submob, start, alpha)
|
||||
submob.make_smooth()
|
||||
|
||||
class ApplyWave(Homotopy):
|
||||
CONFIG = {
|
||||
"direction" : DOWN,
|
||||
"amplitude" : 0.2,
|
||||
"run_time" : 1,
|
||||
"apply_function_kwargs" : {
|
||||
"maintain_smoothness" : False,
|
||||
},
|
||||
}
|
||||
def __init__(self, mobject, **kwargs):
|
||||
digest_config(self, kwargs, locals())
|
||||
left_x = mobject.get_left()[0]
|
||||
right_x = mobject.get_right()[0]
|
||||
vect = self.amplitude*self.direction
|
||||
def homotopy(x, y, z, t):
|
||||
start_point = np.array([x, y, z])
|
||||
alpha = (x-left_x)/(right_x-left_x)
|
||||
power = np.exp(2*(alpha-0.5))
|
||||
nudge = there_and_back(t**power)
|
||||
return np.array([x, y, z]) + nudge*vect
|
||||
Homotopy.__init__(self, homotopy, mobject, **kwargs)
|
||||
|
||||
class PhaseFlow(Animation):
|
||||
CONFIG = {
|
||||
"virtual_time" : 1,
|
||||
"rate_func" : None,
|
||||
}
|
||||
def __init__(self, function, mobject, **kwargs):
|
||||
digest_config(self, kwargs, locals())
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
|
||||
def update_mobject(self, alpha):
|
||||
if hasattr(self, "last_alpha"):
|
||||
dt = self.virtual_time*(alpha-self.last_alpha)
|
||||
self.mobject.apply_function(
|
||||
lambda p : p + dt*self.function(p)
|
||||
)
|
||||
self.last_alpha = alpha
|
||||
|
||||
class MoveAlongPath(Animation):
|
||||
def __init__(self, mobject, path, **kwargs):
|
||||
digest_config(self, kwargs, locals())
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
|
||||
def update_mobject(self, alpha):
|
||||
point = self.path.point_from_proportion(alpha)
|
||||
self.mobject.move_to(point)
|
||||
|
||||
class UpdateFromFunc(Animation):
|
||||
"""
|
||||
update_function of the form func(mobject), presumably
|
||||
to be used when the state of one mobject is dependent
|
||||
on another simultaneously animated mobject
|
||||
"""
|
||||
def __init__(self, mobject, update_function, **kwargs):
|
||||
digest_config(self, kwargs, locals())
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
|
||||
def update_mobject(self, alpha):
|
||||
self.update_function(self.mobject)
|
||||
|
||||
class UpdateFromAlphaFunc(UpdateFromFunc):
|
||||
def update_mobject(self, alpha):
|
||||
self.update_function(self.mobject, alpha)
|
||||
|
||||
class MaintainPositionRelativeTo(Animation):
|
||||
CONFIG = {
|
||||
"tracked_critical_point" : ORIGIN
|
||||
}
|
||||
def __init__(self, mobject, tracked_mobject, **kwargs):
|
||||
digest_config(self, kwargs, locals())
|
||||
tcp = self.tracked_critical_point
|
||||
self.diff = mobject.get_critical_point(tcp) - \
|
||||
tracked_mobject.get_critical_point(tcp)
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
|
||||
def update_mobject(self, alpha):
|
||||
self.mobject.shift(
|
||||
self.tracked_mobject.get_critical_point(self.tracked_critical_point) - \
|
||||
self.mobject.get_critical_point(self.tracked_critical_point) + \
|
||||
self.diff
|
||||
)
|
||||
|
||||
class WiggleOutThenIn(Animation):
|
||||
CONFIG = {
|
||||
"scale_value" : 1.1,
|
||||
"rotation_angle" : 0.01*TAU,
|
||||
"n_wiggles" : 6,
|
||||
"run_time" : 2,
|
||||
"scale_about_point" : None,
|
||||
"rotate_about_point" : None,
|
||||
}
|
||||
def __init__(self, mobject, **kwargs):
|
||||
digest_config(self, kwargs)
|
||||
if self.scale_about_point is None:
|
||||
self.scale_about_point = mobject.get_center()
|
||||
if self.rotate_about_point is None:
|
||||
self.rotate_about_point = mobject.get_center()
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
|
||||
def update_submobject(self, submobject, starting_sumobject, alpha):
|
||||
submobject.points[:,:] = starting_sumobject.points
|
||||
submobject.scale(
|
||||
interpolate(1, self.scale_value, there_and_back(alpha)),
|
||||
about_point = self.scale_about_point
|
||||
)
|
||||
submobject.rotate(
|
||||
wiggle(alpha, self.n_wiggles)*self.rotation_angle,
|
||||
about_point = self.rotate_about_point
|
||||
)
|
||||
|
||||
class ApplyToCenters(Animation):
|
||||
def __init__(self, AnimationClass, mobjects, **kwargs):
|
||||
full_kwargs = AnimationClass.CONFIG
|
||||
full_kwargs.update(kwargs)
|
||||
full_kwargs["mobject"] = Mobject(*[
|
||||
mob.get_point_mobject()
|
||||
for mob in mobjects
|
||||
])
|
||||
self.centers_container = AnimationClass(**full_kwargs)
|
||||
full_kwargs.pop("mobject")
|
||||
Animation.__init__(self, Mobject(*mobjects), **full_kwargs)
|
||||
self.name = str(self) + AnimationClass.__name__
|
||||
|
||||
def update_mobject(self, alpha):
|
||||
self.centers_container.update_mobject(alpha)
|
||||
center_mobs = self.centers_container.mobject.split()
|
||||
mobjects = self.mobject.split()
|
||||
for center_mob, mobject in zip(center_mobs, mobjects):
|
||||
mobject.shift(
|
||||
center_mob.get_center()-mobject.get_center()
|
||||
)
|
||||
|
||||
class FadeInAndShiftFromDirection(Transform):
|
||||
CONFIG = {
|
||||
"direction" : DOWN,
|
||||
}
|
||||
def __init__(self, mobject, **kwargs):
|
||||
digest_config(self, kwargs)
|
||||
target = mobject.copy()
|
||||
mobject.shift(self.direction)
|
||||
mobject.fade(1)
|
||||
Transform.__init__(self, mobject, target, **kwargs)
|
||||
|
||||
# Essentially just a more convenient name for the above animation
|
||||
class FadeInFromDown(FadeInAndShiftFromDirection):
|
||||
CONFIG = {
|
||||
"direction" : DOWN,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,19 +1,18 @@
|
|||
import numpy as np
|
||||
import itertools as it
|
||||
from __future__ import absolute_import
|
||||
|
||||
import inspect
|
||||
import copy
|
||||
import warnings
|
||||
import numpy as np
|
||||
|
||||
from constants import *
|
||||
|
||||
from .animation import Animation
|
||||
from mobject.mobject import Mobject, Group
|
||||
from mobject.vectorized_mobject import VMobject, VectorizedPoint
|
||||
from topics.geometry import Dot, Circle
|
||||
from animation.animation import Animation
|
||||
from mobject.mobject import Group
|
||||
from mobject.mobject import Mobject
|
||||
from utils.config_ops import digest_config
|
||||
from utils.iterables import adjacent_pairs
|
||||
from utils.paths import straight_path, path_along_arc, counterclockwise_path
|
||||
from utils.rate_functions import smooth, there_and_back
|
||||
from utils.paths import path_along_arc
|
||||
from utils.paths import straight_path
|
||||
from utils.rate_functions import smooth
|
||||
from utils.rate_functions import squish_rate_func
|
||||
|
||||
class Transform(Animation):
|
||||
|
@ -74,7 +73,6 @@ class ReplacementTransform(Transform):
|
|||
"replace_mobject_with_target_in_scene" : True,
|
||||
}
|
||||
|
||||
|
||||
class ClockwiseTransform(Transform):
|
||||
CONFIG = {
|
||||
"path_arc" : -np.pi
|
||||
|
@ -91,54 +89,6 @@ class MoveToTarget(Transform):
|
|||
raise Exception("MoveToTarget called on mobject without attribute 'target' ")
|
||||
Transform.__init__(self, mobject, mobject.target, **kwargs)
|
||||
|
||||
class CyclicReplace(Transform):
|
||||
CONFIG = {
|
||||
"path_arc" : np.pi/2
|
||||
}
|
||||
def __init__(self, *mobjects, **kwargs):
|
||||
start = Group(*mobjects)
|
||||
target = Group(*[
|
||||
m1.copy().move_to(m2)
|
||||
for m1, m2 in adjacent_pairs(start)
|
||||
])
|
||||
Transform.__init__(self, start, target, **kwargs)
|
||||
|
||||
class Swap(CyclicReplace):
|
||||
pass #Renaming, more understandable for two entries
|
||||
|
||||
class GrowFromPoint(Transform):
|
||||
CONFIG = {
|
||||
"point_color" : None,
|
||||
}
|
||||
def __init__(self, mobject, point, **kwargs):
|
||||
digest_config(self, kwargs)
|
||||
target = mobject.copy()
|
||||
point_mob = VectorizedPoint(point)
|
||||
if self.point_color:
|
||||
point_mob.set_color(self.point_color)
|
||||
mobject.replace(point_mob)
|
||||
mobject.set_color(point_mob.get_color())
|
||||
Transform.__init__(self, mobject, target, **kwargs)
|
||||
|
||||
class GrowFromCenter(GrowFromPoint):
|
||||
def __init__(self, mobject, **kwargs):
|
||||
GrowFromPoint.__init__(self, mobject, mobject.get_center(), **kwargs)
|
||||
|
||||
class GrowArrow(GrowFromPoint):
|
||||
def __init__(self, arrow, **kwargs):
|
||||
GrowFromPoint.__init__(self, arrow, arrow.get_start(), **kwargs)
|
||||
|
||||
class SpinInFromNothing(GrowFromCenter):
|
||||
CONFIG = {
|
||||
"path_func" : counterclockwise_path()
|
||||
}
|
||||
|
||||
class ShrinkToCenter(Transform):
|
||||
def __init__(self, mobject, **kwargs):
|
||||
Transform.__init__(
|
||||
self, mobject, mobject.get_point_mobject(), **kwargs
|
||||
)
|
||||
|
||||
class ApplyMethod(Transform):
|
||||
CONFIG = {
|
||||
"submobject_mode" : "all_at_once"
|
||||
|
@ -167,94 +117,6 @@ class ApplyMethod(Transform):
|
|||
method.im_func(target, *args, **method_kwargs)
|
||||
Transform.__init__(self, method.im_self, target, **kwargs)
|
||||
|
||||
class FadeOut(Transform):
|
||||
CONFIG = {
|
||||
"remover" : True,
|
||||
}
|
||||
def __init__(self, mobject, **kwargs):
|
||||
target = mobject.copy()
|
||||
target.fade(1)
|
||||
Transform.__init__(self, mobject, target, **kwargs)
|
||||
|
||||
def clean_up(self, surrounding_scene = None):
|
||||
Transform.clean_up(self, surrounding_scene)
|
||||
self.update(0)
|
||||
|
||||
class FadeIn(Transform):
|
||||
def __init__(self, mobject, **kwargs):
|
||||
target = mobject.copy()
|
||||
Transform.__init__(self, mobject, target, **kwargs)
|
||||
self.starting_mobject.fade(1)
|
||||
if isinstance(self.starting_mobject, VMobject):
|
||||
self.starting_mobject.set_stroke(width = 0)
|
||||
self.starting_mobject.set_fill(opacity = 0)
|
||||
|
||||
class FocusOn(Transform):
|
||||
CONFIG = {
|
||||
"opacity" : 0.2,
|
||||
"color" : GREY,
|
||||
"run_time" : 2,
|
||||
"remover" : True,
|
||||
}
|
||||
def __init__(self, mobject_or_point, **kwargs):
|
||||
digest_config(self, kwargs)
|
||||
big_dot = Dot(
|
||||
radius = FRAME_X_RADIUS+FRAME_Y_RADIUS,
|
||||
stroke_width = 0,
|
||||
fill_color = self.color,
|
||||
fill_opacity = 0,
|
||||
)
|
||||
little_dot = Dot(radius = 0)
|
||||
little_dot.set_fill(self.color, opacity = self.opacity)
|
||||
little_dot.move_to(mobject_or_point)
|
||||
|
||||
Transform.__init__(self, big_dot, little_dot, **kwargs)
|
||||
|
||||
class Indicate(Transform):
|
||||
CONFIG = {
|
||||
"rate_func" : there_and_back,
|
||||
"scale_factor" : 1.2,
|
||||
"color" : YELLOW,
|
||||
}
|
||||
def __init__(self, mobject, **kwargs):
|
||||
digest_config(self, kwargs)
|
||||
target = mobject.copy()
|
||||
target.scale_in_place(self.scale_factor)
|
||||
target.set_color(self.color)
|
||||
Transform.__init__(self, mobject, target, **kwargs)
|
||||
|
||||
class CircleIndicate(Indicate):
|
||||
CONFIG = {
|
||||
"rate_func" : squish_rate_func(there_and_back, 0, 0.8),
|
||||
"remover" : True
|
||||
}
|
||||
def __init__(self, mobject, **kwargs):
|
||||
digest_config(self, kwargs)
|
||||
circle = Circle(color = self.color, **kwargs)
|
||||
circle.surround(mobject)
|
||||
Indicate.__init__(self, circle, **kwargs)
|
||||
|
||||
class Rotate(ApplyMethod):
|
||||
CONFIG = {
|
||||
"in_place" : False,
|
||||
"about_point" : None,
|
||||
}
|
||||
def __init__(self, mobject, angle = np.pi, axis = OUT, **kwargs):
|
||||
if "path_arc" not in kwargs:
|
||||
kwargs["path_arc"] = angle
|
||||
if "path_arc_axis" not in kwargs:
|
||||
kwargs["path_arc_axis"] = axis
|
||||
digest_config(self, kwargs, locals())
|
||||
target = mobject.copy()
|
||||
if self.in_place:
|
||||
self.about_point = mobject.get_center()
|
||||
target.rotate(
|
||||
angle,
|
||||
axis = axis,
|
||||
about_point = self.about_point,
|
||||
)
|
||||
Transform.__init__(self, mobject, target, **kwargs)
|
||||
|
||||
class ApplyPointwiseFunction(ApplyMethod):
|
||||
CONFIG = {
|
||||
"run_time" : DEFAULT_POINTWISE_FUNCTION_RUN_TIME
|
||||
|
@ -300,7 +162,22 @@ class ApplyMatrix(ApplyPointwiseFunction):
|
|||
return np.dot(p, transpose)
|
||||
ApplyPointwiseFunction.__init__(self, func, mobject, **kwargs)
|
||||
|
||||
class CyclicReplace(Transform):
|
||||
CONFIG = {
|
||||
"path_arc" : np.pi/2
|
||||
}
|
||||
def __init__(self, *mobjects, **kwargs):
|
||||
start = Group(*mobjects)
|
||||
target = Group(*[
|
||||
m1.copy().move_to(m2)
|
||||
for m1, m2 in adjacent_pairs(start)
|
||||
])
|
||||
Transform.__init__(self, start, target, **kwargs)
|
||||
|
||||
class Swap(CyclicReplace):
|
||||
pass #Renaming, more understandable for two entries
|
||||
|
||||
#TODO: Um...does this work
|
||||
class TransformAnimations(Transform):
|
||||
CONFIG = {
|
||||
"rate_func" : squish_rate_func(smooth)
|
||||
|
@ -330,5 +207,3 @@ class TransformAnimations(Transform):
|
|||
self.end_anim.update(alpha)
|
||||
Transform.update(self, alpha)
|
||||
|
||||
|
||||
|
||||
|
|
47
animation/update.py
Normal file
47
animation/update.py
Normal file
|
@ -0,0 +1,47 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from constants import *
|
||||
|
||||
from animation.animation import Animation
|
||||
from utils.config_ops import digest_config
|
||||
|
||||
|
||||
class UpdateFromFunc(Animation):
|
||||
"""
|
||||
update_function of the form func(mobject), presumably
|
||||
to be used when the state of one mobject is dependent
|
||||
on another simultaneously animated mobject
|
||||
"""
|
||||
def __init__(self, mobject, update_function, **kwargs):
|
||||
digest_config(self, kwargs, locals())
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
|
||||
def update_mobject(self, alpha):
|
||||
self.update_function(self.mobject)
|
||||
|
||||
class UpdateFromAlphaFunc(UpdateFromFunc):
|
||||
def update_mobject(self, alpha):
|
||||
self.update_function(self.mobject, alpha)
|
||||
|
||||
class MaintainPositionRelativeTo(Animation):
|
||||
CONFIG = {
|
||||
"tracked_critical_point" : ORIGIN
|
||||
}
|
||||
def __init__(self, mobject, tracked_mobject, **kwargs):
|
||||
digest_config(self, kwargs, locals())
|
||||
tcp = self.tracked_critical_point
|
||||
self.diff = mobject.get_critical_point(tcp) - \
|
||||
tracked_mobject.get_critical_point(tcp)
|
||||
Animation.__init__(self, mobject, **kwargs)
|
||||
|
||||
def update_mobject(self, alpha):
|
||||
self.mobject.shift(
|
||||
self.tracked_mobject.get_critical_point(self.tracked_critical_point) - \
|
||||
self.mobject.get_critical_point(self.tracked_critical_point) + \
|
||||
self.diff
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -16,14 +16,18 @@ as a convenience for scripts createing scenes for videos
|
|||
from constants import *
|
||||
|
||||
from animation.animation import *
|
||||
from animation.compositions import *
|
||||
from animation.continual_animation import *
|
||||
from animation.playground import *
|
||||
from animation.simple_animations import *
|
||||
from animation.composition import *
|
||||
from animation.creation import *
|
||||
from animation.indication import *
|
||||
from animation.movement import *
|
||||
from animation.rotation import *
|
||||
from animation.transform import *
|
||||
from animation.update import *
|
||||
|
||||
from camera.camera import *
|
||||
|
||||
from continual_animation.continual_animation import *
|
||||
|
||||
from mobject.image_mobject import *
|
||||
from mobject.mobject import *
|
||||
from mobject.point_cloud_mobject import *
|
||||
|
@ -35,7 +39,6 @@ from scene.moving_camera_scene import *
|
|||
from scene.reconfigurable_scene import *
|
||||
from scene.scene import *
|
||||
from scene.scene_from_video import *
|
||||
from scene.tk_scene import *
|
||||
from scene.zoomed_scene import *
|
||||
|
||||
from topics.arithmetic import *
|
||||
|
@ -49,7 +52,6 @@ from topics.functions import *
|
|||
from topics.geometry import *
|
||||
from topics.graph_scene import *
|
||||
from topics.graph_theory import *
|
||||
from topics.light import *
|
||||
from topics.matrix import *
|
||||
from topics.number_line import *
|
||||
from topics.numerals import *
|
||||
|
@ -70,18 +72,17 @@ from utils.sounds import *
|
|||
from utils.space_ops import *
|
||||
from utils.strings import *
|
||||
|
||||
from special_animations import *
|
||||
|
||||
# Non manim libraries that are also nice to have without thinking
|
||||
|
||||
import numpy as np
|
||||
import itertools as it
|
||||
import operator as op
|
||||
import random
|
||||
import inspect
|
||||
import string
|
||||
import re
|
||||
import itertools as it
|
||||
import numpy as np
|
||||
import operator as op
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import string
|
||||
|
||||
from PIL import Image
|
||||
from colour import Color
|
||||
|
||||
|
|
|
@ -1,23 +1,29 @@
|
|||
import numpy as np
|
||||
import itertools as it
|
||||
import numpy as np
|
||||
import os
|
||||
|
||||
from PIL import Image
|
||||
from colour import Color
|
||||
import aggdraw
|
||||
import copy
|
||||
import time
|
||||
|
||||
from PIL import Image
|
||||
from colour import Color
|
||||
|
||||
from constants import *
|
||||
from mobject.mobject import Mobject, Group
|
||||
from mobject.image_mobject import ImageMobject
|
||||
from mobject.mobject import Group
|
||||
from mobject.mobject import Mobject
|
||||
from mobject.point_cloud_mobject import PMobject
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
from mobject.image_mobject import ImageMobject
|
||||
from utils.color import rgb_to_hex, color_to_int_rgba
|
||||
from utils.config_ops import digest_config, digest_locals, DictAsObject
|
||||
from utils.color import color_to_int_rgba
|
||||
from utils.color import rgb_to_hex
|
||||
from utils.config_ops import DictAsObject
|
||||
from utils.config_ops import digest_config
|
||||
from utils.config_ops import digest_locals
|
||||
from utils.images import get_full_raster_image_path
|
||||
from utils.iterables import remove_list_redundancies, list_difference_update
|
||||
from utils.iterables import batch_by_property
|
||||
from utils.iterables import list_difference_update
|
||||
from utils.iterables import remove_list_redundancies
|
||||
from utils.simple_functions import fdiv
|
||||
|
||||
|
||||
|
|
0
continual_animation/__init__.py
Normal file
0
continual_animation/__init__.py
Normal file
|
@ -1,6 +1,6 @@
|
|||
from constants import *
|
||||
from mobject.mobject import Mobject, Group
|
||||
from simple_animations import MaintainPositionRelativeTo
|
||||
from animation.update import MaintainPositionRelativeTo
|
||||
import copy
|
||||
from utils.config_ops import instantiate
|
||||
from utils.config_ops import digest_config
|
|
@ -4,17 +4,18 @@ import sys
|
|||
# import getopt
|
||||
import argparse
|
||||
import imp
|
||||
import itertools as it
|
||||
import inspect
|
||||
import traceback
|
||||
import imp
|
||||
import inspect
|
||||
import itertools as it
|
||||
import os
|
||||
import subprocess as sp
|
||||
import traceback
|
||||
|
||||
from camera.camera import Camera
|
||||
from constants import *
|
||||
from scene.scene import Scene
|
||||
from camera.camera import Camera
|
||||
from utils.sounds import play_error_sound, play_finish_sound
|
||||
from utils.sounds import play_error_sound
|
||||
from utils.sounds import play_finish_sound
|
||||
|
||||
HELP_MESSAGE = """
|
||||
Usage:
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
import numpy as np
|
||||
from __future__ import absolute_import
|
||||
|
||||
import itertools as it
|
||||
import numpy as np
|
||||
import os
|
||||
|
||||
from PIL import Image
|
||||
from random import random
|
||||
|
||||
from mobject.mobject import Mobject
|
||||
from constants import *
|
||||
from .mobject import Mobject
|
||||
from point_cloud_mobject import PMobject
|
||||
from mobject.point_cloud_mobject import PMobject
|
||||
from utils.bezier import interpolate
|
||||
from utils.color import color_to_int_rgb
|
||||
from utils.color import interpolate_color
|
||||
|
|
|
@ -1,20 +1,25 @@
|
|||
import copy
|
||||
import itertools as it
|
||||
import numpy as np
|
||||
import operator as op
|
||||
import itertools as it
|
||||
import os
|
||||
import copy
|
||||
|
||||
from PIL import Image
|
||||
from colour import Color
|
||||
|
||||
from constants import *
|
||||
from container.container import Container
|
||||
from utils.bezier import interpolate
|
||||
from utils.color import color_to_rgb, color_gradient
|
||||
from utils.color import color_gradient
|
||||
from utils.color import color_to_rgb
|
||||
from utils.color import interpolate_color
|
||||
from utils.iterables import remove_list_redundancies, list_update
|
||||
from utils.iterables import list_update
|
||||
from utils.iterables import remove_list_redundancies
|
||||
from utils.paths import straight_path
|
||||
from utils.space_ops import rotation_matrix, angle_of_vector
|
||||
from utils.space_ops import complex_to_R3, R3_to_complex
|
||||
from utils.space_ops import R3_to_complex
|
||||
from utils.space_ops import angle_of_vector
|
||||
from utils.space_ops import complex_to_R3
|
||||
from utils.space_ops import rotation_matrix
|
||||
|
||||
|
||||
#TODO: Explain array_attrs
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from mobject.mobject import Mobject
|
||||
from constants import *
|
||||
from .mobject import Mobject
|
||||
from utils.bezier import interpolate
|
||||
from utils.color import color_to_rgb, color_to_rgba, rgba_to_color
|
||||
from utils.color import color_gradient
|
||||
from utils.color import color_to_rgb
|
||||
from utils.color import color_to_rgba
|
||||
from utils.color import interpolate_color
|
||||
from utils.color import rgba_to_color
|
||||
from utils.config_ops import digest_config
|
||||
from utils.iterables import stretch_array_to_length
|
||||
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
from xml.dom import minidom
|
||||
import itertools as it
|
||||
import re
|
||||
import warnings
|
||||
import string
|
||||
import warnings
|
||||
|
||||
from xml.dom import minidom
|
||||
|
||||
from constants import *
|
||||
from vectorized_mobject import VMobject, VGroup
|
||||
from topics.geometry import Rectangle, Circle
|
||||
from topics.geometry import Circle
|
||||
from topics.geometry import Rectangle
|
||||
from utils.bezier import is_closed
|
||||
from utils.config_ops import digest_config, digest_locals
|
||||
from utils.config_ops import digest_config
|
||||
from utils.config_ops import digest_locals
|
||||
from vectorized_mobject import VGroup
|
||||
from vectorized_mobject import VMobject
|
||||
|
||||
def string_to_numbers(num_string):
|
||||
num_string = num_string.replace("-",",-")
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
from constants import *
|
||||
|
||||
from vectorized_mobject import VMobject, VGroup, VectorizedPoint
|
||||
from svg_mobject import SVGMobject, VMobjectFromSVGPathstring
|
||||
from svg_mobject import SVGMobject
|
||||
from svg_mobject import VMobjectFromSVGPathstring
|
||||
from topics.geometry import BackgroundRectangle
|
||||
from utils.config_ops import digest_config
|
||||
from vectorized_mobject import VGroup
|
||||
from vectorized_mobject import VMobject
|
||||
from vectorized_mobject import VectorizedPoint
|
||||
|
||||
import collections
|
||||
import sys
|
||||
import operator as op
|
||||
import sys
|
||||
|
||||
TEX_MOB_SCALE_FACTOR = 0.05
|
||||
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import re
|
||||
|
||||
from colour import Color
|
||||
|
||||
from mobject.mobject import Mobject
|
||||
from constants import *
|
||||
from .mobject import Mobject
|
||||
from utils.bezier import bezier, partial_bezier_points
|
||||
from utils.bezier import interpolate, get_smooth_handle_points, is_closed
|
||||
from utils.bezier import bezier
|
||||
from utils.bezier import get_smooth_handle_points
|
||||
from utils.bezier import interpolate
|
||||
from utils.bezier import is_closed
|
||||
from utils.bezier import partial_bezier_points
|
||||
from utils.color import color_to_rgb
|
||||
from utils.color import interpolate_color
|
||||
from utils.iterables import make_even
|
||||
|
|
|
@ -1,31 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from constants import *
|
||||
from big_ol_pile_of_manim_imports import *
|
||||
|
||||
from mobject.tex_mobject import TexMobject
|
||||
from mobject.mobject import Mobject
|
||||
from mobject.image_mobject import ImageMobject
|
||||
from mobject.vectorized_mobject import *
|
||||
|
||||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.continual_animation import *
|
||||
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
from topics.functions import *
|
||||
from topics.number_line import *
|
||||
from topics.numerals import *
|
||||
from scene.scene import Scene
|
||||
from camera.camera import Camera
|
||||
from mobject.svg_mobject import *
|
||||
from mobject.tex_mobject import *
|
||||
from topics.three_dimensions import *
|
||||
|
||||
from topics.light import *
|
||||
from old_projects.basel.light import *
|
||||
|
||||
import types
|
||||
import functools
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from big_ol_pile_of_manim_imports import *
|
||||
from old_projects.basel.light import *
|
||||
|
||||
import types
|
||||
import functools
|
||||
|
|
|
@ -1,31 +1,8 @@
|
|||
from constants import *
|
||||
|
||||
from mobject.tex_mobject import TexMobject
|
||||
from mobject.mobject import Mobject
|
||||
from mobject.vectorized_mobject import *
|
||||
|
||||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.continual_animation import *
|
||||
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.functions import *
|
||||
from scene.scene import Scene
|
||||
from camera.camera import Camera
|
||||
from mobject.svg_mobject import *
|
||||
from topics.three_dimensions import *
|
||||
from big_ol_pile_of_manim_imports import *
|
||||
|
||||
from scipy.spatial import ConvexHull
|
||||
from traceback import *
|
||||
|
||||
from utils.space_ops import rotation_matrix, z_to_vector
|
||||
from utils.space_ops import rotate_vector, angle_between, angle_between_vectors
|
||||
from utils.space_ops import project_along_vector
|
||||
|
||||
|
||||
LIGHT_COLOR = YELLOW
|
||||
SHADOW_COLOR = BLACK
|
||||
SWITCH_ON_RUN_TIME = 1.5
|
|
@ -15,7 +15,7 @@ from mobject.vectorized_mobject import *
|
|||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.compositions import *
|
||||
from animation.composition import *
|
||||
from animation.playground import *
|
||||
from animation.continual_animation import *
|
||||
from topics.geometry import *
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
__all__ = [
|
||||
"scene"
|
||||
]
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from constants import *
|
||||
|
||||
from scene.scene import Scene
|
||||
from camera.camera import MovingCamera
|
||||
from .scene import Scene
|
||||
from topics.geometry import ScreenRectangle
|
||||
|
||||
class MovingCameraScene(Scene):
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import numpy as np
|
||||
|
||||
from .scene import Scene
|
||||
from scene.scene import Scene
|
||||
from animation.transform import Transform
|
||||
from mobject.mobject import Mobject
|
||||
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
import copy
|
||||
import inspect
|
||||
import itertools as it
|
||||
import numpy as np
|
||||
import os
|
||||
import random
|
||||
import shutil
|
||||
import subprocess as sp
|
||||
import time
|
||||
import warnings
|
||||
|
||||
from PIL import Image
|
||||
from colour import Color
|
||||
import numpy as np
|
||||
import itertools as it
|
||||
import warnings
|
||||
import time
|
||||
import os
|
||||
import shutil
|
||||
import copy
|
||||
from tqdm import tqdm as ProgressDisplay
|
||||
import inspect
|
||||
import subprocess as sp
|
||||
import random
|
||||
|
||||
from constants import *
|
||||
|
||||
from camera.camera import Camera
|
||||
from tk_scene import TkSceneRoot
|
||||
from mobject.mobject import Mobject
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
from animation.animation import Animation
|
||||
from animation.transform import MoveToTarget
|
||||
from animation.continual_animation import ContinualAnimation
|
||||
from camera.camera import Camera
|
||||
from continual_animation.continual_animation import ContinualAnimation
|
||||
from mobject.mobject import Mobject
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
from utils.iterables import list_update
|
||||
|
||||
from container.container import Container
|
||||
|
@ -538,9 +538,6 @@ class Scene(Container):
|
|||
self.update_frame(dont_update_when_skipping = False)
|
||||
self.get_image().show()
|
||||
|
||||
def preview(self):
|
||||
TkSceneRoot(self)
|
||||
|
||||
def get_image_file_path(self, name = None, dont_update = False):
|
||||
folder = "images"
|
||||
if dont_update:
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import numpy as np
|
||||
from __future__ import absolute_import
|
||||
|
||||
import cv2
|
||||
import itertools as it
|
||||
import numpy as np
|
||||
|
||||
from tqdm import tqdm as show_progress
|
||||
|
||||
from .scene import Scene
|
||||
from scene.scene import Scene
|
||||
|
||||
|
||||
class SceneFromVideo(Scene):
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
import Tkinter
|
||||
from PIL import ImageTk, Image
|
||||
import itertools as it
|
||||
import time
|
||||
|
||||
|
||||
class TkSceneRoot(Tkinter.Tk):
|
||||
def __init__(self, scene):
|
||||
if scene.saved_frames == []:
|
||||
raise Exception(str(scene) + " has no frames!")
|
||||
Tkinter.Tk.__init__(self)
|
||||
|
||||
kwargs = {
|
||||
"height" : scene.camera.pixel_shape[0],
|
||||
"width" : scene.camera.pixel_shape[1],
|
||||
}
|
||||
self.frame = Tkinter.Frame(self, **kwargs)
|
||||
self.frame.pack()
|
||||
self.canvas = Tkinter.Canvas(self.frame, **kwargs)
|
||||
self.canvas.configure(background='black')
|
||||
self.canvas.place(x=0, y=0)
|
||||
|
||||
last_time = time.time()
|
||||
for frame in it.cycle(scene.saved_frames):
|
||||
# try:
|
||||
# self.show_new_image(frame)
|
||||
# except:
|
||||
# break
|
||||
self.show_new_image(frame)
|
||||
sleep_time = scene.frame_duration
|
||||
sleep_time -= time.time() - last_time
|
||||
time.sleep(max(0, sleep_time))
|
||||
last_time = time.time()
|
||||
self.mainloop()
|
||||
|
||||
def show_new_image(self, frame):
|
||||
image = Image.fromarray(frame.astype('uint8')).convert('RGB')
|
||||
photo = ImageTk.PhotoImage(image)
|
||||
self.canvas.delete(Tkinter.ALL)
|
||||
self.canvas.create_image(
|
||||
0, 0,
|
||||
image = photo, anchor = Tkinter.NW
|
||||
)
|
||||
self.update()
|
|
@ -1,11 +1,13 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import numpy as np
|
||||
|
||||
from .scene import Scene
|
||||
from animation.transform import FadeIn
|
||||
from mobject.mobject import Mobject
|
||||
from topics.geometry import Rectangle
|
||||
from scene.scene import Scene
|
||||
from animation.creation import FadeIn
|
||||
from camera.camera import Camera
|
||||
from camera.camera import MovingCamera
|
||||
from mobject.mobject import Mobject
|
||||
from topics.geometry import Rectangle
|
||||
|
||||
from constants import *
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
import sys
|
||||
import inspect
|
||||
import itertools as it
|
||||
import os
|
||||
import shutil
|
||||
import itertools as it
|
||||
from extract_scene import is_scene, get_module
|
||||
from constants import ANIMATIONS_DIR, STAGED_SCENES_DIR
|
||||
import sys
|
||||
|
||||
from constants import ANIMATIONS_DIR
|
||||
from constants import STAGED_SCENES_DIR
|
||||
from extract_scene import get_module
|
||||
from extract_scene import is_scene
|
||||
|
||||
|
||||
def get_sorted_scene_names(module_name):
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
__all__ = [
|
||||
"arithmetic",
|
||||
"characters",
|
||||
"combinatorics",
|
||||
"complex_numbers",
|
||||
"functions",
|
||||
"geometry",
|
||||
"graph_theory",
|
||||
"number_line",
|
||||
"three_dimensions",
|
||||
]
|
|
@ -1,10 +1,10 @@
|
|||
import numpy as np
|
||||
import itertools as it
|
||||
import numpy as np
|
||||
|
||||
from constants import *
|
||||
from scene.scene import Scene
|
||||
from animation.animation import Animation
|
||||
from constants import *
|
||||
from mobject.tex_mobject import TexMobject
|
||||
from scene.scene import Scene
|
||||
|
||||
class RearrangeEquation(Scene):
|
||||
def construct(
|
||||
|
|
|
@ -1,25 +1,36 @@
|
|||
import random
|
||||
import numpy as np
|
||||
import itertools as it
|
||||
import numpy as np
|
||||
import random
|
||||
|
||||
from constants import *
|
||||
|
||||
from mobject.mobject import Mobject, Group
|
||||
from mobject.mobject import Group
|
||||
from mobject.mobject import Mobject
|
||||
from mobject.svg_mobject import SVGMobject
|
||||
from mobject.vectorized_mobject import VMobject, VGroup
|
||||
from mobject.tex_mobject import TextMobject, TexMobject
|
||||
from mobject.tex_mobject import TexMobject
|
||||
from mobject.tex_mobject import TextMobject
|
||||
from mobject.vectorized_mobject import VGroup
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
|
||||
from topics.objects import Bubble, ThoughtBubble, SpeechBubble
|
||||
from topics.geometry import ScreenRectangle
|
||||
from topics.objects import Bubble
|
||||
from topics.objects import SpeechBubble
|
||||
from topics.objects import ThoughtBubble
|
||||
|
||||
from animation.animation import Animation
|
||||
from animation.transform import Transform, ApplyMethod, MoveToTarget
|
||||
from animation.transform import ReplacementTransform, FadeOut, FadeIn
|
||||
from animation.simple_animations import Write, ShowCreation
|
||||
from animation.compositions import AnimationGroup
|
||||
from animation.composition import AnimationGroup
|
||||
from animation.creation import ShowCreation
|
||||
from animation.creation import Write
|
||||
from animation.transform import ApplyMethod
|
||||
from animation.creation import FadeIn
|
||||
from animation.creation import FadeOut
|
||||
from animation.transform import MoveToTarget
|
||||
from animation.transform import ReplacementTransform
|
||||
from animation.transform import Transform
|
||||
from scene.scene import Scene
|
||||
from utils.config_ops import digest_config
|
||||
from utils.rate_functions import there_and_back, squish_rate_func
|
||||
from utils.rate_functions import squish_rate_func
|
||||
from utils.rate_functions import there_and_back
|
||||
|
||||
|
||||
PI_CREATURE_DIR = os.path.join(MEDIA_DIR, "designs", "PiCreature")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from constants import *
|
||||
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
from mobject.tex_mobject import TexMobject
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
|
||||
from scene.scene import Scene
|
||||
from utils.simple_functions import choose
|
||||
|
|
|
@ -1,16 +1,24 @@
|
|||
|
||||
from constants import *
|
||||
|
||||
from scene.scene import Scene
|
||||
from animation.animation import Animation
|
||||
from animation.simple_animations import Write, DrawBorderThenFill
|
||||
from animation.compositions import LaggedStart
|
||||
from animation.transform import FadeIn, FadeOut, ApplyMethod
|
||||
from animation.composition import LaggedStart
|
||||
from animation.creation import DrawBorderThenFill
|
||||
from animation.creation import Write
|
||||
from animation.transform import ApplyMethod
|
||||
from animation.creation import FadeIn
|
||||
from animation.creation import FadeOut
|
||||
from mobject.tex_mobject import TexMobject
|
||||
from mobject.tex_mobject import TextMobject
|
||||
from mobject.vectorized_mobject import VGroup
|
||||
from mobject.tex_mobject import TexMobject, TextMobject
|
||||
from topics.characters import Mortimer, Randolph, Blink
|
||||
from scene.scene import Scene
|
||||
from topics.characters import Blink
|
||||
from topics.characters import Mortimer
|
||||
from topics.characters import Randolph
|
||||
from topics.geometry import DashedLine
|
||||
from topics.geometry import Rectangle
|
||||
from topics.geometry import Square
|
||||
from topics.objects import PatreonLogo
|
||||
from topics.geometry import Square, Rectangle, DashedLine
|
||||
|
||||
|
||||
class OpeningQuote(Scene):
|
||||
|
|
|
@ -1,18 +1,22 @@
|
|||
from constants import *
|
||||
|
||||
|
||||
from mobject.vectorized_mobject import VGroup
|
||||
from mobject.tex_mobject import TexMobject, TextMobject
|
||||
from number_line import NumberPlane
|
||||
from animation.animation import Animation
|
||||
from animation.transform import ApplyPointwiseFunction, MoveToTarget
|
||||
from animation.simple_animations import Homotopy, ShowCreation, \
|
||||
SmoothedVectorizedHomotopy
|
||||
from animation.movement import Homotopy
|
||||
from animation.creation import ShowCreation
|
||||
from animation.movement import SmoothedVectorizedHomotopy
|
||||
from animation.transform import ApplyPointwiseFunction
|
||||
from animation.transform import MoveToTarget
|
||||
from mobject.tex_mobject import TexMobject
|
||||
from mobject.tex_mobject import TextMobject
|
||||
from mobject.vectorized_mobject import VGroup
|
||||
from number_line import NumberPlane
|
||||
from scene.scene import Scene
|
||||
from utils.config_ops import instantiate
|
||||
from utils.config_ops import digest_config
|
||||
from utils.config_ops import instantiate
|
||||
from utils.paths import path_along_arc
|
||||
from utils.space_ops import complex_to_R3, R3_to_complex
|
||||
from utils.space_ops import R3_to_complex
|
||||
from utils.space_ops import complex_to_R3
|
||||
|
||||
|
||||
class ComplexTransformationScene(Scene):
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
from constants import *
|
||||
|
||||
from mobject.tex_mobject import TexMobject, TextMobject
|
||||
from mobject.mobject import Mobject
|
||||
from mobject.vectorized_mobject import VMobject, VGroup
|
||||
from mobject.tex_mobject import TexMobject
|
||||
from mobject.tex_mobject import TextMobject
|
||||
from mobject.vectorized_mobject import VGroup
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
|
||||
from animation.transform import Transform, FadeIn, MoveToTarget
|
||||
from animation.simple_animations import ShowCreation
|
||||
from topics.geometry import Arrow, Circle, Dot
|
||||
from animation.creation import ShowCreation
|
||||
from animation.creation import FadeIn
|
||||
from animation.transform import MoveToTarget
|
||||
from animation.transform import Transform
|
||||
from topics.geometry import Arrow
|
||||
from topics.geometry import Circle
|
||||
from topics.geometry import Dot
|
||||
# from topics.fractals import *
|
||||
from scene.scene import Scene
|
||||
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
# from mobject.mobject import Mobject, Point, Mobject1D
|
||||
from mobject.vectorized_mobject import VMobject, VGroup, VectorizedPoint
|
||||
from scene.scene import Scene
|
||||
from animation.creation import ShowCreation
|
||||
from animation.transform import Transform
|
||||
from animation.simple_animations import ShowCreation
|
||||
from topics.geometry import Line, Polygon, RegularPolygon, Square, Circle
|
||||
from characters import PiCreature, Randolph, get_all_pi_creature_modes
|
||||
from characters import PiCreature
|
||||
from characters import Randolph
|
||||
from characters import get_all_pi_creature_modes
|
||||
from mobject.vectorized_mobject import VGroup
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
from mobject.vectorized_mobject import VectorizedPoint
|
||||
from scene.scene import Scene
|
||||
from topics.geometry import Circle
|
||||
from topics.geometry import Line
|
||||
from topics.geometry import Polygon
|
||||
from topics.geometry import RegularPolygon
|
||||
from topics.geometry import Square
|
||||
from utils.bezier import interpolate
|
||||
from utils.color import color_gradient
|
||||
from utils.config_ops import digest_config
|
||||
from utils.space_ops import rotation_matrix, rotate_vector, compass_directions, center_of_mass
|
||||
from utils.space_ops import center_of_mass
|
||||
from utils.space_ops import compass_directions
|
||||
from utils.space_ops import rotate_vector
|
||||
from utils.space_ops import rotation_matrix
|
||||
|
||||
from constants import *
|
||||
|
||||
|
|
|
@ -4,11 +4,16 @@ import itertools as it
|
|||
import numpy as np
|
||||
|
||||
from mobject.mobject import Mobject
|
||||
from mobject.vectorized_mobject import VMobject, VGroup
|
||||
from mobject.vectorized_mobject import VGroup
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
from utils.bezier import interpolate
|
||||
from utils.config_ops import digest_config, digest_locals
|
||||
from utils.config_ops import digest_config
|
||||
from utils.config_ops import digest_locals
|
||||
from utils.paths import path_along_arc
|
||||
from utils.space_ops import rotate_vector, angle_of_vector, compass_directions, center_of_mass
|
||||
from utils.space_ops import angle_of_vector
|
||||
from utils.space_ops import center_of_mass
|
||||
from utils.space_ops import compass_directions
|
||||
from utils.space_ops import rotate_vector
|
||||
|
||||
class Arc(VMobject):
|
||||
CONFIG = {
|
||||
|
|
|
@ -2,16 +2,22 @@ from constants import *
|
|||
|
||||
from scene.scene import Scene
|
||||
# from topics.geometry import
|
||||
from mobject.tex_mobject import TexMobject, TextMobject
|
||||
from mobject.vectorized_mobject import VGroup, VectorizedPoint
|
||||
from animation.simple_animations import Write, ShowCreation, UpdateFromAlphaFunc
|
||||
from animation.creation import ShowCreation
|
||||
from animation.update import UpdateFromAlphaFunc
|
||||
from animation.creation import Write
|
||||
from animation.transform import Transform
|
||||
from topics.number_line import NumberLine
|
||||
from mobject.tex_mobject import TexMobject
|
||||
from mobject.tex_mobject import TextMobject
|
||||
from mobject.vectorized_mobject import VGroup
|
||||
from mobject.vectorized_mobject import VectorizedPoint
|
||||
from topics.functions import ParametricFunction
|
||||
from topics.geometry import Rectangle, DashedLine, Line
|
||||
from topics.geometry import DashedLine
|
||||
from topics.geometry import Line
|
||||
from topics.geometry import Rectangle
|
||||
from topics.number_line import NumberLine
|
||||
from utils.bezier import interpolate
|
||||
from utils.color import invert_color
|
||||
from utils.color import color_gradient
|
||||
from utils.color import invert_color
|
||||
from utils.space_ops import angle_of_vector
|
||||
|
||||
class GraphScene(Scene):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import itertools as it
|
||||
import numpy as np
|
||||
import operator as op
|
||||
|
||||
from random import random
|
||||
|
||||
from constants import *
|
||||
|
|
|
@ -1,14 +1,26 @@
|
|||
import numpy as np
|
||||
|
||||
from scene.scene import Scene
|
||||
from animation.creation import ShowCreation
|
||||
from animation.creation import Write
|
||||
from animation.transform import ApplyFunction
|
||||
from animation.transform import ApplyMethod
|
||||
from animation.transform import ApplyPointwiseFunction
|
||||
from animation.creation import FadeOut
|
||||
from animation.transform import Transform
|
||||
from mobject.mobject import Mobject
|
||||
from mobject.vectorized_mobject import VMobject, VGroup
|
||||
from mobject.tex_mobject import TexMobject, TextMobject
|
||||
from animation.transform import ApplyPointwiseFunction, Transform, \
|
||||
ApplyMethod, FadeOut, ApplyFunction
|
||||
from animation.simple_animations import ShowCreation, Write
|
||||
from topics.number_line import NumberPlane, Axes
|
||||
from topics.geometry import Vector, Line, Circle, Arrow, Dot, BackgroundRectangle
|
||||
from mobject.tex_mobject import TexMobject
|
||||
from mobject.tex_mobject import TextMobject
|
||||
from mobject.vectorized_mobject import VGroup
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
from scene.scene import Scene
|
||||
from topics.geometry import Arrow
|
||||
from topics.geometry import BackgroundRectangle
|
||||
from topics.geometry import Circle
|
||||
from topics.geometry import Dot
|
||||
from topics.geometry import Line
|
||||
from topics.geometry import Vector
|
||||
from topics.number_line import Axes
|
||||
from topics.number_line import NumberPlane
|
||||
|
||||
from constants import *
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
from constants import *
|
||||
|
||||
from mobject.vectorized_mobject import VMobject, VGroup
|
||||
from mobject.tex_mobject import TexMobject
|
||||
from topics.geometry import Line, Arrow
|
||||
from topics.functions import ParametricFunction
|
||||
from mobject.vectorized_mobject import VGroup
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
from scene.scene import Scene
|
||||
from topics.functions import ParametricFunction
|
||||
from topics.geometry import Arrow
|
||||
from topics.geometry import Line
|
||||
from utils.bezier import interpolate
|
||||
from utils.config_ops import digest_config
|
||||
from utils.space_ops import angle_of_vector
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
|
||||
from mobject.vectorized_mobject import VMobject, VGroup, VectorizedPoint
|
||||
from mobject.tex_mobject import TexMobject
|
||||
from animation.animation import Animation
|
||||
from animation.continual_animation import ContinualAnimation
|
||||
from topics.geometry import BackgroundRectangle
|
||||
from scene.scene import Scene
|
||||
from constants import *
|
||||
from continual_animation.continual_animation import ContinualAnimation
|
||||
from mobject.tex_mobject import TexMobject
|
||||
from mobject.vectorized_mobject import VGroup
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
from mobject.vectorized_mobject import VectorizedPoint
|
||||
from scene.scene import Scene
|
||||
from topics.geometry import BackgroundRectangle
|
||||
from utils.bezier import interpolate
|
||||
from utils.config_ops import digest_config
|
||||
|
||||
|
|
|
@ -1,21 +1,36 @@
|
|||
from constants import *
|
||||
|
||||
from mobject.mobject import Mobject
|
||||
from mobject.vectorized_mobject import VGroup, VMobject, VectorizedPoint
|
||||
from mobject.svg_mobject import SVGMobject
|
||||
from mobject.tex_mobject import TextMobject, TexMobject, Brace
|
||||
from mobject.tex_mobject import Brace
|
||||
from mobject.tex_mobject import TexMobject
|
||||
from mobject.tex_mobject import TextMobject
|
||||
from mobject.vectorized_mobject import VGroup
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
from mobject.vectorized_mobject import VectorizedPoint
|
||||
|
||||
from animation.animation import Animation
|
||||
from animation.simple_animations import Rotating
|
||||
from animation.compositions import LaggedStart, AnimationGroup
|
||||
from animation.transform import ApplyMethod, FadeIn, GrowFromCenter
|
||||
from animation.composition import AnimationGroup
|
||||
from animation.composition import LaggedStart
|
||||
from animation.rotation import Rotating
|
||||
from animation.transform import ApplyMethod
|
||||
from animation.creation import FadeIn
|
||||
from animation.creation import GrowFromCenter
|
||||
|
||||
from topics.geometry import Circle, Line, Rectangle, Square, \
|
||||
Arc, Polygon, SurroundingRectangle
|
||||
from topics.geometry import Arc
|
||||
from topics.geometry import Circle
|
||||
from topics.geometry import Line
|
||||
from topics.geometry import Polygon
|
||||
from topics.geometry import Rectangle
|
||||
from topics.geometry import Square
|
||||
from topics.geometry import SurroundingRectangle
|
||||
from topics.three_dimensions import Cube
|
||||
from utils.config_ops import digest_config, digest_locals
|
||||
from utils.space_ops import rotate_vector, angle_of_vector
|
||||
from utils.space_ops import complex_to_R3, R3_to_complex
|
||||
from utils.config_ops import digest_config
|
||||
from utils.config_ops import digest_locals
|
||||
from utils.space_ops import R3_to_complex
|
||||
from utils.space_ops import angle_of_vector
|
||||
from utils.space_ops import complex_to_R3
|
||||
from utils.space_ops import rotate_vector
|
||||
|
||||
class Lightbulb(SVGMobject):
|
||||
CONFIG = {
|
||||
|
|
|
@ -3,17 +3,28 @@ from constants import *
|
|||
from scene.scene import Scene
|
||||
|
||||
from animation.animation import Animation
|
||||
from animation.transform import Transform, MoveToTarget
|
||||
from animation.simple_animations import UpdateFromFunc
|
||||
from animation.transform import MoveToTarget
|
||||
from animation.transform import Transform
|
||||
from animation.update import UpdateFromFunc
|
||||
|
||||
from mobject.mobject import Mobject
|
||||
from mobject.vectorized_mobject import VGroup, VMobject, VectorizedPoint
|
||||
from mobject.svg_mobject import SVGMobject
|
||||
from mobject.tex_mobject import TextMobject, TexMobject, Brace
|
||||
from topics.geometry import Circle, Line, Rectangle, Square, Arc, Polygon
|
||||
from mobject.tex_mobject import Brace
|
||||
from mobject.tex_mobject import TexMobject
|
||||
from mobject.tex_mobject import TextMobject
|
||||
from mobject.vectorized_mobject import VGroup
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
from mobject.vectorized_mobject import VectorizedPoint
|
||||
from topics.geometry import Arc
|
||||
from topics.geometry import Circle
|
||||
from topics.geometry import Line
|
||||
from topics.geometry import Polygon
|
||||
from topics.geometry import Rectangle
|
||||
from topics.geometry import Square
|
||||
|
||||
from utils.bezier import interpolate
|
||||
from utils.color import color_gradient, average_color
|
||||
from utils.color import average_color
|
||||
from utils.color import color_gradient
|
||||
from utils.config_ops import digest_config
|
||||
from utils.iterables import tuplify
|
||||
from utils.space_ops import center_of_mass
|
||||
|
|
|
@ -1,16 +1,21 @@
|
|||
|
||||
from constants import *
|
||||
|
||||
from mobject.vectorized_mobject import VGroup, VMobject, VectorizedPoint
|
||||
from topics.geometry import Square, Line
|
||||
from scene.scene import Scene
|
||||
from camera.camera import Camera
|
||||
from animation.continual_animation import AmbientMovement
|
||||
from continual_animation.continual_animation import AmbientMovement
|
||||
from animation.transform import ApplyMethod
|
||||
from camera.camera import Camera
|
||||
from mobject.vectorized_mobject import VGroup
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
from mobject.vectorized_mobject import VectorizedPoint
|
||||
from scene.scene import Scene
|
||||
from topics.geometry import Line
|
||||
from topics.geometry import Square
|
||||
|
||||
from utils.bezier import interpolate
|
||||
from utils.iterables import list_update
|
||||
from utils.space_ops import rotation_matrix, rotation_about_z, z_to_vector
|
||||
from utils.space_ops import rotation_about_z
|
||||
from utils.space_ops import rotation_matrix
|
||||
from utils.space_ops import z_to_vector
|
||||
|
||||
|
||||
class CameraWithPerspective(Camera):
|
||||
|
|
|
@ -1,20 +1,35 @@
|
|||
import numpy as np
|
||||
|
||||
from scene.scene import Scene
|
||||
from animation.animation import Animation
|
||||
from animation.creation import ShowCreation
|
||||
from animation.creation import Write
|
||||
from animation.transform import ApplyFunction
|
||||
from animation.transform import ApplyMethod
|
||||
from animation.transform import ApplyPointwiseFunction
|
||||
from animation.creation import FadeOut
|
||||
from animation.transform import Transform
|
||||
from mobject.mobject import Mobject
|
||||
from mobject.vectorized_mobject import VMobject, VGroup
|
||||
from mobject.tex_mobject import TexMobject, TextMobject
|
||||
from animation.animation import Animation
|
||||
from animation.transform import ApplyPointwiseFunction, Transform, \
|
||||
ApplyMethod, FadeOut, ApplyFunction
|
||||
from animation.simple_animations import ShowCreation, Write
|
||||
from topics.number_line import NumberPlane, Axes
|
||||
from topics.geometry import Vector, Line, Circle, Arrow, Dot, \
|
||||
BackgroundRectangle, Square
|
||||
from mobject.tex_mobject import TexMobject
|
||||
from mobject.tex_mobject import TextMobject
|
||||
from mobject.vectorized_mobject import VGroup
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
from scene.scene import Scene
|
||||
from topics.geometry import Arrow
|
||||
from topics.geometry import BackgroundRectangle
|
||||
from topics.geometry import Circle
|
||||
from topics.geometry import Dot
|
||||
from topics.geometry import Line
|
||||
from topics.geometry import Square
|
||||
from topics.geometry import Vector
|
||||
from topics.number_line import Axes
|
||||
from topics.number_line import NumberPlane
|
||||
|
||||
from constants import *
|
||||
from topics.matrix import Matrix, VECTOR_LABEL_SCALE_FACTOR, vector_coordinate_label
|
||||
from utils.rate_functions import rush_into, rush_from
|
||||
from topics.matrix import Matrix
|
||||
from topics.matrix import VECTOR_LABEL_SCALE_FACTOR
|
||||
from topics.matrix import vector_coordinate_label
|
||||
from utils.rate_functions import rush_from
|
||||
from utils.rate_functions import rush_into
|
||||
from utils.space_ops import angle_of_vector
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import numpy as np
|
||||
|
||||
from scipy import linalg
|
||||
from utils.simple_functions import choose
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
from colour import Color
|
||||
import numpy as np
|
||||
import random
|
||||
|
||||
from colour import Color
|
||||
|
||||
from utils.bezier import interpolate
|
||||
|
||||
def color_to_rgb(color):
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import numpy as np
|
||||
import os
|
||||
|
||||
from PIL import Image
|
||||
from constants import RASTER_IMAGE_DIR
|
||||
import os
|
||||
|
||||
def get_full_raster_image_path(image_file_name):
|
||||
possible_paths = [
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import numpy as np
|
||||
import itertools as it
|
||||
import numpy as np
|
||||
|
||||
def remove_list_redundancies(l):
|
||||
"""
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import numpy as np
|
||||
|
||||
from constants import OUT
|
||||
from utils.bezier import interpolate
|
||||
from utils.space_ops import rotation_matrix
|
||||
from constants import OUT
|
||||
|
||||
STRAIGHT_PATH_THRESHOLD = 0.01
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import numpy as np
|
||||
from utils.simple_functions import sigmoid
|
||||
|
||||
from utils.bezier import bezier
|
||||
from utils.simple_functions import sigmoid
|
||||
|
||||
def smooth(t, inflection = 10.0):
|
||||
error = sigmoid(-inflection / 2)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import operator as op
|
||||
import numpy as np
|
||||
import operator as op
|
||||
|
||||
def sigmoid(x):
|
||||
return 1.0/(1 + np.exp(-x))
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import numpy as np
|
||||
from constants import RIGHT, OUT
|
||||
|
||||
from constants import OUT
|
||||
from constants import RIGHT
|
||||
|
||||
#Matrix operations
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue