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

Unified Diff: test/codegen/sunflower.dart

Issue 1016003003: sort classes in dependency order, or load lazily if needed, fixes #78 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/codegen/expect/sunflower.js ('k') | test/sunflower/sunflower.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « test/codegen/expect/sunflower.js ('k') | test/sunflower/sunflower.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698