Phi*_*ier 11

我只是移植用gif动画,以ASCII动画从我的答案我的例子在这里给蟒蛇.你需要从这里安装pyglet库,因为python遗憾的是没有内置的动画gif支持.希望你喜欢 :)

import pyglet, sys, os, time

def animgif_to_ASCII_animation(animated_gif_path):
    # map greyscale to characters
    chars = ('#', '#', '@', '%', '=', '+', '*', ':', '-', '.', ' ')
    clear_console = 'clear' if os.name == 'posix' else 'CLS'

    # load image
    anim = pyglet.image.load_animation(animated_gif_path)

    # Step through forever, frame by frame
    while True:
        for frame in anim.frames:

            # Gets a list of luminance ('L') values of the current frame
            data = frame.image.get_data('L', frame.image.width)

            # Built up the string, by translating luminance values to characters
            outstr = ''
            for (i, pixel) in enumerate(data):
                outstr += chars[(ord(pixel) * (len(chars) - 1)) / 255] + \
                          ('\n' if (i + 1) % frame.image.width == 0 else '')

            # Clear the console
            os.system(clear_console)

            # Write the current frame on stdout and sleep
            sys.stdout.write(outstr)
            sys.stdout.flush()
            time.sleep(0.1)

# run the animation based on some animated gif
animgif_to_ASCII_animation(u'C:\\some_animated_gif.gif')
Run Code Online (Sandbox Code Playgroud)


Pet*_*ain 6

这正是我为其创建了学名的应用程序。

它是一个跨平台的控制台API,支持从一组丰富的文本效果生成动画场景。它已被证明可以在各种口味的CentOS和Windows和OSX上运行。

可从画廊获得样品。这是与其他答案中提供的GIF动画代码相似的示例。

彩色图像

我假设您只是在寻找一种制作动画的方法,但是如果您真的想复制蒸汽火车,则可以将其转换为Sprite,并为其指定一个可以在屏幕上运行它的Path,然后按以下方式播放场景的一部分。对象的完整说明可以在docs中找到。