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

Side by Side Diff: samples/openglui/src/openglui_canvas_tests.dart

Issue 12428011: Change ImageElement to use onLoad.listen instead of on.load and (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // Canvas API tests. Some of these are adapted from: 5 // Canvas API tests. Some of these are adapted from:
6 // 6 //
7 // http://www.html5canvastutorials.com/ 7 // http://www.html5canvastutorials.com/
8 8
9 library openglui_canvas_tests; 9 library openglui_canvas_tests;
10 10
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 ctx.setLineDash([]); 493 ctx.setLineDash([]);
494 ctx.strokeStyle = "#0000FF"; 494 ctx.strokeStyle = "#0000FF";
495 ctx.strokeStyle = "rgba(128,128,128, 0.5)"; 495 ctx.strokeStyle = "rgba(128,128,128, 0.5)";
496 ctx.strokeRect(width / 5, height / 10, width / 2, height / 8); 496 ctx.strokeRect(width / 5, height / 10, width / 2, height / 8);
497 log("Width = $width"); 497 log("Width = $width");
498 } 498 }
499 499
500 void loadImage() { 500 void loadImage() {
501 initTest("Image loading"); 501 initTest("Image loading");
502 var imageObj = new ImageElement(); 502 var imageObj = new ImageElement();
503 // TODO(Gram): Change gl.dart to handle to onLoad.listen. 503 var sub;
504 imageObj.on.load.add((e) { 504 sub = imageObj.onLoad.listen((e) {
505 ctx.drawImage(e, 69, 50); 505 ctx.drawImage(e.target, 69, 50);
506 sub.cancel();
506 }); 507 });
507 imageObj.src = 'chrome.png'; 508 imageObj.src = 'chrome.png';
508 } 509 }
509 510
510 void clip() { 511 void clip() {
511 initTest("Clipping"); 512 initTest("Clipping");
512 var x = width / 2; 513 var x = width / 2;
513 var y = height / 2; 514 var y = height / 2;
514 var radius = height / 4; 515 var radius = height / 4;
515 var offset = 2 * radius / 3; 516 var offset = 2 * radius / 3;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 case 23: 735 case 23:
735 var rayTracer = new RayTracer(); 736 var rayTracer = new RayTracer();
736 rayTracer.render(defaultScene(), ctx, width, height); 737 rayTracer.render(defaultScene(), ctx, width, height);
737 break; 738 break;
738 default: 739 default:
739 if (testnum < 0) { 740 if (testnum < 0) {
740 testnum = 23; 741 testnum = 23;
741 } else { 742 } else {
742 testnum = 0; 743 testnum = 0;
743 } 744 }
744 update(); 745 return;
745 break;
746 } 746 }
747 isDirty = false; 747 isDirty = false;
748 } 748 }
749 749
750 // Raytracer adapted from https://gist.github.com/mythz/3817303. 750 // Raytracer adapted from https://gist.github.com/mythz/3817303.
751 751
752 Scene defaultScene() => 752 Scene defaultScene() =>
753 new Scene( 753 new Scene(
754 [new Plane(new Vector(0.0, 1.0, 0.0), 0.0, Surfaces.checkerboard), 754 [new Plane(new Vector(0.0, 1.0, 0.0), 0.0, Surfaces.checkerboard),
755 new Sphere(new Vector(0.0, 1.0, -0.25), 1.0, Surfaces.shiny), 755 new Sphere(new Vector(0.0, 1.0, -0.25), 1.0, Surfaces.shiny),
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 for (int x = 0; x < screenWidth; x++) { 999 for (int x = 0; x < screenWidth; x++) {
1000 var color = _traceRay(new Ray(scene.camera.pos, 1000 var color = _traceRay(new Ray(scene.camera.pos,
1001 getPoint(x, y, scene.camera) ), scene, 0); 1001 getPoint(x, y, scene.camera) ), scene, 0);
1002 ctx.fillStyle = Color.toDrawingRGB(color); 1002 ctx.fillStyle = Color.toDrawingRGB(color);
1003 ctx.fillRect(x, y, x + 1, y + 1); 1003 ctx.fillRect(x, y, x + 1, y + 1);
1004 } 1004 }
1005 } 1005 }
1006 } 1006 }
1007 } 1007 }
1008 1008
OLDNEW
« runtime/embedders/openglui/common/gl.dart ('K') | « runtime/embedders/openglui/common/gl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698