Exemplo n.º 1
0
def main(config):
    module = config["module"]
    all_scene_classes = get_scene_classes_from_module(module)
    scene_classes_to_render = get_scenes_to_render(all_scene_classes, config)

    scene_kwargs = dict([(key, config[key]) for key in [
        "camera_config",
        "file_writer_config",
        "skip_animations",
        "start_at_animation_number",
        "end_at_animation_number",
        "remove_progress_bars",
    ]])

    for SceneClass in scene_classes_to_render:
        try:
            # By invoking, this renders the full scene
            scene = SceneClass(**scene_kwargs)
            open_file_if_needed(scene.file_writer, **config)
            if config["sound"]:
                play_finish_sound()
        except Exception:
            print("\n\n")
            traceback.print_exc()
            print("\n\n")
            if config["sound"]:
                play_error_sound()
Exemplo n.º 2
0
def main(config):
    module = config["module"]
    all_scene_classes = get_scene_classes_from_module(module)
    scene_classes_to_render = get_scenes_to_render(all_scene_classes, config)

    scene_kwargs = dict([
        (key, config[key])
        for key in [
            "camera_config",
            "file_writer_config",
            "skip_animations",
            "start_at_animation_number",
            "end_at_animation_number",
            "leave_progress_bars",
        ]
    ])

    for SceneClass in scene_classes_to_render:
        try:
            # By invoking, this renders the full scene
            scene = SceneClass(**scene_kwargs)
            open_file_if_needed(scene.file_writer, **config)
            if config["sound"]:
                play_finish_sound()
        except Exception:
            print("\n\n")
            traceback.print_exc()
            print("\n\n")
            if config["sound"]:
                play_error_sound()
Exemplo n.º 3
0
def main(config):
    module = config["module"]
    scene_names_to_classes = dict(
        inspect.getmembers(module, lambda x: is_child_scene(x, module)))

    scene_kwargs = dict([(key, config[key]) for key in [
        "camera_config",
        "frame_duration",
        "skip_animations",
        "write_to_movie",
        "save_pngs",
        "movie_file_extension",
        "start_at_animation_number",
        "end_at_animation_number",
    ]])

    scene_kwargs["name"] = config["output_name"]
    if config["save_pngs"]:
        print("We are going to save a PNG sequence as well...")
        scene_kwargs["save_pngs"] = True
        scene_kwargs["pngs_mode"] = config["saved_image_mode"]

    for SceneClass in get_scene_classes(scene_names_to_classes, config):
        try:
            handle_scene(SceneClass(**scene_kwargs), **config)
            play_finish_sound()
            sys.exit(0)
        except Exception:
            print("\n\n")
            traceback.print_exc()
            print("\n\n")
            play_error_sound()
            sys.exit(2)
Exemplo n.º 4
0
def main(config={}):
    module = config["module"]
    all_scene_classes = get_scene_classes_from_module(module)
    scene_classes_to_render = get_scenes_to_render(all_scene_classes, config)

    scene_kwargs = dict([(key, config[key]) for key in [
        "camera_config",
        "file_writer_config",
        "skip_animations",
        "start_at_animation_number",
        "end_at_animation_number",
        "leave_progress_bars",
    ]])

    for SceneClass in scene_classes_to_render:
        try:
            # Before we start rendering, fire the on_render_ready() function in each addon
            manimlib.addon_loader.run_on_render_ready(scene_classes_to_render)

            # By invoking, this renders the full scene
            scene = SceneClass(**scene_kwargs)

            # By this point, the scene is done rendering, so fire the on_render() function in each addon
            manimlib.addon_loader.run_on_rendered(scene_classes_to_render)

            open_file_if_needed(scene.file_writer, **config)
            if config["sound"]:
                play_finish_sound()
        except Exception:
            print("\n\n")
            traceback.print_exc()
            print("\n\n")
            if config["sound"]:
                play_error_sound()
Exemplo n.º 5
0
def main():
    args = manimlib.config.parse_cli()

    if args.config:
        manimlib.utils.init_config.init_customization()
    else:
        if not args.livestream:
            config = manimlib.config.get_configuration(args)
            scene_config = get_scene_config(config)
            scenes = manimlib.extract_scene.main(config)

            for scene in scenes:
                try:
                    # By invoking, this renders the full scene
                    scene = scene(**scene_config)
                    open_file_if_needed(scene.file_writer, **config)
                    if config["sound"]:
                        play_finish_sound()
                except Exception:
                    print("\n\n")
                    traceback.print_exc()
                    print("\n\n")
                    if config["sound"]:
                        play_error_sound()
        else:
            manimlib.stream_starter.start_livestream(
                to_twitch=args.to_twitch,
                twitch_key=args.twitch_key,
            )
Exemplo n.º 6
0
def main(config):
    # 获取module
    module = config["module"]
    # 获取module中的所有Scene
    all_scene_classes = get_scene_classes_from_module(module)
    # 获取需要渲染的Scene
    scene_classes_to_render = get_scenes_to_render(all_scene_classes, config)
    # 提取Scene的配置,使用可迭代对象创建字典
    scene_kwargs = dict([(key, config[key]) for key in [
        "camera_config",
        "file_writer_config",
        "skip_animations",
        "start_at_animation_number",
        "end_at_animation_number",
        "leave_progress_bars",
    ]])

    for SceneClass in scene_classes_to_render:
        try:
            # By invoking, this renders the full scene
            print("Start creating a Scene:", SceneClass)
            # 创建给定的Scene
            scene = SceneClass(**scene_kwargs)
            # 渲染完成打开文件
            open_file_if_needed(scene.file_writer, **config)
            # 如果参数中给定--sound参数,完成渲染后播放play_finish_sound
            if config["sound"]:
                play_finish_sound()
        except Exception:
            print("\n\n")
            traceback.print_exc()
            print("\n\n")
            # 如果有异常,播放play_error_sound
            if config["sound"]:
                play_error_sound()
Exemplo n.º 7
0
def main(config, verbose, quiet):
    module = config["module"]
    all_scene_classes = get_scene_classes_from_module(module)
    scene_classes_to_render = get_scenes_to_render(all_scene_classes, config)

    #io.capture_output() suppress output until its 
    #closed. So if args.verbose == true, then suppress
    #the output. This statement wasn't placed on the top
    #because we want "get_scenes_to_render" to output a 
    #list of scene classes when, more than one scenes are
    #present in the module
    if not verbose:
        capture_output = io.capture_output(stderr=quiet)
        capture_output.__enter__()
    scene_kwargs = dict([
        (key, config[key])
        for key in [
            "camera_config",
            "file_writer_config",
            "skip_animations",
            "start_at_animation_number",
            "end_at_animation_number",
            "leave_progress_bars",
        ]
    ])

    #list to store objects of all scene classes. This
    #will be used in the main file to extract scene's 
    #output media directory
    all_scene_objects = []
    for SceneClass in scene_classes_to_render:
        try:
            # By invoking, this renders the full scene
            scene = SceneClass(**scene_kwargs)
            all_scene_objects.append(scene)
            open_file_if_needed(scene.file_writer, **config)
            if config["sound"]:
                play_finish_sound()
        except Exception:
            print("\n\n")
            traceback.print_exc()
            print("\n\n")
            if config["sound"]:
                play_error_sound()
    if not verbose:
        capture_output.__exit__(None, None, None)
    #return "all_scene_objects" list
    return all_scene_objects
Exemplo n.º 8
0
    def do_final_stuff(scene_class):
        try:
            # By invoking, this renders the full scene

            # scene = threading.Thread(target=SceneClass(**scene_kwargs))
            # render_threads.append(scene)
            # scene.start()

            scene = scene_class(**scene_kwargs)
            open_file_if_needed(scene.file_writer, **config)
            if config["sound"]:
                play_finish_sound()
        except Exception:
            print("\n\n")
            traceback.print_exc()
            print("\n\n")
            if config["sound"]:
                play_error_sound()