mirror of
https://github.com/3b1b/manim.git
synced 2025-07-29 13:03:31 +08:00
Renamed ANIMATION_DIR to VIDEO_DIR, also replacing 'animations' with 'video' in the path
This commit is contained in:
12
constants.py
12
constants.py
@ -114,11 +114,11 @@ PI = np.pi
|
|||||||
TAU = 2 * PI
|
TAU = 2 * PI
|
||||||
DEGREES = TAU / 360
|
DEGREES = TAU / 360
|
||||||
|
|
||||||
ANIMATIONS_DIR = os.path.join(MEDIA_DIR, "animations")
|
VIDEO_DIR = os.path.join(MEDIA_DIR, "videos")
|
||||||
RASTER_IMAGE_DIR = os.path.join(MEDIA_DIR, "designs", "raster_images")
|
RASTER_IMAGE_DIR = os.path.join(MEDIA_DIR, "designs", "raster_images")
|
||||||
SVG_IMAGE_DIR = os.path.join(MEDIA_DIR, "designs", "svg_images")
|
SVG_IMAGE_DIR = os.path.join(MEDIA_DIR, "designs", "svg_images")
|
||||||
# TODO, staged scenes should really go into a subdirectory of a given scenes directory
|
# TODO, staged scenes should really go into a subdirectory of a given scenes directory
|
||||||
STAGED_SCENES_DIR = os.path.join(ANIMATIONS_DIR, "staged_scenes")
|
STAGED_SCENES_DIR = os.path.join(VIDEO_DIR, "staged_scenes")
|
||||||
###
|
###
|
||||||
THIS_DIR = os.path.dirname(os.path.realpath(__file__))
|
THIS_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||||
FILE_DIR = os.path.join(THIS_DIR, "files")
|
FILE_DIR = os.path.join(THIS_DIR, "files")
|
||||||
@ -128,7 +128,7 @@ TEX_IMAGE_DIR = TEX_DIR # TODO, What is this doing?
|
|||||||
MOBJECT_DIR = os.path.join(FILE_DIR, "mobjects")
|
MOBJECT_DIR = os.path.join(FILE_DIR, "mobjects")
|
||||||
IMAGE_MOBJECT_DIR = os.path.join(MOBJECT_DIR, "image")
|
IMAGE_MOBJECT_DIR = os.path.join(MOBJECT_DIR, "image")
|
||||||
|
|
||||||
for folder in [FILE_DIR, RASTER_IMAGE_DIR, SVG_IMAGE_DIR, ANIMATIONS_DIR, TEX_DIR,
|
for folder in [FILE_DIR, RASTER_IMAGE_DIR, SVG_IMAGE_DIR, VIDEO_DIR, TEX_DIR,
|
||||||
TEX_IMAGE_DIR, MOBJECT_DIR, IMAGE_MOBJECT_DIR,
|
TEX_IMAGE_DIR, MOBJECT_DIR, IMAGE_MOBJECT_DIR,
|
||||||
STAGED_SCENES_DIR]:
|
STAGED_SCENES_DIR]:
|
||||||
if not os.path.exists(folder):
|
if not os.path.exists(folder):
|
||||||
@ -136,8 +136,10 @@ for folder in [FILE_DIR, RASTER_IMAGE_DIR, SVG_IMAGE_DIR, ANIMATIONS_DIR, TEX_DI
|
|||||||
|
|
||||||
TEX_USE_CTEX = False
|
TEX_USE_CTEX = False
|
||||||
TEX_TEXT_TO_REPLACE = "YourTextHere"
|
TEX_TEXT_TO_REPLACE = "YourTextHere"
|
||||||
TEMPLATE_TEX_FILE = os.path.join(THIS_DIR, "tex_template.tex" if not TEX_USE_CTEX
|
TEMPLATE_TEX_FILE = os.path.join(
|
||||||
else "ctex_template.tex")
|
THIS_DIR, "tex_template.tex" if not TEX_USE_CTEX
|
||||||
|
else "ctex_template.tex"
|
||||||
|
)
|
||||||
with open(TEMPLATE_TEX_FILE, "r") as infile:
|
with open(TEMPLATE_TEX_FILE, "r") as infile:
|
||||||
TEMPLATE_TEXT_FILE_BODY = infile.read()
|
TEMPLATE_TEXT_FILE_BODY = infile.read()
|
||||||
TEMPLATE_TEX_FILE_BODY = TEMPLATE_TEXT_FILE_BODY.replace(
|
TEMPLATE_TEX_FILE_BODY = TEMPLATE_TEXT_FILE_BODY.replace(
|
||||||
|
@ -260,7 +260,7 @@ def main():
|
|||||||
scene_names_to_classes = dict(inspect.getmembers(module, is_scene))
|
scene_names_to_classes = dict(inspect.getmembers(module, is_scene))
|
||||||
|
|
||||||
# config["output_directory"] = os.path.join(
|
# config["output_directory"] = os.path.join(
|
||||||
# ANIMATIONS_DIR,
|
# VIDEO_DIR,
|
||||||
# config["file"].replace(".py", "")
|
# config["file"].replace(".py", "")
|
||||||
# )
|
# )
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ class Mobject(Container):
|
|||||||
|
|
||||||
def save_image(self, name=None):
|
def save_image(self, name=None):
|
||||||
self.get_image().save(
|
self.get_image().save(
|
||||||
os.path.join(ANIMATIONS_DIR, (name or str(self)) + ".png")
|
os.path.join(VIDEO_DIR, (name or str(self)) + ".png")
|
||||||
)
|
)
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
|
@ -10,7 +10,7 @@ from big_ol_pile_of_manim_imports import *
|
|||||||
from script_wrapper import command_line_create_scene
|
from script_wrapper import command_line_create_scene
|
||||||
|
|
||||||
MOVIE_PREFIX = "counting_in_binary/"
|
MOVIE_PREFIX = "counting_in_binary/"
|
||||||
BASE_HAND_FILE = os.path.join(ANIMATIONS_DIR, MOVIE_PREFIX, "Base.mp4")
|
BASE_HAND_FILE = os.path.join(VIDEO_DIR, MOVIE_PREFIX, "Base.mp4")
|
||||||
FORCED_FRAME_DURATION = 0.02
|
FORCED_FRAME_DURATION = 0.02
|
||||||
TIME_RANGE = (0, 42)
|
TIME_RANGE = (0, 42)
|
||||||
INITIAL_PADDING = 27
|
INITIAL_PADDING = 27
|
||||||
@ -84,7 +84,7 @@ class Hand(ImageMobject):
|
|||||||
def __init__(self, num, small = False, **kwargs):
|
def __init__(self, num, small = False, **kwargs):
|
||||||
Mobject2D.__init__(self, **kwargs)
|
Mobject2D.__init__(self, **kwargs)
|
||||||
path = os.path.join(
|
path = os.path.join(
|
||||||
ANIMATIONS_DIR, MOVIE_PREFIX, "images", "Hand%d.png"%num
|
VIDEO_DIR, MOVIE_PREFIX, "images", "Hand%d.png"%num
|
||||||
)
|
)
|
||||||
invert = False
|
invert = False
|
||||||
if not self.read_in_cached_attrs(path, invert):
|
if not self.read_in_cached_attrs(path, invert):
|
||||||
@ -160,7 +160,7 @@ class SaveEachNumber(OverHand):
|
|||||||
OverHand.construct(self)
|
OverHand.construct(self)
|
||||||
for count in COUNT_TO_FRAME_NUM:
|
for count in COUNT_TO_FRAME_NUM:
|
||||||
path = os.path.join(
|
path = os.path.join(
|
||||||
ANIMATIONS_DIR, MOVIE_PREFIX, "images",
|
VIDEO_DIR, MOVIE_PREFIX, "images",
|
||||||
"Hand%d.png"%count
|
"Hand%d.png"%count
|
||||||
)
|
)
|
||||||
Image.fromarray(self.frames[COUNT_TO_FRAME_NUM[count]]).save(path)
|
Image.fromarray(self.frames[COUNT_TO_FRAME_NUM[count]]).save(path)
|
||||||
|
@ -99,7 +99,7 @@ if __name__ == "__main__":
|
|||||||
animated_name=name,
|
animated_name=name,
|
||||||
write_to_movie=True,
|
write_to_movie=True,
|
||||||
output_directory=os.path.join(
|
output_directory=os.path.join(
|
||||||
ANIMATIONS_DIR,
|
VIDEO_DIR,
|
||||||
"active_projects",
|
"active_projects",
|
||||||
"name_animations",
|
"name_animations",
|
||||||
),
|
),
|
||||||
|
@ -57,7 +57,7 @@ class Hand(ImageMobject):
|
|||||||
def __init__(self, num, **kwargs):
|
def __init__(self, num, **kwargs):
|
||||||
Mobject2D.__init__(self, **kwargs)
|
Mobject2D.__init__(self, **kwargs)
|
||||||
path = os.path.join(
|
path = os.path.join(
|
||||||
ANIMATIONS_DIR, MOVIE_PREFIX, "images", "Hand%d.png"%num
|
VIDEO_DIR, MOVIE_PREFIX, "images", "Hand%d.png"%num
|
||||||
)
|
)
|
||||||
invert = False
|
invert = False
|
||||||
if self.read_in_cached_attrs(path, invert):
|
if self.read_in_cached_attrs(path, invert):
|
||||||
@ -83,14 +83,14 @@ class EdgeDetection(SceneFromVideo):
|
|||||||
return "-".join([filename.split(".")[0], str(t1), str(t2)])
|
return "-".join([filename.split(".")[0], str(t1), str(t2)])
|
||||||
|
|
||||||
def construct(self, filename, t1, t2):
|
def construct(self, filename, t1, t2):
|
||||||
path = os.path.join(ANIMATIONS_DIR, filename)
|
path = os.path.join(VIDEO_DIR, filename)
|
||||||
SceneFromVideo.construct(self, path)
|
SceneFromVideo.construct(self, path)
|
||||||
self.apply_gaussian_blur()
|
self.apply_gaussian_blur()
|
||||||
self.apply_edge_detection(t1, t2)
|
self.apply_edge_detection(t1, t2)
|
||||||
|
|
||||||
class BufferedCounting(SceneFromVideo):
|
class BufferedCounting(SceneFromVideo):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
path = os.path.join(ANIMATIONS_DIR, "CountingInBinary.m4v")
|
path = os.path.join(VIDEO_DIR, "CountingInBinary.m4v")
|
||||||
time_range = (3, 42)
|
time_range = (3, 42)
|
||||||
SceneFromVideo.construct(self, path, time_range = time_range)
|
SceneFromVideo.construct(self, path, time_range = time_range)
|
||||||
self.buffer_pixels(spreads = (3, 2))
|
self.buffer_pixels(spreads = (3, 2))
|
||||||
@ -130,7 +130,7 @@ class ClearLeftSide(SceneFromVideo):
|
|||||||
return scenename
|
return scenename
|
||||||
|
|
||||||
def construct(self, scenename):
|
def construct(self, scenename):
|
||||||
path = os.path.join(ANIMATIONS_DIR, MOVIE_PREFIX, scenename + ".mp4")
|
path = os.path.join(VIDEO_DIR, MOVIE_PREFIX, scenename + ".mp4")
|
||||||
SceneFromVideo.construct(self, path)
|
SceneFromVideo.construct(self, path)
|
||||||
self.set_color_region_over_time_range(
|
self.set_color_region_over_time_range(
|
||||||
Region(lambda x, y : x < -1, shape = self.shape)
|
Region(lambda x, y : x < -1, shape = self.shape)
|
||||||
@ -148,7 +148,7 @@ class DraggedPixels(SceneFromVideo):
|
|||||||
return args[0]
|
return args[0]
|
||||||
|
|
||||||
def construct(self, video):
|
def construct(self, video):
|
||||||
path = os.path.join(ANIMATIONS_DIR, MOVIE_PREFIX, video+".mp4")
|
path = os.path.join(VIDEO_DIR, MOVIE_PREFIX, video+".mp4")
|
||||||
SceneFromVideo.construct(self, path)
|
SceneFromVideo.construct(self, path)
|
||||||
self.drag_pixels()
|
self.drag_pixels()
|
||||||
|
|
||||||
@ -165,11 +165,11 @@ class DraggedPixels(SceneFromVideo):
|
|||||||
|
|
||||||
class SaveEachNumber(SceneFromVideo):
|
class SaveEachNumber(SceneFromVideo):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
path = os.path.join(ANIMATIONS_DIR, MOVIE_PREFIX, "ClearLeftSideBufferedCounting.mp4")
|
path = os.path.join(VIDEO_DIR, MOVIE_PREFIX, "ClearLeftSideBufferedCounting.mp4")
|
||||||
SceneFromVideo.construct(self, path)
|
SceneFromVideo.construct(self, path)
|
||||||
for count in COUNT_TO_FRAME_NUM:
|
for count in COUNT_TO_FRAME_NUM:
|
||||||
path = os.path.join(
|
path = os.path.join(
|
||||||
ANIMATIONS_DIR, MOVIE_PREFIX, "images",
|
VIDEO_DIR, MOVIE_PREFIX, "images",
|
||||||
"Hand%d.png"%count
|
"Hand%d.png"%count
|
||||||
)
|
)
|
||||||
Image.fromarray(self.frames[COUNT_TO_FRAME_NUM[count]]).save(path)
|
Image.fromarray(self.frames[COUNT_TO_FRAME_NUM[count]]).save(path)
|
||||||
@ -184,7 +184,7 @@ class ShowCounting(SceneFromVideo):
|
|||||||
return filename
|
return filename
|
||||||
|
|
||||||
def construct(self, filename):
|
def construct(self, filename):
|
||||||
path = os.path.join(ANIMATIONS_DIR, MOVIE_PREFIX, filename + ".mp4")
|
path = os.path.join(VIDEO_DIR, MOVIE_PREFIX, filename + ".mp4")
|
||||||
SceneFromVideo.construct(self, path)
|
SceneFromVideo.construct(self, path)
|
||||||
total_time = len(self.frames)*self.frame_duration
|
total_time = len(self.frames)*self.frame_duration
|
||||||
for count in range(32):
|
for count in range(32):
|
||||||
@ -208,7 +208,7 @@ class ShowFrameNum(SceneFromVideo):
|
|||||||
return filename
|
return filename
|
||||||
|
|
||||||
def construct(self, filename):
|
def construct(self, filename):
|
||||||
path = os.path.join(ANIMATIONS_DIR, MOVIE_PREFIX, filename+".mp4")
|
path = os.path.join(VIDEO_DIR, MOVIE_PREFIX, filename+".mp4")
|
||||||
SceneFromVideo.construct(self, path)
|
SceneFromVideo.construct(self, path)
|
||||||
for frame, count in zip(self.frames, it.count()):
|
for frame, count in zip(self.frames, it.count()):
|
||||||
print(count + "of" + len(self.frames))
|
print(count + "of" + len(self.frames))
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import inspect
|
import inspect
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from constants import ANIMATIONS_DIR
|
from constants import VIDEO_DIR
|
||||||
|
|
||||||
|
|
||||||
def add_extension_if_not_present(file_name, extension):
|
def add_extension_if_not_present(file_name, extension):
|
||||||
@ -28,7 +28,7 @@ def get_scene_output_directory(scene_class):
|
|||||||
file_path = os.path.join(*sub_parts)
|
file_path = os.path.join(*sub_parts)
|
||||||
file_path = file_path.replace(".pyc", "")
|
file_path = file_path.replace(".pyc", "")
|
||||||
file_path = file_path.replace(".py", "")
|
file_path = file_path.replace(".py", "")
|
||||||
return guarantee_existance(os.path.join(ANIMATIONS_DIR, file_path))
|
return guarantee_existance(os.path.join(VIDEO_DIR, file_path))
|
||||||
|
|
||||||
|
|
||||||
def get_movie_output_directory(scene_class, camera_config, frame_duration):
|
def get_movie_output_directory(scene_class, camera_config, frame_duration):
|
||||||
|
Reference in New Issue
Block a user