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

Unified Diff: test/codegen/sunflower/sunflower.dart

Issue 1147053003: Modified sunflower (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Refactor Created 5 years, 7 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/sunflower/painter.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codegen/sunflower/sunflower.dart
diff --git a/test/codegen/sunflower/sunflower.dart b/test/codegen/sunflower/sunflower.dart
index bf140b188d51e00df6a56064bd27ebf2e6a9cb0a..baec7b86d7a219c0c378d8e239c566014102387c 100644
--- a/test/codegen/sunflower/sunflower.dart
+++ b/test/codegen/sunflower/sunflower.dart
@@ -1,28 +1,29 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library sunflower;
import 'dart:math';
+
+import 'circle.dart';
import 'dom.dart';
+import 'painter.dart';
-const ORANGE = "orange";
const SEED_RADIUS = 2;
const SCALE_FACTOR = 4;
-const TAU = PI * 2;
const MAX_D = 300;
const centerX = MAX_D / 2;
const centerY = centerX;
Element querySelector(String selector) => document.querySelector(selector);
-
-final InputElement slider = querySelector("#slider");
+final canvas = querySelector("#canvas") as CanvasElement;
+final context = canvas.getContext('2d') as CanvasRenderingContext2D;
+final slider = querySelector("#slider") as InputElement;
final notes = querySelector("#notes");
+
final PHI = (sqrt(5) + 1) / 2;
int seeds = 0;
-final CanvasRenderingContext2D context =
- (querySelector("#canvas") as CanvasElement).getContext('2d');
void main() {
slider.addEventListener('change', (e) => draw());
@@ -38,7 +39,7 @@ void draw() {
final r = sqrt(i) * SCALE_FACTOR;
final x = centerX + r * cos(theta);
final y = centerY - r * sin(theta);
- new SunflowerSeed(x, y, SEED_RADIUS).draw();
+ new SunflowerSeed(x, y, SEED_RADIUS).draw(context);
}
notes.textContent = "$seeds seeds";
}
@@ -51,26 +52,4 @@ class SunflowerSeed extends Circle with CirclePainter {
}
}
-abstract class CirclePainter implements Circle {
- // This demonstrates a field in a mixin.
- String color = ORANGE;
-
- /// Draw a small circle representing a seed centered at (x,y).
- void draw() {
- context
- ..beginPath()
- ..lineWidth = 2
- ..fillStyle = color
- ..strokeStyle = color
- ..arc(x, y, radius, 0, TAU, false)
- ..fill()
- ..closePath()
- ..stroke();
- }
-}
-
-class Circle {
- final num x, y, radius;
- Circle(this.x, this.y, this.radius);
-}
« no previous file with comments | « test/codegen/sunflower/painter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698