psd2bmf
Version:
Convert the psd to bmfont.
112 lines (82 loc) • 2.1 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _path = _interopRequireDefault(require("path"));
var _utils = require("../utils");
var _const = require("../const");
var _GroupOpt = _interopRequireDefault(require("./GroupOpt"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class Option {
constructor(option) {
this._input = '';
this._inputInfo = null;
this._inputPng = '';
this._output = '';
this._filename = '';
this._groups = [];
(0, _utils.merge)(this, option);
}
get input() {
return (0, _utils.mustExist)(this._input, _const.PSD_EXT);
}
set input(value) {
if (value && (0, _utils.isString)(value)) {
this._input = value;
this._inputInfo = _path.default.parse(value);
}
}
get inputInfo() {
return this._inputInfo;
}
get inputPng() {
let inputPng = this._inputPng;
if (!(0, _utils.isExist)(inputPng, _const.PNG_EXT)) {
inputPng = this._input.replace(_const.PSD_EXT, _const.PNG_EXT);
}
return inputPng;
}
set inputPng(value) {
if (value) this._inputPng = value;
}
get output() {
let output = this._output;
if (!output) {
output = this._inputInfo.dir;
}
return output;
}
set output(value) {
if (value) this._output = value;
}
get filename() {
let filename = this._filename;
if (!filename) {
filename = this._inputInfo.name;
}
return filename;
}
set filename(value) {
if (value) this._filename = value;
}
get groups() {
return this._groups;
}
set groups(groups) {
this._groups.length = 0;
if ((0, _utils.isArray)(groups)) {
for (let i = 0, length = groups.length; i < length; i++) {
this._groups[i] = (0, _utils.merge)(new _GroupOpt.default(), groups[i]);
}
}
}
getGroup(i) {
let group = this._groups[i];
if (!group) {
this._groups[i] = group = new _GroupOpt.default();
}
return group;
}
}
exports.default = Option;