Added default player-faces.

This commit is contained in:
FrozenCow 2011-02-10 01:20:50 +01:00
parent 29517e9a24
commit 403a2acc53

View File

@ -16,7 +16,7 @@ function blitImage(ctx, image, sx ,sy, sw, sh, dx, dy, dw, dh) {
} }
} }
function createMinecraftHead(player,completed) { function createMinecraftHead(player,completed,failed) {
var skinImage = new Image(); var skinImage = new Image();
skinImage.onload = function() { skinImage.onload = function() {
var headCanvas = document.createElement('canvas'); var headCanvas = document.createElement('canvas');
@ -27,6 +27,13 @@ function createMinecraftHead(player,completed) {
blitImage(headContext, skinImage, 40,8,8,8, 0,0,8,8); blitImage(headContext, skinImage, 40,8,8,8, 0,0,8,8);
completed(headCanvas); completed(headCanvas);
}; };
skinImage.onerror = function() {
if (skinImage.src == 'http://www.minecraft.net/img/char.png') {
failed();
} else {
skinImage.src = 'http://www.minecraft.net/img/char.png';
}
};
skinImage.src = 'http://www.minecraft.net/skin/' + player + '.png'; skinImage.src = 'http://www.minecraft.net/skin/' + player + '.png';
} }
@ -60,6 +67,8 @@ function getMinecraftHead(player,size,completed) {
for(i=0;i<hooks.length;i++) { for(i=0;i<hooks.length;i++) {
hooks[i].f(resizeImage(head,hooks[i].s)); hooks[i].f(resizeImage(head,hooks[i].s));
} }
}, function() {
}); });
} else if (head.working) { } else if (head.working) {
//console.log('Other process working on head of ',player,', will add myself to hooks...'); //console.log('Other process working on head of ',player,', will add myself to hooks...');