Cerberus X Documentation

Module cerberus.interpolate

Functions to interpolate between two values. More...

Declarations

Imported By
cerberus
Please note that only documented modules are listed here, there might be undocumented modules that import this one.
Functions
InterpolateBackEaseIn : Float ( y0:Float, y1:Float, x:Float ) Interpolates on a pull back curve from (0,y0) to (1,y1) at x.
InterpolateBackEaseInOut : Float ( y0:Float, y1:Float, x:Float ) Interpolates on a pull back curve from (0,y0) to (1,y1) at x.
InterpolateBackEaseOut : Float ( y0:Float, y1:Float, x:Float ) Interpolates on a pull back curve from (0,y0) to (1,y1) at x.
InterpolateBounceEaseIn : Float ( y0:Float, y1:Float, x:Float ) Interpolates on a bouncing curve from (0,y0) to (1,y1) at x.
InterpolateBounceEaseInOut : Float ( y0:Float, y1:Float, x:Float ) Interpolates on a bouncing curve from (0,y0) to (1,y1) at x.
InterpolateBounceEaseOut : Float ( y0:Float, y1:Float, x:Float ) Interpolates on a bouncing curve from (0,y0) to (1,y1) at x.
InterpolateCubicBezier : Float ( y0:Float, y1:Float, A:Float, B:Float, C:Float, D:Float, x:Float, pPrecision:Float=0.0001 ) Interpolates on a cubic bézier curve from (0,y0) to (1,y1) with control points (A,B) and (C,D) at x.
InterpolateCurve : Float ( y0:Float, y1:Float, yA:Float, x:Float ) Interpolates on a curve from (0,y0) to (1,y1) going through (0.5,yA) at x.
InterpolateCustomLine : Float ( dataY:Float[], x:Float ) Interpolates on a sawtooth line through all the points in dataY[] spread evenly from (0,dataY[0]) to (1,dataY[n]) at x.
InterpolateElasticEaseIn : Float ( y0:Float, y1:Float, x:Float ) Interpolates on an elastic bouncing curve from (0,y0) to (1,y1) at x.
InterpolateElasticEaseInOut : Float ( y0:Float, y1:Float, x:Float ) Interpolates on an elastic bouncing curve from (0,y0) to (1,y1) at x.
InterpolateElasticEaseOut : Float ( y0:Float, y1:Float, x:Float ) Interpolates on an elastic bouncing curve from (0,y0) to (1,y1) at x.
InterpolateFit : Float ( y0:Float, y1:Float, s0:Float, s1:Float, x:Float ) Interpolates on a curve from (0,y0) to (1,y1) with slopes s0 and s1 respectively at x.
InterpolateFlats : Float ( y0:Float, y1:Float, yA:Float, x:Float ) Interpolates on a curve from (0,y0) to (1,y1) with slopes=0 going through (0.5,yA) at x.
InterpolateLin : Float ( y0:Float, y1:Float, x:Float ) Interpolates linearly between (0,y0) and (1,y1) at x.
InterpolateSin : Float ( y0:Float, y1:Float, x:Float ) Interpolates on a sinusoidal from (0,y0) to (1,y1) at x.
LinMap : Float ( dt:Float, t0:Float, t1:Float ) Returns percentage of where about dt is in the range of t0 to t1.

Detailed Discussion

Functions to interpolate between two values. This is mostly used for timed transitions or to ease movements' beginnings and endings.

Try the Live demo


Functions Documentation

Function InterpolateBackEaseIn : Float ( y0:Float, y1:Float, x:Float )

Interpolates on a pull back curve from (0,y0) to (1,y1) at x. This eases in the pull back mechanism.

InterpolateBackEaseIn diagram

Parameters
  • y0 - value at x=0.0
  • y1 - value at x=1.0
  • x - point to interpolate, ranging from 0 to 1
      Returns

      Interpolated y value at x

      See also

      Live demo

      Function InterpolateBackEaseInOut : Float ( y0:Float, y1:Float, x:Float )

      Interpolates on a pull back curve from (0,y0) to (1,y1) at x. This eases in and out the pull back mechanism.

      InterpolateBackEaseInOut diagram

      Parameters
      • y0 - value at x=0.0
      • y1 - value at x=1.0
      • x - point to interpolate, ranging from 0 to 1
          Returns

          Interpolated y value at x

          See also

          Live demo

          Function InterpolateBackEaseOut : Float ( y0:Float, y1:Float, x:Float )

          Interpolates on a pull back curve from (0,y0) to (1,y1) at x. This eases out the pull back mechanism.

          InterpolateBackEaseOut diagram

          Parameters
          • y0 - value at x=0.0
          • y1 - value at x=1.0
          • x - point to interpolate, ranging from 0 to 1
              Returns

              Interpolated y value at x

              See also

              Live demo

              Function InterpolateBounceEaseIn : Float ( y0:Float, y1:Float, x:Float )

              Interpolates on a bouncing curve from (0,y0) to (1,y1) at x. This eases in the bouncing.

              InterpolateBounceEaseIn diagram

              Parameters
              • y0 - value at x=0.0
              • y1 - value at x=1.0
              • x - point to interpolate, ranging from 0 to 1
                  Returns

                  Interpolated y value at x

                  See also

                  Live demo

                  Function InterpolateBounceEaseInOut : Float ( y0:Float, y1:Float, x:Float )

                  Interpolates on a bouncing curve from (0,y0) to (1,y1) at x. This eases in and out the bouncing.

                  InterpolateBounceEaseIn diagram

                  Parameters
                  • y0 - value at x=0.0
                  • y1 - value at x=1.0
                  • x - point to interpolate, ranging from 0 to 1
                      Returns

                      Interpolated y value at x

                      See also

                      Live demo

                      Function InterpolateBounceEaseOut : Float ( y0:Float, y1:Float, x:Float )

                      Interpolates on a bouncing curve from (0,y0) to (1,y1) at x. This eases out the bouncing.

                      InterpolateBounceEaseOut diagram

                      Parameters
                      • y0 - value at x=0.0
                      • y1 - value at x=1.0
                      • x - point to interpolate, ranging from 0 to 1
                          Returns

                          Interpolated y value at x

                          See also

                          Live demo

                          Function InterpolateCubicBezier : Float ( y0:Float, y1:Float, A:Float, B:Float, C:Float, D:Float, x:Float, pPrecision:Float=0.0001 )

                          Interpolates on a cubic bézier curve from (0,y0) to (1,y1) with control points (A,B) and (C,D) at x.

                          InterpolateCubicBezier diagram

                          Parameters
                          • y0 - value at x=0.0
                          • y1 - value at x=1.0
                          • A, B, C, D - cubic bézier points
                          • x - point to interpolate, ranging from 0 to 1
                          • pPrecision (optional) - to which precision the x value shall be evaluated
                              Returns

                              Interpolated y value at x

                              See also

                              Live demo

                              Function InterpolateCurve : Float ( y0:Float, y1:Float, yA:Float, x:Float )

                              Interpolates on a curve from (0,y0) to (1,y1) going through (0.5,yA) at x.

                              InterpolateCurve diagram

                              Parameters
                              • y0 - value at x=0.0
                              • y1 - value at x=1.0
                              • yA - value at x=0.5
                              • x - point to interpolate, ranging from 0 to 1
                                  Returns

                                  Interpolated y value at x

                                  See also

                                  Live demo

                                  Function InterpolateCustomLine : Float ( dataY:Float[], x:Float )

                                  Interpolates on a sawtooth line through all the points in dataY[] spread evenly from (0,dataY[0]) to (1,dataY[n]) at x. dataY must contain 2 or more points.

                                  InterpolateCustomLine diagram

                                  Parameters
                                  • dataY[] - an array of y points
                                  • x - point to interpolate, ranging from 0 to 1
                                      Returns

                                      Interpolated y value at x

                                      See also

                                      Live demo

                                      Function InterpolateElasticEaseIn : Float ( y0:Float, y1:Float, x:Float )

                                      Interpolates on an elastic bouncing curve from (0,y0) to (1,y1) at x. This eases in the bouncing.

                                      InterpolateElasticEaseIn diagram

                                      Parameters
                                      • y0 - value at x=0.0
                                      • y1 - value at x=1.0
                                      • x - point to interpolate, ranging from 0 to 1
                                          Returns

                                          Interpolated y value at x

                                          See also

                                          Live demo

                                          Function InterpolateElasticEaseInOut : Float ( y0:Float, y1:Float, x:Float )

                                          Interpolates on an elastic bouncing curve from (0,y0) to (1,y1) at x. This eases in and out the bouncing.

                                          InterpolateElasticEaseInOut diagram

                                          Parameters
                                          • y0 - value at x=0.0
                                          • y1 - value at x=1.0
                                          • x - point to interpolate, ranging from 0 to 1
                                              Returns

                                              Interpolated y value at x

                                              See also

                                              Live demo

                                              Function InterpolateElasticEaseOut : Float ( y0:Float, y1:Float, x:Float )

                                              Interpolates on an elastic bouncing curve from (0,y0) to (1,y1) at x. This eases out the bouncing.

                                              InterpolateElasticEaseOut diagram

                                              Parameters
                                              • y0 - value at x=0.0
                                              • y1 - value at x=1.0
                                              • x - point to interpolate, ranging from 0 to 1
                                                  Returns

                                                  Interpolated y value at x

                                                  See also

                                                  Live demo

                                                  Function InterpolateFit : Float ( y0:Float, y1:Float, s0:Float, s1:Float, x:Float )

                                                  Interpolates on a curve from (0,y0) to (1,y1) with slopes s0 and s1 respectively at x.

                                                  InterpolateFit diagram

                                                  Parameters
                                                  • y0 - value at x=0.0
                                                  • y1 - value at x=1.0
                                                  • s0 - slope at x=0.0
                                                  • s1 - slope at x=1.0
                                                  • x - point to interpolate, ranging from 0 to 1
                                                      Returns

                                                      Interpolated y value at x

                                                      See also

                                                      Live demo

                                                      Function InterpolateFlats : Float ( y0:Float, y1:Float, yA:Float, x:Float )

                                                      Interpolates on a curve from (0,y0) to (1,y1) with slopes=0 going through (0.5,yA) at x.

                                                      InterpolateFlats diagram

                                                      Parameters
                                                      • y0 - value at x=0.0
                                                      • y1 - value at x=1.0
                                                      • yA - value at x=0.5
                                                      • x - point to interpolate, ranging from 0 to 1
                                                          Returns

                                                          Interpolated y value at x

                                                          See also

                                                          Live demo

                                                          Function InterpolateLin : Float ( y0:Float, y1:Float, x:Float )

                                                          Interpolates linearly between (0,y0) and (1,y1) at x.

                                                          InterpolateLin diagram

                                                          Parameters
                                                          • y0 - value at x=0.0
                                                          • y1 - value at x=1.0
                                                          • x - point to interpolate, ranging from 0 to 1
                                                              Returns

                                                              Interpolated y value at x

                                                              See also

                                                              LinMap, Live demo

                                                              Function InterpolateSin : Float ( y0:Float, y1:Float, x:Float )

                                                              Interpolates on a sinusoidal from (0,y0) to (1,y1) at x.

                                                              InterpolateSin diagram

                                                              Parameters
                                                              • y0 - value at x=0.0
                                                              • y1 - value at x=1.0
                                                              • x - point to interpolate, ranging from 0 to 1
                                                                  Returns

                                                                  Interpolated y value at x

                                                                  See also

                                                                  Live demo

                                                                  Function LinMap : Float ( dt:Float, t0:Float, t1:Float )

                                                                  Returns percentage of where about dt is in the range of t0 to t1. This is basically the inverse function of InterpolateLin.