mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Video work (#2356)
* Only use -no-pdf for xelatex rendering * Instead of tracking du and dv points on surface, track points off the surface in the normal direction This means that surface shading will not necessarily work well for arbitrary transformations of the surface. But the existing solution was flimsy anyway, and caused annoying issues with singularity points. * Have density of anchor points on arcs depend on arc length * Allow for specifying true normals and orientation of Sphere * Change miter threshold on stroke shader * Add get_start_and_end to DashedLine * Add min_total_width option to DecimalNumber * Have BackgroundRectangle.set_style absorb (and ignore) added configuration Note, this feels suboptimal * Add LineBrace * Update font_size adjustment in Tex * Add scale_factor parameter to BulletedList.fade_all_but * Minor import tweaks * Add play_sound * Small if -> elif update * Always use Group for FadeTransform * Use time_spanned_alpha in ChangingDecimal * Change priority of number_config vs. self.decimal_number_config in NumberLine init * Fix clock animation * Allow sample_coords to be passed into VectorField
This commit is contained in:
parent
f4737828f6
commit
c7ef8404b7
6 changed files with 16 additions and 9 deletions
|
@ -43,7 +43,7 @@ class AnimationGroup(Animation):
|
||||||
mobs = remove_list_redundancies([a.mobject for a in self.animations])
|
mobs = remove_list_redundancies([a.mobject for a in self.animations])
|
||||||
if group is not None:
|
if group is not None:
|
||||||
self.group = group
|
self.group = group
|
||||||
if group_type is not None:
|
elif group_type is not None:
|
||||||
self.group = group_type(*mobs)
|
self.group = group_type(*mobs)
|
||||||
elif all(isinstance(anim.mobject, VMobject) for anim in animations):
|
elif all(isinstance(anim.mobject, VMobject) for anim in animations):
|
||||||
self.group = VGroup(*mobs)
|
self.group = VGroup(*mobs)
|
||||||
|
|
|
@ -6,6 +6,7 @@ from manimlib.animation.animation import Animation
|
||||||
from manimlib.animation.transform import Transform
|
from manimlib.animation.transform import Transform
|
||||||
from manimlib.constants import ORIGIN
|
from manimlib.constants import ORIGIN
|
||||||
from manimlib.mobject.types.vectorized_mobject import VMobject
|
from manimlib.mobject.types.vectorized_mobject import VMobject
|
||||||
|
from manimlib.mobject.mobject import Group
|
||||||
from manimlib.utils.bezier import interpolate
|
from manimlib.utils.bezier import interpolate
|
||||||
from manimlib.utils.rate_functions import there_and_back
|
from manimlib.utils.rate_functions import there_and_back
|
||||||
|
|
||||||
|
@ -101,7 +102,7 @@ class FadeTransform(Transform):
|
||||||
self.dim_to_match = dim_to_match
|
self.dim_to_match = dim_to_match
|
||||||
|
|
||||||
mobject.save_state()
|
mobject.save_state()
|
||||||
super().__init__(mobject.get_group_class()(mobject, target_mobject.copy()), **kwargs)
|
super().__init__(Group(mobject, target_mobject.copy()), **kwargs)
|
||||||
|
|
||||||
def begin(self) -> None:
|
def begin(self) -> None:
|
||||||
self.ending_mobject = self.mobject.copy()
|
self.ending_mobject = self.mobject.copy()
|
||||||
|
|
|
@ -29,9 +29,9 @@ class ChangingDecimal(Animation):
|
||||||
self.mobject = decimal_mob
|
self.mobject = decimal_mob
|
||||||
|
|
||||||
def interpolate_mobject(self, alpha: float) -> None:
|
def interpolate_mobject(self, alpha: float) -> None:
|
||||||
self.mobject.set_value(
|
true_alpha = self.time_spanned_alpha(alpha)
|
||||||
self.number_update_func(alpha)
|
new_value = self.number_update_func(true_alpha)
|
||||||
)
|
self.mobject.set_value(new_value)
|
||||||
|
|
||||||
|
|
||||||
class ChangeDecimalToValue(ChangingDecimal):
|
class ChangeDecimalToValue(ChangingDecimal):
|
||||||
|
|
|
@ -164,7 +164,7 @@ class NumberLine(Line):
|
||||||
**number_config
|
**number_config
|
||||||
) -> DecimalNumber:
|
) -> DecimalNumber:
|
||||||
number_config = merge_dicts_recursively(
|
number_config = merge_dicts_recursively(
|
||||||
number_config, self.decimal_number_config,
|
self.decimal_number_config, number_config,
|
||||||
)
|
)
|
||||||
if direction is None:
|
if direction is None:
|
||||||
direction = self.line_to_number_direction
|
direction = self.line_to_number_direction
|
||||||
|
|
|
@ -344,6 +344,8 @@ class ClockPassesTime(AnimationGroup):
|
||||||
angle=12 * hour_radians,
|
angle=12 * hour_radians,
|
||||||
**rot_kwargs
|
**rot_kwargs
|
||||||
),
|
),
|
||||||
|
group=clock,
|
||||||
|
run_time=run_time,
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -145,6 +145,7 @@ class VectorField(VMobject):
|
||||||
func: Callable[[VectArray], VectArray],
|
func: Callable[[VectArray], VectArray],
|
||||||
# Typically a set of Axes or NumberPlane
|
# Typically a set of Axes or NumberPlane
|
||||||
coordinate_system: CoordinateSystem,
|
coordinate_system: CoordinateSystem,
|
||||||
|
sample_coords: Optional[VectArray] = None,
|
||||||
density: float = 2.0,
|
density: float = 2.0,
|
||||||
magnitude_range: Optional[Tuple[float, float]] = None,
|
magnitude_range: Optional[Tuple[float, float]] = None,
|
||||||
color: Optional[ManimColor] = None,
|
color: Optional[ManimColor] = None,
|
||||||
|
@ -168,14 +169,17 @@ class VectorField(VMobject):
|
||||||
self.norm_to_opacity_func = norm_to_opacity_func
|
self.norm_to_opacity_func = norm_to_opacity_func
|
||||||
|
|
||||||
# Search for sample_points
|
# Search for sample_points
|
||||||
self.sample_coords = get_sample_coords(coordinate_system, density)
|
if sample_coords is not None:
|
||||||
|
self.sample_coords = sample_coords
|
||||||
|
else:
|
||||||
|
self.sample_coords = get_sample_coords(coordinate_system, density)
|
||||||
self.update_sample_points()
|
self.update_sample_points()
|
||||||
|
|
||||||
if max_vect_len is None:
|
if max_vect_len is None:
|
||||||
step_size = get_norm(self.sample_points[1] - self.sample_points[0])
|
step_size = get_norm(self.sample_points[1] - self.sample_points[0])
|
||||||
self.max_displayed_vect_len = max_vect_len_to_step_size * step_size
|
self.max_displayed_vect_len = max_vect_len_to_step_size * step_size
|
||||||
else:
|
else:
|
||||||
self.max_displayed_vect_len = max_vect_len * coordinate_system.get_x_unit_size()
|
self.max_displayed_vect_len = max_vect_len * coordinate_system.x_axis.get_unit_size()
|
||||||
|
|
||||||
# Prepare the color map
|
# Prepare the color map
|
||||||
if magnitude_range is None:
|
if magnitude_range is None:
|
||||||
|
@ -406,7 +410,7 @@ class StreamLines(VGroup):
|
||||||
|
|
||||||
noise_factor = self.noise_factor
|
noise_factor = self.noise_factor
|
||||||
if noise_factor is None:
|
if noise_factor is None:
|
||||||
noise_factor = (cs.get_x_unit_size() / self.density) * 0.5
|
noise_factor = (cs.x_axis.get_unit_size() / self.density) * 0.5
|
||||||
|
|
||||||
return np.array([
|
return np.array([
|
||||||
coords + noise_factor * np.random.random(coords.shape)
|
coords + noise_factor * np.random.random(coords.shape)
|
||||||
|
|
Loading…
Add table
Reference in a new issue