1
0
Fork
You've already forked Animake
0
Quick and tiny Python+Qt library to script animations
  • Python 100%
Find a file
2018年02月12日 11:23:41 +01:00
scenes Support a .start() method on the scene modules 2018年02月11日 19:36:46 +01:00
.gitignore Introduce the concept of scenes 2018年02月10日 15:21:41 +01:00
anistate.py Add a poly function to the AniState 2018年02月11日 18:43:45 +01:00
gui.py Support a .start() method on the scene modules 2018年02月11日 19:36:46 +01:00
LICENSE Add LICENSE and README.md 2018年02月10日 11:18:02 +01:00
README.md Better README showing a more concrete example 2018年02月12日 11:23:41 +01:00

Animake

This is a small helper program that aims at providing an easy-to-use interface for animating small things, such as text, boxes, and other basic shapes.

Based on @expectocode's captivox, but modified to only provide a thin wrapper for rendering animations and exporting the result to a video file.

To create your own scenes, add your own .py files inside the scenes/ directory. They must have a function definition called callback that accepts a single AniState parameter, like so:

def callback(ani):
 pass # Use the input 'AniState' at will

Example

Say you want to make a quick scene. You would create a scenes/quick.py file and then add some code:

import math
from PyQt5.QtGui import QColor
def callback(ani):
 if ani.time > 2 * math.pi:
 raise StopIteration
 ani.color(None)
 for y in range(5, ani.height - 5, 10):
 x = (1 + math.sin(ani.time + y * 0.03)) * ani.width / 2
 ani.fill(QColor.fromHsv((x + y) % 360, 127, 255)).circle(x, y, 10)
 x = ani.width / 2 - math.sin(ani.time + y * 0.06) * ani.width / 4
 ani.fill(QColor.fromHsv(y % 360, 127, 255)).circle(x, y, 5)

Run with python3 gui.py quick to get this. As you might have noticed, you can chain ani.calls().together().

More details

If the module defines a DURATION constant, after that period of time, the scene will be restarted. To stop the scene earlier, you should raise StopIteration (which will restart it). You can also set the duration to None or 0 to represent infinite.

If the module defines a start() callback, it will be called every time the simulation is restarted, before any call to callback occurs.