Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Adjusted import statements

XorUnison9e18d4f88e7e
diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py
index ff3e8ba97..edd22af14 100644
--- a/manim/mobject/mobject.py
+++ b/manim/mobject/mobject.py
@@ -10,7 +10,7 @@ from colour import Color
import numpy as np
from ..constants import *
-from ..dirs import VIDEO_DIR
+from .. import dirs
from ..container.container import Container
from ..utils.color import color_gradient
from ..utils.color import interpolate_color
@@ -110,7 +110,7 @@ class Mobject(Container):
def save_image(self, name=None):
self.get_image().save(
- os.path.join(VIDEO_DIR, (name or str(self)) + ".png")
+ os.path.join(dirs.VIDEO_DIR, (name or str(self)) + ".png")
)
def copy(self):
diff --git a/manim/mobject/svg/text_mobject.py b/manim/mobject/svg/text_mobject.py
index c68ff2912..64da1c4dc 100644
--- a/manim/mobject/svg/text_mobject.py
+++ b/manim/mobject/svg/text_mobject.py
@@ -5,7 +5,7 @@ import hashlib
import cairo
from ...constants import *
-from ...dirs import TEXT_DIR
+from ... import dirs
from ...container.container import Container
from ...mobject.geometry import Dot, Rectangle
from ...mobject.svg.svg_mobject import SVGMobject
@@ -95,7 +95,7 @@ class Text(SVGMobject):
def get_space_width(self):
size = self.size * 10
- dir_name = TEXT_DIR
+ dir_name = dirs.TEXT_DIR
file_name = os.path.join(dir_name, "space") + '.svg'
surface = cairo.SVGSurface(file_name, 600, 400)
@@ -291,7 +291,7 @@ class Text(SVGMobject):
if NOT_SETTING_FONT_MSG != '':
print(NOT_SETTING_FONT_MSG)
- dir_name = TEXT_DIR
+ dir_name = dirs.TEXT_DIR
hash_name = self.text2hash()
file_name = os.path.join(dir_name, hash_name)+'.svg'
if os.path.exists(file_name):
diff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.py
index d99c91ed6..5467ed59e 100644
--- a/manim/scene/scene_file_writer.py
+++ b/manim/scene/scene_file_writer.py
@@ -12,8 +12,7 @@ from ..constants import FFMPEG_BIN
from ..constants import STREAMING_IP
from ..constants import STREAMING_PORT
from ..constants import STREAMING_PROTOCOL
-from ..dirs import MEDIA_DIR
-from ..dirs import VIDEO_DIR
+from .. import dirs
from ..utils.config_ops import digest_config
from ..utils.file_ops import guarantee_existence
from ..utils.file_ops import add_extension_if_not_present
@@ -68,26 +67,23 @@ class SceneFileWriter(object):
"""
module_directory = self.output_directory or self.get_default_module_directory()
scene_name = self.file_name or self.get_default_scene_name()
+ #print("1")
+ #print(dirs.MEDIA_DIR)
if self.save_last_frame or self.save_pngs:
- if MEDIA_DIR != "":
+ if dirs.MEDIA_DIR != "":
image_dir = guarantee_existence(os.path.join(
- MEDIA_DIR,
+ dirs.MEDIA_DIR,
"images",
module_directory,
))
- else:
- image_dir = guarantee_existence(os.path.join(
- VIDEO_OUTPUT_DIR,
- "images",
- ))
self.image_file_path = os.path.join(
image_dir,
add_extension_if_not_present(scene_name, ".png")
)
if self.write_to_movie:
- if VIDEO_DIR != "":
+ if dirs.VIDEO_DIR != "":
movie_dir = guarantee_existence(os.path.join(
- VIDEO_DIR,
+ dirs.VIDEO_DIR,
module_directory,
self.get_resolution_directory(),
))
diff --git a/manim/utils/tex_file_writing.py b/manim/utils/tex_file_writing.py
index d401d25e0..78cf60ba3 100644
--- a/manim/utils/tex_file_writing.py
+++ b/manim/utils/tex_file_writing.py
@@ -5,7 +5,7 @@ from pathlib import Path
from ..constants import TEX_TEXT_TO_REPLACE
from ..constants import TEX_USE_CTEX
-from ..dirs import TEX_DIR
+from .. import dirs
def tex_hash(expression, template_tex_file_body):
id_str = str(expression + template_tex_file_body)
@@ -23,7 +23,7 @@ def tex_to_svg_file(expression, template_tex_file_body):
def generate_tex_file(expression, template_tex_file_body):
result = os.path.join(
- TEX_DIR,
+ dirs.TEX_DIR,
tex_hash(expression, template_tex_file_body)
) + ".tex"
if not os.path.exists(result):
@@ -42,7 +42,7 @@ def tex_to_dvi(tex_file):
result = tex_file.replace(".tex", ".dvi" if not TEX_USE_CTEX else ".xdv")
result = Path(result).as_posix()
tex_file = Path(tex_file).as_posix()
- tex_dir = Path(TEX_DIR).as_posix()
+ tex_dir = Path(dirs.TEX_DIR).as_posix()
if not os.path.exists(result):
commands = [
"latex",