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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 jupiter.addPlanet(new PlanetaryBody( | 112 jupiter.addPlanet(new PlanetaryBody( |
113 this, "Ganymede", "gray", 5.3 * f, 1070 * h, 7.154 * g)); | 113 this, "Ganymede", "gray", 5.3 * f, 1070 * h, 7.154 * g)); |
114 jupiter.addPlanet(new PlanetaryBody( | 114 jupiter.addPlanet(new PlanetaryBody( |
115 this, "Callisto", "gray", 4.8 * f, 1882 * h, 16.689 * g)); | 115 this, "Callisto", "gray", 4.8 * f, 1882 * h, 16.689 * g)); |
116 | 116 |
117 // Start the animation loop. | 117 // Start the animation loop. |
118 requestRedraw(); | 118 requestRedraw(); |
119 } | 119 } |
120 | 120 |
121 void draw(num _) { | 121 void draw(num _) { |
122 num time = new Date.now().millisecondsSinceEpoch; | 122 num time = new DateTime.now().millisecondsSinceEpoch; |
123 | 123 |
124 if (renderTime != null) { | 124 if (renderTime != null) { |
125 showFps((1000 / (time - renderTime)).round()); | 125 showFps((1000 / (time - renderTime)).round()); |
126 } | 126 } |
127 | 127 |
128 renderTime = time; | 128 renderTime = time; |
129 | 129 |
130 var context = canvas.context2d; | 130 var context = canvas.context2d; |
131 | 131 |
132 drawBackground(context); | 132 drawBackground(context); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 } else { | 267 } else { |
268 num angle = solarSystem.renderTime * orbitSpeed; | 268 num angle = solarSystem.renderTime * orbitSpeed; |
269 | 269 |
270 return new Point( | 270 return new Point( |
271 orbitRadius * cos(angle) + x, | 271 orbitRadius * cos(angle) + x, |
272 orbitRadius * sin(angle) + y); | 272 orbitRadius * sin(angle) + y); |
273 } | 273 } |
274 } | 274 } |
275 | 275 |
276 } | 276 } |
OLD | NEW |