keyframe_lerp

ABSTRACT

To avoid having to write many redundant lerps, we can use a keyframe lerp that essentially allows interpolation with many intermediate states. In particular, we can say what the output should be at sseveral key times using a map from times to values, and then a basic linear interpolation is used in the intermediate areas. In contrast to lerp, if a value of t is provided outside the range of keyframes, then either the lowest or highest keyframe is used. Also, to see what sort of inputs are allowed to be inputted, see the write-up in lerp.

IMPORTANT ELEMENT

This function is one of the easiest ways to create color gradients by hand. The semantics of this function are also similar to that of Keyframe.

REMARK

Maps in Monocurl are guaranteed to be traversed in insertion order. Moreover, if we declare a dictionary literal such as {0: ..., 1: ..., 4:....}, then the keys are said to be inserted in the order 0, 1, 4. When providing the keyframes to keyframe_lerp, you should insure that the insertion order of the keyframes is the order you want them to be processed in (in other words, make sure that you do not write something such as {2:..., 1:....} because then the insertion order has descending keys).

PARAMETERS
keyframesa map from time to values. It is (currently) your duty to ensure that the order of keys in the map is increasing order, but this is pretty easy to do if we use a map literal
thow far along to go in the interpolation process. A value of t that is below the minimum specified in the keyframes will result in the output being the value associated with the minimum such time, and similarly for values of t that exceed the maximum. Otherwise, a linear interpolation of the keyframes that the value of t is sandwiched between is output
RETURN

the keyframe interpolated value as specified by the above procedure

DECLARATION
func keyframe_lerp(keyframes, t)