Commit graph

3154 commits

Author SHA1 Message Date
Grant Sanderson
4cc2e5ed17 Consolidate camera configuration 2024-12-10 11:39:13 -06:00
Grant Sanderson
d4c5c4736a Move logic for window size and position into Window class 2024-12-10 11:07:54 -06:00
Grant Sanderson
178cca0ca5 Factor out get_window_position 2024-12-10 10:35:31 -06:00
Grant Sanderson
c02259a39e Remove import 2024-12-10 10:35:21 -06:00
Grant Sanderson
1276724891 Pull out the initial Window.to_default_position from init_for_scene 2024-12-10 10:14:59 -06:00
Grant Sanderson
9e77b0dcdd Consolidate window configuration 2024-12-10 10:10:58 -06:00
Grant Sanderson
950ac31b9b Replace IGNORE_MANIMLIB_MODULES constant with a piece of global configuration 2024-12-09 16:57:55 -06:00
Grant Sanderson
8706ba1589 No real need to track ReloadManager.scenes
This was to be able to loop through an tear them down, but tear down is primarily about ending any file writing, and potentially cleaning up a window, which for the sake of reusing a window we don't want to do anyway.
2024-12-09 16:46:13 -06:00
Grant Sanderson
dd508b8cfc No need to track ReloadManager.start_at_line 2024-12-09 16:43:08 -06:00
Grant Sanderson
88bae476ce Don't print filename that is being reloaded 2024-12-09 16:25:18 -06:00
Grant Sanderson
7a69807ce6 Remove mobject.save_to_file
This simply didn't work, and had no resilience to changes to the library. For cases where this might be useful, it's likely much better deliberately save specific data which is time-consuming to generate on the fly.
2024-12-09 16:24:50 -06:00
Grant Sanderson
6d0b23f914 Slightly simplify ReloadManager 2024-12-09 16:14:27 -06:00
Grant Sanderson
bf81d94362 Don't make reload_manager a global variable 2024-12-09 15:54:16 -06:00
Grant Sanderson
5b315d5c70 Get rid of the (hacky) solution to redefining Scene methods, since reload handles it better 2024-12-09 14:02:22 -06:00
Grant Sanderson
cb3e115a6c Minor cleaning 2024-12-09 14:01:34 -06:00
Grant Sanderson
40b5c7c1c1 Slightly clean up interactive_scene_embed 2024-12-09 13:56:33 -06:00
Grant Sanderson
636fb3a45b Factor interactive embed logic out of Scene class 2024-12-09 13:53:03 -06:00
Grant Sanderson
ea3f77e3f1 Add blank line 2024-12-09 11:59:22 -06:00
Grant Sanderson
0692afdfec Bug fix 2024-12-09 11:59:16 -06:00
Grant Sanderson
14c6fdc1d9 Slight refactor of get_indent 2024-12-09 09:49:48 -06:00
Grant Sanderson
89bf0b1297 Track all mobjects as a set in Scene. begin_animations 2024-12-07 08:21:33 -07:00
Grant Sanderson
5fa99b7723 Set default log level to "WARNING" 2024-12-07 08:14:56 -07:00
Grant Sanderson
0ef12ad7e4 Move FRAME_HEIGHT back to constants
Where it belongs
2024-12-06 12:35:39 -07:00
Grant Sanderson
09c27a654f Minor cleaning of imports 2024-12-06 12:26:54 -07:00
Grant Sanderson
90dfb02cc6 Move get_scene_module logic to extract_scene.py 2024-12-06 12:24:16 -07:00
Grant Sanderson
e270f5c3d3 Change from get_module_with_inserted_embed_line to insert_embed_line_to_module
Rather than taking in a file_name and reading it in, directly take the module and edit its code.
2024-12-06 11:59:18 -07:00
Grant Sanderson
fadd045fc1 Don't write new file when inserting embed line
Instead, load the relevant module of the true file, and execute the modified code within that.

This also cleans up some of the previous now-unnecessary code around get_module_with_inserted_embed_line
2024-12-06 11:05:57 -07:00
Grant Sanderson
dd0aa14442 Clean up get_module_with_inserted_embed_line, only accept line number as embed arg 2024-12-06 10:39:02 -06:00
Grant Sanderson
d357e21c1d Change how ModuleLoader receives is_reload information
Use on the fly import of reload_manager rather than altering the args
2024-12-06 10:07:07 -06:00
Grant Sanderson
dd251ab8c2 Remove "preview" as a scene parameter, just look for whether window is None 2024-12-06 09:54:14 -06:00
Grant Sanderson
2e49c60148 Use config.get_resolution for constants 2024-12-06 09:49:21 -06:00
Grant Sanderson
33c7f6d063 Factor out resolution from get_camera_config 2024-12-06 09:46:26 -06:00
Grant Sanderson
53b6c34ebe Create Window outside of Scene, and pass it in as an argument 2024-12-06 09:39:12 -06:00
Grant Sanderson
49c2b5cfe0 Check if animation.mobject is in the full family of scene mobjects before adding 2024-12-06 08:51:08 -06:00
Splines
6196daa5ec
Reload user-defined modules during reload() (#2257)
* Experiment a lot with module loading

* Extract methods out of experimental mess

* Fix get module return type

* Only reload() modules during reload() command

* Remove unnecessary default parameter

* Add docstrings and logging statements

* Delete unwanted printout

* Improve logging messages

* Extract methods to a new class ModuleLoader

* Remove unused builtins import

* exec_module in any case at the end

* Clarify docstrings & move get_module method up in file

* Add more additionally excluded modules as array

* Distinguish between user-defined modules and external libraries like numpy

* Improved tracked_import docstring

* Remove _insert_embed suffix before logging

* Fix args.is_reload not defined error

* Refine logic to determine whether module is user-defined or not

* Fix list vs. set type annotations

* Improve docstrings & change order of early return

* Fix spelling mistake of "Reloading"

* Try out custom deep reload

* Make deep reload more robust

* Also reload modules imported as classes

* Move early return up to greatly improve performance

* Clean up comments

* Make methods of Module Loader "private"

* Add backticks around function in docstring

---------

Co-authored-by: Grant Sanderson <grant@3blue1brown.com>
2024-12-05 16:18:10 -08:00
Grant Sanderson
94f6f0aa96
Cleaner local caching of Tex/Text data, and partially cleaned up configuration (#2259)
* Remove print("Reloading...")

* Change where exception mode is set, to be quieter

* Add default fallback monitor for when no monitors are detected

* Have StringMobject work with svg strings rather than necessarily writing to file

Change SVGMobject to allow taking in a string of svg code as an input

* Add caching functionality, and have Tex and Text both use it for saved svg strings

* Clean up tex_file_writing

* Get rid of get_tex_dir and get_text_dir

* Allow for a configurable cache location

* Make caching on disk a decorator, and update implementations for Tex and Text mobjects

* Remove stray prints

* Clean up how configuration is handled

In principle, all we need here is that manim looks to the default_config.yaml file, and updates it based on any local configuration files, whether in the current working directory or as specified by a CLI argument.

* Make the default size for hash_string an option

* Remove utils/customization.py

* Remove stray prints

* Consolidate camera configuration

This is still not optimal, but at least makes clearer the way that importing from constants.py kicks off some of the configuration code.

* Factor out configuration to be passed into a scene vs. that used to run a scene

* Use newer extract_scene.main interface

* Add clarifying message to note what exactly is being reloaded

* Minor clean up

* Minor clean up

* If it's worth caching to disk, then might as well do so in memory too during development

* No longer any need for custom hash_seeds in Tex and Text

* Remove display_during_execution

* Get rid of (no longer used) mobject_data directory reference

* Remove get_downloads_dir reference from register_font

* Update where downloads go

* Easier use of subdirectories in configuration

* Add new pip requirements
2024-12-05 14:51:14 -08:00
Iñaki Rabanillo
5a70d67b98
Update coordinate_systems.py (#2258) 2024-12-05 14:49:16 -08:00
Varniex
5d3f730824
Cleaning up some imports + Minor Bug fixed in VectorField (#2253)
* cleaning up imports

* sample_points -> sample_coords
2024-12-05 14:42:46 -08:00
Splines
1fa17030a2
Add reload() command for interactive scene reloading (#2240)
* Init reload command (lots of things not working yet)

* Add back in class line (accidentally deleted)

* Add back in key modifiers (accidentally deleted)

* Unpack tuple from changed `get_module`

* Init MainRunManager & respawn IPython shell

* Init cleanup of scenes from manager

* Restore string quotes

* Still take `self.preview` into account

* Remove left-over code from module experimentation

* Remove double window activation

* Reset scenes array in RunManager

* Move self.args None check up

* Use first available window

* Don't use constructor for RunManager

* Use self. syntax

* Init moderngl context manually

* Add some comments for failed attempts to reset scene

* Reuse existing shell (this fixed the bug 🎉)

* Remove unused code

* Remove unnecessary intermediate ReloadSceneException

* Allow users to finally exit

* Rename main_run_manager to reload_manager

* Add docstrings to `ReloadManager`

* Improve reset management in window

* Clarify why we use magic exit_raise command

* Add comment about window reuse

* Improve docstrings in ReloadManager & handle case of 0 scenes

* Set scene and title earlier

* Run linter suggestions
2024-11-26 10:09:43 -08:00
Grant Sanderson
530cb4f104
Merge pull request #2250 from 3b1b/video-work
Video work
2024-11-25 13:44:08 -06:00
Grant Sanderson
85638d88dc Update parameter range for sphere 2024-11-25 12:39:41 -07:00
Grant Sanderson
fbce0b132c Temporary band-aide for degenerate normal vector calculations
This solution is a bit too specific to the case of spheres.
2024-11-25 12:39:32 -07:00
Grant Sanderson
dd51b696e5 Only apply non-flat-stroke correction in non-zero joint angle vertices 2024-11-25 12:35:32 -07:00
Grant Sanderson
9cd6a87ff8 Make sure VMobject uniform flat_stroke matches the use inside the quadratic_bezier/stroke/geom.glsl code 2024-11-25 12:28:31 -07:00
Grant Sanderson
54c8a9014b Add scale_stroke_with_zoom option to VMobject 2024-11-25 11:27:11 -07:00
Grant Sanderson
e19ceaaff0 Have TexMobject keep track of font_size 2024-11-25 11:02:54 -07:00
Grant Sanderson
5b88d2347c Allow for LaTeX in DecimalNumber, e.g. for units 2024-11-25 11:01:38 -07:00
Grant Sanderson
c6b9826f84 Update TimeVaryingVectorField to match new VectorField configuration 2024-11-25 10:50:12 -07:00
Grant Sanderson
90ab2f64bb Clean up style arguments on VectorField 2024-11-25 10:49:29 -07:00
Grant Sanderson
ed2f9f3305 Fix import of pyplot 2024-11-25 10:49:05 -07:00