2 CLASS(Keyframe) EXTENDS(Animation)
3 METHOD(Keyframe, addEasing, entity(entity, float, float, float(float, float, float, float)))
4 METHOD(Keyframe, addAnim, void(entity, entity))
5 METHOD(Keyframe, calcValue, float(entity, float, float, float, float))
6 ATTRIB(Keyframe, currentChild, entity, NULL)
7 ATTRIB(Keyframe, firstChild, entity, NULL)
8 ATTRIB(Keyframe, lastChild, entity, NULL)
10 entity makeHostedKeyframe(entity, void(entity, float), float, float, float);
11 entity makeKeyframe(entity, void(entity, float), float, float, float);
12 float getNewChildStart(entity);
13 float getNewChildDuration(entity, float);
14 float getNewChildValue(entity);
18 entity makeHostedKeyframe(entity obj, void(entity, float) objSetter, float animDuration, float animStart, float animEnd)
21 me = makeKeyframe(obj, objSetter, animDuration, animStart, animEnd);
22 anim.addAnim(anim, me);
26 entity makeKeyframe(entity obj, void(entity, float) objSetter, float animDuration, float animStart, float animEnd)
30 me.configureAnimation(me, obj, objSetter, time, animDuration, animStart, animEnd);
34 entity Keyframe_addEasing(entity me, float animDurationTime, float animEnd, float(float, float, float, float) func)
37 other = makeEasing(me.object, me.setter, func, getNewChildStart(me), getNewChildDuration(me, animDurationTime), getNewChildValue(me), animEnd);
38 me.addAnim(me, other);
42 float getNewChildStart(entity me)
45 return (me.lastChild.startTime + me.lastChild.duration);
50 float getNewChildDuration(entity me, float durationTime)
53 maxDura = me.duration;
54 if (me.lastChild) maxDura = maxDura - (me.lastChild.startTime + me.lastChild.duration);
56 if (0 >= dura || dura > maxDura) dura = maxDura;
60 float getNewChildValue(entity me)
63 return (me.lastChild.startValue + me.lastChild.delta);
68 void Keyframe_addAnim(entity me, entity other)
71 error("Can't add already added anim!");
73 if(other.isFinished(other))
74 error("Can't add finished anim!");
82 l.nextSibling = other;
85 me.currentChild = other;
86 me.firstChild = other;
89 other.prevSibling = l;
90 other.nextSibling = NULL;
94 float Keyframe_calcValue(entity me, float tickTime, float animDuration, float animStartValue, float animDelta)
97 if (me.currentChild.isFinished(me.currentChild))
98 me.currentChild = me.currentChild.nextSibling;
102 me.currentChild.tick(me.currentChild, tickTime);
103 return me.currentChild.value;
106 return animStartValue + animDelta;