| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * A solar system visualization. | 6 * A solar system visualization. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 library solar; | 9 library solar; |
| 10 | 10 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 void draw(num _) { | 114 void draw(num _) { |
| 115 num time = new DateTime.now().millisecondsSinceEpoch; | 115 num time = new DateTime.now().millisecondsSinceEpoch; |
| 116 | 116 |
| 117 if (renderTime != null) { | 117 if (renderTime != null) { |
| 118 showFps((1000 / (time - renderTime)).round()); | 118 showFps((1000 / (time - renderTime)).round()); |
| 119 } | 119 } |
| 120 | 120 |
| 121 renderTime = time; | 121 renderTime = time; |
| 122 | 122 |
| 123 var context = canvas.context2d; | 123 var context = canvas.context2D; |
| 124 | 124 |
| 125 drawBackground(context); | 125 drawBackground(context); |
| 126 drawPlanets(context); | 126 drawPlanets(context); |
| 127 | 127 |
| 128 requestRedraw(); | 128 requestRedraw(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 void drawBackground(CanvasRenderingContext2D context) { | 131 void drawBackground(CanvasRenderingContext2D context) { |
| 132 context.clearRect(0, 0, width, height); | 132 context.clearRect(0, 0, width, height); |
| 133 } | 133 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 } else { | 261 } else { |
| 262 num angle = solarSystem.renderTime * orbitSpeed; | 262 num angle = solarSystem.renderTime * orbitSpeed; |
| 263 | 263 |
| 264 return new Point( | 264 return new Point( |
| 265 orbitRadius * cos(angle) + x, | 265 orbitRadius * cos(angle) + x, |
| 266 orbitRadius * sin(angle) + y); | 266 orbitRadius * sin(angle) + y); |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 | 269 |
| 270 } | 270 } |
| OLD | NEW |