OLD | NEW |
1 var sunflower; | 1 var sunflower; |
2 (function(exports) { | 2 (function(exports) { |
3 'use strict'; | 3 'use strict'; |
4 let ORANGE = "orange"; | 4 let ORANGE = "orange"; |
5 let SEED_RADIUS = 2; | 5 let SEED_RADIUS = 2; |
6 let SCALE_FACTOR = 4; | 6 let SCALE_FACTOR = 4; |
7 let TAU = dart.notNull(math.PI) * 2; | 7 let TAU = dart.notNull(math.PI) * 2; |
8 let MAX_D = 300; | 8 let MAX_D = 300; |
9 let centerX = dart.notNull(MAX_D) / 2; | 9 let centerX = dart.notNull(MAX_D) / 2; |
10 let centerY = centerX; | 10 let centerY = centerX; |
(...skipping 29 matching lines...) Expand all Loading... |
40 let theta = dart.notNull(i) * dart.notNull(TAU) / dart.notNull(exports.PHI
); | 40 let theta = dart.notNull(i) * dart.notNull(TAU) / dart.notNull(exports.PHI
); |
41 let r = dart.notNull(math.sqrt(i)) * dart.notNull(SCALE_FACTOR); | 41 let r = dart.notNull(math.sqrt(i)) * dart.notNull(SCALE_FACTOR); |
42 let x = dart.notNull(centerX) + dart.notNull(r) * dart.notNull(math.cos(th
eta)); | 42 let x = dart.notNull(centerX) + dart.notNull(r) * dart.notNull(math.cos(th
eta)); |
43 let y = dart.notNull(centerY) - dart.notNull(r) * dart.notNull(math.sin(th
eta)); | 43 let y = dart.notNull(centerY) - dart.notNull(r) * dart.notNull(math.sin(th
eta)); |
44 new SunflowerSeed(x, y, SEED_RADIUS).draw(); | 44 new SunflowerSeed(x, y, SEED_RADIUS).draw(); |
45 } | 45 } |
46 exports.notes.textContent = `${exports.seeds} seeds`; | 46 exports.notes.textContent = `${exports.seeds} seeds`; |
47 } | 47 } |
48 class Circle extends core.Object { | 48 class Circle extends core.Object { |
49 Circle(x, y, radius) { | 49 Circle(x, y, radius) { |
50 this.x = x; | 50 dart.initField(Circle, this, 'x', x); |
51 this.y = y; | 51 dart.initField(Circle, this, 'y', y); |
52 this.radius = radius; | 52 dart.initField(Circle, this, 'radius', radius); |
53 } | 53 } |
54 } | 54 } |
55 class CirclePainter extends core.Object { | 55 class CirclePainter extends core.Object { |
56 CirclePainter() { | 56 CirclePainter() { |
57 this.color = ORANGE; | 57 dart.initField(CirclePainter, this, 'color', ORANGE); |
58 } | 58 } |
59 draw() { | 59 draw() { |
60 exports.context.beginPath(); | 60 exports.context.beginPath(); |
61 exports.context.lineWidth = 2; | 61 exports.context.lineWidth = 2; |
62 exports.context.fillStyle = this.color; | 62 exports.context.fillStyle = this.color; |
63 exports.context.strokeStyle = this.color; | 63 exports.context.strokeStyle = this.color; |
64 exports.context.arc(this.x, this.y, this.radius, 0, TAU, false); | 64 exports.context.arc(this.x, this.y, this.radius, 0, TAU, false); |
65 exports.context.fill(); | 65 exports.context.fill(); |
66 exports.context.closePath(); | 66 exports.context.closePath(); |
67 exports.context.stroke(); | 67 exports.context.stroke(); |
(...skipping 17 matching lines...) Expand all Loading... |
85 exports.MAX_D = MAX_D; | 85 exports.MAX_D = MAX_D; |
86 exports.centerX = centerX; | 86 exports.centerX = centerX; |
87 exports.centerY = centerY; | 87 exports.centerY = centerY; |
88 exports.querySelector = querySelector; | 88 exports.querySelector = querySelector; |
89 exports.main = main; | 89 exports.main = main; |
90 exports.draw = draw; | 90 exports.draw = draw; |
91 exports.SunflowerSeed = SunflowerSeed; | 91 exports.SunflowerSeed = SunflowerSeed; |
92 exports.Circle = Circle; | 92 exports.Circle = Circle; |
93 exports.CirclePainter = CirclePainter; | 93 exports.CirclePainter = CirclePainter; |
94 })(sunflower || (sunflower = {})); | 94 })(sunflower || (sunflower = {})); |
OLD | NEW |