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

Side by Side Diff: samples/spirodraw/Spirodraw.dart

Issue 10067009: Migrate the samples to one-argument version of requestAnimationFrame and re-enable the test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 | « client/tests/client/client.status ('k') | samples/total/client/InnerMenuView.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 #library('spirodraw'); 5 #library('spirodraw');
6 6
7 #import('dart:html'); 7 #import('dart:html');
8 #source("ColorPicker.dart"); 8 #source("ColorPicker.dart");
9 // TODO(732): Reenable when this works in the VM. 9 // TODO(732): Reenable when this works in the VM.
10 // #resource("spirodraw.css"); 10 // #resource("spirodraw.css");
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 157 }
158 drawWheel(theta); 158 drawWheel(theta);
159 } 159 }
160 160
161 void animate(int time) { 161 void animate(int time) {
162 if (run && rad <= maxTurns * PI2) { 162 if (run && rad <= maxTurns * PI2) {
163 rad+=stepSize; 163 rad+=stepSize;
164 drawFrame(rad); 164 drawFrame(rad);
165 int nTurns = (rad / PI2).toInt(); 165 int nTurns = (rad / PI2).toInt();
166 numTurns.text = '${nTurns}/$maxTurns'; 166 numTurns.text = '${nTurns}/$maxTurns';
167 window.webkitRequestAnimationFrame(animate, frontCanvas); 167 window.webkitRequestAnimationFrame(animate);
168 } else { 168 } else {
169 stop(); 169 stop();
170 } 170 }
171 } 171 }
172 172
173 void start() { 173 void start() {
174 refresh(); 174 refresh();
175 rad = 0.0; 175 rad = 0.0;
176 run = true; 176 run = true;
177 window.webkitRequestAnimationFrame(animate, frontCanvas); 177 window.webkitRequestAnimationFrame(animate);
178 } 178 }
179 179
180 int calcTurns() { 180 int calcTurns() {
181 // compute ratio of wheel radius to big R then find LCM 181 // compute ratio of wheel radius to big R then find LCM
182 if ((dUnits==0) || (rUnits==0)) 182 if ((dUnits==0) || (rUnits==0))
183 return 1; 183 return 1;
184 int ru = rUnits.abs(); 184 int ru = rUnits.abs();
185 int wrUnits = RUnits + rUnits; 185 int wrUnits = RUnits + rUnits;
186 int g = gcf (wrUnits, ru); 186 int g = gcf (wrUnits, ru);
187 return (ru ~/ g).toInt(); 187 return (ru ~/ g).toInt();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 301
302 int gcf(int n, int d) { 302 int gcf(int n, int d) {
303 if (n==d) 303 if (n==d)
304 return n; 304 return n;
305 int max = Math.max(n, d); 305 int max = Math.max(n, d);
306 for (int i = max ~/ 2; i > 1; i--) 306 for (int i = max ~/ 2; i > 1; i--)
307 if ((n % i == 0) && (d % i == 0)) 307 if ((n % i == 0) && (d % i == 0))
308 return i; 308 return i;
309 return 1; 309 return 1;
310 } 310 }
OLDNEW
« no previous file with comments | « client/tests/client/client.status ('k') | samples/total/client/InnerMenuView.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698