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 27 matching lines...) Expand all Loading... |
38 exports.context.clearRect(0, 0, MAX_D, MAX_D); | 38 exports.context.clearRect(0, 0, MAX_D, MAX_D); |
39 for (let i = 0; dart.notNull(i) < dart.notNull(exports.seeds); i = dart.notN
ull(i) + 1) { | 39 for (let i = 0; dart.notNull(i) < dart.notNull(exports.seeds); i = dart.notN
ull(i) + 1) { |
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 let x$ = Symbol('x'); |
| 49 let y$ = Symbol('y'); |
| 50 let radius$ = Symbol('radius'); |
| 51 let color = Symbol('color'); |
48 class Circle extends core.Object { | 52 class Circle extends core.Object { |
| 53 get x() { |
| 54 return this[x$]; |
| 55 } |
| 56 get y() { |
| 57 return this[y$]; |
| 58 } |
| 59 get radius() { |
| 60 return this[radius$]; |
| 61 } |
49 Circle(x, y, radius) { | 62 Circle(x, y, radius) { |
50 this.x = x; | 63 this[x$] = x; |
51 this.y = y; | 64 this[y$] = y; |
52 this.radius = radius; | 65 this[radius$] = radius; |
53 } | 66 } |
54 } | 67 } |
55 class CirclePainter extends core.Object { | 68 class CirclePainter extends core.Object { |
56 CirclePainter() { | 69 CirclePainter() { |
57 this.color = ORANGE; | 70 this[color] = ORANGE; |
| 71 } |
| 72 get color() { |
| 73 return this[color]; |
| 74 } |
| 75 set color(value) { |
| 76 this[color] = value; |
58 } | 77 } |
59 draw() { | 78 draw() { |
60 exports.context.beginPath(); | 79 exports.context.beginPath(); |
61 exports.context.lineWidth = 2; | 80 exports.context.lineWidth = 2; |
62 exports.context.fillStyle = this.color; | 81 exports.context.fillStyle = this.color; |
63 exports.context.strokeStyle = this.color; | 82 exports.context.strokeStyle = this.color; |
64 exports.context.arc(this.x, this.y, this.radius, 0, TAU, false); | 83 exports.context.arc(this.x, this.y, this.radius, 0, TAU, false); |
65 exports.context.fill(); | 84 exports.context.fill(); |
66 exports.context.closePath(); | 85 exports.context.closePath(); |
67 exports.context.stroke(); | 86 exports.context.stroke(); |
(...skipping 17 matching lines...) Expand all Loading... |
85 exports.MAX_D = MAX_D; | 104 exports.MAX_D = MAX_D; |
86 exports.centerX = centerX; | 105 exports.centerX = centerX; |
87 exports.centerY = centerY; | 106 exports.centerY = centerY; |
88 exports.querySelector = querySelector; | 107 exports.querySelector = querySelector; |
89 exports.main = main; | 108 exports.main = main; |
90 exports.draw = draw; | 109 exports.draw = draw; |
91 exports.SunflowerSeed = SunflowerSeed; | 110 exports.SunflowerSeed = SunflowerSeed; |
92 exports.Circle = Circle; | 111 exports.Circle = Circle; |
93 exports.CirclePainter = CirclePainter; | 112 exports.CirclePainter = CirclePainter; |
94 })(sunflower || (sunflower = {})); | 113 })(sunflower || (sunflower = {})); |
OLD | NEW |