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

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

Issue 12506004: Added window.requestAnimationFrame. (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 25 matching lines...) Expand all
36 }); 36 });
37 canvas.onKeyDown.listen((e) { 37 canvas.onKeyDown.listen((e) {
38 ++testnum; 38 ++testnum;
39 isDirty = true; 39 isDirty = true;
40 }); 40 });
41 ctx = canvas.getContext("2d"); 41 ctx = canvas.getContext("2d");
42 if (ctx == null) { 42 if (ctx == null) {
43 throw "Failed to get 2D context"; 43 throw "Failed to get 2D context";
44 } 44 }
45 resize(w, h); 45 resize(w, h);
46 window.requestAnimationFrame(update);
46 log("Done setup"); 47 log("Done setup");
47 } 48 }
48 49
49 resetCanvas() { 50 resetCanvas() {
50 ctx.globalCompositeOperation = "source-over"; 51 ctx.globalCompositeOperation = "source-over";
51 ctx.setTransform(1, 0, 0, 1, 0, 0); 52 ctx.setTransform(1, 0, 0, 1, 0, 0);
52 ctx.fillStyle = "#FFFFFF"; 53 ctx.fillStyle = "#FFFFFF";
53 ctx.clearRect(0, 0, width, height); 54 ctx.clearRect(0, 0, width, height);
54 ctx.shadowOffsetX = ctx.shadowOffsetY = ctx.shadowBlur = 0.0; 55 ctx.shadowOffsetX = ctx.shadowOffsetY = ctx.shadowBlur = 0.0;
55 ctx.beginPath(); 56 ctx.beginPath();
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 ctx.rect(myRectangle.x, myRectangle.y, myRectangle.width, myRectangle.height); 649 ctx.rect(myRectangle.x, myRectangle.y, myRectangle.width, myRectangle.height);
649 ctx.fillStyle = '#8ED6FF'; 650 ctx.fillStyle = '#8ED6FF';
650 ctx.fill(); 651 ctx.fill();
651 ctx.lineWidth = myRectangle.borderWidth; 652 ctx.lineWidth = myRectangle.borderWidth;
652 ctx.strokeStyle = 'black'; 653 ctx.strokeStyle = 'black';
653 ctx.stroke(); 654 ctx.stroke();
654 } 655 }
655 656
656 int testnum = 0; // Set this to -1 to start with last test. 657 int testnum = 0; // Set this to -1 to start with last test.
657 658
658 void update() { 659 void update(num when) {
660 window.requestAnimationFrame(update);
659 if (testnum == 0) { 661 if (testnum == 0) {
660 anim(); 662 anim();
661 return; 663 return;
662 } 664 }
663 if (!isDirty) return; 665 if (!isDirty) return;
664 switch(testnum) { 666 switch(testnum) {
665 case 1: 667 case 1:
666 helloWorld(); 668 helloWorld();
667 break; 669 break;
668 case 2: 670 case 2:
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 for (int x = 0; x < screenWidth; x++) { 998 for (int x = 0; x < screenWidth; x++) {
997 var color = _traceRay(new Ray(scene.camera.pos, 999 var color = _traceRay(new Ray(scene.camera.pos,
998 getPoint(x, y, scene.camera) ), scene, 0); 1000 getPoint(x, y, scene.camera) ), scene, 0);
999 ctx.fillStyle = Color.toDrawingRGB(color); 1001 ctx.fillStyle = Color.toDrawingRGB(color);
1000 ctx.fillRect(x, y, x + 1, y + 1); 1002 ctx.fillRect(x, y, x + 1, y + 1);
1001 } 1003 }
1002 } 1004 }
1003 } 1005 }
1004 } 1006 }
1005 1007
1006
1007
1008
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698