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

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

Issue 27441002: Removing setImmediate and hiding WindowTimers interface (take 2) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: The fix Created 7 years, 2 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
« no previous file with comments | « samples/clock/web/numbers.dart ('k') | samples/swarm/Views.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 import 'dart:async';
11 import 'dart:html'; 12 import 'dart:html';
12 import 'dart:math'; 13 import 'dart:math';
13 14
14 void main() { 15 void main() {
15 CanvasElement canvas = query("#area"); 16 CanvasElement canvas = query("#area");
16 window.setImmediate(new SolarSystem(canvas).start); 17 scheduleMicrotask(new SolarSystem(canvas).start);
17 } 18 }
18 19
19 Element notes = query("#fps"); 20 Element notes = query("#fps");
20 num fpsAverage; 21 num fpsAverage;
21 22
22 /// Display the animation's FPS in a div. 23 /// Display the animation's FPS in a div.
23 void showFps(num fps) { 24 void showFps(num fps) {
24 if (fpsAverage == null) fpsAverage = fps; 25 if (fpsAverage == null) fpsAverage = fps;
25 fpsAverage = fps * 0.05 + fpsAverage * 0.95; 26 fpsAverage = fps * 0.05 + fpsAverage * 0.95;
26 notes.text = "${fpsAverage.round()} fps"; 27 notes.text = "${fpsAverage.round()} fps";
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 num calculateSpeed(num period) => 197 num calculateSpeed(num period) =>
197 period == 0.0 ? 0.0 : 1 / (60.0 * 24.0 * 2 * period); 198 period == 0.0 ? 0.0 : 1 / (60.0 * 24.0 * 2 * period);
198 199
199 Point calculatePos(Point p) { 200 Point calculatePos(Point p) {
200 if (orbitSpeed == 0.0) return p; 201 if (orbitSpeed == 0.0) return p;
201 num angle = solarSystem.renderTime * orbitSpeed; 202 num angle = solarSystem.renderTime * orbitSpeed;
202 return new Point(orbitRadius * cos(angle) + p.x, 203 return new Point(orbitRadius * cos(angle) + p.x,
203 orbitRadius * sin(angle) + p.y); 204 orbitRadius * sin(angle) + p.y);
204 } 205 }
205 } 206 }
OLDNEW
« no previous file with comments | « samples/clock/web/numbers.dart ('k') | samples/swarm/Views.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698