laya-coreui-es
Version:
laya核心库、ui库es版本,剔除了媒体、TTF等功能。基于 LayaAir-release_2.12.0 修改
99 lines (98 loc) • 3.58 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FillTextCmd = void 0;
const Context_1 = require("../../resource/Context");
const ColorUtils_1 = require("../../utils/ColorUtils");
const FontInfo_1 = require("../../utils/FontInfo");
const Pool_1 = require("../../utils/Pool");
const WordText_1 = require("../../utils/WordText");
const ILaya_1 = require("../../../ILaya");
class FillTextCmd {
constructor() {
this._textIsWorldText = false;
this._fontColor = 0xffffffff;
this._strokeColor = 0;
this._fontObj = FillTextCmd._defFontObj;
this._nTexAlign = 0;
}
static create(text, words, x, y, font, color, textAlign, lineWidth, borderColor) {
var cmd = Pool_1.Pool.getItemByClass("FillTextCmd", FillTextCmd);
cmd.text = text;
cmd._textIsWorldText = text instanceof WordText_1.WordText;
cmd._words = words;
cmd.x = x;
cmd.y = y;
cmd.font = font;
cmd.color = color;
cmd.textAlign = textAlign;
cmd._lineWidth = lineWidth;
cmd._borderColor = borderColor;
return cmd;
}
recover() {
Pool_1.Pool.recover("FillTextCmd", this);
}
run(context, gx, gy) {
if (ILaya_1.ILaya.stage.isGlobalRepaint()) {
this._textIsWorldText && this._text.cleanCache();
}
if (this._words) {
Context_1.Context._textRender.fillWords(context, this._words, this.x + gx, this.y + gy, this._fontObj, this._color, this._borderColor, this._lineWidth);
}
else {
if (this._textIsWorldText) {
context._fast_filltext(this._text, this.x + gx, this.y + gy, this._fontObj, this._color, this._borderColor, this._lineWidth, this._nTexAlign, 0);
}
else {
Context_1.Context._textRender.filltext(context, this._text, this.x + gx, this.y + gy, this.font, this.color, this._borderColor, this._lineWidth, this._textAlign);
}
}
}
get cmdID() {
return FillTextCmd.ID;
}
get text() {
return this._text;
}
set text(value) {
this._text = value;
this._textIsWorldText = value instanceof WordText_1.WordText;
this._textIsWorldText && this._text.cleanCache();
}
get font() {
return this._font;
}
set font(value) {
this._font = value;
this._fontObj = FontInfo_1.FontInfo.Parse(value);
this._textIsWorldText && this._text.cleanCache();
}
get color() {
return this._color;
}
set color(value) {
this._color = value;
this._fontColor = ColorUtils_1.ColorUtils.create(value).numColor;
this._textIsWorldText && this._text.cleanCache();
}
get textAlign() {
return this._textAlign;
}
set textAlign(value) {
this._textAlign = value;
switch (value) {
case 'center':
this._nTexAlign = ILaya_1.ILaya.Context.ENUM_TEXTALIGN_CENTER;
break;
case 'right':
this._nTexAlign = ILaya_1.ILaya.Context.ENUM_TEXTALIGN_RIGHT;
break;
default:
this._nTexAlign = ILaya_1.ILaya.Context.ENUM_TEXTALIGN_DEFAULT;
}
this._textIsWorldText && this._text.cleanCache();
}
}
exports.FillTextCmd = FillTextCmd;
FillTextCmd.ID = "FillText";
FillTextCmd._defFontObj = new FontInfo_1.FontInfo(null);