Browse Source

Added some drawImage() tests

v1.x
Tj Holowaychuk 14 years ago
parent
commit
d535c7aa88
  1. BIN
      test/public/state.png
  2. 40
      test/public/tests.js
  3. 1
      test/server.js

BIN
test/public/state.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 B

40
test/public/tests.js

@ -1386,4 +1386,44 @@ tests['font state'] = function(ctx){
ctx.restore(); ctx.restore();
ctx.fillText('Boom again!', 50, 140); ctx.fillText('Boom again!', 50, 140);
};
tests['drawImage(img,0,0)'] = function(ctx){
var img = new Image;
img.onload = function(){
ctx.drawImage(img, 0, 0);
};
img.src = 'state.png';
};
tests['drawImage(img,x,y)'] = function(ctx){
var img = new Image;
img.onload = function(){
ctx.drawImage(img, 5, 25);
};
img.src = 'state.png';
};
tests['drawImage(img,x,y,w,h) scale down'] = function(ctx){
var img = new Image;
img.onload = function(){
ctx.drawImage(img, 25, 25, 10, 10);
};
img.src = 'state.png';
};
tests['drawImage(img,x,y,w,h) scale up'] = function(ctx){
var img = new Image;
img.onload = function(){
ctx.drawImage(img, 0, 0, 200, 200);
};
img.src = 'state.png';
};
tests['drawImage(img,x,y,w,h) scale vertical'] = function(ctx){
var img = new Image;
img.onload = function(){
ctx.drawImage(img, 0, 0, img.width, 200);
};
img.src = 'state.png';
}; };

1
test/server.js

@ -5,6 +5,7 @@
var express = require('../support/express') var express = require('../support/express')
, Canvas = require('../lib/canvas') , Canvas = require('../lib/canvas')
, Image = Canvas.Image
, jade = require('../support/jade') , jade = require('../support/jade')
, app = express.createServer(); , app = express.createServer();

Loading…
Cancel
Save