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

Side by Side Diff: samples/clock/balls.dart

Issue 10829459: Deprecate Math object in corelib in favor of dart:math library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 4 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/chat/chat_server_lib.dart ('k') | samples/clock/clock.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 int clientWidth() => window.innerWidth; 5 int clientWidth() => window.innerWidth;
6 6
7 int clientHeight() => window.innerHeight; 7 int clientHeight() => window.innerHeight;
8 8
9 class Balls { 9 class Balls {
10 static final double RADIUS2 = Ball.RADIUS * Ball.RADIUS; 10 static final double RADIUS2 = Ball.RADIUS * Ball.RADIUS;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 111 }
112 112
113 class Ball { 113 class Ball {
114 static final double GRAVITY = 400.0; 114 static final double GRAVITY = 400.0;
115 static final double RESTITUTION = 0.8; 115 static final double RESTITUTION = 0.8;
116 static final double MIN_VELOCITY = 100.0; 116 static final double MIN_VELOCITY = 100.0;
117 static final double INIT_VELOCITY = 800.0; 117 static final double INIT_VELOCITY = 800.0;
118 static final double RADIUS = 14.0; 118 static final double RADIUS = 14.0;
119 119
120 static double randomVelocity() { 120 static double randomVelocity() {
121 return (Math.random() - 0.5) * INIT_VELOCITY; 121 return (new Math.Random().nextDouble() - 0.5) * INIT_VELOCITY;
122 } 122 }
123 123
124 Element root; 124 Element root;
125 ImageElement elem; 125 ImageElement elem;
126 double x, y; 126 double x, y;
127 double vx, vy; 127 double vx, vy;
128 double ax, ay; 128 double ax, ay;
129 double age; 129 double age;
130 130
131 Ball(this.root, this.x, this.y, int color) { 131 Ball(this.root, this.x, this.y, int color) {
(...skipping 29 matching lines...) Expand all
161 y = clientHeight().toDouble(); 161 y = clientHeight().toDouble();
162 vy *= -RESTITUTION; 162 vy *= -RESTITUTION;
163 } 163 }
164 164
165 // Position the element. 165 // Position the element.
166 setElementPosition(elem, x - RADIUS, y - RADIUS); 166 setElementPosition(elem, x - RADIUS, y - RADIUS);
167 167
168 return true; 168 return true;
169 } 169 }
170 } 170 }
OLDNEW
« no previous file with comments | « samples/chat/chat_server_lib.dart ('k') | samples/clock/clock.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698