当前位置:网站首页>Animation curves are used every day. Can you make one by yourself? After reading this article, you will!
Animation curves are used every day. Can you make one by yourself? After reading this article, you will!
2022-07-25 21:53:00 【InfoQ】
Preface
Curve
Curve Class definition
Curveabstract class Curve extends ParametricCurve<double> {
const Curve();
@override
double transform(double t) {
if (t == 0.0 || t == 1.0) {
return t;
}
return super.transform(t);
}
Curve get flipped => FlippedCurve(this);
}
doubletransformParametricCurvetransformInternalParametricCurveabstract class ParametricCurve<T> {
const ParametricCurve();
T transform(double t) {
assert(t != null);
assert(t >= 0.0 && t <= 1.0, 'parametric value $t is outside of [0, 1] range.');
return transformInternal(t);
}
@protected
T transformInternal(double t) {
throw UnimplementedError();
}
@override
String toString() => objectRuntimeType(this, 'ParametricCurve');
}
transformtransformInternalUnimplementedErrorInstance analysis
ttttt Curves.linearclass _Linear extends Curve {
const _Linear._();
@override
double transformInternal(double t) => t;
}
y = f(t) = t
decelerateclass _DecelerateCurve extends Curve {
const _DecelerateCurve._();
@override
double transformInternal(double t) {
t = 1.0 - t;
return 1.0 - t * t;
}
}


transformInternal
DurationCurveSinusoidal animation curve
class SineCurve extends Curve {
final int count;
const SineCurve({this.count = 1}) : assert(count > 0);
@override
double transformInternal(double t) {
return sin(2 * count* pi * t);
}
}
countAnimatedContainer(
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(30.0),
),
transform: Matrix4.identity()..translate(0.0, up ? 60.0 : 0.0, 0.0),
duration: Duration(milliseconds: 3000),
curve: SineCurve(count: 1),
child: ClipOval(
child: Container(
width: 60.0,
height: 60.0,
color: Colors.blue,
),
),
)


count=2
class SineCurve extends Curve {
final int count;
const SineCurve({this.count = 1}) : assert(count > 0);
@override
double transformInternal(double t) {
// Need compensation pi/2 Angles , So that the starting value is 0. The end value is 1, Avoid the last sudden return to 0
return sin(2 * (count + 0.25) * pi * t);
}
}

summary
transformInternal边栏推荐
- Does the open source agreement have legal effect?
- 【面试:并发篇25:多线程:volatile】可见性
- Children's programming electronic society graphical programming level examination scratch level 1 real problem analysis (judgment question) June 2022
- QT | learn about QT creator by creating a simple project
- ansible+Crontab批部署巡检
- NVIDIA has opened source a comprehensive library of 3D deep learning based on pytorch
- 性能调试 -- Chrome Performance
- Special class design
- Detailed summary of C language game dual cache to solve the flash screen problem [easy to understand]
- [51nod1676 undirected graph isomorphism] undirected graph hash [easy to understand]
猜你喜欢

动画曲线天天用,你能自己整一个吗?看完这篇你就会了!

Vivo official website app full model UI adaptation scheme

Jmeter---设置代理录制请求

Oracle RAC RMAN backup error ora-19501 ora-15081
![[interview: concurrent 25: multithreading: volatile] visibility](/img/03/6b44242a019775222fdf9c7a920ae5.png)
[interview: concurrent 25: multithreading: volatile] visibility

函数栈帧的创建和销毁

【面试:并发篇23:多线程:join】join再理解

C#Socket

【leetcode天梯】链表 · 021 合并两个有序链表

五、品达通用权限系统__pd-tools-xxs(防跨站脚本攻击)
随机推荐
PE格式: 分析IatHook并实现
Detailed explanation of several ideas for implementing timed tasks in PHP
Babbitt | metauniverse daily must read: the popularity of virtual people has decreased, and some "debut is the peak", and the onlookers have dispersed
Basic knowledge in the project
全志芯片bsp命名规则
Is there any document for synchronizing from Oracle to ODPs?
Basic knowledge in the project
【饭谈】如何设计好一款测试平台?
Come again
Handwriting distributed configuration center (1)
五、品达通用权限系统__pd-tools-xxs(防跨站脚本攻击)
【饭谈】那些看似为公司着想,实际却很自私的故事 (一:造轮子)
sql语句练习题整理
mouseEvent事件——mouse坐标描述——focus事件——input事件——节流(thorttle)——mouseWheel(滚轮事件)
[MAIXPY]kpu: load error:2005, ERR_READ_FILE: read file failed问题解决
【饭谈】测试平台为什么有组件化?模块化?很多看不到的地方设计的很好是种浪费么?
【Redis底层解析】链表类型
8000 word super detailed custom structure type
Pyg tutorial (8): calculate a more efficient sparse matrix form
MPI learning notes (II): two implementation methods of matrix multiplication