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

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

Issue 27440002: Revert "Removing setImmediate and hiding WindowTimers interface" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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';
12 import 'dart:html'; 11 import 'dart:html';
13 import 'dart:math'; 12 import 'dart:math';
14 13
15 void main() { 14 void main() {
16 CanvasElement canvas = query("#area"); 15 CanvasElement canvas = query("#area");
17 scheduleMicrotask(new SolarSystem(canvas).start); 16 window.setImmediate(new SolarSystem(canvas).start);
18 } 17 }
19 18
20 Element notes = query("#fps"); 19 Element notes = query("#fps");
21 num fpsAverage; 20 num fpsAverage;
22 21
23 /// Display the animation's FPS in a div. 22 /// Display the animation's FPS in a div.
24 void showFps(num fps) { 23 void showFps(num fps) {
25 if (fpsAverage == null) fpsAverage = fps; 24 if (fpsAverage == null) fpsAverage = fps;
26 fpsAverage = fps * 0.05 + fpsAverage * 0.95; 25 fpsAverage = fps * 0.05 + fpsAverage * 0.95;
27 notes.text = "${fpsAverage.round()} fps"; 26 notes.text = "${fpsAverage.round()} fps";
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 num calculateSpeed(num period) => 196 num calculateSpeed(num period) =>
198 period == 0.0 ? 0.0 : 1 / (60.0 * 24.0 * 2 * period); 197 period == 0.0 ? 0.0 : 1 / (60.0 * 24.0 * 2 * period);
199 198
200 Point calculatePos(Point p) { 199 Point calculatePos(Point p) {
201 if (orbitSpeed == 0.0) return p; 200 if (orbitSpeed == 0.0) return p;
202 num angle = solarSystem.renderTime * orbitSpeed; 201 num angle = solarSystem.renderTime * orbitSpeed;
203 return new Point(orbitRadius * cos(angle) + p.x, 202 return new Point(orbitRadius * cos(angle) + p.x,
204 orbitRadius * sin(angle) + p.y); 203 orbitRadius * sin(angle) + p.y);
205 } 204 }
206 } 205 }
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