OLD | NEW |
| (Empty) |
1 dart_library.library('sunflower/painter', null, /* Imports */[ | |
2 'dart/_runtime', | |
3 'dart/math', | |
4 'sunflower/dom', | |
5 'dart/core', | |
6 'sunflower/circle' | |
7 ], /* Lazy imports */[ | |
8 ], function(exports, dart, math, dom, core, circle) { | |
9 'use strict'; | |
10 let dartx = dart.dartx; | |
11 const ORANGE = "orange"; | |
12 const RED = "red"; | |
13 const BLUE = "blue"; | |
14 const TAU = dart.notNull(math.PI) * 2; | |
15 function querySelector(selector) { | |
16 return dom.document.querySelector(selector); | |
17 } | |
18 dart.fn(querySelector, dom.Element, [core.String]); | |
19 dart.defineLazyProperties(exports, { | |
20 get canvas() { | |
21 return dart.as(querySelector("#canvas"), dom.CanvasElement); | |
22 } | |
23 }); | |
24 dart.defineLazyProperties(exports, { | |
25 get context() { | |
26 return dart.as(exports.canvas.getContext('2d'), dom.CanvasRenderingContext
2D); | |
27 } | |
28 }); | |
29 class CirclePainter extends core.Object { | |
30 CirclePainter() { | |
31 this.color = ORANGE; | |
32 } | |
33 draw(context) { | |
34 context.beginPath(); | |
35 context.lineWidth = 2; | |
36 context.fillStyle = this.color; | |
37 context.strokeStyle = this.color; | |
38 context.arc(this.x, this.y, this.radius, 0, TAU, false); | |
39 context.fill(); | |
40 context.closePath(); | |
41 context.stroke(); | |
42 } | |
43 } | |
44 CirclePainter[dart.implements] = () => [circle.Circle]; | |
45 dart.setSignature(CirclePainter, { | |
46 methods: () => ({draw: [dart.void, [dom.CanvasRenderingContext2D]]}) | |
47 }); | |
48 // Exports: | |
49 exports.ORANGE = ORANGE; | |
50 exports.RED = RED; | |
51 exports.BLUE = BLUE; | |
52 exports.TAU = TAU; | |
53 exports.querySelector = querySelector; | |
54 exports.CirclePainter = CirclePainter; | |
55 }); | |
OLD | NEW |