| OLD | NEW |
| 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 Loading... |
| 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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 for (int x = 0; x < screenWidth; x++) { | 1000 for (int x = 0; x < screenWidth; x++) { |
| 1000 var color = _traceRay(new Ray(scene.camera.pos, | 1001 var color = _traceRay(new Ray(scene.camera.pos, |
| 1001 getPoint(x, y, scene.camera) ), scene, 0); | 1002 getPoint(x, y, scene.camera) ), scene, 0); |
| 1002 ctx.fillStyle = Color.toDrawingRGB(color); | 1003 ctx.fillStyle = Color.toDrawingRGB(color); |
| 1003 ctx.fillRect(x, y, x + 1, y + 1); | 1004 ctx.fillRect(x, y, x + 1, y + 1); |
| 1004 } | 1005 } |
| 1005 } | 1006 } |
| 1006 } | 1007 } |
| 1007 } | 1008 } |
| 1008 | 1009 |
| OLD | NEW |