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:
Grant Sanderson 2025-06-10 08:02:32 -07:00 committed by GitHub
parent f4737828f6
commit c7ef8404b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 16 additions and 9 deletions

View file

@ -43,7 +43,7 @@ class AnimationGroup(Animation):
mobs = remove_list_redundancies([a.mobject for a in self.animations])
if group is not None:
self.group = group
if group_type is not None:
elif group_type is not None:
self.group = group_type(*mobs)
elif all(isinstance(anim.mobject, VMobject) for anim in animations):
self.group = VGroup(*mobs)

View file

@ -6,6 +6,7 @@ from manimlib.animation.animation import Animation
from manimlib.animation.transform import Transform
from manimlib.constants import ORIGIN
from manimlib.mobject.types.vectorized_mobject import VMobject
from manimlib.mobject.mobject import Group
from manimlib.utils.bezier import interpolate
from manimlib.utils.rate_functions import there_and_back
@ -101,7 +102,7 @@ class FadeTransform(Transform):
self.dim_to_match = dim_to_match
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:
self.ending_mobject = self.mobject.copy()

View file

@ -29,9 +29,9 @@ class ChangingDecimal(Animation):
self.mobject = decimal_mob
def interpolate_mobject(self, alpha: float) -> None:
self.mobject.set_value(
self.number_update_func(alpha)
)
true_alpha = self.time_spanned_alpha(alpha)
new_value = self.number_update_func(true_alpha)
self.mobject.set_value(new_value)
class ChangeDecimalToValue(ChangingDecimal):

View file

@ -164,7 +164,7 @@ class NumberLine(Line):
**number_config
) -> DecimalNumber:
number_config = merge_dicts_recursively(
number_config, self.decimal_number_config,
self.decimal_number_config, number_config,
)
if direction is None:
direction = self.line_to_number_direction

View file

@ -344,6 +344,8 @@ class ClockPassesTime(AnimationGroup):
angle=12 * hour_radians,
**rot_kwargs
),
group=clock,
run_time=run_time,
**kwargs
)

View file

@ -145,6 +145,7 @@ class VectorField(VMobject):
func: Callable[[VectArray], VectArray],
# Typically a set of Axes or NumberPlane
coordinate_system: CoordinateSystem,
sample_coords: Optional[VectArray] = None,
density: float = 2.0,
magnitude_range: Optional[Tuple[float, float]] = None,
color: Optional[ManimColor] = None,
@ -168,6 +169,9 @@ class VectorField(VMobject):
self.norm_to_opacity_func = norm_to_opacity_func
# Search for sample_points
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()
@ -175,7 +179,7 @@ class VectorField(VMobject):
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
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
if magnitude_range is None:
@ -406,7 +410,7 @@ class StreamLines(VGroup):
noise_factor = self.noise_factor
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([
coords + noise_factor * np.random.random(coords.shape)