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

Unified Diff: test/codegen/expect/sunflower.js

Issue 1007313003: Move sunflower to a new directory, make final tweaks to make it all work. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/codegen/expect/server_mode/html_input.html ('k') | test/codegen/expect/sunflower.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codegen/expect/sunflower.js
diff --git a/test/codegen/expect/sunflower.js b/test/codegen/expect/sunflower.js
deleted file mode 100644
index 5f680329a8c9f091cc825096fd494ac9288286a0..0000000000000000000000000000000000000000
--- a/test/codegen/expect/sunflower.js
+++ /dev/null
@@ -1,93 +0,0 @@
-var sunflower;
-(function(exports) {
- 'use strict';
- let ORANGE = "orange";
- let SEED_RADIUS = 2;
- let SCALE_FACTOR = 4;
- let TAU = dart.notNull(math.PI) * 2;
- let MAX_D = 300;
- let centerX = dart.notNull(MAX_D) / 2;
- let centerY = centerX;
- // Function querySelector: (String) → Element
- function querySelector(selector) {
- return dom.document.querySelector(selector);
- }
- exports.seeds = 0;
- dart.defineLazyProperties(exports, {
- get slider() {
- return dart.as(querySelector("#slider"), dom.InputElement);
- },
- get notes() {
- return querySelector("#notes");
- },
- get PHI() {
- return (dart.notNull(math.sqrt(5)) + 1) / 2;
- },
- get context() {
- return dart.as(dart.as(querySelector("#canvas"), dom.CanvasElement).getContext('2d'), dom.CanvasRenderingContext2D);
- }
- });
- class Circle extends core.Object {
- Circle(x, y, radius) {
- this.x = x;
- this.y = y;
- this.radius = radius;
- }
- }
- class CirclePainter extends core.Object {
- CirclePainter() {
- this.color = ORANGE;
- }
- draw() {
- exports.context.beginPath();
- exports.context.lineWidth = 2;
- exports.context.fillStyle = this.color;
- exports.context.strokeStyle = this.color;
- exports.context.arc(this.x, this.y, this.radius, 0, TAU, false);
- exports.context.fill();
- exports.context.closePath();
- exports.context.stroke();
- }
- }
- class SunflowerSeed extends dart.mixin(Circle, CirclePainter) {
- SunflowerSeed(x, y, radius, color) {
- if (color === void 0)
- color = null;
- super.Circle(x, y, radius);
- if (color !== null)
- this.color = color;
- }
- }
- // Function main: () → void
- function main() {
- exports.slider.addEventListener('change', (e) => draw());
- draw();
- }
- // Function draw: () → void
- function draw() {
- exports.seeds = core.int.parse(exports.slider.value);
- exports.context.clearRect(0, 0, MAX_D, MAX_D);
- for (let i = 0; dart.notNull(i) < dart.notNull(exports.seeds); i = dart.notNull(i) + 1) {
- let theta = dart.notNull(i) * dart.notNull(TAU) / dart.notNull(exports.PHI);
- let r = dart.notNull(math.sqrt(i)) * dart.notNull(SCALE_FACTOR);
- let x = dart.notNull(centerX) + dart.notNull(r) * dart.notNull(math.cos(theta));
- let y = dart.notNull(centerY) - dart.notNull(r) * dart.notNull(math.sin(theta));
- new SunflowerSeed(x, y, SEED_RADIUS).draw();
- }
- exports.notes.textContent = `${exports.seeds} seeds`;
- }
- // Exports:
- exports.ORANGE = ORANGE;
- exports.SEED_RADIUS = SEED_RADIUS;
- exports.SCALE_FACTOR = SCALE_FACTOR;
- exports.TAU = TAU;
- exports.MAX_D = MAX_D;
- exports.centerX = centerX;
- exports.centerY = centerY;
- exports.querySelector = querySelector;
- exports.Circle = Circle;
- exports.CirclePainter = CirclePainter;
- exports.SunflowerSeed = SunflowerSeed;
- exports.main = main;
- exports.draw = draw;
-})(sunflower || (sunflower = {}));
« no previous file with comments | « test/codegen/expect/server_mode/html_input.html ('k') | test/codegen/expect/sunflower.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698