Chromium Code Reviews| Index: test/codegen/sunflower/painter.dart |
| diff --git a/test/codegen/sunflower/painter.dart b/test/codegen/sunflower/painter.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5ce0002aeba74a73a2201c1e3324fe15b4ede989 |
| --- /dev/null |
| +++ b/test/codegen/sunflower/painter.dart |
| @@ -0,0 +1,38 @@ |
| +// 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 painter; |
| + |
| +import 'dom.dart'; |
| +import 'dart:math'; |
| + |
| +import 'circle.dart'; |
| + |
| +const ORANGE = "orange"; |
| +const RED = "red"; |
| +const BLUE = "blue"; |
| +const TAU = PI * 2; |
| + |
| +Element querySelector(String selector) => document.querySelector(selector); |
|
Jennifer Messerly
2015/05/28 21:04:22
move this to dom.dart?
vsm
2015/05/29 13:23:01
Moved it to sunflower - I've been using the type o
|
| + |
| +final canvas = querySelector("#canvas") as CanvasElement; |
| +final context = canvas.getContext('2d') as CanvasRenderingContext2D; |
|
Jennifer Messerly
2015/05/28 21:04:22
I wonder if "context" should be an input to "draw"
vsm
2015/05/29 13:23:01
Done. Moved to these to sunflower and passing in
|
| + |
| +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(); |
| + } |
| +} |