Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
spring_animation.h
Go to the documentation of this file.
1//
2// Copyright (c) Meta Platforms, Inc. and affiliates.
3//
4// This source code is licensed under the MIT license found in the
5// LICENSE file in the root directory of this source tree.
6//
7// @flow
8// @format
9//
10
11#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_SPRING_ANIMATION_H_
12#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_SPRING_ANIMATION_H_
13
14#include <Foundation/NSObject.h>
15
16// This simplified spring model is based off of a damped harmonic oscillator.
17// See:
18// https://en.wikipedia.org/wiki/Harmonic_oscillator#Damped_harmonic_oscillator
19//
20// This models the closed form of the second order differential equation which
21// happens to match the algorithm used by CASpringAnimation, a QuartzCore (iOS)
22// API that creates spring animations.
23@interface SpringAnimation : NSObject
24
25- (instancetype)initWithStiffness:(double)stiffness
26 damping:(double)damping
27 mass:(double)mass
28 initialVelocity:(double)initialVelocity
29 fromValue:(double)fromValue
30 toValue:(double)toValue;
31
32- (double)curveFunction:(double)t;
33
34@property(nonatomic, assign, readonly) double stiffness;
35@property(nonatomic, assign, readonly) double damping;
36@property(nonatomic, assign, readonly) double mass;
37@property(nonatomic, assign, readonly) double initialVelocity;
38@property(nonatomic, assign) double fromValue;
39@property(nonatomic, assign) double toValue;
40
41@end
42
43#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_SPRING_ANIMATION_H_