Skip to content

Commit 9bb2a6c

Browse files
committed
Reset change to manim source code, to separate the PRs
1 parent 0f2324f commit 9bb2a6c

File tree

5 files changed

+58
-84
lines changed

5 files changed

+58
-84
lines changed

manim/constants.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66

77

88
# Messages
9+
NOT_SETTING_FONT_MSG = """
10+
You haven't set font.
11+
If you are not using English, this may cause text rendering problem.
12+
You set font like:
13+
text = Text('your text', font='your font')
14+
or:
15+
class MyText(Text):
16+
CONFIG = {
17+
'font': 'My Font'
18+
}
19+
"""
920
SCENE_NOT_FOUND_MESSAGE = """
1021
{} is not in the script
1122
"""

manim/mobject/svg/text_mobject.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,8 @@ def text2svg(self):
307307
line_spacing = self.line_spacing * 10
308308

309309
if self.font == "":
310-
logger.warning(
311-
"You haven't set a font, non-english characters may not be rendered correctly"
312-
)
310+
if NOT_SETTING_FONT_MSG:
311+
logger.warning(NOT_SETTING_FONT_MSG)
313312

314313
dir_name = file_writer_config["text_dir"]
315314
if not os.path.exists(dir_name):
@@ -935,5 +934,8 @@ def construct(self):
935934
"""
936935

937936
def __init__(self, text, **config):
938-
logger.warning("Text currently uses Cairo Toy API, but will soon use PangoText")
937+
logger.warning(
938+
"Using Text uses Cairo Toy API to Render Text."
939+
"Using PangoText is recommended and soon Text would point to PangoText"
940+
)
939941
CairoText.__init__(self, text, **config)

manim/mobject/types/image_mobject.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -49,38 +49,6 @@ def reset_points(self):
4949

5050

5151
class ImageMobject(AbstractImageMobject):
52-
"""Displays an Image from a numpy array or a file.
53-
54-
Examples
55-
--------
56-
.. manim:: ImageFromArray
57-
:save_last_frame:
58-
59-
class ImageFromArray(Scene):
60-
def construct(self):
61-
image = ImageMobject(np.uint8([[0, 100, 30, 200],
62-
[255, 0, 5, 33]]))
63-
image.set_height(7)
64-
self.add(image)
65-
66-
.. manim:: ImageFromFile
67-
:save_last_frame:
68-
69-
class ImageFromFile(Scene):
70-
def construct(self):
71-
# Use PIL when you want to import an image from the web
72-
import requests
73-
from PIL import Image
74-
img = Image.open(requests.get("https://raw.githubusercontent.com/ManimCommunity/manim/master/logo/cropped.png",
75-
stream=True).raw)
76-
img_mobject = ImageMobject(img)
77-
# this line, when you want to import your Image on your machine
78-
# img_mobject = ImageMobject("<your image address>")
79-
img_mobject.scale(3)
80-
self.add(img_mobject)
81-
82-
"""
83-
8452
CONFIG = {
8553
"invert": False,
8654
"image_mode": "RGBA",

manim/scene/scene.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -781,10 +781,8 @@ def play_internal(self, *args, **kwargs):
781781
782782
Parameters
783783
----------
784-
args
785-
Animation or mobject with mobject method and params
786-
kwargs
787-
named parameters affecting what was passed in ``args`` e.g. ``run_time``, ``lag_ratio`` etc.
784+
*args : Animation or mobject with mobject method and params
785+
**kwargs : named parameters affecting what was passed in *args e.g run_time, lag_ratio etc.
788786
"""
789787
if len(args) == 0:
790788
warnings.warn("Called Scene.play with no animations")

manim/scene/scene_file_writer.py

Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -77,48 +77,46 @@ def init_output_directories(self, scene_name):
7777
)
7878

7979
if file_writer_config["write_to_movie"]:
80-
pass
81-
if file_writer_config["video_dir"]:
80+
if file_writer_config["video_dir"]:
81+
if not file_writer_config["custom_folders"]:
82+
movie_dir = guarantee_existence(
83+
os.path.join(
84+
file_writer_config["video_dir"],
85+
module_directory,
86+
self.get_resolution_directory(),
87+
)
88+
)
89+
else:
90+
movie_dir = guarantee_existence(
91+
os.path.join(file_writer_config["video_dir"])
92+
)
93+
self.movie_file_path = os.path.join(
94+
movie_dir,
95+
add_extension_if_not_present(
96+
default_name, file_writer_config["movie_file_extension"]
97+
),
98+
)
99+
self.gif_file_path = os.path.join(
100+
movie_dir,
101+
add_extension_if_not_present(default_name, GIF_FILE_EXTENSION),
102+
)
82103
if not file_writer_config["custom_folders"]:
83-
movie_dir = guarantee_existence(
104+
self.partial_movie_directory = guarantee_existence(
84105
os.path.join(
85-
file_writer_config["video_dir"],
86-
module_directory,
87-
self.get_resolution_directory(),
106+
movie_dir,
107+
"partial_movie_files",
108+
default_name,
88109
)
89110
)
90111
else:
91-
movie_dir = guarantee_existence(
92-
os.path.join(file_writer_config["video_dir"])
93-
)
94-
self.movie_file_path = os.path.join(
95-
movie_dir,
96-
add_extension_if_not_present(
97-
default_name, file_writer_config["movie_file_extension"]
98-
),
99-
)
100-
self.gif_file_path = os.path.join(
101-
movie_dir,
102-
add_extension_if_not_present(default_name, GIF_FILE_EXTENSION),
103-
)
104-
# The partial movie directory has to be set even if we do not write to movie
105-
if not file_writer_config["custom_folders"]:
106-
self.partial_movie_directory = guarantee_existence(
107-
os.path.join(
108-
movie_dir,
109-
"partial_movie_files",
110-
default_name,
111-
)
112-
)
113-
else:
114-
self.partial_movie_directory = guarantee_existence(
115-
os.path.join(
116-
file_writer_config["media_dir"],
117-
"temp_files",
118-
"partial_movie_files",
119-
default_name,
112+
self.partial_movie_directory = guarantee_existence(
113+
os.path.join(
114+
file_writer_config["media_dir"],
115+
"temp_files",
116+
"partial_movie_files",
117+
default_name,
118+
)
120119
)
121-
)
122120

123121
def add_partial_movie_file(self, hash_animation):
124122
"""Adds a new partial movie file path to scene.partial_movie_files from an hash. This method will compute the path from the hash.
@@ -484,14 +482,11 @@ def is_already_cached(self, hash_invocation):
484482
:class:`bool`
485483
Whether the file exists.
486484
"""
487-
if hasattr(self, "partial_movie_directory"):
488-
path = os.path.join(
489-
self.partial_movie_directory,
490-
"{}{}".format(hash_invocation, self.movie_file_extension),
491-
)
492-
return os.path.exists(path)
493-
else:
494-
return False # If there is no partial movie directory, then the file is not cached
485+
path = os.path.join(
486+
self.partial_movie_directory,
487+
"{}{}".format(hash_invocation, self.movie_file_extension),
488+
)
489+
return os.path.exists(path)
495490

496491
def combine_movie_files(self):
497492
"""

0 commit comments

Comments
 (0)