chap1-anim.py 1.07 KB
from t2g import *

markings = {0: dict(a=3, b=0, c=0, d=0),
            1: dict(a=1, b=1, c=0, d=0),
            2: dict(a=1, b=0, c=1, d=0),
            3: dict(a=1, b=0, c=0, d=2),
            4: dict(a=2, b=0, c=0, d=1),
            5: dict(a=0, b=1, c=0, d=1),
            6: dict(a=0, b=0, c=1, d=1),
            7: dict(a=0, b=0, c=0, d=3)}

state = {"a": 0, "b": 0, "c": 0, "d": 0}

trans = {(0,1): "t",
         (1,2): "u",
         (2,3): "v",
         (3,4): "w",
         (4,0): "w",
         (4,5): "t",
         (5,6): "u",
         (6,7): "v",
         (7,3): "w",
         (6,2): "w",
         (5,1): "w"}

active = dict((t, "") for t in "tuvw")
active.update((s, "") for s in range(8))
active.update((f, "") for f in trans)

load("chap1-anim.tex")
src = 0

for dst in [1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 6, 7, 3, 4, 5, 1, 2, 3, 4, 5, 6, 2, 3, 4, 0] :
    state = markings[src]
    active[src] = "active"
    frame(.8)
    active[src,dst] = active[trans[src,dst]] = "active"
    frame(.8)
    active[src] = active[src,dst] = active[trans[src,dst]] = ""
    src = dst

gif("chap1-anim.gif")