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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 sunflower.seeds = 0; | 48 sunflower.seeds = 0; |
49 sunflower.main = function() { | 49 sunflower.main = function() { |
50 sunflower.slider[dartx.addEventListener]('change', dart.fn(e => sunflower.dr
aw(), EventTovoid())); | 50 sunflower.slider[dartx.addEventListener]('change', dart.fn(e => sunflower.dr
aw(), EventTovoid())); |
51 sunflower.draw(); | 51 sunflower.draw(); |
52 }; | 52 }; |
53 dart.fn(sunflower.main, VoidTovoid()); | 53 dart.fn(sunflower.main, VoidTovoid()); |
54 sunflower.draw = function() { | 54 sunflower.draw = function() { |
55 sunflower.seeds = core.int.parse(sunflower.slider.value); | 55 sunflower.seeds = core.int.parse(sunflower.slider.value); |
56 sunflower.context.clearRect(0, 0, sunflower.MAX_D, sunflower.MAX_D); | 56 sunflower.context.clearRect(0, 0, sunflower.MAX_D, sunflower.MAX_D); |
57 for (let i = 0; i < dart.notNull(sunflower.seeds); i++) { | 57 for (let i = 0; i < dart.notNull(sunflower.seeds); i++) { |
58 let theta = i * painter.TAU / dart.notNull(sunflower.PHI); | 58 let theta = i * dart.notNull(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 new(x, y, radius) { | 68 new(x, y, radius) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 dart.trackLibraries("sunflower", {"sunflower.dart": sunflower, "circle.dart":
circle, "painter.dart": painter}, null); | 126 dart.trackLibraries("sunflower", {"sunflower.dart": sunflower, "circle.dart":
circle, "painter.dart": painter}, null); |
127 // Exports: | 127 // Exports: |
128 return { | 128 return { |
129 sunflower: sunflower, | 129 sunflower: sunflower, |
130 circle: circle, | 130 circle: circle, |
131 painter: painter | 131 painter: painter |
132 }; | 132 }; |
133 }); | 133 }); |
134 | 134 |
135 //# sourceMappingURL=sunflower.js.map | 135 //# sourceMappingURL=sunflower.js.map |
OLD | NEW |