Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: samples/solar/web/solar.dart

Issue 12218131: Combine window.setTimeout/setInterval with Timer and Timer.repeating. Also (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698