当前位置:网站首页>动画曲线天天用,你能自己整一个吗?看完这篇你就会了!
动画曲线天天用,你能自己整一个吗?看完这篇你就会了!
2022-07-25 21:45:00 【InfoQ】
前言
Curve
Curve 类定义
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');
}
transformtransformInternalUnimplementedError实例解析
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
DurationCurve正弦动画曲线
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) {
// 需要补偿pi/2个角度,使得起始值是0.终止值是1,避免出现最后突然回到0
return sin(2 * (count + 0.25) * pi * t);
}
}

总结
transformInternal边栏推荐
- 【饭谈】软件测试薪资层次和分段(修仙)
- 卸载npm和安装npm_使用`npm uninstall`卸载npm软件包「建议收藏」
- 选择的能力
- C#Socket
- In Oracle 19C version, logminer package continuous_ The outdated function of mine leads to CDC failure
- Reading the pointpillar code of openpcdet -- Part 3: Calculation of loss function
- 开源协议是否具有法律效力?
- 919. 完全二叉树插入器 : 简单 BFS 运用题
- C#常见的集合
- [hand torn STL] unordered_ set、unordered_ Map (encapsulated with hash table)
猜你喜欢

C#Socket

How to solve the problem of high concurrency and large traffic with PHP

如何用 Redis 实现分布式锁的?
![PHP zero time task, PHP laravel time task schedule [dry goods]](/img/09/c9a4c83fe23c852aa76a6f5a6cea52.png)
PHP zero time task, PHP laravel time task schedule [dry goods]

Why do independent sellers like to do e-mail marketing? The original conversion rate can be improved so much!

Face and key point detection: yolo5face practice

MySQL master-slave configuration

工作面试总遇秒杀? 看了京东 T8 大咖私藏的秒杀系统笔记, 已献出膝盖
![[hand torn STL] unordered_ set、unordered_ Map (encapsulated with hash table)](/img/33/08f7b72ce99e07821a1f4b6e594e13.png)
[hand torn STL] unordered_ set、unordered_ Map (encapsulated with hash table)

【Redis底层解析】链表类型
随机推荐
ONEFLOW V0.8.0 officially released
Bitcoin.com:usdd represents a truly decentralized stable currency
Apache Shenyu admin authentication bypass vulnerability (cve-2021-37580) analysis and protection measures
pyqt5使用pyqtgraph绘制多个Y值散点图
[interview: concurrent Article 23: multithreading: Join] re understanding of join
GPON introduction and Huawei OLT gateway registration and configuration process
Autojs learning - Automatic screenshot of the king
少儿编程 电子学会图形化编程等级考试Scratch一级真题解析(判断题)2022年6月
【饭谈】测试平台为什么有组件化?模块化?很多看不到的地方设计的很好是种浪费么?
腾讯云数据库的可信可控之路
c sqlite ... ...
New maixhub deployment (v831 and k210)
Detailed explanation of several ideas for implementing timed tasks in PHP
Naming rules for BSP of Quanzhi chip
Job interviews are always a second kill? After reading the seckill system notes secretly stored by JD T8, I have given my knees
人脸与关键点检测:YOLO5Face实战
Apple estimates that iPhone will give up the Chinese market, and the Chinese industrial chain needs to consider living a hard life
Basic knowledge in the project
【饭谈】那些看似为公司着想,实际却很自私的故事 (一:造轮子)
FAW red flag "King fried" is listed, which is safe and comfortable