Improved efficiency of blocktype
This commit is contained in:
parent
d57c5868ee
commit
a9f03f7d7c
1 changed files with 271 additions and 257 deletions
|
@ -2,7 +2,8 @@ load(__folder + "drone.js");
|
|||
|
||||
(function(){
|
||||
|
||||
var bitmap = {
|
||||
var bitmaps = {
|
||||
raw: {
|
||||
'0':' ### '+
|
||||
' # # '+
|
||||
' # # '+
|
||||
|
@ -278,7 +279,23 @@ load(__folder + "drone.js");
|
|||
' '+
|
||||
' '+
|
||||
' '
|
||||
},
|
||||
computed: {}
|
||||
};
|
||||
/*
|
||||
wph 20130121 compute the width, and x,y coords of pixels ahead of time
|
||||
*/
|
||||
for (var c in bitmaps.raw){
|
||||
var bits = bitmaps.raw[c];
|
||||
var width = bits.length/5;
|
||||
var bmInfo = {"width": width,"pixels":[]}
|
||||
bitmaps.computed[c] = bmInfo;
|
||||
for (var j = 0; j < bits.length; j++){
|
||||
if (bits.charAt(j) != ' '){
|
||||
bmInfo.pixels.push([j%width,Math.ceil(j/width)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Drone.extend('blocktype', function(message,fg,bg){
|
||||
|
||||
this.chkpt('blocktext');
|
||||
|
@ -287,25 +304,22 @@ load(__folder + "drone.js");
|
|||
for (var h = 0;h < lineCount; h++) {
|
||||
var line = lines[h];
|
||||
line = line.toLowerCase().replace(/[^0-9a-z \.\-\+\/\;\'\:\!]/g,"");
|
||||
print ("lineCount=" + lineCount);
|
||||
this.up(7*(lineCount-(h+1)));
|
||||
|
||||
for (var i =0;i < line.length; i++) {
|
||||
var ch = line.charAt(i)
|
||||
var bits = bitmap[ch];
|
||||
var bits = bitmaps.computed[ch];
|
||||
if (typeof bits == "undefined"){
|
||||
bits = bitmap[' '];
|
||||
bits = bitmaps.computed[' '];
|
||||
}
|
||||
var charWidth = bits.length/5;
|
||||
var charWidth = bits.width;
|
||||
if (typeof bg != "undefined")
|
||||
this.box(bg,charWidth,7,1);
|
||||
for (var j = 0;j < bits.length;j++){
|
||||
for (var j = 0;j < bits.pixels.length;j++){
|
||||
this.chkpt('btbl');
|
||||
if (bits.charAt(j) != ' '){
|
||||
var x = j % charWidth;
|
||||
var y = Math.ceil(j/charWidth);
|
||||
var x = bits.pixels[j][0];
|
||||
var y = bits.pixels[j][1];
|
||||
this.up(6-y).right(x).box(fg);
|
||||
}
|
||||
this.move('btbl');
|
||||
}
|
||||
this.right(charWidth-1);
|
||||
|
|
Reference in a new issue