Fork me on GitHub

Example: Color

Source code:

import qs
from common import *

def init():
    qs.init_anims([
        # name, path, nframes, duration(s)
        ["crab-up", "crab-up.png", 2, 1.],
    ])
    return {
        "p0": [1., 1.],
        "p1": [100., 100.],
        "color": [0,0,0,1],
    }

def update(state):
    state["p0"][0] += 0.3
    state["p0"][1] += 0.3

    state["color"][0] += 0.001
    state["color"][1] += 0.002
    state["color"][2] += 0.003
    state["color"][0] %= 1
    state["color"][1] %= 1
    state["color"][2] %= 1


def draw(state):
    qs.clear(state["color"])
    qs.anim("crab-up", rect=[state["p0"], state["p1"]])

def event(state, event):
    if event["event"] == "mouse_moved":
        state["p0"][0] = event["x"]
        state["p0"][1] = event["y"]