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,39 +48,41 @@
myGlyphs.push(glyphs[v]); myGlyphs.push(glyphs[v]);
}); });
} }
// Merge the glyphs together if(num>0) {
var combined = []; // Merge the glyphs together
var glyphHeight = myGlyphs[0].length; var combined = [];
$.each(myGlyphs, function(k,v){ var glyphHeight = myGlyphs[0].length;
for(y=0; y<glyphHeight; y++){ $.each(myGlyphs, function(k,v){
// First pass? for(y=0; y<glyphHeight; y++){
if(combined[y] === undefined) { // First pass?
combined[y] = v[y]; if(combined[y] === undefined) {
} else { combined[y] = v[y];
// Merge the glyph parts, careful of the boundaries } else {
var l = combined[y].length; // Merge the glyph parts, careful of the boundaries
if(combined[y][(l-1)] == ' '){ var l = combined[y].length;
combined[y] = combined[y].substring(0, (l-1)) + v[y]; if(combined[y][(l-1)] === ' '){
} else { combined[y] = combined[y].substring(0, (l-1)) + v[y];
combined[y] += v[y].substring(1); } else {
} combined[y] += v[y].substring(1);
} }
} }
}); }
// Figure out our starting position });
var glyphWidth = combined[0].length; // Figure out our starting position
var x = (myPos.indexOf('l') != -1) ? 0 : (16 - glyphWidth); var glyphWidth = combined[0].length;
var y = (myPos.indexOf('t') != -1) ? 0 : (16 - glyphHeight); var x = (myPos.indexOf('l') !== -1) ? 0 : (16 - glyphWidth);
// Draw them pixels! var y = (myPos.indexOf('t') !== -1) ? 0 : (16 - glyphHeight);
for(dX=0; dX<glyphWidth; dX++){ // Draw them pixels!
for(dY=0; dY<glyphHeight; dY++){ for(dX=0; dX<glyphWidth; dX++){
var pixel = combined[dY][dX]; for(dY=0; dY<glyphHeight; dY++){
if(pixel != ' '){ var pixel = combined[dY][dX];
ctx.fillStyle = (pixel == '@') ? myFg : myBg; if(pixel !== ' '){
ctx.fillRect((x+dX), (y+dY), 1, 1); ctx.fillStyle = (pixel === '@') ? myFg : myBg;
} ctx.fillRect((x+dX), (y+dY), 1, 1);
} }
} }
}
}
} }
// Update the favicon // Update the favicon
$('link[rel$=icon]').remove(); $('link[rel$=icon]').remove();