don't render 0 ... also this file needs some love

This commit is contained in:
Sam 2013-06-11 15:26:36 +10:00
parent 4e01b84695
commit 4d7a520a8c

View file

@ -48,6 +48,7 @@
myGlyphs.push(glyphs[v]); myGlyphs.push(glyphs[v]);
}); });
} }
if(num>0) {
// Merge the glyphs together // Merge the glyphs together
var combined = []; var combined = [];
var glyphHeight = myGlyphs[0].length; var glyphHeight = myGlyphs[0].length;
@ -59,7 +60,7 @@
} else { } else {
// Merge the glyph parts, careful of the boundaries // Merge the glyph parts, careful of the boundaries
var l = combined[y].length; var l = combined[y].length;
if(combined[y][(l-1)] == ' '){ if(combined[y][(l-1)] === ' '){
combined[y] = combined[y].substring(0, (l-1)) + v[y]; combined[y] = combined[y].substring(0, (l-1)) + v[y];
} else { } else {
combined[y] += v[y].substring(1); combined[y] += v[y].substring(1);
@ -69,17 +70,18 @@
}); });
// Figure out our starting position // Figure out our starting position
var glyphWidth = combined[0].length; var glyphWidth = combined[0].length;
var x = (myPos.indexOf('l') != -1) ? 0 : (16 - glyphWidth); var x = (myPos.indexOf('l') !== -1) ? 0 : (16 - glyphWidth);
var y = (myPos.indexOf('t') != -1) ? 0 : (16 - glyphHeight); var y = (myPos.indexOf('t') !== -1) ? 0 : (16 - glyphHeight);
// Draw them pixels! // Draw them pixels!
for(dX=0; dX<glyphWidth; dX++){ for(dX=0; dX<glyphWidth; dX++){
for(dY=0; dY<glyphHeight; dY++){ for(dY=0; dY<glyphHeight; dY++){
var pixel = combined[dY][dX]; var pixel = combined[dY][dX];
if(pixel != ' '){ if(pixel !== ' '){
ctx.fillStyle = (pixel == '@') ? myFg : myBg; ctx.fillStyle = (pixel === '@') ? myFg : myBg;
ctx.fillRect((x+dX), (y+dY), 1, 1); ctx.fillRect((x+dX), (y+dY), 1, 1);
} }
} }
}
} }
} }
// Update the favicon // Update the favicon