| OLD | NEW |
| 1 define(['dart_sdk'], function(dart_sdk) { | 1 define(['dart_sdk'], function(dart_sdk) { |
| 2 'use strict'; | 2 'use strict'; |
| 3 const core = dart_sdk.core; | 3 const core = dart_sdk.core; |
| 4 const html = dart_sdk.html; | 4 const html = dart_sdk.html; |
| 5 const math = dart_sdk.math; | 5 const math = dart_sdk.math; |
| 6 const dart = dart_sdk.dart; | 6 const dart = dart_sdk.dart; |
| 7 const dartx = dart_sdk.dartx; | 7 const dartx = dart_sdk.dartx; |
| 8 const sunflower = Object.create(null); | 8 const sunflower = Object.create(null); |
| 9 const circle = Object.create(null); | 9 const circle = Object.create(null); |
| 10 const painter = Object.create(null); | 10 const painter = Object.create(null); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 let theta = i * painter.TAU / dart.notNull(sunflower.PHI); | 58 let theta = i * painter.TAU / dart.notNull(sunflower.PHI); |
| 59 let r = dart.notNull(math.sqrt(i)) * sunflower.SCALE_FACTOR; | 59 let r = dart.notNull(math.sqrt(i)) * sunflower.SCALE_FACTOR; |
| 60 let x = sunflower.centerX + r * dart.notNull(math.cos(theta)); | 60 let x = sunflower.centerX + r * dart.notNull(math.cos(theta)); |
| 61 let y = sunflower.centerY - r * dart.notNull(math.sin(theta)); | 61 let y = sunflower.centerY - r * dart.notNull(math.sin(theta)); |
| 62 new sunflower.SunflowerSeed(x, y, sunflower.SEED_RADIUS).draw(sunflower.co
ntext); | 62 new sunflower.SunflowerSeed(x, y, sunflower.SEED_RADIUS).draw(sunflower.co
ntext); |
| 63 } | 63 } |
| 64 sunflower.notes[dartx.text] = dart.str`${sunflower.seeds} seeds`; | 64 sunflower.notes[dartx.text] = dart.str`${sunflower.seeds} seeds`; |
| 65 }; | 65 }; |
| 66 dart.fn(sunflower.draw, VoidTovoid()); | 66 dart.fn(sunflower.draw, VoidTovoid()); |
| 67 circle.Circle = class Circle extends core.Object { | 67 circle.Circle = class Circle extends core.Object { |
| 68 get x() { |
| 69 return this[x$]; |
| 70 } |
| 71 set x(value) { |
| 72 super.x = value; |
| 73 } |
| 74 get y() { |
| 75 return this[y$]; |
| 76 } |
| 77 set y(value) { |
| 78 super.y = value; |
| 79 } |
| 80 get radius() { |
| 81 return this[radius$]; |
| 82 } |
| 83 set radius(value) { |
| 84 super.radius = value; |
| 85 } |
| 68 new(x, y, radius) { | 86 new(x, y, radius) { |
| 69 this.x = x; | 87 this[x$] = x; |
| 70 this.y = y; | 88 this[y$] = y; |
| 71 this.radius = radius; | 89 this[radius$] = radius; |
| 72 } | 90 } |
| 73 }; | 91 }; |
| 92 const x$ = Symbol("Circle.x"); |
| 93 const y$ = Symbol("Circle.y"); |
| 94 const radius$ = Symbol("Circle.radius"); |
| 74 dart.setSignature(circle.Circle, { | 95 dart.setSignature(circle.Circle, { |
| 75 fields: () => ({ | 96 fields: () => ({ |
| 76 x: core.num, | 97 x: core.num, |
| 77 y: core.num, | 98 y: core.num, |
| 78 radius: core.num | 99 radius: core.num |
| 79 }) | 100 }) |
| 80 }); | 101 }); |
| 81 painter.CirclePainter = class CirclePainter extends core.Object { | 102 painter.CirclePainter = class CirclePainter extends core.Object { |
| 82 new() { | 103 new() { |
| 83 this.color = painter.ORANGE; | 104 this[color] = painter.ORANGE; |
| 105 } |
| 106 get color() { |
| 107 return this[color]; |
| 108 } |
| 109 set color(value) { |
| 110 this[color] = value; |
| 84 } | 111 } |
| 85 draw(context) { | 112 draw(context) { |
| 86 context.beginPath(); | 113 context.beginPath(); |
| 87 context.lineWidth = 2; | 114 context.lineWidth = 2; |
| 88 context.fillStyle = this.color; | 115 context.fillStyle = this.color; |
| 89 context.strokeStyle = this.color; | 116 context.strokeStyle = this.color; |
| 90 context[dartx.arc](this.x, this.y, this.radius, 0, painter.TAU, false); | 117 context[dartx.arc](this.x, this.y, this.radius, 0, painter.TAU, false); |
| 91 context[dartx.fill](); | 118 context[dartx.fill](); |
| 92 context.closePath(); | 119 context.closePath(); |
| 93 context.stroke(); | 120 context.stroke(); |
| 94 } | 121 } |
| 95 }; | 122 }; |
| 123 const color = Symbol("CirclePainter.color"); |
| 96 painter.CirclePainter[dart.implements] = () => [circle.Circle]; | 124 painter.CirclePainter[dart.implements] = () => [circle.Circle]; |
| 97 dart.setSignature(painter.CirclePainter, { | 125 dart.setSignature(painter.CirclePainter, { |
| 98 fields: () => ({color: core.String}), | 126 fields: () => ({color: core.String}), |
| 99 methods: () => ({draw: dart.definiteFunctionType(dart.void, [html.CanvasRend
eringContext2D])}) | 127 methods: () => ({draw: dart.definiteFunctionType(dart.void, [html.CanvasRend
eringContext2D])}) |
| 100 }); | 128 }); |
| 101 sunflower.SunflowerSeed = class SunflowerSeed extends dart.mixin(circle.Circle
, painter.CirclePainter) { | 129 sunflower.SunflowerSeed = class SunflowerSeed extends dart.mixin(circle.Circle
, painter.CirclePainter) { |
| 102 new(x, y, radius, color) { | 130 new(x, y, radius, color) { |
| 103 if (color === void 0) color = null; | 131 if (color === void 0) color = null; |
| 104 super.new(x, y, radius); | 132 super.new(x, y, radius); |
| 105 if (color != null) this.color = color; | 133 if (color != null) this.color = color; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 126 dart.trackLibraries("sunflower", {"sunflower.dart": sunflower, "circle.dart":
circle, "painter.dart": painter}, null); | 154 dart.trackLibraries("sunflower", {"sunflower.dart": sunflower, "circle.dart":
circle, "painter.dart": painter}, null); |
| 127 // Exports: | 155 // Exports: |
| 128 return { | 156 return { |
| 129 sunflower: sunflower, | 157 sunflower: sunflower, |
| 130 circle: circle, | 158 circle: circle, |
| 131 painter: painter | 159 painter: painter |
| 132 }; | 160 }; |
| 133 }); | 161 }); |
| 134 | 162 |
| 135 //# sourceMappingURL=sunflower.js.map | 163 //# sourceMappingURL=sunflower.js.map |
| OLD | NEW |