malwoden
Version:
   
49 lines • 1.64 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Glyph = void 0;
var color_1 = require("./color");
/**
* Represents a glyph to be drawn to the screen.
*/
var Glyph = /** @class */ (function () {
/**
* Creates a Glyph from a single character.
*
* @param char - A single character.
* @param fore - A foreground color (default white)
* @param back - A background color (default black)
*/
function Glyph(char, fore, back) {
if (fore === void 0) { fore = color_1.Color.White; }
if (back === void 0) { back = color_1.Color.Black; }
this.char = char.charCodeAt(0);
this.fore = fore;
this.back = back;
}
/**
* Creates a glyph from a charCode.
*
* @param char - A number representing a charCode.
* @param fore - A foreground color (default white)
* @param back - A background color (default black)
*/
Glyph.fromCharCode = function (char, fore, back) {
if (fore === void 0) { fore = color_1.Color.White; }
if (back === void 0) { back = color_1.Color.Black; }
return new Glyph(String.fromCharCode(char), fore, back);
};
/**
* Checks to see if two glyphs are equal.
* @param other Glyph - The other glyph.
*/
Glyph.prototype.isEqual = function (other) {
if (other instanceof Glyph === false)
return false;
return (this.char === other.char &&
this.fore.isEqual(other.fore) &&
this.back.isEqual(other.back));
};
return Glyph;
}());
exports.Glyph = Glyph;
//# sourceMappingURL=glyph.js.map