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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 SolarSystem(this.canvas) { | 61 SolarSystem(this.canvas) { |
62 | 62 |
63 } | 63 } |
64 | 64 |
65 num get width => _width; | 65 num get width => _width; |
66 | 66 |
67 num get height => _height; | 67 num get height => _height; |
68 | 68 |
69 start() { | 69 start() { |
70 // Measure the canvas element. | 70 // Measure the canvas element. |
71 window.setImmediate(() { | 71 window.immediate.then((_) { |
72 _width = (canvas.parent as Element).clientWidth; | 72 _width = (canvas.parent as Element).clientWidth; |
73 _height = (canvas.parent as Element).clientHeight; | 73 _height = (canvas.parent as Element).clientHeight; |
74 | 74 |
75 canvas.width = _width; | 75 canvas.width = _width; |
76 | 76 |
77 // Initialize the planets and start the simulation. | 77 // Initialize the planets and start the simulation. |
78 _start(); | 78 _start(); |
79 }); | 79 }); |
80 } | 80 } |
81 | 81 |
(...skipping 185 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 |