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

Unified Diff: test/codegen/sunflower.dart

Issue 1007313003: Move sunflower to a new directory, make final tweaks to make it all work. (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/sunflower.txt ('k') | test/codegen/sunflower/README.md » ('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
deleted file mode 100644
index d5958c5ca318733ec17fdc77fefc81d57977b8bc..0000000000000000000000000000000000000000
--- a/test/codegen/sunflower.dart
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (c) 2012, 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 'dom.dart';
-
-const String ORANGE = "orange";
-const int SEED_RADIUS = 2;
-const int SCALE_FACTOR = 4;
-const num TAU = PI * 2;
-const int MAX_D = 300;
-const num centerX = MAX_D / 2;
-const num centerY = centerX;
-
-Element querySelector(String selector) => document.querySelector(selector);
-
-final InputElement slider = querySelector("#slider");
-final Element notes = querySelector("#notes");
-final num PHI = (sqrt(5) + 1) / 2;
-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;
-
- Circle(this.x, this.y, this.radius);
-}
-
-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 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();
-}
-
-/// 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";
-}
« no previous file with comments | « test/codegen/expect/sunflower/sunflower.txt ('k') | test/codegen/sunflower/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698