Index: test/codegen/sunflower.dart |
diff --git a/test/codegen/sunflower.dart b/test/codegen/sunflower.dart |
index d5958c5ca318733ec17fdc77fefc81d57977b8bc..9e4be1347d6a1a42e2cbc68f710162c4f36e277e 100644 |
--- a/test/codegen/sunflower.dart |
+++ b/test/codegen/sunflower.dart |
@@ -24,11 +24,31 @@ int seeds = 0; |
final CanvasRenderingContext2D context = |
(querySelector("#canvas") as CanvasElement).getContext('2d'); |
-// TODO(jmesserly): modified this example to use classes and mixins. |
-class Circle { |
- final num x, y, radius; |
+void main() { |
+ slider.addEventListener('change', (e) => draw()); |
+ draw(); |
+} |
- Circle(this.x, this.y, this.radius); |
+/// Draw the complete figure for the current number of seeds. |
+void draw() { |
+ seeds = int.parse(slider.value); |
+ context.clearRect(0, 0, MAX_D, MAX_D); |
+ for (var i = 0; i < seeds; i++) { |
+ final num theta = i * TAU / PHI; |
+ final num r = sqrt(i) * SCALE_FACTOR; |
+ final num x = centerX + r * cos(theta); |
+ final num y = centerY - r * sin(theta); |
+ new SunflowerSeed(x, y, SEED_RADIUS).draw(); |
+ } |
+ notes.textContent = "$seeds seeds"; |
+} |
+ |
+// This example was modified to use classes and mixins. |
+class SunflowerSeed extends Circle with CirclePainter { |
+ SunflowerSeed(num x, num y, num radius, [String color]) |
+ : super(x, y, radius) { |
+ if (color != null) this.color = color; |
+ } |
} |
abstract class CirclePainter implements Circle { |
@@ -49,28 +69,8 @@ abstract class CirclePainter implements Circle { |
} |
} |
-class SunflowerSeed extends Circle with CirclePainter { |
- SunflowerSeed(num x, num y, num radius, [String color]) |
- : super(x, y, radius) { |
- if (color != null) this.color = color; |
- } |
-} |
- |
-void main() { |
- slider.addEventListener('change', (e) => draw()); |
- draw(); |
-} |
+class Circle { |
+ final num x, y, radius; |
-/// Draw the complete figure for the current number of seeds. |
-void draw() { |
- seeds = int.parse(slider.value); |
- context.clearRect(0, 0, MAX_D, MAX_D); |
- for (var i = 0; i < seeds; i++) { |
- final num theta = i * TAU / PHI; |
- final num r = sqrt(i) * SCALE_FACTOR; |
- final num x = centerX + r * cos(theta); |
- final num y = centerY - r * sin(theta); |
- new SunflowerSeed(x, y, SEED_RADIUS).draw(); |
- } |
- notes.textContent = "$seeds seeds"; |
+ Circle(this.x, this.y, this.radius); |
} |