mirror of
https://github.com/3b1b/manim.git
synced 2025-11-13 19:57:48 +00:00
Move display_during_execturion call
Such that it only gets called when a new svg needs to be written
This commit is contained in:
parent
c2c8149627
commit
e0e7e24351
3 changed files with 10 additions and 12 deletions
|
|
@ -3,7 +3,6 @@ from __future__ import annotations
|
|||
import re
|
||||
|
||||
from manimlib.mobject.svg.string_mobject import StringMobject
|
||||
from manimlib.utils.tex_file_writing import display_during_execution
|
||||
from manimlib.utils.tex_file_writing import tex_content_to_svg_file
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
|
@ -79,10 +78,9 @@ class MTex(StringMobject):
|
|||
)
|
||||
|
||||
def get_file_path_by_content(self, content: str) -> str:
|
||||
with display_during_execution(f"Writing \"{self.tex_string}\""):
|
||||
file_path = tex_content_to_svg_file(
|
||||
content, self.template, self.additional_preamble
|
||||
)
|
||||
file_path = tex_content_to_svg_file(
|
||||
content, self.template, self.additional_preamble, self.tex_string
|
||||
)
|
||||
return file_path
|
||||
|
||||
# Parsing
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ from manimlib.constants import MED_LARGE_BUFF, SMALL_BUFF
|
|||
from manimlib.mobject.geometry import Line
|
||||
from manimlib.mobject.svg.svg_mobject import SVGMobject
|
||||
from manimlib.mobject.types.vectorized_mobject import VGroup
|
||||
from manimlib.utils.tex_file_writing import display_during_execution
|
||||
from manimlib.utils.tex_file_writing import tex_content_to_svg_file
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
|
@ -86,10 +85,9 @@ class SingleStringTex(SVGMobject):
|
|||
|
||||
def get_file_path(self) -> str:
|
||||
content = self.get_tex_file_body(self.tex_string)
|
||||
with display_during_execution(f"Writing \"{self.tex_string}\""):
|
||||
file_path = tex_content_to_svg_file(
|
||||
content, self.template, self.additional_preamble
|
||||
)
|
||||
file_path = tex_content_to_svg_file(
|
||||
content, self.template, self.additional_preamble, self.tex_string
|
||||
)
|
||||
return file_path
|
||||
|
||||
def get_tex_file_body(self, tex_string: str) -> str:
|
||||
|
|
|
|||
|
|
@ -52,7 +52,8 @@ def get_tex_config() -> dict[str, str]:
|
|||
|
||||
|
||||
def tex_content_to_svg_file(
|
||||
content: str, template: str, additional_preamble: str
|
||||
content: str, template: str, additional_preamble: str,
|
||||
short_tex: str
|
||||
) -> str:
|
||||
tex_config = get_tex_config()
|
||||
if not template or template == tex_config["template"]:
|
||||
|
|
@ -78,7 +79,8 @@ def tex_content_to_svg_file(
|
|||
)
|
||||
if not os.path.exists(svg_file):
|
||||
# If svg doesn't exist, create it
|
||||
create_tex_svg(full_tex, svg_file, compiler)
|
||||
with display_during_execution("Writing " + short_tex):
|
||||
create_tex_svg(full_tex, svg_file, compiler)
|
||||
return svg_file
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue