* Interpolates the output value based on the normalized frame value. * @param t - The normalized frame value (between 0 and 1). * @param segment - The current segment index. * @returns The interpolated output value.
(t: number, segment: number)
| 99 | * @returns The interpolated output value. |
| 100 | */ |
| 101 | private interpolate(t: number, segment: number): T { |
| 102 | const outputStart = this.output[segment]; |
| 103 | const outputEnd = this.output[segment + 1]; |
| 104 | const easedT = utils.easingFunctions[this.options.easing](t); |
| 105 | |
| 106 | if (typeof outputStart === 'number' && typeof outputEnd === 'number') { |
| 107 | return utils.lerp(outputStart, outputEnd, easedT) as T; |
| 108 | } |
| 109 | if (typeof outputStart === 'string' && typeof outputEnd === 'string') { |
| 110 | return utils.interpolateColor(outputStart, outputEnd, easedT) as T; |
| 111 | } |
| 112 | if (this.output.length == 1) { |
| 113 | return this.output[0]; |
| 114 | } |
| 115 | throw new ValidationError({ |
| 116 | code: 'invalidKeyframes', |
| 117 | message: 'Unsupported output range types', |
| 118 | }); |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Evaluates the interpolated value for a given milliseconds number. |