Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Unified Diff: sky/framework/animation/fling_curve.dart

Issue 1132063007: Rationalize Dart mojo and sky package structure (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/framework/animation/curves.dart ('k') | sky/framework/animation/generators.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/animation/fling_curve.dart
diff --git a/sky/framework/animation/fling_curve.dart b/sky/framework/animation/fling_curve.dart
deleted file mode 100644
index 3a9f54f4a54d03f8476bde7a322e03564db72d0e..0000000000000000000000000000000000000000
--- a/sky/framework/animation/fling_curve.dart
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import "dart:math" as math;
-
-const double _kDefaultAlpha = -5707.62;
-const double _kDefaultBeta = 172.0;
-const double _kDefaultGamma = 3.7;
-
-double _positionAtTime(double t) {
- return _kDefaultAlpha * math.exp(-_kDefaultGamma * t)
- - _kDefaultBeta * t
- - _kDefaultAlpha;
-}
-
-double _velocityAtTime(double t) {
- return -_kDefaultAlpha * _kDefaultGamma * math.exp(-_kDefaultGamma * t)
- - _kDefaultBeta;
-}
-
-double _timeAtVelocity(double v) {
- return -math.log((v + _kDefaultBeta) / (-_kDefaultAlpha * _kDefaultGamma))
- / _kDefaultGamma;
-}
-
-final double _kMaxVelocity = _velocityAtTime(0.0);
-final double _kCurveDuration = _timeAtVelocity(0.0);
-
-class FlingCurve {
- double _timeOffset;
- double _positionOffset;
- double _startTime;
- double _previousPosition;
- double _direction;
-
- FlingCurve(double velocity, double startTime) {
- double startingVelocity = math.min(_kMaxVelocity, velocity.abs());
- _timeOffset = _timeAtVelocity(startingVelocity);
- _positionOffset = _positionAtTime(_timeOffset);
- _startTime = startTime / 1000.0;
- _previousPosition = 0.0;
- _direction = velocity.sign;
- }
-
- double update(double timeStamp) {
- double t = timeStamp / 1000.0 - _startTime + _timeOffset;
- if (t >= _kCurveDuration)
- return 0.0;
- double position = _positionAtTime(t) - _positionOffset;
- double positionDelta = position - _previousPosition;
- _previousPosition = position;
- return _direction * math.max(0.0, positionDelta);
- }
-}
« no previous file with comments | « sky/framework/animation/curves.dart ('k') | sky/framework/animation/generators.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698