smoothFrame
smoothFrame
can be used to smooth motion across a single frame, independent of framerate.
This can be used, for example, to implement input smoothing.
Note: To smooth motion using a Framesync-based process or library like Popmotion Pure, the smooth utility offers a simpler API.
Import
import { smoothFrame } from '@popmotion/popcorn';
Usage
smoothFrame
accepts prevValue
, nextValue
, frameDuration
and strength
arguments.
It will return a value that smooths the difference between prevValue
and nextValue
according to the frameDuration
and strength
properties.
smoothFrame(0, 100, 16.7, 50); // 33.4
Higher strength
values impose stronger smoothing, with values the same as or less than the frameDuration
imposing no smoothing.
Types
smoothFrame(
prev: number,
next: number,
frameDuration: number,
strength: number
): number