Skip to content
Snippets Groups Projects
Commit a6a710a3 authored by mcmlxxix's avatar mcmlxxix
Browse files

Added "Center()" method for centering text within a given width

rather than on an entire line
parent 498eb5ef
Branches
Tags
No related merge requests found
......@@ -83,6 +83,23 @@ function PrintPadded(string,length,padding,justification)
if(justification=="right") newstring=(padded + newstring);
return(newstring);
}
function CenterString(string,length,padding)
{
if(!padding) padding=" ";
var strlength=console.strlen(string);
if(strlength>length)
{
string=string.substring(0,length);
}
var padlength=length-strlength;
var newstring=string;
for(p=1;p<=padlength;p++)
{
if(p%2==0) newstring+=padding;
else newstring=padding+newstring;
}
return newstring;
}
function DrawLine(x,y,length,color)
{
if(x && y)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment