Skip to content
Snippets Groups Projects
Commit d20a8bba authored by rswindell's avatar rswindell
Browse files

Graphic.draw() now supports 'center' as the value for xpos or ypos for

displaying a graphic centered in the terminal window.
parent 58108398
No related branches found
No related tags found
No related merge requests found
...@@ -504,10 +504,6 @@ Graphic.prototype.draw = function(xpos,ypos,width,height,xoff,yoff,delay) ...@@ -504,10 +504,6 @@ Graphic.prototype.draw = function(xpos,ypos,width,height,xoff,yoff,delay)
var x; var x;
var y; var y;
if(xpos==undefined)
xpos=1;
if(ypos==undefined)
ypos=1;
if(width==undefined) if(width==undefined)
width=this.width; width=this.width;
if(height==undefined) if(height==undefined)
...@@ -516,6 +512,14 @@ Graphic.prototype.draw = function(xpos,ypos,width,height,xoff,yoff,delay) ...@@ -516,6 +512,14 @@ Graphic.prototype.draw = function(xpos,ypos,width,height,xoff,yoff,delay)
xoff=0; xoff=0;
if(yoff==undefined) if(yoff==undefined)
yoff=0; yoff=0;
if(xpos == 'center') // center
xpos = Math.floor((console.screen_columns - width) / 2);
if(xpos==undefined || xpos < 1)
xpos=1;
if(ypos == 'center') // center
ypos = Math.floor((console.screen_rows - height) / 2);
if(ypos==undefined || ypos < 1)
ypos=1;
if(delay==undefined) if(delay==undefined)
delay=0; delay=0;
if(xoff+width > this.width || yoff+height > this.height) { if(xoff+width > this.width || yoff+height > this.height) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment