| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library painter; |
| 6 |
| 7 import 'dom.dart'; |
| 8 import 'dart:math'; |
| 9 |
| 10 import 'circle.dart'; |
| 11 |
| 12 const ORANGE = "orange"; |
| 13 const RED = "red"; |
| 14 const BLUE = "blue"; |
| 15 const TAU = PI * 2; |
| 16 |
| 17 Element querySelector(String selector) => document.querySelector(selector); |
| 18 |
| 19 final canvas = querySelector("#canvas") as CanvasElement; |
| 20 final context = canvas.getContext('2d') as CanvasRenderingContext2D; |
| 21 |
| 22 abstract class CirclePainter implements Circle { |
| 23 // This demonstrates a field in a mixin. |
| 24 String color = ORANGE; |
| 25 |
| 26 /// Draw a small circle representing a seed centered at (x,y). |
| 27 void draw(CanvasRenderingContext2D context) { |
| 28 context |
| 29 ..beginPath() |
| 30 ..lineWidth = 2 |
| 31 ..fillStyle = color |
| 32 ..strokeStyle = color |
| 33 ..arc(x, y, radius, 0, TAU, false) |
| 34 ..fill() |
| 35 ..closePath() |
| 36 ..stroke(); |
| 37 } |
| 38 } |
| OLD | NEW |