| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 double _evaluateCubic(double a, double b, double m) { | 5 double _evaluateCubic(double a, double b, double m) { |
| 6 // TODO(abarth): Would Math.pow be faster? | 6 // TODO(abarth): Would Math.pow be faster? |
| 7 return 3 * a * (1 - m) * (1 - m) * m + 3 * b * (1 - m) * m * m + m * m * m; | 7 return 3 * a * (1 - m) * (1 - m) * m + 3 * b * (1 - m) * m * m + m * m * m; |
| 8 } | 8 } |
| 9 | 9 |
| 10 const double _kCubicErrorBound = 0.001; | 10 const double _kCubicErrorBound = 0.001; |
| 11 | 11 |
| 12 abstract class Curve { | 12 abstract class Curve { |
| 13 double transform(double t); | 13 double transform(double t); |
| 14 } | 14 } |
| 15 | 15 |
| 16 class Linear implements Curve { | 16 class Linear implements Curve { |
| 17 const Linear(); | 17 const Linear(); |
| 18 | 18 |
| 19 double transform(double t) { | 19 double transform(double t) { |
| 20 return t; | 20 return t; |
| 21 } | 21 } |
| 22 } | 22 } |
| 23 | 23 |
| 24 class ParabolicFall implements Curve { |
| 25 const ParabolicFall(); |
| 26 |
| 27 double transform(double t) { |
| 28 return -t*t + 1; |
| 29 } |
| 30 } |
| 31 |
| 32 class ParabolicRise implements Curve { |
| 33 const ParabolicRise(); |
| 34 |
| 35 double transform(double t) { |
| 36 return -(t-1)*(t-1) + 1; |
| 37 } |
| 38 } |
| 39 |
| 24 class Cubic implements Curve { | 40 class Cubic implements Curve { |
| 25 final double a; | 41 final double a; |
| 26 final double b; | 42 final double b; |
| 27 final double c; | 43 final double c; |
| 28 final double d; | 44 final double d; |
| 29 | 45 |
| 30 const Cubic(this.a, this.b, this.c, this.d); | 46 const Cubic(this.a, this.b, this.c, this.d); |
| 31 | 47 |
| 32 double transform(double t) { | 48 double transform(double t) { |
| 33 double start = 0.0; | 49 double start = 0.0; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 45 end = midpoint; | 61 end = midpoint; |
| 46 } | 62 } |
| 47 } | 63 } |
| 48 } | 64 } |
| 49 | 65 |
| 50 const Linear linear = const Linear(); | 66 const Linear linear = const Linear(); |
| 51 const Cubic ease = const Cubic(0.25, 0.1, 0.25, 1.0); | 67 const Cubic ease = const Cubic(0.25, 0.1, 0.25, 1.0); |
| 52 const Cubic easeIn = const Cubic(0.42, 0.0, 1.0, 1.0); | 68 const Cubic easeIn = const Cubic(0.42, 0.0, 1.0, 1.0); |
| 53 const Cubic easeOut = const Cubic(0.0, 0.0, 0.58, 1.0); | 69 const Cubic easeOut = const Cubic(0.0, 0.0, 0.58, 1.0); |
| 54 const Cubic easeInOut = const Cubic(0.42, 0.0, 0.58, 1.0); | 70 const Cubic easeInOut = const Cubic(0.42, 0.0, 0.58, 1.0); |
| 71 const Cubic parabolicRise = const ParabolicRise(); |
| 72 const Cubic parabolicFall = const ParabolicFall(); |
| OLD | NEW |