Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: test/codegen/expect/sunflower/sunflower.js

Issue 968273002: Fixing layout in js output (use full paths rather than just the library name) (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: address review comments Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/codegen/expect/sunflower.js ('k') | test/codegen/expect/typed_data/typed_data.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 var sunflower;
2 (function(exports) {
3 'use strict';
4 let ORANGE = "orange";
5 let SEED_RADIUS = 2;
6 let SCALE_FACTOR = 4;
7 let TAU = math.PI * 2;
8 let MAX_D = 300;
9 let centerX = MAX_D / 2;
10 let centerY = centerX;
11 // Function querySelector: (String) → Element
12 function querySelector(selector) {
13 return dom.document.querySelector(selector);
14 }
15 exports.seeds = 0;
16 dart.defineLazyProperties(exports, {
17 get slider() {
18 return dart.as(querySelector("#slider"), dom.InputElement);
19 },
20 get notes() {
21 return querySelector("#notes");
22 },
23 get PHI() {
24 return (math.sqrt(5) + 1) / 2;
25 },
26 get context() {
27 return dart.as(dart.as(querySelector("#canvas"), dom.CanvasElement).getCon text('2d'), dom.CanvasRenderingContext2D);
28 }
29 });
30 class Circle extends dart.Object {
31 Circle(x, y, radius) {
32 this.x = x;
33 this.y = y;
34 this.radius = radius;
35 }
36 }
37 class CirclePainter extends dart.Object {
38 CirclePainter() {
39 this.color = ORANGE;
40 }
41 draw() {
42 exports.context.beginPath();
43 exports.context.lineWidth = 2;
44 exports.context.fillStyle = this.color;
45 exports.context.strokeStyle = this.color;
46 exports.context.arc(this.x, this.y, this.radius, 0, TAU, false);
47 exports.context.fill();
48 exports.context.closePath();
49 exports.context.stroke();
50 }
51 }
52 class SunflowerSeed extends dart.mixin(Circle, CirclePainter) {
53 SunflowerSeed(x, y, radius, color) {
54 if (color === void 0)
55 color = null;
56 super.Circle(x, y, radius);
57 if (color !== null)
58 this.color = color;
59 }
60 }
61 // Function main: () → void
62 function main() {
63 exports.slider.addEventListener('change', (e) => draw());
64 draw();
65 }
66 // Function draw: () → void
67 function draw() {
68 exports.seeds = core.int.parse(exports.slider.value);
69 exports.context.clearRect(0, 0, MAX_D, MAX_D);
70 for (let i = 0; i < exports.seeds; i++) {
71 let theta = dart.notNull(i * dart.notNull(TAU)) / dart.notNull(exports.PHI );
72 let r = math.sqrt(i) * SCALE_FACTOR;
73 let x = dart.notNull(centerX) + dart.notNull(dart.notNull(r) * math.cos(th eta));
74 let y = dart.notNull(centerY) - dart.notNull(dart.notNull(r) * math.sin(th eta));
75 new SunflowerSeed(x, y, SEED_RADIUS).draw();
76 }
77 exports.notes.textContent = `${exports.seeds} seeds`;
78 }
79 // Exports:
80 exports.ORANGE = ORANGE;
81 exports.SEED_RADIUS = SEED_RADIUS;
82 exports.SCALE_FACTOR = SCALE_FACTOR;
83 exports.TAU = TAU;
84 exports.MAX_D = MAX_D;
85 exports.centerX = centerX;
86 exports.centerY = centerY;
87 exports.querySelector = querySelector;
88 exports.Circle = Circle;
89 exports.CirclePainter = CirclePainter;
90 exports.SunflowerSeed = SunflowerSeed;
91 exports.main = main;
92 exports.draw = draw;
93 })(sunflower || (sunflower = {}));
OLDNEW
« no previous file with comments | « test/codegen/expect/sunflower.js ('k') | test/codegen/expect/typed_data/typed_data.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698