一个动画图像制作者。
nummu的Python项目详细描述
nummu(南無)
一个动画图像制作者。
注意:这个项目在WIP中,因此接口可能会有很大的变化。在生产中使用时要小心。
Image | Script |
---|---|
examples/helloworld.py | |
examples/line.py | |
examples/rect.py | |
Bubble Sort Heap Sort Insertion Sort Merge Sort Quick Sort Selection Sort | examples/sort.py |
examples/image.py | |
examples/text.py |
安装
$ pip install nummu
用法
nummu只是一个框架,因此您可能希望实现一个具有以下方法的类:update(delta)
,draw(palette)
。它们都不是绝对必要的。
class HelloWorld:
def __init__(self):
# Do initial work here
self.position = 0
def update(self, delta):
# Do some calculation before draw each frame.
# The delta is in millisecond unit.
#
# Don't forget to raise StopIteration somewhere!
#
self.position += delta
if self.position >= 100:
raise StopIteration
def draw(self, pallete):
# Pallete is simply a numpy.zeros instance.
# Overwrite any pixels as you want.
#
pallete[:, self.position, :] = 255
基本用法:
# import nummu
from nummu import Nummu
# set file size
nm = Nummu(100, 100)
# add drawer defined previously
nm.add(HelloWorld())
# export to gif
nm.export('helloworld.gif', delay=5)
查看project repo中的示例,希望它可以帮助您!
开发
$ poetry develop
$ poetry run python examples/helloworld.py
测试
当前NUMMU支持在3.6、3.7上运行
$ pyenv install 3.6.5
$ pyenv install 3.7.0b2
$ pyenv local 3.6.5 3.7.0b2
$ export PATH=$(pyenv root)/shims:$PATH
$ tox
py36 runtests: commands[0] | poetry develop
py36 runtests: commands[0] | poetry run pytest
py37 runtests: commands[0] | poetry develop
py37 runtests: commands[0] | poetry run pytest
py36: commands succeeded
py37: commands succeeded
congratulations :)
学分
谢谢枕头,努比,努姆普和阿拉吉夫!努姆站在巨人的肩膀上!