mirror of
https://github.com/3b1b/manim.git
synced 2025-08-21 05:44:04 +00:00
commit
1d81e3a3af
6 changed files with 1016 additions and 27 deletions
File diff suppressed because it is too large
Load diff
|
@ -160,6 +160,33 @@ class FadeInFromDown(FadeInAndShiftFromDirection):
|
|||
"direction": DOWN,
|
||||
}
|
||||
|
||||
|
||||
class VFadeIn(Animation):
|
||||
"""
|
||||
VFadeIn and VFadeOut only work for VMobjects, but they can be applied
|
||||
to mobjects while they are being animated in some other way (e.g. shifting
|
||||
then) in a way that does not work with FadeIn and FadeOut
|
||||
"""
|
||||
def update_submobject(self, submobject, starting_submobject, alpha):
|
||||
submobject.set_stroke(
|
||||
width=interpolate(0, starting_submobject.get_stroke_width(), alpha)
|
||||
)
|
||||
submobject.set_fill(
|
||||
opacity=interpolate(0, starting_submobject.get_fill_opacity(), alpha)
|
||||
)
|
||||
|
||||
|
||||
class VFadeOut(VFadeIn):
|
||||
CONFIG = {
|
||||
"remover": True
|
||||
}
|
||||
|
||||
def update_submobject(self, submobject, starting_submobject, alpha):
|
||||
VFadeIn.update_submobject(
|
||||
self, submobject, starting_submobject, 1 - alpha
|
||||
)
|
||||
|
||||
|
||||
# Growing
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ DEFAULT_POINT_DENSITY_1D = 250
|
|||
|
||||
DEFAULT_POINT_THICKNESS = 4
|
||||
|
||||
|
||||
FRAME_HEIGHT = 8.0
|
||||
FRAME_WIDTH = FRAME_HEIGHT * DEFAULT_PIXEL_WIDTH / DEFAULT_PIXEL_HEIGHT
|
||||
FRAME_Y_RADIUS = FRAME_HEIGHT / 2
|
||||
|
|
|
@ -2,6 +2,7 @@ from __future__ import absolute_import
|
|||
|
||||
from continual_animation.continual_animation import ContinualAnimation
|
||||
from animation.update import MaintainPositionRelativeTo
|
||||
from mobject.value_tracker import ValueTracker
|
||||
|
||||
|
||||
class ContinualUpdateFromFunc(ContinualAnimation):
|
||||
|
@ -35,3 +36,21 @@ class ContinualMaintainPositionRelativeTo(ContinualAnimation):
|
|||
|
||||
def update_mobject(self, dt):
|
||||
self.anim.update(0) # 0 is arbitrary
|
||||
|
||||
|
||||
# TODO, maybe factor into a different file
|
||||
class ContinualGrowValue(ContinualAnimation):
|
||||
CONFIG = {
|
||||
"rate": 1,
|
||||
}
|
||||
|
||||
def __init__(self, value_tracker, **kwargs):
|
||||
if not isinstance(value_tracker, ValueTracker):
|
||||
raise Exception("ContinualGrowValue must take a ValueTracker as its mobject")
|
||||
self.value_tracker = value_tracker
|
||||
ContinualAnimation.__init__(self, value_tracker, **kwargs)
|
||||
|
||||
def update_mobject(self, dt):
|
||||
self.value_tracker.set_value(
|
||||
self.value_tracker.get_value() + self.rate * dt
|
||||
)
|
||||
|
|
|
@ -550,6 +550,7 @@ class Arrow(Line):
|
|||
start - perp_vect * width / 2,
|
||||
tip_base - perp_vect * width / 2,
|
||||
])
|
||||
self.stem = self.rect # Alternate name
|
||||
return self
|
||||
|
||||
def set_tip_points(
|
||||
|
|
|
@ -913,7 +913,7 @@ class NudgeSideLengthOfCube(Scene):
|
|||
df_equation.to_edge(UP)
|
||||
|
||||
faces_brace = Brace(faces, DOWN)
|
||||
derivative = faces_brace.get_text("$3x^2", "\\, dx$")
|
||||
derivative = faces_brace.get_tex("3x^2", "\\, dx")
|
||||
extras_brace = Brace(VGroup(bars, corner_cube), DOWN)
|
||||
ignore_text = extras_brace.get_text(
|
||||
"Multiple \\\\ of $dx^2$"
|
||||
|
@ -1149,7 +1149,6 @@ class NudgeSideLengthOfCube(Scene):
|
|||
def get_corner_cube(self):
|
||||
return self.get_prism(self.dx, self.dx, self.dx)
|
||||
|
||||
|
||||
def get_prism(self, width, height, depth):
|
||||
color_kwargs = {
|
||||
"fill_color" : YELLOW,
|
||||
|
|
Loading…
Add table
Reference in a new issue