@wcardinal/wcardinal-ui 0.402.0 → 0.403.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,13 +6,20 @@ import { BaseTexture, Rectangle, Texture, settings } from "pixi.js";
6
6
  import { toSvgUrl } from "./to-svg-url";
7
7
  var UtilSvgAtlasBuilder = /** @class */ (function () {
8
8
  function UtilSvgAtlasBuilder(options) {
9
- var _a, _b, _c, _d, _e, _f, _g;
9
+ var _a, _b, _c, _d, _e, _f;
10
10
  this._width = (_a = options.width) !== null && _a !== void 0 ? _a : 256;
11
11
  this._ratio = (_b = options.ratio) !== null && _b !== void 0 ? _b : 1;
12
12
  this._margin = (_c = options.margin) !== null && _c !== void 0 ? _c : 3;
13
- this._resolution = (_e = (_d = options.resolution) !== null && _d !== void 0 ? _d : window.devicePixelRatio) !== null && _e !== void 0 ? _e : 1;
14
- this._scaling = (_f = options.scaling) !== null && _f !== void 0 ? _f : settings.SCALE_MODE;
15
- this._mipmap = (_g = options.mipmap) !== null && _g !== void 0 ? _g : settings.MIPMAP_TEXTURES;
13
+ var resolution = options.resolution;
14
+ if (resolution != null) {
15
+ this._resolution = resolution;
16
+ }
17
+ else {
18
+ var dpr = (_d = window.devicePixelRatio) !== null && _d !== void 0 ? _d : 1;
19
+ this._resolution = 2 < dpr ? dpr : dpr * 2;
20
+ }
21
+ this._scaling = (_e = options.scaling) !== null && _e !== void 0 ? _e : settings.SCALE_MODE;
22
+ this._mipmap = (_f = options.mipmap) !== null && _f !== void 0 ? _f : settings.MIPMAP_TEXTURES;
16
23
  this._frames = {};
17
24
  this._svg = "";
18
25
  this._nextX = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"util-svg-atlas-builder.js","sourceRoot":"","sources":["../../../../src/main/typescript/wcardinal/ui/util/util-svg-atlas-builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAgB,SAAS,EAAe,OAAO,EAAE,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AP,OAAO,CAAE,OAAO,mCAAI,IAAI,CAAC,QAAQ,CAAC;YACpD,IAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE;gBACzC,UAAU,YAAA;gBACV,SAAS,WAAA;gBACT,MAAM,EAAE,IAAI,CAAC,OAAO;aACpB,CAAC,CAAC;YACH,IAAM,QAAM,GAAG,IAAI,CAAC,OAAO,CAAC;YAC5B,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;YACzB,KAAK,IAAM,MAAI,IAAI,QAAM,EAAE;gBAC1B,KAAK,CAAC,MAAI,CAAC,GAAG,IAAI,OAAO,CAAC,WAAW,EAAE,QAAM,CAAC,MAAI,CAAC,CAAC,CAAC;aACrD;SACD;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACF,0BAAC;AAAD,CAAC,AAtID,IAsIC","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { BaseTexture, MIPMAP_MODES, Rectangle, SCALE_MODES, Texture, settings } from \"pixi.js\";\nimport { toSvgUrl } from \"./to-svg-url\";\n\nexport interface UtilSvgAtlasBuilderBuildOptions {\n\tforce?: boolean;\n\tscaling?: SCALE_MODES;\n\tresolution?: number;\n}\n\nexport interface UtilSvgAtlasBuilderOptions {\n\twidth?: number;\n\tratio?: number;\n\tmargin?: number;\n\tresolution?: number;\n\tscaling?: SCALE_MODES;\n\tmipmap?: MIPMAP_MODES;\n}\n\nexport class UtilSvgAtlasBuilder {\n\tprotected _width: number;\n\tprotected _ratio: number;\n\tprotected _margin: number;\n\tprotected _resolution: number;\n\tprotected _scaling: SCALE_MODES;\n\tprotected _mipmap: MIPMAP_MODES;\n\n\tprotected _frames: Record<string, Rectangle>;\n\tprotected _svg: string;\n\tprotected _nextX: number;\n\tprotected _nextY: number;\n\tprotected _height: number;\n\n\tprotected _built?: Record<string, Texture>;\n\n\tconstructor(options: UtilSvgAtlasBuilderOptions) {\n\t\tthis._width = options.width ?? 256;\n\t\tthis._ratio = options.ratio ?? 1;\n\t\tthis._margin = options.margin ?? 3;\n\t\tthis._resolution = options.resolution ?? window.devicePixelRatio ?? 1;\n\t\tthis._scaling = options.scaling ?? settings.SCALE_MODE;\n\t\tthis._mipmap = options.mipmap ?? settings.MIPMAP_TEXTURES;\n\n\t\tthis._frames = {};\n\t\tthis._svg = \"\";\n\t\tthis._nextX = 0;\n\t\tthis._nextY = 0;\n\t\tthis._height = 0;\n\t}\n\n\tget width(): number {\n\t\treturn this._width;\n\t}\n\n\tget ratio(): number {\n\t\treturn this._ratio;\n\t}\n\n\tget margin(): number {\n\t\treturn this._margin;\n\t}\n\n\tadd(name: string, width: number, height: number, path: string): boolean;\n\tadd(\n\t\tname: string,\n\t\twidth: number,\n\t\theight: number,\n\t\tpath: string,\n\t\tframeX: number,\n\t\tframeY: number,\n\t\tframeWidth: number,\n\t\tframeHeight: number\n\t): boolean;\n\tadd(\n\t\tname: string,\n\t\twidth: number,\n\t\theight: number,\n\t\tpath: string,\n\t\tframeX?: number,\n\t\tframeY?: number,\n\t\tframeWidth?: number,\n\t\tframeHeight?: number\n\t): boolean {\n\t\tconst frames = this._frames;\n\t\tif (!(name in frames)) {\n\t\t\t// Position\n\t\t\tconst margin = this._margin;\n\t\t\tlet x = this._nextX;\n\t\t\tlet y = this._nextY;\n\t\t\tif (this._width <= x + width) {\n\t\t\t\tx = 0;\n\t\t\t\ty = this._nextY + this._height + margin;\n\t\t\t\tthis._height = height;\n\t\t\t\tthis._nextY = y;\n\t\t\t} else {\n\t\t\t\tthis._height = Math.max(this._height, height);\n\t\t\t}\n\t\t\tthis._nextX = x + width + margin;\n\n\t\t\t// Frame\n\t\t\tframes[name] = new Rectangle(\n\t\t\t\tx + (frameX ?? 0),\n\t\t\t\ty + (frameY ?? 0),\n\t\t\t\tframeWidth ?? width,\n\t\t\t\tframeHeight ?? height\n\t\t\t);\n\n\t\t\t// Svg\n\t\t\tconst ratio = this._ratio;\n\t\t\tthis._svg += `<g transform=\"translate(${x * ratio},${y * ratio})\">${path}</g>`;\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\thas(name: string): boolean {\n\t\treturn name in this._frames;\n\t}\n\n\tget mappings(): Record<string, Texture> {\n\t\treturn this.build();\n\t}\n\n\tbuild(options?: UtilSvgAtlasBuilderBuildOptions): Record<string, Texture> {\n\t\tlet built = this._built;\n\t\tif (built == null || options?.force) {\n\t\t\tconst resolution = options?.resolution ?? this._resolution;\n\t\t\tconst width = this._width;\n\t\t\tconst height = Math.pow(2, Math.ceil(Math.log(this._nextY + this._height) / Math.LN2));\n\t\t\tconst realWidth = width * resolution;\n\t\t\tconst realHeight = height * resolution;\n\t\t\tconst ratio = this._ratio;\n\t\t\tconst attrWidth = `width=\"${realWidth}\"`;\n\t\t\tconst attrHeight = `height=\"${realHeight}\"`;\n\t\t\tconst attrViewBox = `viewBox=\"0 0 ${width * ratio} ${height * ratio}\"`;\n\t\t\tconst attrXmlns = `xmlns=\"http://www.w3.org/2000/svg\"`;\n\t\t\tconst url = toSvgUrl(\n\t\t\t\t`<svg ${attrWidth} ${attrHeight} ${attrViewBox} ${attrXmlns}>${this._svg}</svg>`\n\t\t\t);\n\t\t\tconst scaleMode = options?.scaling ?? this._scaling;\n\t\t\tconst baseTexture = BaseTexture.from(url, {\n\t\t\t\tresolution,\n\t\t\t\tscaleMode,\n\t\t\t\tmipmap: this._mipmap\n\t\t\t});\n\t\t\tconst frames = this._frames;\n\t\t\tbuilt = this._built = {};\n\t\t\tfor (const name in frames) {\n\t\t\t\tbuilt[name] = new Texture(baseTexture, frames[name]);\n\t\t\t}\n\t\t}\n\t\treturn built;\n\t}\n}\n"]}
1
+ {"version":3,"file":"util-svg-atlas-builder.js","sourceRoot":"","sources":["../../../../src/main/typescript/wcardinal/ui/util/util-svg-atlas-builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAgB,SAAS,EAAe,OA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OAAG,CAAC;YACvE,IAAM,SAAS,GAAG,sCAAoC,CAAC;YACvD,IAAM,GAAG,GAAG,QAAQ,CACnB,eAAQ,SAAS,cAAI,UAAU,cAAI,WAAW,cAAI,SAAS,cAAI,IAAI,CAAC,IAAI,WAAQ,CAChF,CAAC;YACF,IAAM,SAAS,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,mCAAI,IAAI,CAAC,QAAQ,CAAC;YACpD,IAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE;gBACzC,UAAU,YAAA;gBACV,SAAS,WAAA;gBACT,MAAM,EAAE,IAAI,CAAC,OAAO;aACpB,CAAC,CAAC;YACH,IAAM,QAAM,GAAG,IAAI,CAAC,OAAO,CAAC;YAC5B,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;YACzB,KAAK,IAAM,MAAI,IAAI,QAAM,EAAE;gBAC1B,KAAK,CAAC,MAAI,CAAC,GAAG,IAAI,OAAO,CAAC,WAAW,EAAE,QAAM,CAAC,MAAI,CAAC,CAAC,CAAC;aACrD;SACD;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACF,0BAAC;AAAD,CAAC,AA5ID,IA4IC","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { BaseTexture, MIPMAP_MODES, Rectangle, SCALE_MODES, Texture, settings } from \"pixi.js\";\nimport { toSvgUrl } from \"./to-svg-url\";\n\nexport interface UtilSvgAtlasBuilderBuildOptions {\n\tforce?: boolean;\n\tscaling?: SCALE_MODES;\n\tresolution?: number;\n}\n\nexport interface UtilSvgAtlasBuilderOptions {\n\twidth?: number;\n\tratio?: number;\n\tmargin?: number;\n\tresolution?: number;\n\tscaling?: SCALE_MODES;\n\tmipmap?: MIPMAP_MODES;\n}\n\nexport class UtilSvgAtlasBuilder {\n\tprotected _width: number;\n\tprotected _ratio: number;\n\tprotected _margin: number;\n\tprotected _resolution: number;\n\tprotected _scaling: SCALE_MODES;\n\tprotected _mipmap: MIPMAP_MODES;\n\n\tprotected _frames: Record<string, Rectangle>;\n\tprotected _svg: string;\n\tprotected _nextX: number;\n\tprotected _nextY: number;\n\tprotected _height: number;\n\n\tprotected _built?: Record<string, Texture>;\n\n\tconstructor(options: UtilSvgAtlasBuilderOptions) {\n\t\tthis._width = options.width ?? 256;\n\t\tthis._ratio = options.ratio ?? 1;\n\t\tthis._margin = options.margin ?? 3;\n\t\tconst resolution = options.resolution;\n\t\tif (resolution != null) {\n\t\t\tthis._resolution = resolution;\n\t\t} else {\n\t\t\tconst dpr = window.devicePixelRatio ?? 1;\n\t\t\tthis._resolution = 2 < dpr ? dpr : dpr * 2;\n\t\t}\n\t\tthis._scaling = options.scaling ?? settings.SCALE_MODE;\n\t\tthis._mipmap = options.mipmap ?? settings.MIPMAP_TEXTURES;\n\n\t\tthis._frames = {};\n\t\tthis._svg = \"\";\n\t\tthis._nextX = 0;\n\t\tthis._nextY = 0;\n\t\tthis._height = 0;\n\t}\n\n\tget width(): number {\n\t\treturn this._width;\n\t}\n\n\tget ratio(): number {\n\t\treturn this._ratio;\n\t}\n\n\tget margin(): number {\n\t\treturn this._margin;\n\t}\n\n\tadd(name: string, width: number, height: number, path: string): boolean;\n\tadd(\n\t\tname: string,\n\t\twidth: number,\n\t\theight: number,\n\t\tpath: string,\n\t\tframeX: number,\n\t\tframeY: number,\n\t\tframeWidth: number,\n\t\tframeHeight: number\n\t): boolean;\n\tadd(\n\t\tname: string,\n\t\twidth: number,\n\t\theight: number,\n\t\tpath: string,\n\t\tframeX?: number,\n\t\tframeY?: number,\n\t\tframeWidth?: number,\n\t\tframeHeight?: number\n\t): boolean {\n\t\tconst frames = this._frames;\n\t\tif (!(name in frames)) {\n\t\t\t// Position\n\t\t\tconst margin = this._margin;\n\t\t\tlet x = this._nextX;\n\t\t\tlet y = this._nextY;\n\t\t\tif (this._width <= x + width) {\n\t\t\t\tx = 0;\n\t\t\t\ty = this._nextY + this._height + margin;\n\t\t\t\tthis._height = height;\n\t\t\t\tthis._nextY = y;\n\t\t\t} else {\n\t\t\t\tthis._height = Math.max(this._height, height);\n\t\t\t}\n\t\t\tthis._nextX = x + width + margin;\n\n\t\t\t// Frame\n\t\t\tframes[name] = new Rectangle(\n\t\t\t\tx + (frameX ?? 0),\n\t\t\t\ty + (frameY ?? 0),\n\t\t\t\tframeWidth ?? width,\n\t\t\t\tframeHeight ?? height\n\t\t\t);\n\n\t\t\t// Svg\n\t\t\tconst ratio = this._ratio;\n\t\t\tthis._svg += `<g transform=\"translate(${x * ratio},${y * ratio})\">${path}</g>`;\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\thas(name: string): boolean {\n\t\treturn name in this._frames;\n\t}\n\n\tget mappings(): Record<string, Texture> {\n\t\treturn this.build();\n\t}\n\n\tbuild(options?: UtilSvgAtlasBuilderBuildOptions): Record<string, Texture> {\n\t\tlet built = this._built;\n\t\tif (built == null || options?.force) {\n\t\t\tconst resolution = options?.resolution ?? this._resolution;\n\t\t\tconst width = this._width;\n\t\t\tconst height = Math.pow(2, Math.ceil(Math.log(this._nextY + this._height) / Math.LN2));\n\t\t\tconst realWidth = width * resolution;\n\t\t\tconst realHeight = height * resolution;\n\t\t\tconst ratio = this._ratio;\n\t\t\tconst attrWidth = `width=\"${realWidth}\"`;\n\t\t\tconst attrHeight = `height=\"${realHeight}\"`;\n\t\t\tconst attrViewBox = `viewBox=\"0 0 ${width * ratio} ${height * ratio}\"`;\n\t\t\tconst attrXmlns = `xmlns=\"http://www.w3.org/2000/svg\"`;\n\t\t\tconst url = toSvgUrl(\n\t\t\t\t`<svg ${attrWidth} ${attrHeight} ${attrViewBox} ${attrXmlns}>${this._svg}</svg>`\n\t\t\t);\n\t\t\tconst scaleMode = options?.scaling ?? this._scaling;\n\t\t\tconst baseTexture = BaseTexture.from(url, {\n\t\t\t\tresolution,\n\t\t\t\tscaleMode,\n\t\t\t\tmipmap: this._mipmap\n\t\t\t});\n\t\t\tconst frames = this._frames;\n\t\t\tbuilt = this._built = {};\n\t\t\tfor (const name in frames) {\n\t\t\t\tbuilt[name] = new Texture(baseTexture, frames[name]);\n\t\t\t}\n\t\t}\n\t\treturn built;\n\t}\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.402.0
2
+ Winter Cardinal UI v0.403.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.402.0
2
+ Winter Cardinal UI v0.403.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.402.0
2
+ Winter Cardinal UI v0.403.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.402.0
2
+ Winter Cardinal UI v0.403.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.402.0
2
+ Winter Cardinal UI v0.403.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.402.0
2
+ Winter Cardinal UI v0.403.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.402.0
2
+ Winter Cardinal UI v0.403.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.402.0
2
+ Winter Cardinal UI v0.403.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.402.0
2
+ Winter Cardinal UI v0.403.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.402.0
2
+ Winter Cardinal UI v0.403.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.402.0
2
+ Winter Cardinal UI v0.403.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.402.0
2
+ Winter Cardinal UI v0.403.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.402.0
2
+ Winter Cardinal UI v0.403.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -47171,13 +47171,20 @@ var ESnapper = /** @class */ (function (_super) {
47171
47171
  */
47172
47172
  var UtilSvgAtlasBuilder = /** @class */ (function () {
47173
47173
  function UtilSvgAtlasBuilder(options) {
47174
- var _a, _b, _c, _d, _e, _f, _g;
47174
+ var _a, _b, _c, _d, _e, _f;
47175
47175
  this._width = (_a = options.width) !== null && _a !== void 0 ? _a : 256;
47176
47176
  this._ratio = (_b = options.ratio) !== null && _b !== void 0 ? _b : 1;
47177
47177
  this._margin = (_c = options.margin) !== null && _c !== void 0 ? _c : 3;
47178
- this._resolution = (_e = (_d = options.resolution) !== null && _d !== void 0 ? _d : window.devicePixelRatio) !== null && _e !== void 0 ? _e : 1;
47179
- this._scaling = (_f = options.scaling) !== null && _f !== void 0 ? _f : pixi_js.settings.SCALE_MODE;
47180
- this._mipmap = (_g = options.mipmap) !== null && _g !== void 0 ? _g : pixi_js.settings.MIPMAP_TEXTURES;
47178
+ var resolution = options.resolution;
47179
+ if (resolution != null) {
47180
+ this._resolution = resolution;
47181
+ }
47182
+ else {
47183
+ var dpr = (_d = window.devicePixelRatio) !== null && _d !== void 0 ? _d : 1;
47184
+ this._resolution = 2 < dpr ? dpr : dpr * 2;
47185
+ }
47186
+ this._scaling = (_e = options.scaling) !== null && _e !== void 0 ? _e : pixi_js.settings.SCALE_MODE;
47187
+ this._mipmap = (_f = options.mipmap) !== null && _f !== void 0 ? _f : pixi_js.settings.MIPMAP_TEXTURES;
47181
47188
  this._frames = {};
47182
47189
  this._svg = "";
47183
47190
  this._nextX = 0;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.402.0
2
+ Winter Cardinal UI v0.403.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -47776,13 +47776,20 @@
47776
47776
  */
47777
47777
  var UtilSvgAtlasBuilder = /** @class */ (function () {
47778
47778
  function UtilSvgAtlasBuilder(options) {
47779
- var _a, _b, _c, _d, _e, _f, _g;
47779
+ var _a, _b, _c, _d, _e, _f;
47780
47780
  this._width = (_a = options.width) !== null && _a !== void 0 ? _a : 256;
47781
47781
  this._ratio = (_b = options.ratio) !== null && _b !== void 0 ? _b : 1;
47782
47782
  this._margin = (_c = options.margin) !== null && _c !== void 0 ? _c : 3;
47783
- this._resolution = (_e = (_d = options.resolution) !== null && _d !== void 0 ? _d : window.devicePixelRatio) !== null && _e !== void 0 ? _e : 1;
47784
- this._scaling = (_f = options.scaling) !== null && _f !== void 0 ? _f : pixi_js.settings.SCALE_MODE;
47785
- this._mipmap = (_g = options.mipmap) !== null && _g !== void 0 ? _g : pixi_js.settings.MIPMAP_TEXTURES;
47783
+ var resolution = options.resolution;
47784
+ if (resolution != null) {
47785
+ this._resolution = resolution;
47786
+ }
47787
+ else {
47788
+ var dpr = (_d = window.devicePixelRatio) !== null && _d !== void 0 ? _d : 1;
47789
+ this._resolution = 2 < dpr ? dpr : dpr * 2;
47790
+ }
47791
+ this._scaling = (_e = options.scaling) !== null && _e !== void 0 ? _e : pixi_js.settings.SCALE_MODE;
47792
+ this._mipmap = (_f = options.mipmap) !== null && _f !== void 0 ? _f : pixi_js.settings.MIPMAP_TEXTURES;
47786
47793
  this._frames = {};
47787
47794
  this._svg = "";
47788
47795
  this._nextX = 0;