| 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 import 'curves.dart'; | 5 import 'curves.dart'; |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'dart:math' as math; | 7 import 'dart:math' as math; |
| 8 import 'dart:sky' as sky; | 8 import 'dart:sky' as sky; |
| 9 | 9 |
| 10 class FrameGenerator { | 10 class FrameGenerator { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 this.curve: linear, | 66 this.curve: linear, |
| 67 Function onDone | 67 Function onDone |
| 68 }):super(onDone: onDone) { | 68 }):super(onDone: onDone) { |
| 69 double startTime = 0.0; | 69 double startTime = 0.0; |
| 70 _stream = super.onTick.map((timeStamp) { | 70 _stream = super.onTick.map((timeStamp) { |
| 71 if (startTime == 0.0) | 71 if (startTime == 0.0) |
| 72 startTime = timeStamp; | 72 startTime = timeStamp; |
| 73 return math.min((timeStamp - startTime) / duration, 1.0); | 73 return math.min((timeStamp - startTime) / duration, 1.0); |
| 74 }) | 74 }) |
| 75 .takeWhile(_checkForCompletion) | 75 .takeWhile(_checkForCompletion) |
| 76 .map((t) => begin + (end - begin) * curve.transform(t)); | 76 .map(_transform); |
| 77 } |
| 78 |
| 79 double _transform(double t) { |
| 80 if (_done) |
| 81 return end; |
| 82 return begin + (end - begin) * curve.transform(t); |
| 77 } | 83 } |
| 78 | 84 |
| 79 bool _checkForCompletion(double t) { | 85 bool _checkForCompletion(double t) { |
| 80 if (_done) | 86 if (_done) |
| 81 return false; | 87 return false; |
| 82 _done = t >= 1; | 88 _done = t >= 1; |
| 83 return true; | 89 return true; |
| 84 } | 90 } |
| 85 } | 91 } |
| OLD | NEW |