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

Side by Side Diff: client/samples/sunflower/Sunflower.dart

Issue 8637013: Remove support for attribute event listeners. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « client/samples/spirodraw/Spirodraw.dart ('k') | client/testing/unittest/unittest.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #library('sunflower'); 5 #library('sunflower');
6 6
7 #import('dart:dom'); 7 #import('dart:dom');
8 8
9 #resource('sunflower.css'); 9 #resource('sunflower.css');
10 10
11 main() { 11 main() {
12 new Sunflower(); 12 new Sunflower();
13 } 13 }
14 14
15 class Sunflower { 15 class Sunflower {
16 16
17 Sunflower() { 17 Sunflower() {
18 PHI = (Math.sqrt(5) + 1) / 2; 18 PHI = (Math.sqrt(5) + 1) / 2;
19 var doc = window.document; 19 var doc = window.document;
20 20
21 HTMLCanvasElement canvas = doc.getElementById("canvas"); 21 HTMLCanvasElement canvas = doc.getElementById("canvas");
22 xc = yc = MAX_D / 2; 22 xc = yc = MAX_D / 2;
23 ctx = canvas.getContext("2d"); 23 ctx = canvas.getContext("2d");
24 24
25 HTMLInputElement slider = doc.getElementById("slider"); 25 HTMLInputElement slider = doc.getElementById("slider");
26 slider.onchange = (Event e) { 26 slider.addEventListener('change', (Event e) {
27 seeds = Math.parseInt(slider.value); 27 seeds = Math.parseInt(slider.value);
28 drawFrame(); 28 drawFrame();
29 }; 29 }, true);
30 30
31 drawFrame(); 31 drawFrame();
32 } 32 }
33 33
34 // Draw the complete figure for the current number of seeds. 34 // Draw the complete figure for the current number of seeds.
35 void drawFrame() { 35 void drawFrame() {
36 ctx.clearRect(0, 0, MAX_D, MAX_D); 36 ctx.clearRect(0, 0, MAX_D, MAX_D);
37 for (var i=0; i<seeds; i++) { 37 for (var i=0; i<seeds; i++) {
38 var theta = i * TAU / PHI; 38 var theta = i * TAU / PHI;
39 var r = Math.sqrt(i) * SCALE_FACTOR; 39 var r = Math.sqrt(i) * SCALE_FACTOR;
(...skipping 20 matching lines...) Expand all
60 num seeds = 0; 60 num seeds = 0;
61 61
62 static final SEED_RADIUS = 2; 62 static final SEED_RADIUS = 2;
63 static final SCALE_FACTOR = 4; 63 static final SCALE_FACTOR = 4;
64 static final TAU = Math.PI * 2; 64 static final TAU = Math.PI * 2;
65 var PHI; 65 var PHI;
66 static final MAX_D = 300; 66 static final MAX_D = 300;
67 static final String ORANGE = "orange"; 67 static final String ORANGE = "orange";
68 68
69 } 69 }
OLDNEW
« no previous file with comments | « client/samples/spirodraw/Spirodraw.dart ('k') | client/testing/unittest/unittest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698