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

Unified Diff: samples/openglui/src/openglui_canvas_tests.dart

Issue 13345002: Cleaned up OpenGLUI samples and added Blasteroids. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samples/openglui/src/gl.dart ('k') | samples/openglui/src/openglui_raytrace.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/openglui/src/openglui_canvas_tests.dart
===================================================================
--- samples/openglui/src/openglui_canvas_tests.dart (revision 20700)
+++ samples/openglui/src/openglui_canvas_tests.dart (working copy)
@@ -21,7 +21,7 @@
height = h;
}
-void setup(canvasp, int w, int h) {
+void setup(canvasp, int w, int h, int f) {
if (canvasp == null) {
log("Allocating canvas");
canvas = new CanvasElement(width: w, height: h);
@@ -500,12 +500,11 @@
void loadImage() {
initTest("Image loading");
var imageObj = new ImageElement();
- var sub;
- sub = imageObj.onLoad.listen((e) {
- ctx.drawImage(e.target, 69, 50);
- sub.cancel();
+ // Setting src before onLoad is a more interesting test.
+ imageObj.src = 'chrome.png';
+ imageObj.onLoad.listen((e) {
+ ctx.drawImage(e.target, 0, 0, width, height, 0, 0, width, height);
});
- imageObj.src = 'chrome.png';
}
void clip() {
@@ -656,8 +655,40 @@
ctx.stroke();
}
+void linearGradient() {
+ initTest("Linear Gradient");
+ ctx.rect(0, 0, width, height);
+ var grd = ctx.createLinearGradient(0, 0, width, height);
+ // light blue
+ grd.addColorStop(0, '#8ED6FF');
+ // dark blue
+ grd.addColorStop(1, '#004CB3');
+ ctx.fillStyle = grd;
+ ctx.fill();
+}
+
+void radialGradient() {
+ initTest("Radial Gradient");
+ ctx.rect(0, 0, width, height);
+ var grd = ctx.createRadialGradient(238, 50, 10, 238, 50, 300);
+ // light blue
+ grd.addColorStop(0, '#8ED6FF');
+ // dark blue
+ grd.addColorStop(1, '#004CB3');
+ ctx.fillStyle = grd;
+ ctx.fill();
+}
+
int testnum = 0; // Set this to -1 to start with last test.
+double x, y, z;
+
+onAccelerometer(double xx, double yy, double zz) {
+ x = xx;
+ y = yy;
+ z = zz;
+}
+
void update(num when) {
window.requestAnimationFrame(update);
if (testnum == 0) {
@@ -733,17 +764,25 @@
smiley();
break;
case 23:
+ linearGradient();
+ break;
+ case 24:
+ radialGradient();
+ break;
+ case 25:
+ break; // Skip for now; this is really slow.
var rayTracer = new RayTracer();
rayTracer.render(defaultScene(), ctx, width, height);
break;
default:
if (testnum < 0) {
- testnum = 23;
+ testnum = 24;
} else {
testnum = 0;
}
return;
}
+
isDirty = false;
}
« no previous file with comments | « samples/openglui/src/gl.dart ('k') | samples/openglui/src/openglui_raytrace.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698