Skip to content
Snippets Groups Projects
Commit 3269db2c authored by deuce's avatar deuce
Browse files

Add a write(xpos, ypos, text, attribute) method.

parent a5ff2f9f
No related branches found
No related tags found
No related merge requests found
...@@ -39,6 +39,7 @@ function Graphic(w,h,attr,ch) ...@@ -39,6 +39,7 @@ function Graphic(w,h,attr,ch)
} }
this.draw=Graphic_draw; this.draw=Graphic_draw;
this.load=Graphic_load; this.load=Graphic_load;
this.write=Graphic_write;
} }
function Graphic_draw(xpos,ypos,width,height,xoff,yoff) function Graphic_draw(xpos,ypos,width,height,xoff,yoff)
...@@ -101,3 +102,21 @@ function Graphic_load(filename) ...@@ -101,3 +102,21 @@ function Graphic_load(filename)
} }
return(true); return(true);
} }
function Graphic_write(xpos, ypos, txt, attr)
{
var x=xpos-1;
var y=ypos-1;
var p=0;
while(p<txt.length && x<=this.width && y<=this.height) {
this.data[x][y].ch=txt.substr(p,1);
if(attr!=undefined)
this.data[x][y].attr=attr;
x++;
if(x>=this.width) {
x=0;
y++;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment