3246 Commits

Author SHA1 Message Date
Shavez
c5e23d9365 Fix shared reference issue in traced_points initialization (#2426) 2026-03-26 09:56:44 -05:00
Shavez
e14177036c This change introduces program-type aware shader code replacement (#2424)
in VShaderWrapper, allowing independent GLSL modifications for:

- stroke programs
- fill programs
- depth programs

Previously, `set_color_by_code()` relied on a single global
replacement mechanism. As a result:

- Multiple calls to `set_color_by_code()` would override each other.
- Applying different GLSL logic to stroke and fill was not possible.
- The last shader replacement always won.

This update solves that limitation by:

1. Storing shader code replacements per program type.
2. Applying replacements only to shaders matching the given program_type.
3. Preserving previously applied replacements for other program types.
4. Maintaining backward compatibility when program_type is None.

Now users can safely do:

    set_color_by_code(..., program_type="stroke")
    set_color_by_code(..., program_type="fill")

without one affecting the other.

This makes stroke and fill shader logic fully independent,
opening the door for:

- Different gradients for stroke and fill
- Custom sheen effects per layer
- Advanced shader experimentation
- Cleaner shader architecture

Backward compatibility:
If no program_type is provided, behavior falls back to the
original global replacement logic.

This improves flexibility without breaking existing scenes.
2026-03-26 09:37:11 -05:00
Aaron Gostein
0d3b06d44d Dedenting copied code for checkpoint_paste (#2432)
For some reason, it seems like this may only cause an issue for certain users (potentially Windows users in particular).
2026-03-26 09:33:15 -05:00
Grant Sanderson
2e31f79a23 Multiple clip planes (#2437)
* Use preferred_creation_axis in TexturedSurface

* Add ComplexPlane.get_unit_size

* Enable up to 4 clip planes

* Add Mobject.clip_to_box

* Use tex "i" for complex numbers
2026-03-14 09:15:57 -05:00
Grant Sanderson
2636e8dfef Allow path_along_arc to take in multiple arc_angle values 2026-03-11 14:33:42 -05:00
Grant Sanderson
2c7209b13e Add set_image_coords_by_uv_func to TextureSurface 2026-03-09 11:43:15 -05:00
Grant Sanderson
e7787d7910 Replace TEXT_MOB_SCALE_FACTOR with a dynamically calculated value (#2423)
- Set font_size_for_unit_height: 144 in config
- Calculate the relevant scaling factors for Text and Text using a rendered "0" as a reference, ensuring that a font size of 144 (or whatever is set) would give it a height of 1 in manim coordinates.
2026-02-12 20:31:35 -06:00
Andrey Zhuchkov
5f84e20c2a Minor Fixes for Example Scenes (#2374)
* Fixed Dot color parameter in example scenes

* Automatically create downloads directory if necessary
2026-02-10 12:50:50 -06:00
Abdallah Soliman
e47871f32c Minor edits (#2380)
* Added a shortcut for remove_all_except() in scene_embed

* Added **kwargs argument to get_axis_label() and get_axis_labels() such that properties of the label like font size and t2c can be configured.

* Comments for set_color_by_rgba_func and set_color_by_rgb_func were ambiguous; clarified the comments.

* Changed the comment to remove the old description. The old description was valid up until pull request #2316.
2026-02-10 12:50:26 -06:00
Shavez
bb495112d1 feat(InteractiveScene): add z-axis object grabbing support (#2379) 2026-02-10 12:49:20 -06:00
Shavez
8f5feafb54 Fix StrokeArrow: preserve tip geometry for large angles (#2392) 2026-02-10 12:48:14 -06:00
Awais Khan
5d397a7d00 Fix: remove pkg_resources usage (deprecated), use importlib.metadata (#2389) 2026-02-10 12:47:48 -06:00
Shavez
bf4ae585aa fix(Latex): add latex_cache directory to resolve LaTeX compilation errors. Fixes #2390 (#2391) 2026-02-10 12:46:25 -06:00
Shavez
52827fffd4 Geometry improvements (#2394)
* refactor(Line): move reset_points_around_ends from Arrow to Line

* fix(Line): make set_path_arc work for both Arrow and StrokeArrow

* refactor(Line): move set_perpendicular_to_camera from Arrow to Line

* typing: add missing Tuple import in Line.get_start_and_end
2026-02-10 12:43:30 -06:00
Shavez
40529b98d9 fix(interactive_scene): handle OverflowError in on_key_press for large key symbols (#2396) 2026-02-10 12:40:54 -06:00
Shavez
018b7ce947 fix(SceneState): clear updaters on restore_scene (#2397)
* fix(SceneState): clear updaters on restore_scene

Previously, restoring a scene checkpoint did not reset updaters.
This caused discrepancies when switching between checkpoints if
a mobject had updaters attached.

Now, restore_scene clears all updaters before restoring the mobject,
ensuring scene state consistency across checkpoints.

* Refactor restore_scene to use list comprehension

---------

Co-authored-by: Grant Sanderson <grant@3blue1brown.com>
2026-02-10 12:40:02 -06:00
mjmjmtl
553231b1e1 Improve SVG path parsing by re-using ref_path (#2407) 2026-02-10 12:31:43 -06:00
mjmjmtl
048e1f34b1 Fix Mobject.get_area_vector() using subpath area sum (#2408) 2026-02-10 12:27:13 -06:00
Pablo Coloma
7a462d8cc5 Fix degenerate bezier handles (#2420) 2026-02-10 12:25:22 -06:00
Grant Sanderson
77feda7a3d Updates made for the Hairy Ball Theorem video (#2422)
* Bug fix for TransformMatchingStrings with incompatible lengths

* Change faded line in NumberPlane initialization to be more explicit, and lower opacity

* Add option hide_zero_components_on_complex to DecimalNumber

* Validate syntax before reloading

* Add remembered stroke_config to TracedPath

* Add CLAUDE.md to gitignore

* Move pre-calculated traced points to TracingTail

* Fix interplay between time_span and alpha in Animation

* Clearer init for points in TracingTail

* Fix CoordinateSystem.get_area_under_graph

* Allow ComplexPlane.n2p to take in array of complex numbers

* Add put_start_on and put_end_on

* Add Slider

* Add \minus option for Tex to give shorter negative sign

* Put interp_by_hsl option in various color interpretation functions

* Swap priority of matched_keys vs key_map is TransformMatchingStrings

* Have z-index apply recursively

* Set self.svg_string property for SVGMobject

* Fix num_decimal_places config in Tex.make_number_changeable

* Add Surface. color_by_uv_function

* Add VMobject. set_color_by_proportion

* Add \mathcal to tex_to_symbol_count

* Allow option for BulletedList to be numbered

* ShowPartial should not be restricted to VMobject

* Add basic functionality for imported 3d geometries with texture

* Add interp_by_hsl option to Mobject.set_submobject_colors_by_gradient

* Update Clock class

* Add \circ to tex_to_symbol_count
2026-02-10 12:22:21 -06:00
Grant Sanderson
e5298385ed Video work (#2402)
* Bug fix for TransformMatchingStrings with incompatible lengths

* Change faded line in NumberPlane initialization to be more explicit, and lower opacity

* Add option hide_zero_components_on_complex to DecimalNumber

* Validate syntax before reloading

* Add remembered stroke_config to TracedPath

* Add CLAUDE.md to gitignore

* Move pre-calculated traced points to TracingTail

* Fix interplay between time_span and alpha in Animation

* Clearer init for points in TracingTail

* Fix CoordinateSystem.get_area_under_graph

* Allow ComplexPlane.n2p to take in array of complex numbers

* Add put_start_on and put_end_on

* Add Slider

* Add \minus option for Tex to give shorter negative sign

* Put interp_by_hsl option in various color interpretation functions

* Swap priority of matched_keys vs key_map is TransformMatchingStrings

* Have z-index apply recursively

* Set self.svg_string property for SVGMobject

* Fix num_decimal_places config in Tex.make_number_changeable

* Add Surface. color_by_uv_function

* Add VMobject. set_color_by_proportion

* Add \mathcal to tex_to_symbol_count
2025-10-14 07:15:39 -07:00
Grant Sanderson
41613db7ec Remove stray prints 2025-06-14 10:47:52 -05:00
Grant Sanderson
cc5fbe17b9 Fix bug with mirroring file prefixes 2025-06-10 10:59:47 -05:00
Grant Sanderson
d330e1db7f Added documentation from @AkashKarnatak to geometry.py
Based on https://github.com/3b1b/manim/pull/1024
2025-06-10 10:41:09 -05:00
Abdallah Soliman
fd2a6a69e5 Created a method `remove_all_except()` in scene.py and interactive_scene.py, and made default colors easily configurable. (#2346)
* created a method remove_all_except() in scene.py and interactive_scene.py

* Made it such that default mobject colors can be set through the yaml config file.

* * Default color initialisation wasn't working.
Changed conditional expression to `or` instead.

* Added default values to yaml file.

* added set_background_color() function to Scene class

* Changed default font back to Consolas
2025-06-10 08:15:55 -07:00
Irvanal Haq
6fb1845f4a Enhance Autocompletion for mobject.animate. to Display Mobject Methods (#2342)
* Improve autocompletion for mobject.animate to show Mobject methods

- Added type hint `-> _AnimationBuilder | Self` to `Mobject.animate`, enabling autocompletion for `Mobject` methods after `mobject.animate`.

- Prioritized `typing_extensions.Self` over `typing.Self` in imports, so autocompletion of `Mobject` methods also works in Python < 3.11.

* Support `mobject.animate.` autocompletion in IPython

* Add docstring to `__dir__` and add return type hint

* improve docsting `__dir__` _AnimationBuilder
2025-06-10 08:13:29 -07:00
Irvanal Haq
a5a73cb2da Fix typos in GLSL comments and add constants PURE_RED, PURE_GREEN, PURE_BLUE (#2340)
* Fix typos in GLSL comments

* Fix typos in GLSL comments

* add constants PURE_RED, PURE_GREEN, PURE_BLUE
2025-06-10 08:12:11 -07:00
Irvanal Haq
53bc83d94a Refactor: move type validation to top of Animation.__init__ and extract into method (#2332) 2025-06-10 08:11:16 -07:00
Varniex
8b9ae95703 Resolving minor bug in StreamLines (#2330)
* resolving minor bug in StreamLines

* minute changes
2025-06-10 08:05:07 -07:00
Irvanal Haq
c667136060 Fix error when using VFadeIn (and its subclasses) (#2328)
* Fix error when using VFadeIn and its subclasses

* add np.floating in type checking of Mobject.set_rgba_array_by_color and VMobject.set_stroke and removing the change in VFadeIn
2025-06-10 08:04:13 -07:00
Grant Sanderson
c7ef8404b7 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
2025-06-10 08:02:32 -07:00
Grant Sanderson
f4737828f6 Video work (#2326)
* 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
2025-03-20 12:00:35 -07:00
jkjkil4
be7d93cf40 Fix path arc handling for SVGMobject when a matrix transform is present in the SVG (#2322) 2025-03-20 11:59:06 -07:00
Varniex
dbfe7ac75d Performance improved in set_color_by_rgba_func (#2316)
* removing 1 in neg axis if unit_tex is specified

* performance improved in `set_color_by_rgba_func`

* resolving imag axis number mob in ComplexPlane
2025-03-20 11:56:29 -07:00
AStarySky
7a61a13691 Fix issues in number_line.py (#2310)
Fix the issue that changes in decimal_number_config["font_size"] get rewritten by number_config
2025-03-20 11:54:59 -07:00
Shinapri De Lucania
2ddec95ce5 Fix --fps type conversion to int (#2299) 2025-03-20 11:52:17 -07:00
Grant Sanderson
db421e3981 Video work (#2318)
* 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
2025-02-26 07:52:59 -08:00
Grant Sanderson
7a7bf83f11 Only use -no-pdf for xelatex rendering (#2298) 2025-01-08 08:22:03 -08:00
Varniex
24eefef5bf Automatically identify the class name based on the specified line number. (#2280)
* identify the scene name based on the line number

* resolving a minor bug in string_mobject

* removing bug of string validation

* Update manimlib/default_config.yml

Co-authored-by: Splines <37160523+Splines@users.noreply.github.com>

* Update manimlib/extract_scene.py

Co-authored-by: Splines <37160523+Splines@users.noreply.github.com>

* update search scene names

---------

Co-authored-by: Splines <37160523+Splines@users.noreply.github.com>
2024-12-28 07:18:32 -08:00
Grant Sanderson
96d44bd560 Video work (#2284)
* Comment tweak

* Directly print traceback

Since the shell.showtraceback is giving some issues

* Make InteracrtiveSceneEmbed into a class

This way it can keep track of it's internal shell; use of get_ipython has a finicky relationship with reloading.

* Move remaining checkpoint_paste logic into scene_embed.py

This involved making a few context managers for Scene: temp_record, temp_skip, temp_progress_bar, which seem useful in and of themselves.

* Change null key to be the empty string

* Ensure temporary svg paths for Text are deleted

* Remove unused dict_ops.py functions

* Remove break_into_partial_movies from file_writer configuration

* Rewrite guarantee_existence using Path

* Clean up SceneFileWriter

It had a number of vestigial functions no longer used, and some setup that could be made more organized.

* Remove --save_pngs CLI arg (which did nothing)

* Add --subdivide CLI arg

* Remove add_extension_if_not_present

* Remove get_sorted_integer_files

* Have find_file return Path

* Minor clean up

* Clean up num_tex_symbols

* Fix find_file

* Minor cleanup for extract_scene.py

* Add preview_frame_while_skipping option to scene config

* Use shell.showtraceback function

* Move keybindings to config, instead of in-place constants

* Replace DEGREES -> DEG

* Add arg to clear the cache

* Separate out full_tex_to_svg from tex_to_svg

And only cache to disk the results of full_tex_to_svg.  Otherwise, making edits to the tex_templates would not show up without clearing the cache.

* Bug fix in handling BlankScene

* Make checkpoint_states an instance variable of CheckpointManager

As per https://github.com/3b1b/manim/issues/2272

* Move resizing out of Window.focus, and into Window.init_for_scene

* Make default output directory "." instead of ""

To address https://github.com/3b1b/manim/issues/2261

* Remove input_file_path arg from SceneFileWriter

* Use Dict syntax in place of dict for config more consistently across config.py

* Simplify get_output_directory

* Swap order of preamble and additional preamble

* Minor stylistic tweak

* Have UnitInterval pass on kwargs to NumberLine

* Add simple get_dist function

* Have TracedPath always update to the stroke configuration passed in

* Have Mobject.match_points apply to all parts of data in pointlike_data_key

* Always call Mobject.update upon adding an updater

* Add Surface.uv_to_point

* Make sure Surface.set_opacity takes in a recurse option

* Update num_tex_symbols to account for \{ and \}
2024-12-26 09:35:34 -08:00
Grant Sanderson
39fbb677dc Have autoreload update shell namespace with reloaded module variables (#2278)
* Have autoreload update shell namespace with reloaded module variables

* Update comments
2024-12-13 13:23:50 -08:00
syhner
c13d2a946b fix typos (#2270) 2024-12-13 11:05:48 -08:00
Grant Sanderson
f427fc67df A few bug fixes (#2277)
* Comment tweak

* Directly print traceback

Since the shell.showtraceback is giving some issues

* Make InteracrtiveSceneEmbed into a class

This way it can keep track of it's internal shell; use of get_ipython has a finicky relationship with reloading.

* Move remaining checkpoint_paste logic into scene_embed.py

This involved making a few context managers for Scene: temp_record, temp_skip, temp_progress_bar, which seem useful in and of themselves.

* Change null key to be the empty string

* Ensure temporary svg paths for Text are deleted

* Remove unused dict_ops.py functions

* Remove break_into_partial_movies from file_writer configuration

* Rewrite guarantee_existence using Path

* Clean up SceneFileWriter

It had a number of vestigial functions no longer used, and some setup that could be made more organized.

* Remove --save_pngs CLI arg (which did nothing)

* Add --subdivide CLI arg

* Remove add_extension_if_not_present

* Remove get_sorted_integer_files

* Have find_file return Path

* Minor clean up

* Clean up num_tex_symbols

* Fix find_file

* Minor cleanup for extract_scene.py

* Add preview_frame_while_skipping option to scene config

* Use shell.showtraceback function

* Move keybindings to config, instead of in-place constants

* Replace DEGREES -> DEG

* Add arg to clear the cache

* Separate out full_tex_to_svg from tex_to_svg

And only cache to disk the results of full_tex_to_svg.  Otherwise, making edits to the tex_templates would not show up without clearing the cache.

* Bug fix in handling BlankScene

* Make checkpoint_states an instance variable of CheckpointManager

As per https://github.com/3b1b/manim/issues/2272

* Move resizing out of Window.focus, and into Window.init_for_scene

* Make default output directory "." instead of ""

To address https://github.com/3b1b/manim/issues/2261

* Remove input_file_path arg from SceneFileWriter

* Use Dict syntax in place of dict for config more consistently across config.py

* Simplify get_output_directory

* Swap order of preamble and additional preamble
2024-12-12 18:45:34 -08:00
Grant Sanderson
3d9a0cd25e Move resizing out of Window.focus, and into Window.init_for_scene (#2274) 2024-12-12 14:16:45 -08:00
Grant Sanderson
33dbf04985 Make checkpoint_states an instance variable of CheckpointManager (#2273)
As per https://github.com/3b1b/manim/issues/2272
2024-12-12 14:07:55 -08:00
Grant Sanderson
744e695340 Misc. clean up (#2269)
* Comment tweak

* Directly print traceback

Since the shell.showtraceback is giving some issues

* Make InteracrtiveSceneEmbed into a class

This way it can keep track of it's internal shell; use of get_ipython has a finicky relationship with reloading.

* Move remaining checkpoint_paste logic into scene_embed.py

This involved making a few context managers for Scene: temp_record, temp_skip, temp_progress_bar, which seem useful in and of themselves.

* Change null key to be the empty string

* Ensure temporary svg paths for Text are deleted

* Remove unused dict_ops.py functions

* Remove break_into_partial_movies from file_writer configuration

* Rewrite guarantee_existence using Path

* Clean up SceneFileWriter

It had a number of vestigial functions no longer used, and some setup that could be made more organized.

* Remove --save_pngs CLI arg (which did nothing)

* Add --subdivide CLI arg

* Remove add_extension_if_not_present

* Remove get_sorted_integer_files

* Have find_file return Path

* Minor clean up

* Clean up num_tex_symbols

* Fix find_file

* Minor cleanup for extract_scene.py

* Add preview_frame_while_skipping option to scene config

* Use shell.showtraceback function

* Move keybindings to config, instead of in-place constants

* Replace DEGREES -> DEG
2024-12-12 08:39:54 -08:00
Grant Sanderson
00b34f2020 Autoreload v2 (#2268)
* Add autoreload

* Typo correction

* Add --autoreload to configuration docts

Co-Authored-By: Splines <37160523+Splines@users.noreply.github.com>

---------

Co-authored-by: Splines <37160523+Splines@users.noreply.github.com>
2024-12-12 06:52:03 -08:00
Grant Sanderson
bafea89ac9 Update InteractiveSceneEmbed (#2267)
* Comment tweak

* Directly print traceback

Since the shell.showtraceback is giving some issues

* Make InteracrtiveSceneEmbed into a class

This way it can keep track of it's internal shell; use of get_ipython has a finicky relationship with reloading.

* Move remaining checkpoint_paste logic into scene_embed.py

This involved making a few context managers for Scene: temp_record, temp_skip, temp_progress_bar, which seem useful in and of themselves.

* Change null key to be the empty string
2024-12-11 11:33:48 -08:00
Grant Sanderson
e2e785d6c9 Remove init_config.py
It may become a bit unwieldy to make sure this matches the structure of default_config, given the amount of code repetition involved. It seems easier for a user to just create their own custom_config.yml file directly.
2024-12-11 10:50:53 -06:00
Grant Sanderson
6d753a297a Remove stray imports 2024-12-11 10:38:23 -06:00