| OLD | NEW |
| 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' as Math; | 8 import 'dart:math' as Math; |
| 9 | 9 |
| 10 part "colorpicker.dart"; | 10 part "colorpicker.dart"; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 Spirodraw() { | 43 Spirodraw() { |
| 44 doc = window.document; | 44 doc = window.document; |
| 45 inOrOut = doc.query("#in_out"); | 45 inOrOut = doc.query("#in_out"); |
| 46 fixedRadiusSlider = doc.query("#fixed_radius"); | 46 fixedRadiusSlider = doc.query("#fixed_radius"); |
| 47 wheelRadiusSlider = doc.query("#wheel_radius"); | 47 wheelRadiusSlider = doc.query("#wheel_radius"); |
| 48 penRadiusSlider = doc.query("#pen_radius"); | 48 penRadiusSlider = doc.query("#pen_radius"); |
| 49 penWidthSlider = doc.query("#pen_width"); | 49 penWidthSlider = doc.query("#pen_width"); |
| 50 speedSlider = doc.query("#speed"); | 50 speedSlider = doc.query("#speed"); |
| 51 mainDiv = doc.query("#main"); | 51 mainDiv = doc.query("#main"); |
| 52 frontCanvas = doc.query("#canvas"); | 52 frontCanvas = doc.query("#canvas"); |
| 53 front = frontCanvas.context2d; | 53 front = frontCanvas.context2D; |
| 54 backCanvas = new Element.tag("canvas"); | 54 backCanvas = new Element.tag("canvas"); |
| 55 back = backCanvas.context2d; | 55 back = backCanvas.context2D; |
| 56 paletteElement = doc.query("#palette"); | 56 paletteElement = doc.query("#palette"); |
| 57 window.onResize.listen(onResize); | 57 window.onResize.listen(onResize); |
| 58 initControlPanel(); | 58 initControlPanel(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void go() { | 61 void go() { |
| 62 onResize(null); | 62 onResize(null); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void onResize(Event event) { | 65 void onResize(Event event) { |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 int gcf(int n, int d) { | 292 int gcf(int n, int d) { |
| 293 if (n == d) return n; | 293 if (n == d) return n; |
| 294 int max = Math.max(n, d); | 294 int max = Math.max(n, d); |
| 295 | 295 |
| 296 for (int i = max ~/ 2; i > 1; i--) { | 296 for (int i = max ~/ 2; i > 1; i--) { |
| 297 if ((n % i == 0) && (d % i == 0)) return i; | 297 if ((n % i == 0) && (d % i == 0)) return i; |
| 298 } | 298 } |
| 299 | 299 |
| 300 return 1; | 300 return 1; |
| 301 } | 301 } |
| OLD | NEW |