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

move drawBorder prototype method into oneliners script

parent f23417fe
No related branches found
No related tags found
No related merge requests found
......@@ -57,8 +57,6 @@ METHODS:
frame.gotoxy(x,y)
frame.pushxy()
frame.popxy()
frame.drawBorder(color) //draw a border along the inside edge of the frame; see sbbsdefs.js for valid 'color' arguments
//'color' can be an array of colors (try it to see the effect)
PROPERTIES:
......@@ -1212,43 +1210,6 @@ function Frame(x,y,width,height,attr,parent) {
init.apply(this,arguments);
}
Frame.prototype.drawBorder = function(color) {
var theColor = color;
if(Array.isArray(color));
var sectionLength = Math.round(this.width / color.length);
this.pushxy();
for(var y = 1; y <= this.height; y++) {
for(var x = 1; x <= this.width; x++) {
if(x > 1 && x < this.width && y > 1 && y < this.height)
continue;
var msg;
this.gotoxy(x, y);
if(y == 1 && x == 1)
msg = ascii(218);
else if(y == 1 && x == this.width)
msg = ascii(191);
else if(y == this.height && x == 1)
msg = ascii(192);
else if(y == this.height && x == this.width)
msg = ascii(217);
else if(x == 1 || x == this.width)
msg = ascii(179);
else
msg = ascii(196);
if(Array.isArray(color)) {
if(x == 1)
theColor = color[0];
else if(x % sectionLength == 0 && x < this.width)
theColor = color[x / sectionLength];
else if(x == this.width)
theColor = color[color.length - 1];
}
this.putmsg(msg, theColor);
}
}
this.popxy();
}
/* frame reference object */
function Canvas(frame,display) {
this.frame = frame;
......
......@@ -14,6 +14,45 @@ var initFrames = function() {
console.clear(BG_BLACK|LIGHTGRAY);
/* frame.drawBorder(color) //draw a border along the inside edge of the frame; see sbbsdefs.js for valid 'color' arguments
//'color' can be an array of colors (try it to see the effect) */
Frame.prototype.drawBorder = function(color) {
var theColor = color;
if(Array.isArray(color));
var sectionLength = Math.round(this.width / color.length);
this.pushxy();
for(var y = 1; y <= this.height; y++) {
for(var x = 1; x <= this.width; x++) {
if(x > 1 && x < this.width && y > 1 && y < this.height)
continue;
var msg;
this.gotoxy(x, y);
if(y == 1 && x == 1)
msg = ascii(218);
else if(y == 1 && x == this.width)
msg = ascii(191);
else if(y == this.height && x == 1)
msg = ascii(192);
else if(y == this.height && x == this.width)
msg = ascii(217);
else if(x == 1 || x == this.width)
msg = ascii(179);
else
msg = ascii(196);
if(Array.isArray(color)) {
if(x == 1)
theColor = color[0];
else if(x % sectionLength == 0 && x < this.width)
theColor = color[x / sectionLength];
else if(x == this.width)
theColor = color[color.length - 1];
}
this.putmsg(msg, theColor);
}
}
this.popxy();
}
frame = new Frame(
1,
1,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment