nc-photos/app/lib/animation_util.dart
2024-05-25 17:46:01 +08:00

18 lines
325 B
Dart

double tremblingTransform(int count, double t) {
final tt = (t * count) % 1;
return _tremblingTransformT(tt);
}
double _tremblingTransformT(double t) {
if (t <= 0 || t >= 1) {
return 0;
}
final x = 4 * t;
if (x < 1) {
return -x;
} else if (x < 3) {
return x - 1;
} else {
return 4 - x;
}
}