All pastes #88734 Raw Edit

xbmcanim

public python v1 · immutable
·published 2006-07-15 08:17 UTC
rendered paste body
#!/usr/bin/env python#Animation library for XBMCfrom time import sleepdef linear(control,x1,y1,x2,y2,speed):    if (x2 - x1):        m = (y2 - y1)/float((x2 - x1))        b = y1 - (m * x1)    else:        m = 0    x = x1    y = y1    if m:        while x <= x2 + speed:            y = (m * x) + b            control.setPosition(x,y)            x += speed            sleep(0.08)    else:        while y <= y2 + speed:            control.setPosition(x,y)            y += speed            sleep(0.08)def bezier(control,x1,y1,x2,y2,x3,y3,x4,y4,s):    s = 1/float(s)    cx = 3 * (x2 - x1)    bx = 3 * (x3 - x2) - cx    ax = x4 - x1 - cx - bx    cy = 3 * (y2 - y1)    by = 3 * (y3 - y2) - cy    ay = y4 - y1 - cy - by     i = 0    while i <= 1 + s:        i2 = i * i        i3 = i * i * i        x = (ax * i3) + (bx * i2) + (cx * i) + x1        y = (ay * i3) + (by * i2) + (cy * i) + y1        control.setPosition(int(x),int(y))        i += s        sleep(0.08)