当前位置:网站首页>动画曲线天天用,你能自己整一个吗?看完这篇你就会了!
动画曲线天天用,你能自己整一个吗?看完这篇你就会了!
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边栏推荐
- How to evaluate hardware resources (number of CPUs, memory size) when Oracle migrates from small computers to x86 architecture? Is there a measurement index or company?
- How to use RS485 half duplex chip correctly
- Pyqt5 use pyqtgraph to draw multiple y-value scatter plots
- Automatic assembly and fuse degradation of feign
- Research: more than 70% of doctors are still prescribing unsafe antibiotic drugs
- Redis 使用详解
- 【饭谈】软件测试薪资层次和分段(修仙)
- Performance debugging -- chrome performance
- Idea resolves the prompt of profile properties disappear
- Mysql8.0 MHA to achieve high availability "MHA"
猜你喜欢
![[database] index](/img/57/4921cf3eee9e8395415a8624b28d0a.png)
[database] index

Research: more than 70% of doctors are still prescribing unsafe antibiotic drugs

Idea resolves the prompt of profile properties disappear

Trusted and controllable way of Tencent cloud database

Stm3 (cubeide) lighting experiment

How to choose sentinel vs. hystrix current limiting?
![[ManageEngine] value brought by Siem to enterprises](/img/1e/56d64d193e0428523418bef5e98866.png)
[ManageEngine] value brought by Siem to enterprises

Oracle RAC RMAN backup error ora-19501 ora-15081

FAW red flag "King fried" is listed, which is safe and comfortable

Creation and destruction of function stack frames
随机推荐
MySQL master-slave configuration
[JS] the problem pointed by this
Six principles of C program design
CNN structural design skills: taking into account speed accuracy and engineering implementation
ES6 -- Deconstruction assignment
YUV420 YUV420sp 图像格式「建议收藏」
C common set
少儿编程 电子学会图形化编程等级考试Scratch一级真题解析(判断题)2022年6月
The adequacy of source evaluation forum · observation model test
Share | intelligent fire emergency management platform solution (PDF attached)
Detailed explanation of JVM memory model and structure (five model diagrams)
Stm3 (cubeide) lighting experiment
[leetcode ladder] linked list · 876 find the middle node of the linked list
Pyqt5 use pyqtgraph to draw multiple y-value scatter plots
Ability to choose
若依如何解决导出使用下载插件出现异常?
Mysql8.0 MHA to achieve high availability "MHA"
I/O案例实操
开源协议是否具有法律效力?
分享|智慧消防应急管理平台解决方案(附PDF)