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

Side by Side Diff: samples/spirodraw/Spirodraw.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/solar/solar.dart ('k') | samples/sunflower/sunflower.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 #library('spirodraw'); 5 #library('spirodraw');
6 6
7 #import('dart:html'); 7 #import('dart:html');
8 #import('dart:math', prefix: 'Math');
8 9
9 #source("ColorPicker.dart"); 10 #source("ColorPicker.dart");
10 11
11 void main() { 12 void main() {
12 new Spirodraw().go(); 13 new Spirodraw().go();
13 } 14 }
14 15
15 class Spirodraw { 16 class Spirodraw {
16 static double PI2 = Math.PI * 2; 17 static double PI2 = Math.PI * 2;
17 Document doc; 18 Document doc;
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 back.clearRect(0, 0, width, height); 200 back.clearRect(0, 0, width, height);
200 refresh(); 201 refresh();
201 } 202 }
202 203
203 /** 204 /**
204 * Choose random settings for wheel and pen, but 205 * Choose random settings for wheel and pen, but
205 * leave fixed radius alone as it often changes 206 * leave fixed radius alone as it often changes
206 * things too much. 207 * things too much.
207 */ 208 */
208 void lucky() { 209 void lucky() {
209 wheelRadiusSlider.valueAsNumber = Math.random() * 9; 210 var rand = new Math.Random();
210 penRadiusSlider.valueAsNumber = Math.random() * 9; 211 wheelRadiusSlider.valueAsNumber = rand.nextDouble() * 9;
211 penWidthSlider.valueAsNumber = 1 + Math.random() * 9; 212 penRadiusSlider.valueAsNumber = rand.nextDouble() * 9;
212 colorPicker.selectedColor = colorPicker.getHexString(Math.random() * 215); 213 penWidthSlider.valueAsNumber = 1 + rand.nextDouble() * 9;
214 colorPicker.selectedColor = colorPicker.getHexString(rand.nextDouble() * 215 );
213 start(); 215 start();
214 } 216 }
215 217
216 void drawFixed() { 218 void drawFixed() {
217 if (animationEnabled) { 219 if (animationEnabled) {
218 front.beginPath(); 220 front.beginPath();
219 front.setLineWidth(2); 221 front.setLineWidth(2);
220 front.strokeStyle = "gray"; 222 front.strokeStyle = "gray";
221 front.arc(xc, yc, R, 0, PI2, true); 223 front.arc(xc, yc, R, 0, PI2, true);
222 front.closePath(); 224 front.closePath();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 301
300 int gcf(int n, int d) { 302 int gcf(int n, int d) {
301 if (n==d) 303 if (n==d)
302 return n; 304 return n;
303 int max = Math.max(n, d); 305 int max = Math.max(n, d);
304 for (int i = max ~/ 2; i > 1; i--) 306 for (int i = max ~/ 2; i > 1; i--)
305 if ((n % i == 0) && (d % i == 0)) 307 if ((n % i == 0) && (d % i == 0))
306 return i; 308 return i;
307 return 1; 309 return 1;
308 } 310 }
OLDNEW
« no previous file with comments | « samples/solar/solar.dart ('k') | samples/sunflower/sunflower.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698