initial commit
This commit is contained in:
@@ -0,0 +1,257 @@
|
||||
shadow$provide.module$node_modules$pixi_DOT_js$lib$scene$text$TextStyle = function(global, require, module, exports) {
|
||||
function convertV7Tov8Style(style) {
|
||||
if ("boolean" === typeof style.dropShadow && style.dropShadow) {
|
||||
var defaults = TextStyle.defaultDropShadow;
|
||||
style.dropShadow = {alpha:style.dropShadowAlpha ?? defaults.alpha, angle:style.dropShadowAngle ?? defaults.angle, blur:style.dropShadowBlur ?? defaults.blur, color:style.dropShadowColor ?? defaults.color, distance:style.dropShadowDistance ?? defaults.distance};
|
||||
}
|
||||
if (void 0 !== style.strokeThickness) {
|
||||
deprecation.deprecation(deprecation.v8_0_0, "strokeThickness is now a part of stroke");
|
||||
defaults = style.stroke;
|
||||
let obj = {};
|
||||
if (Color.Color.isColorLike(defaults)) {
|
||||
obj.color = defaults;
|
||||
} else if (defaults instanceof FillGradient.FillGradient || defaults instanceof FillPattern.FillPattern) {
|
||||
obj.fill = defaults;
|
||||
} else if (Object.hasOwnProperty.call(defaults, "color") || Object.hasOwnProperty.call(defaults, "fill")) {
|
||||
obj = defaults;
|
||||
} else {
|
||||
throw Error("Invalid stroke value.");
|
||||
}
|
||||
style.stroke = {...obj, width:style.strokeThickness};
|
||||
}
|
||||
if (Array.isArray(style.fillGradientStops)) {
|
||||
deprecation.deprecation(deprecation.v8_0_0, "gradient fill is now a fill pattern: `new FillGradient(...)`");
|
||||
if (!Array.isArray(style.fill) || 0 === style.fill.length) {
|
||||
throw Error("Invalid fill value. Expected an array of colors for gradient fill.");
|
||||
}
|
||||
style.fill.length !== style.fillGradientStops.length && warn.warn("The number of fill colors must match the number of fill gradient stops.");
|
||||
const gradientFill = new FillGradient.FillGradient({start:{x:0, y:0}, end:{x:0, y:1}, textureSpace:"local"});
|
||||
defaults = style.fillGradientStops.slice();
|
||||
const fills = style.fill.map(color => Color.Color.shared.setValue(color).toNumber());
|
||||
defaults.forEach((stop, index) => {
|
||||
gradientFill.addColorStop(stop, fills[index]);
|
||||
});
|
||||
style.fill = {fill:gradientFill};
|
||||
}
|
||||
}
|
||||
global = require("module$node_modules$eventemitter3$index");
|
||||
var Color = require("module$node_modules$pixi_DOT_js$lib$color$Color"), uid = require("module$node_modules$pixi_DOT_js$lib$utils$data$uid"), deprecation = require("module$node_modules$pixi_DOT_js$lib$utils$logging$deprecation"), warn = require("module$node_modules$pixi_DOT_js$lib$utils$logging$warn"), FillGradient = require("module$node_modules$pixi_DOT_js$lib$scene$graphics$shared$fill$FillGradient"), FillPattern = require("module$node_modules$pixi_DOT_js$lib$scene$graphics$shared$fill$FillPattern"),
|
||||
GraphicsContext = require("module$node_modules$pixi_DOT_js$lib$scene$graphics$shared$GraphicsContext"), convertFillInputToFillStyle = require("module$node_modules$pixi_DOT_js$lib$scene$graphics$shared$utils$convertFillInputToFillStyle"), fontStringFromTextStyle = require("module$node_modules$pixi_DOT_js$lib$scene$text$canvas$utils$fontStringFromTextStyle");
|
||||
"use strict";
|
||||
const node_modules$pixi_DOT_js$lib$scene$text$TextStyle$classdecl$var35 = class extends global {
|
||||
constructor(style = {}) {
|
||||
super();
|
||||
this.uid = uid.uid("textStyle");
|
||||
this._tick = 0;
|
||||
this._cachedFontString = null;
|
||||
convertV7Tov8Style(style);
|
||||
var existingStyle = style;
|
||||
style instanceof node_modules$pixi_DOT_js$lib$scene$text$TextStyle$classdecl$var35 && (style = existingStyle._toObject());
|
||||
existingStyle = {...node_modules$pixi_DOT_js$lib$scene$text$TextStyle$classdecl$var35.defaultTextStyle, ...style};
|
||||
for (const key in existingStyle) {
|
||||
this[key] = existingStyle[key];
|
||||
}
|
||||
this._tagStyles = style.tagStyles ?? void 0;
|
||||
this.update();
|
||||
this._tick = 0;
|
||||
}
|
||||
get align() {
|
||||
return this._align;
|
||||
}
|
||||
set align(value) {
|
||||
this._align !== value && (this._align = value, this.update());
|
||||
}
|
||||
get breakWords() {
|
||||
return this._breakWords;
|
||||
}
|
||||
set breakWords(value) {
|
||||
this._breakWords !== value && (this._breakWords = value, this.update());
|
||||
}
|
||||
get dropShadow() {
|
||||
return this._dropShadow;
|
||||
}
|
||||
set dropShadow(value) {
|
||||
this._dropShadow !== value && (this._dropShadow = null !== value && "object" === typeof value ? this._createProxy({...node_modules$pixi_DOT_js$lib$scene$text$TextStyle$classdecl$var35.defaultDropShadow, ...value}) : value ? this._createProxy({...node_modules$pixi_DOT_js$lib$scene$text$TextStyle$classdecl$var35.defaultDropShadow}) : null, this.update());
|
||||
}
|
||||
get fontFamily() {
|
||||
return this._fontFamily;
|
||||
}
|
||||
set fontFamily(value) {
|
||||
this._fontFamily !== value && (this._fontFamily = value, this.update());
|
||||
}
|
||||
get fontSize() {
|
||||
return this._fontSize;
|
||||
}
|
||||
set fontSize(value) {
|
||||
this._fontSize !== value && (this._fontSize = "string" === typeof value ? parseInt(value, 10) : value, this.update());
|
||||
}
|
||||
get fontStyle() {
|
||||
return this._fontStyle;
|
||||
}
|
||||
set fontStyle(value) {
|
||||
this._fontStyle !== value && (this._fontStyle = value.toLowerCase(), this.update());
|
||||
}
|
||||
get fontVariant() {
|
||||
return this._fontVariant;
|
||||
}
|
||||
set fontVariant(value) {
|
||||
this._fontVariant !== value && (this._fontVariant = value, this.update());
|
||||
}
|
||||
get fontWeight() {
|
||||
return this._fontWeight;
|
||||
}
|
||||
set fontWeight(value) {
|
||||
this._fontWeight !== value && (this._fontWeight = value, this.update());
|
||||
}
|
||||
get leading() {
|
||||
return this._leading;
|
||||
}
|
||||
set leading(value) {
|
||||
this._leading !== value && (this._leading = value, this.update());
|
||||
}
|
||||
get letterSpacing() {
|
||||
return this._letterSpacing;
|
||||
}
|
||||
set letterSpacing(value) {
|
||||
this._letterSpacing !== value && (this._letterSpacing = value, this.update());
|
||||
}
|
||||
get lineHeight() {
|
||||
return this._lineHeight;
|
||||
}
|
||||
set lineHeight(value) {
|
||||
this._lineHeight !== value && (this._lineHeight = value, this.update());
|
||||
}
|
||||
get padding() {
|
||||
return this._padding;
|
||||
}
|
||||
set padding(value) {
|
||||
this._padding !== value && (this._padding = value, this.update());
|
||||
}
|
||||
get filters() {
|
||||
return this._filters;
|
||||
}
|
||||
set filters(value) {
|
||||
this._filters !== value && (this._filters = Object.freeze(value), this.update());
|
||||
}
|
||||
get trim() {
|
||||
return this._trim;
|
||||
}
|
||||
set trim(value) {
|
||||
this._trim !== value && (this._trim = value, this.update());
|
||||
}
|
||||
get textBaseline() {
|
||||
return this._textBaseline;
|
||||
}
|
||||
set textBaseline(value) {
|
||||
this._textBaseline !== value && (this._textBaseline = value, this.update());
|
||||
}
|
||||
get whiteSpace() {
|
||||
return this._whiteSpace;
|
||||
}
|
||||
set whiteSpace(value) {
|
||||
this._whiteSpace !== value && (this._whiteSpace = value, this.update());
|
||||
}
|
||||
get wordWrap() {
|
||||
return this._wordWrap;
|
||||
}
|
||||
set wordWrap(value) {
|
||||
this._wordWrap !== value && (this._wordWrap = value, this.update());
|
||||
}
|
||||
get wordWrapWidth() {
|
||||
return this._wordWrapWidth;
|
||||
}
|
||||
set wordWrapWidth(value) {
|
||||
this._wordWrapWidth !== value && (this._wordWrapWidth = value, this.update());
|
||||
}
|
||||
get fill() {
|
||||
return this._originalFill;
|
||||
}
|
||||
set fill(value) {
|
||||
value !== this._originalFill && (this._originalFill = value, this._isFillStyle(value) && (this._originalFill = this._createProxy({...GraphicsContext.GraphicsContext.defaultFillStyle, ...value}, () => {
|
||||
this._fill = convertFillInputToFillStyle.toFillStyle({...this._originalFill}, GraphicsContext.GraphicsContext.defaultFillStyle);
|
||||
})), this._fill = convertFillInputToFillStyle.toFillStyle(0 === value ? "black" : value, GraphicsContext.GraphicsContext.defaultFillStyle), this.update());
|
||||
}
|
||||
get stroke() {
|
||||
return this._originalStroke;
|
||||
}
|
||||
set stroke(value) {
|
||||
value !== this._originalStroke && (this._originalStroke = value, this._isFillStyle(value) && (this._originalStroke = this._createProxy({...GraphicsContext.GraphicsContext.defaultStrokeStyle, ...value}, () => {
|
||||
this._stroke = convertFillInputToFillStyle.toStrokeStyle({...this._originalStroke}, GraphicsContext.GraphicsContext.defaultStrokeStyle);
|
||||
})), this._stroke = convertFillInputToFillStyle.toStrokeStyle(value, GraphicsContext.GraphicsContext.defaultStrokeStyle), this.update());
|
||||
}
|
||||
get tagStyles() {
|
||||
return this._tagStyles;
|
||||
}
|
||||
set tagStyles(value) {
|
||||
this._tagStyles !== value && (this._tagStyles = value ?? void 0, this.update());
|
||||
}
|
||||
update() {
|
||||
this._tick++;
|
||||
this._cachedFontString = null;
|
||||
this.emit("update", this);
|
||||
}
|
||||
reset() {
|
||||
const defaultStyle = node_modules$pixi_DOT_js$lib$scene$text$TextStyle$classdecl$var35.defaultTextStyle;
|
||||
for (const key in defaultStyle) {
|
||||
this[key] = defaultStyle[key];
|
||||
}
|
||||
}
|
||||
assign(values) {
|
||||
for (const key in values) {
|
||||
this[key] = values[key];
|
||||
}
|
||||
return this;
|
||||
}
|
||||
get styleKey() {
|
||||
return `${this.uid}-${this._tick}`;
|
||||
}
|
||||
get _fontString() {
|
||||
null === this._cachedFontString && (this._cachedFontString = fontStringFromTextStyle.fontStringFromTextStyle(this));
|
||||
return this._cachedFontString;
|
||||
}
|
||||
_toObject() {
|
||||
return {align:this.align, breakWords:this.breakWords, dropShadow:this._dropShadow ? {...this._dropShadow} : null, fill:this._fill ? {...this._fill} : void 0, fontFamily:this.fontFamily, fontSize:this.fontSize, fontStyle:this.fontStyle, fontVariant:this.fontVariant, fontWeight:this.fontWeight, leading:this.leading, letterSpacing:this.letterSpacing, lineHeight:this.lineHeight, padding:this.padding, stroke:this._stroke ? {...this._stroke} : void 0, textBaseline:this.textBaseline, trim:this.trim,
|
||||
whiteSpace:this.whiteSpace, wordWrap:this.wordWrap, wordWrapWidth:this.wordWrapWidth, filters:this._filters ? [...this._filters] : void 0, tagStyles:this._tagStyles ? {...this._tagStyles} : void 0};
|
||||
}
|
||||
clone() {
|
||||
return new node_modules$pixi_DOT_js$lib$scene$text$TextStyle$classdecl$var35(this._toObject());
|
||||
}
|
||||
_getFinalPadding() {
|
||||
let filterPadding = 0;
|
||||
if (this._filters) {
|
||||
for (let i = 0; i < this._filters.length; i++) {
|
||||
filterPadding += this._filters[i].padding;
|
||||
}
|
||||
}
|
||||
return Math.max(this._padding, filterPadding);
|
||||
}
|
||||
destroy(options = !1) {
|
||||
this.removeAllListeners();
|
||||
if ("boolean" === typeof options ? options : options?.texture) {
|
||||
options = "boolean" === typeof options ? options : options?.textureSource, this._fill?.texture && this._fill.texture.destroy(options), this._originalFill?.texture && this._originalFill.texture.destroy(options), this._stroke?.texture && this._stroke.texture.destroy(options), this._originalStroke?.texture && this._originalStroke.texture.destroy(options);
|
||||
}
|
||||
this._originalFill = this._originalStroke = this.dropShadow = this._stroke = this._fill = null;
|
||||
}
|
||||
_createProxy(value, cb) {
|
||||
return new Proxy(value, {set:(target, property, newValue) => {
|
||||
if (target[property] === newValue) {
|
||||
return !0;
|
||||
}
|
||||
target[property] = newValue;
|
||||
cb?.(property, newValue);
|
||||
this.update();
|
||||
return !0;
|
||||
}});
|
||||
}
|
||||
_isFillStyle(value) {
|
||||
return null !== (value ?? null) && !(Color.Color.isColorLike(value) || value instanceof FillGradient.FillGradient || value instanceof FillPattern.FillPattern);
|
||||
}
|
||||
};
|
||||
require = node_modules$pixi_DOT_js$lib$scene$text$TextStyle$classdecl$var35;
|
||||
require.defaultDropShadow = {alpha:1, angle:Math.PI / 6, blur:0, color:"black", distance:5};
|
||||
require.defaultTextStyle = {align:"left", breakWords:!1, dropShadow:null, fill:"black", fontFamily:"Arial", fontSize:26, fontStyle:"normal", fontVariant:"normal", fontWeight:"normal", leading:0, letterSpacing:0, lineHeight:0, padding:0, stroke:null, textBaseline:"alphabetic", trim:!1, whiteSpace:"pre", wordWrap:!1, wordWrapWidth:100};
|
||||
let TextStyle = require;
|
||||
exports.TextStyle = TextStyle;
|
||||
};
|
||||
|
||||
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$scene$text$TextStyle.js.map
|
||||
Reference in New Issue
Block a user