stage-js 1.0.0 → 1.0.2
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.
- package/dist/stage.d.ts +32 -15
- package/dist/stage.js +196 -128
- package/dist/stage.js.map +1 -1
- package/dist/stage.umd.cjs +198 -130
- package/dist/stage.umd.cjs.map +1 -1
- package/package.json +13 -10
- package/src/core/component.ts +52 -10
- package/src/core/debug.ts +33 -0
- package/src/core/easing.ts +1 -1
- package/src/core/pin.ts +60 -10
- package/src/core/pointer.ts +6 -0
- package/src/core/root.ts +88 -114
package/dist/stage.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Stage.js v1.0.
|
|
2
|
+
* Stage.js v1.0.2
|
|
3
3
|
* @copyright Copyright Ali Shakiba
|
|
4
4
|
* @license Licensed under the MIT (https://github.com/piqnt/stage.js/blob/main/LICENSE.md)
|
|
5
5
|
*/
|
|
@@ -52,7 +52,7 @@ math.rotate = wrap;
|
|
|
52
52
|
math.limit = clamp;
|
|
53
53
|
var Matrix = (
|
|
54
54
|
/** @class */
|
|
55
|
-
function() {
|
|
55
|
+
(function() {
|
|
56
56
|
function Matrix2(a, b, c, d, e, f) {
|
|
57
57
|
this.a = 1;
|
|
58
58
|
this.b = 0;
|
|
@@ -216,7 +216,7 @@ var Matrix = (
|
|
|
216
216
|
return this.b * x + this.d * y + this.f;
|
|
217
217
|
};
|
|
218
218
|
return Matrix2;
|
|
219
|
-
}()
|
|
219
|
+
})()
|
|
220
220
|
);
|
|
221
221
|
/*! *****************************************************************************
|
|
222
222
|
Copyright (c) Microsoft Corporation.
|
|
@@ -373,7 +373,7 @@ var uid = function() {
|
|
|
373
373
|
};
|
|
374
374
|
var Texture = (
|
|
375
375
|
/** @class */
|
|
376
|
-
function() {
|
|
376
|
+
(function() {
|
|
377
377
|
function Texture2() {
|
|
378
378
|
this.uid = "texture:" + uid();
|
|
379
379
|
this.sx = 0;
|
|
@@ -431,11 +431,11 @@ var Texture = (
|
|
|
431
431
|
this.drawWithNormalizedArgs(context, sx, sy, sw, sh, dx, dy, dw, dh);
|
|
432
432
|
};
|
|
433
433
|
return Texture2;
|
|
434
|
-
}()
|
|
434
|
+
})()
|
|
435
435
|
);
|
|
436
436
|
var ImageTexture = (
|
|
437
437
|
/** @class */
|
|
438
|
-
function(_super) {
|
|
438
|
+
(function(_super) {
|
|
439
439
|
__extends(ImageTexture2, _super);
|
|
440
440
|
function ImageTexture2(source, pixelRatio) {
|
|
441
441
|
var _this = _super.call(this) || this;
|
|
@@ -492,11 +492,11 @@ var ImageTexture = (
|
|
|
492
492
|
}
|
|
493
493
|
};
|
|
494
494
|
return ImageTexture2;
|
|
495
|
-
}(Texture)
|
|
495
|
+
})(Texture)
|
|
496
496
|
);
|
|
497
497
|
var PipeTexture = (
|
|
498
498
|
/** @class */
|
|
499
|
-
function(_super) {
|
|
499
|
+
(function(_super) {
|
|
500
500
|
__extends(PipeTexture2, _super);
|
|
501
501
|
function PipeTexture2(source) {
|
|
502
502
|
var _this = _super.call(this) || this;
|
|
@@ -525,11 +525,11 @@ var PipeTexture = (
|
|
|
525
525
|
texture2.draw(context, sx, sy, sw, sh, dx, dy, dw, dh);
|
|
526
526
|
};
|
|
527
527
|
return PipeTexture2;
|
|
528
|
-
}(Texture)
|
|
528
|
+
})(Texture)
|
|
529
529
|
);
|
|
530
530
|
var Atlas = (
|
|
531
531
|
/** @class */
|
|
532
|
-
function(_super) {
|
|
532
|
+
(function(_super) {
|
|
533
533
|
__extends(Atlas2, _super);
|
|
534
534
|
function Atlas2(def) {
|
|
535
535
|
if (def === void 0) {
|
|
@@ -644,7 +644,7 @@ var Atlas = (
|
|
|
644
644
|
});
|
|
645
645
|
};
|
|
646
646
|
return Atlas2;
|
|
647
|
-
}(ImageTexture)
|
|
647
|
+
})(ImageTexture)
|
|
648
648
|
);
|
|
649
649
|
function asyncLoadImage(src) {
|
|
650
650
|
console.debug && console.debug("Loading image: " + src);
|
|
@@ -684,7 +684,7 @@ function isAtlasSpriteDefinition(selection) {
|
|
|
684
684
|
}
|
|
685
685
|
var TextureSelection = (
|
|
686
686
|
/** @class */
|
|
687
|
-
function() {
|
|
687
|
+
(function() {
|
|
688
688
|
function TextureSelection2(selection, atlas2) {
|
|
689
689
|
this.selection = selection;
|
|
690
690
|
this.atlas = atlas2;
|
|
@@ -727,10 +727,10 @@ var TextureSelection = (
|
|
|
727
727
|
return array;
|
|
728
728
|
};
|
|
729
729
|
return TextureSelection2;
|
|
730
|
-
}()
|
|
730
|
+
})()
|
|
731
731
|
);
|
|
732
732
|
var NO_TEXTURE = new /** @class */
|
|
733
|
-
(function(_super) {
|
|
733
|
+
((function(_super) {
|
|
734
734
|
__extends(class_1, _super);
|
|
735
735
|
function class_1() {
|
|
736
736
|
var _this = _super.call(this) || this;
|
|
@@ -759,7 +759,7 @@ var NO_TEXTURE = new /** @class */
|
|
|
759
759
|
class_1.prototype.draw = function() {
|
|
760
760
|
};
|
|
761
761
|
return class_1;
|
|
762
|
-
}(Texture))();
|
|
762
|
+
})(Texture))();
|
|
763
763
|
var NO_SELECTION = new TextureSelection(NO_TEXTURE);
|
|
764
764
|
var ATLAS_MEMO_BY_NAME = {};
|
|
765
765
|
var ATLAS_ARRAY = [];
|
|
@@ -839,7 +839,7 @@ function texture(query) {
|
|
|
839
839
|
}
|
|
840
840
|
var ResizableTexture = (
|
|
841
841
|
/** @class */
|
|
842
|
-
function(_super) {
|
|
842
|
+
(function(_super) {
|
|
843
843
|
__extends(ResizableTexture2, _super);
|
|
844
844
|
function ResizableTexture2(source, mode) {
|
|
845
845
|
var _this = _super.call(this) || this;
|
|
@@ -936,7 +936,7 @@ var ResizableTexture = (
|
|
|
936
936
|
}
|
|
937
937
|
};
|
|
938
938
|
return ResizableTexture2;
|
|
939
|
-
}(Texture)
|
|
939
|
+
})(Texture)
|
|
940
940
|
);
|
|
941
941
|
function getDevicePixelRatio() {
|
|
942
942
|
return typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
@@ -945,9 +945,12 @@ function isValidFitMode(value) {
|
|
|
945
945
|
return value && (value === "cover" || value === "contain" || value === "fill" || value === "in" || value === "in-pad" || value === "out" || value === "out-crop");
|
|
946
946
|
}
|
|
947
947
|
var iid$1 = 0;
|
|
948
|
+
function getIID() {
|
|
949
|
+
return iid$1++;
|
|
950
|
+
}
|
|
948
951
|
var Pin = (
|
|
949
952
|
/** @class */
|
|
950
|
-
function() {
|
|
953
|
+
(function() {
|
|
951
954
|
function Pin2(owner) {
|
|
952
955
|
this.uid = "pin:" + uid();
|
|
953
956
|
this._directionX = 1;
|
|
@@ -1012,6 +1015,7 @@ var Pin = (
|
|
|
1012
1015
|
var abs = this._absoluteMatrix;
|
|
1013
1016
|
abs.reset(this.relativeMatrix());
|
|
1014
1017
|
this._parent && abs.concat(this._parent._absoluteMatrix);
|
|
1018
|
+
this._owner._xf && abs.concat(this._owner._xf);
|
|
1015
1019
|
this._ts_matrix = ++iid$1;
|
|
1016
1020
|
return abs;
|
|
1017
1021
|
};
|
|
@@ -1135,8 +1139,39 @@ var Pin = (
|
|
|
1135
1139
|
}
|
|
1136
1140
|
};
|
|
1137
1141
|
return Pin2;
|
|
1138
|
-
}()
|
|
1142
|
+
})()
|
|
1139
1143
|
);
|
|
1144
|
+
function fit(inWidth, inHeight, outWidth, outHeight, mode) {
|
|
1145
|
+
if (mode === "contain")
|
|
1146
|
+
mode = "in-pad";
|
|
1147
|
+
if (mode === "cover")
|
|
1148
|
+
mode = "out-crop";
|
|
1149
|
+
var scaleX;
|
|
1150
|
+
var scaleY;
|
|
1151
|
+
var width;
|
|
1152
|
+
var height;
|
|
1153
|
+
if (typeof outWidth === "number") {
|
|
1154
|
+
scaleX = outWidth / inWidth;
|
|
1155
|
+
width = inWidth;
|
|
1156
|
+
}
|
|
1157
|
+
if (typeof outHeight === "number") {
|
|
1158
|
+
scaleY = outHeight / inHeight;
|
|
1159
|
+
height = inHeight;
|
|
1160
|
+
}
|
|
1161
|
+
if (typeof outWidth === "number" && typeof outHeight === "number" && typeof mode === "string") {
|
|
1162
|
+
if (mode === "fill") ;
|
|
1163
|
+
else if (mode === "out" || mode === "out-crop") {
|
|
1164
|
+
scaleX = scaleY = Math.max(scaleX, scaleY);
|
|
1165
|
+
} else if (mode === "in" || mode === "in-pad") {
|
|
1166
|
+
scaleX = scaleY = Math.min(scaleX, scaleY);
|
|
1167
|
+
}
|
|
1168
|
+
if (mode === "out-crop" || mode === "in-pad") {
|
|
1169
|
+
width = outWidth / scaleX;
|
|
1170
|
+
height = outHeight / scaleY;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
return { scaleX, scaleY, width, height };
|
|
1174
|
+
}
|
|
1140
1175
|
var getters = {
|
|
1141
1176
|
alpha: function(pin) {
|
|
1142
1177
|
return pin._alpha;
|
|
@@ -1364,7 +1399,7 @@ var IDENTITY = function(x) {
|
|
|
1364
1399
|
};
|
|
1365
1400
|
var Easing = (
|
|
1366
1401
|
/** @class */
|
|
1367
|
-
function() {
|
|
1402
|
+
(function() {
|
|
1368
1403
|
function Easing2() {
|
|
1369
1404
|
}
|
|
1370
1405
|
Easing2.init = function(query, params) {
|
|
@@ -1386,7 +1421,7 @@ var Easing = (
|
|
|
1386
1421
|
return easing;
|
|
1387
1422
|
};
|
|
1388
1423
|
return Easing2;
|
|
1389
|
-
}()
|
|
1424
|
+
})()
|
|
1390
1425
|
);
|
|
1391
1426
|
var initEasing = function(query, params) {
|
|
1392
1427
|
var easing;
|
|
@@ -1446,6 +1481,9 @@ var bounce = function(t) {
|
|
|
1446
1481
|
return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + 0.75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + 0.9375 : 7.5625 * (t -= 2.625 / 2.75) * t + 0.984375;
|
|
1447
1482
|
};
|
|
1448
1483
|
var poly = function(e) {
|
|
1484
|
+
if (e === void 0) {
|
|
1485
|
+
e = 3;
|
|
1486
|
+
}
|
|
1449
1487
|
return function(t) {
|
|
1450
1488
|
return Math.pow(t, e);
|
|
1451
1489
|
};
|
|
@@ -1569,7 +1607,7 @@ var EasingFactories = {
|
|
|
1569
1607
|
};
|
|
1570
1608
|
var Transition = (
|
|
1571
1609
|
/** @class */
|
|
1572
|
-
function() {
|
|
1610
|
+
(function() {
|
|
1573
1611
|
function Transition2(owner, options) {
|
|
1574
1612
|
if (options === void 0) {
|
|
1575
1613
|
options = {};
|
|
@@ -1739,7 +1777,7 @@ var Transition = (
|
|
|
1739
1777
|
return this;
|
|
1740
1778
|
};
|
|
1741
1779
|
return Transition2;
|
|
1742
|
-
}()
|
|
1780
|
+
})()
|
|
1743
1781
|
);
|
|
1744
1782
|
function pinning(component2, map, key, value) {
|
|
1745
1783
|
if (typeof component2._pin.get(key) === "number") {
|
|
@@ -1749,6 +1787,37 @@ function pinning(component2, map, key, value) {
|
|
|
1749
1787
|
map[key + "Y"] = value;
|
|
1750
1788
|
}
|
|
1751
1789
|
}
|
|
1790
|
+
function renderAxis(ctx, size) {
|
|
1791
|
+
ctx.strokeStyle = "rgba(93, 173, 226)";
|
|
1792
|
+
ctx.beginPath();
|
|
1793
|
+
ctx.moveTo(0, 0);
|
|
1794
|
+
ctx.lineTo(0, 0.8 * size);
|
|
1795
|
+
ctx.lineTo(-0.2 * size, 0.8 * size);
|
|
1796
|
+
ctx.lineTo(0, size);
|
|
1797
|
+
ctx.lineTo(0.2 * size, 0.8 * size);
|
|
1798
|
+
ctx.lineTo(0, 0.8 * size);
|
|
1799
|
+
ctx.stroke();
|
|
1800
|
+
ctx.strokeStyle = "rgba(236, 112, 99)";
|
|
1801
|
+
ctx.beginPath();
|
|
1802
|
+
ctx.moveTo(0, 0);
|
|
1803
|
+
ctx.lineTo(0.8 * size, 0);
|
|
1804
|
+
ctx.lineTo(0.8 * size, -0.2 * size);
|
|
1805
|
+
ctx.lineTo(size, 0);
|
|
1806
|
+
ctx.lineTo(0.8 * size, 0.2 * size);
|
|
1807
|
+
ctx.lineTo(0.8 * size, 0);
|
|
1808
|
+
ctx.stroke();
|
|
1809
|
+
}
|
|
1810
|
+
function renderPoint(ctx, px, py) {
|
|
1811
|
+
ctx.beginPath();
|
|
1812
|
+
ctx.beginPath();
|
|
1813
|
+
ctx.moveTo(px - 0.2, py - 0.2);
|
|
1814
|
+
ctx.lineTo(px + 0.2, py + 0.2);
|
|
1815
|
+
ctx.stroke();
|
|
1816
|
+
ctx.beginPath();
|
|
1817
|
+
ctx.moveTo(px - 0.2, py + 0.2);
|
|
1818
|
+
ctx.lineTo(px + 0.2, py - 0.2);
|
|
1819
|
+
ctx.stroke();
|
|
1820
|
+
}
|
|
1752
1821
|
var iid = 0;
|
|
1753
1822
|
stats.create = 0;
|
|
1754
1823
|
function assertType(obj) {
|
|
@@ -1786,7 +1855,7 @@ function maximize() {
|
|
|
1786
1855
|
}
|
|
1787
1856
|
var Component = (
|
|
1788
1857
|
/** @class */
|
|
1789
|
-
function() {
|
|
1858
|
+
(function() {
|
|
1790
1859
|
function Component2() {
|
|
1791
1860
|
var _this = this;
|
|
1792
1861
|
this.uid = "component:" + uid();
|
|
@@ -1848,15 +1917,14 @@ var Component = (
|
|
|
1848
1917
|
return this._pin.absoluteMatrix();
|
|
1849
1918
|
};
|
|
1850
1919
|
Component2.prototype.getPixelRatio = function() {
|
|
1851
|
-
|
|
1852
|
-
var m = (_a = this._parent) === null || _a === void 0 ? void 0 : _a.matrix();
|
|
1853
|
-
var pixelRatio = !m ? 1 : Math.max(Math.abs(m.a), Math.abs(m.b)) / getDevicePixelRatio();
|
|
1854
|
-
return pixelRatio;
|
|
1920
|
+
return this.getLogicalPixelRatio();
|
|
1855
1921
|
};
|
|
1856
1922
|
Component2.prototype.getDevicePixelRatio = function() {
|
|
1857
1923
|
var _a;
|
|
1858
1924
|
var parentMatrix = (_a = this._parent) === null || _a === void 0 ? void 0 : _a.matrix();
|
|
1859
|
-
|
|
1925
|
+
if (!parentMatrix)
|
|
1926
|
+
return 1;
|
|
1927
|
+
var pixelRatio = Math.max(Math.abs(parentMatrix.a), Math.abs(parentMatrix.b));
|
|
1860
1928
|
return pixelRatio;
|
|
1861
1929
|
};
|
|
1862
1930
|
Component2.prototype.getLogicalPixelRatio = function() {
|
|
@@ -2228,6 +2296,7 @@ var Component = (
|
|
|
2228
2296
|
}
|
|
2229
2297
|
stats.component++;
|
|
2230
2298
|
var m = this.matrix();
|
|
2299
|
+
this.renderDebug(context, m);
|
|
2231
2300
|
context.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
|
|
2232
2301
|
this._alpha = this._pin._alpha * (this._parent ? this._parent._alpha : 1);
|
|
2233
2302
|
var alpha = this._pin._textureAlpha * this._alpha;
|
|
@@ -2618,8 +2687,30 @@ var Component = (
|
|
|
2618
2687
|
this._spacing = space;
|
|
2619
2688
|
return this;
|
|
2620
2689
|
};
|
|
2690
|
+
Component2.prototype.renderDebug = function(ctx, xf) {
|
|
2691
|
+
if (!this._debug)
|
|
2692
|
+
return;
|
|
2693
|
+
var ppu = this.getLogicalPixelRatio();
|
|
2694
|
+
ctx.lineWidth = 1 / ppu;
|
|
2695
|
+
ctx.lineCap = "round";
|
|
2696
|
+
ctx.lineJoin = "round";
|
|
2697
|
+
renderAxis(ctx, 1);
|
|
2698
|
+
var pin = this._pin;
|
|
2699
|
+
if (pin._pivoted) {
|
|
2700
|
+
ctx.strokeStyle = "orange";
|
|
2701
|
+
renderPoint(ctx, pin._pivotX * pin._width, pin._pivotY * pin._height);
|
|
2702
|
+
}
|
|
2703
|
+
if (pin._aligned) {
|
|
2704
|
+
ctx.strokeStyle = "green";
|
|
2705
|
+
renderPoint(ctx, pin._alignX * pin._width, pin._alignY * pin._height);
|
|
2706
|
+
}
|
|
2707
|
+
if (pin._handled) {
|
|
2708
|
+
ctx.strokeStyle = "yellow";
|
|
2709
|
+
renderPoint(ctx, pin._handleX * pin._width, pin._handleY * pin._height);
|
|
2710
|
+
}
|
|
2711
|
+
};
|
|
2621
2712
|
return Component2;
|
|
2622
|
-
}()
|
|
2713
|
+
})()
|
|
2623
2714
|
);
|
|
2624
2715
|
function sprite(frame) {
|
|
2625
2716
|
var sprite2 = new Sprite();
|
|
@@ -2628,7 +2719,7 @@ function sprite(frame) {
|
|
|
2628
2719
|
}
|
|
2629
2720
|
var Sprite = (
|
|
2630
2721
|
/** @class */
|
|
2631
|
-
function(_super) {
|
|
2722
|
+
(function(_super) {
|
|
2632
2723
|
__extends(Sprite2, _super);
|
|
2633
2724
|
function Sprite2() {
|
|
2634
2725
|
var _this = _super.call(this) || this;
|
|
@@ -2696,11 +2787,11 @@ var Sprite = (
|
|
|
2696
2787
|
this._texture.draw(context);
|
|
2697
2788
|
};
|
|
2698
2789
|
return Sprite2;
|
|
2699
|
-
}(Component)
|
|
2790
|
+
})(Component)
|
|
2700
2791
|
);
|
|
2701
2792
|
var CanvasTexture = (
|
|
2702
2793
|
/** @class */
|
|
2703
|
-
function(_super) {
|
|
2794
|
+
(function(_super) {
|
|
2704
2795
|
__extends(CanvasTexture2, _super);
|
|
2705
2796
|
function CanvasTexture2() {
|
|
2706
2797
|
var _this = _super.call(this, document.createElement("canvas")) || this;
|
|
@@ -2773,7 +2864,7 @@ var CanvasTexture = (
|
|
|
2773
2864
|
return this;
|
|
2774
2865
|
};
|
|
2775
2866
|
return CanvasTexture2;
|
|
2776
|
-
}(ImageTexture)
|
|
2867
|
+
})(ImageTexture)
|
|
2777
2868
|
);
|
|
2778
2869
|
function canvas(type, attributes, legacyTextureDrawer) {
|
|
2779
2870
|
if (typeof type === "function") {
|
|
@@ -2825,7 +2916,7 @@ var POINTER_START = "touchstart mousedown";
|
|
|
2825
2916
|
var POINTER_END = "touchend mouseup";
|
|
2826
2917
|
var EventPoint = (
|
|
2827
2918
|
/** @class */
|
|
2828
|
-
function() {
|
|
2919
|
+
(function() {
|
|
2829
2920
|
function EventPoint2() {
|
|
2830
2921
|
}
|
|
2831
2922
|
EventPoint2.prototype.clone = function(obj) {
|
|
@@ -2844,11 +2935,11 @@ var EventPoint = (
|
|
|
2844
2935
|
return (this.x | 0) + "x" + (this.y | 0);
|
|
2845
2936
|
};
|
|
2846
2937
|
return EventPoint2;
|
|
2847
|
-
}()
|
|
2938
|
+
})()
|
|
2848
2939
|
);
|
|
2849
2940
|
var PointerSyntheticEvent = (
|
|
2850
2941
|
/** @class */
|
|
2851
|
-
function() {
|
|
2942
|
+
(function() {
|
|
2852
2943
|
function PointerSyntheticEvent2() {
|
|
2853
2944
|
this.abs = new EventPoint();
|
|
2854
2945
|
}
|
|
@@ -2868,11 +2959,11 @@ var PointerSyntheticEvent = (
|
|
|
2868
2959
|
return this.type + ": " + (this.x | 0) + "x" + (this.y | 0);
|
|
2869
2960
|
};
|
|
2870
2961
|
return PointerSyntheticEvent2;
|
|
2871
|
-
}()
|
|
2962
|
+
})()
|
|
2872
2963
|
);
|
|
2873
2964
|
var VisitPayload = (
|
|
2874
2965
|
/** @class */
|
|
2875
|
-
function() {
|
|
2966
|
+
(function() {
|
|
2876
2967
|
function VisitPayload2() {
|
|
2877
2968
|
this.type = "";
|
|
2878
2969
|
this.x = 0;
|
|
@@ -2886,13 +2977,13 @@ var VisitPayload = (
|
|
|
2886
2977
|
return this.type + ": " + (this.x | 0) + "x" + (this.y | 0);
|
|
2887
2978
|
};
|
|
2888
2979
|
return VisitPayload2;
|
|
2889
|
-
}()
|
|
2980
|
+
})()
|
|
2890
2981
|
);
|
|
2891
2982
|
var syntheticEvent = new PointerSyntheticEvent();
|
|
2892
2983
|
var PAYLOAD = new VisitPayload();
|
|
2893
2984
|
var Pointer = (
|
|
2894
2985
|
/** @class */
|
|
2895
|
-
function() {
|
|
2986
|
+
(function() {
|
|
2896
2987
|
function Pointer2() {
|
|
2897
2988
|
var _this = this;
|
|
2898
2989
|
this.ratio = 1;
|
|
@@ -3056,7 +3147,7 @@ var Pointer = (
|
|
|
3056
3147
|
};
|
|
3057
3148
|
Pointer2.DEBUG = false;
|
|
3058
3149
|
return Pointer2;
|
|
3059
|
-
}()
|
|
3150
|
+
})()
|
|
3060
3151
|
);
|
|
3061
3152
|
var Mouse = {
|
|
3062
3153
|
CLICK: "click",
|
|
@@ -3088,18 +3179,18 @@ function mount(configs) {
|
|
|
3088
3179
|
var DEFAULT_CANVAS_MOUNTED = false;
|
|
3089
3180
|
var Root = (
|
|
3090
3181
|
/** @class */
|
|
3091
|
-
function(_super) {
|
|
3182
|
+
(function(_super) {
|
|
3092
3183
|
__extends(Root2, _super);
|
|
3093
3184
|
function Root2() {
|
|
3094
3185
|
var _this = _super.call(this) || this;
|
|
3095
3186
|
_this.canvas = null;
|
|
3096
3187
|
_this.dom = null;
|
|
3097
3188
|
_this.context = null;
|
|
3098
|
-
_this.
|
|
3099
|
-
_this.
|
|
3189
|
+
_this.clientWidth = -1;
|
|
3190
|
+
_this.clientHeight = -1;
|
|
3100
3191
|
_this.pixelRatio = 1;
|
|
3101
|
-
_this.
|
|
3102
|
-
_this.
|
|
3192
|
+
_this.canvasWidth = 0;
|
|
3193
|
+
_this.canvasHeight = 0;
|
|
3103
3194
|
_this.mounted = false;
|
|
3104
3195
|
_this.paused = false;
|
|
3105
3196
|
_this.sleep = false;
|
|
@@ -3168,24 +3259,7 @@ var Root = (
|
|
|
3168
3259
|
return;
|
|
3169
3260
|
}
|
|
3170
3261
|
_this.requestFrame();
|
|
3171
|
-
|
|
3172
|
-
var newPixelHeight = _this.canvas.clientHeight;
|
|
3173
|
-
if (_this.pixelWidth !== newPixelWidth || _this.pixelHeight !== newPixelHeight) {
|
|
3174
|
-
_this.pixelWidth = newPixelWidth;
|
|
3175
|
-
_this.pixelHeight = newPixelHeight;
|
|
3176
|
-
_this.drawingWidth = newPixelWidth * _this.pixelRatio;
|
|
3177
|
-
_this.drawingHeight = newPixelHeight * _this.pixelRatio;
|
|
3178
|
-
if (_this.canvas.width !== _this.drawingWidth || _this.canvas.height !== _this.drawingHeight) {
|
|
3179
|
-
_this.canvas.width = _this.drawingWidth;
|
|
3180
|
-
_this.canvas.height = _this.drawingHeight;
|
|
3181
|
-
console.debug && console.debug("Resize: [" + _this.drawingWidth + ", " + _this.drawingHeight + "] = " + _this.pixelRatio + " x [" + _this.pixelWidth + ", " + _this.pixelHeight + "]");
|
|
3182
|
-
_this.viewport({
|
|
3183
|
-
width: _this.drawingWidth,
|
|
3184
|
-
height: _this.drawingHeight,
|
|
3185
|
-
ratio: _this.pixelRatio
|
|
3186
|
-
});
|
|
3187
|
-
}
|
|
3188
|
-
}
|
|
3262
|
+
_this.resizeCanvas();
|
|
3189
3263
|
var last = _this._lastFrameTime || now;
|
|
3190
3264
|
var elapsed = now - last;
|
|
3191
3265
|
if (!_this.mounted || _this.paused || _this.sleep) {
|
|
@@ -3197,12 +3271,9 @@ var Root = (
|
|
|
3197
3271
|
if (_this._mo_touch != _this._ts_touch) {
|
|
3198
3272
|
_this._mo_touch = _this._ts_touch;
|
|
3199
3273
|
_this.sleep = false;
|
|
3200
|
-
if (_this.
|
|
3274
|
+
if (_this.canvasWidth > 0 && _this.canvasHeight > 0) {
|
|
3201
3275
|
_this.context.setTransform(1, 0, 0, 1, 0, 0);
|
|
3202
|
-
_this.context.clearRect(0, 0, _this.
|
|
3203
|
-
if (_this.debugDrawAxis > 0) {
|
|
3204
|
-
_this.renderDebug(_this.context);
|
|
3205
|
-
}
|
|
3276
|
+
_this.context.clearRect(0, 0, _this.canvasWidth, _this.canvasHeight);
|
|
3206
3277
|
_this.render(_this.context);
|
|
3207
3278
|
}
|
|
3208
3279
|
} else if (tickRequest) {
|
|
@@ -3212,39 +3283,44 @@ var Root = (
|
|
|
3212
3283
|
}
|
|
3213
3284
|
stats.fps = elapsed ? 1e3 / elapsed : 0;
|
|
3214
3285
|
};
|
|
3215
|
-
_this.debugDrawAxis = 0;
|
|
3216
3286
|
_this.label("Root");
|
|
3217
3287
|
return _this;
|
|
3218
3288
|
}
|
|
3219
|
-
Root2.prototype.
|
|
3220
|
-
var
|
|
3221
|
-
var
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3289
|
+
Root2.prototype.resizeCanvas = function() {
|
|
3290
|
+
var newClientWidth = this.canvas.clientWidth;
|
|
3291
|
+
var newClientHeight = this.canvas.clientHeight;
|
|
3292
|
+
if (this.clientWidth === newClientWidth && this.clientHeight === newClientHeight)
|
|
3293
|
+
return;
|
|
3294
|
+
this.clientWidth = newClientWidth;
|
|
3295
|
+
this.clientHeight = newClientHeight;
|
|
3296
|
+
var notStyled = this.canvas.clientWidth === this.canvas.width && this.canvas.clientHeight === this.canvas.height;
|
|
3297
|
+
var pixelRatio;
|
|
3298
|
+
if (notStyled) {
|
|
3299
|
+
pixelRatio = 1;
|
|
3300
|
+
this.canvasWidth = this.canvas.width;
|
|
3301
|
+
this.canvasHeight = this.canvas.height;
|
|
3302
|
+
} else {
|
|
3303
|
+
pixelRatio = this.pixelRatio;
|
|
3304
|
+
this.canvasWidth = this.clientWidth * pixelRatio;
|
|
3305
|
+
this.canvasHeight = this.clientHeight * pixelRatio;
|
|
3306
|
+
if (this.canvas.width !== this.canvasWidth || this.canvas.height !== this.canvasHeight) {
|
|
3307
|
+
this.canvas.width = this.canvasWidth;
|
|
3308
|
+
this.canvas.height = this.canvasHeight;
|
|
3309
|
+
}
|
|
3310
|
+
}
|
|
3311
|
+
console.debug && console.debug("Resize: [" + this.canvasWidth + ", " + this.canvasHeight + "] = " + pixelRatio + " x [" + this.clientWidth + ", " + this.clientHeight + "]");
|
|
3312
|
+
this.viewport({
|
|
3313
|
+
width: this.canvasWidth,
|
|
3314
|
+
height: this.canvasHeight,
|
|
3315
|
+
ratio: pixelRatio
|
|
3316
|
+
});
|
|
3317
|
+
};
|
|
3318
|
+
Root2.prototype.renderDebug = function(ctx, m) {
|
|
3319
|
+
if (!this._debug)
|
|
3320
|
+
return;
|
|
3321
|
+
ctx.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
|
|
3322
|
+
ctx.lineWidth = 3 / m.a;
|
|
3323
|
+
renderAxis(ctx, 10);
|
|
3248
3324
|
};
|
|
3249
3325
|
Root2.prototype.resume = function() {
|
|
3250
3326
|
if (this.sleep || this.paused) {
|
|
@@ -3301,7 +3377,7 @@ var Root = (
|
|
|
3301
3377
|
height,
|
|
3302
3378
|
ratio: typeof ratio === "number" ? ratio : 1
|
|
3303
3379
|
};
|
|
3304
|
-
this.
|
|
3380
|
+
this.rescale();
|
|
3305
3381
|
var data_1 = Object.assign({}, this._viewport);
|
|
3306
3382
|
this.visit({
|
|
3307
3383
|
start: function(component2) {
|
|
@@ -3328,37 +3404,25 @@ var Root = (
|
|
|
3328
3404
|
return this;
|
|
3329
3405
|
};
|
|
3330
3406
|
Root2.prototype.camera = function(matrix) {
|
|
3331
|
-
this.
|
|
3332
|
-
this.
|
|
3407
|
+
this._xf = matrix.clone();
|
|
3408
|
+
this._pin._ts_transform = getIID();
|
|
3409
|
+
this.touch();
|
|
3333
3410
|
return this;
|
|
3334
3411
|
};
|
|
3335
3412
|
Root2.prototype.rescale = function() {
|
|
3336
3413
|
var viewbox = this._viewbox;
|
|
3337
3414
|
var viewport = this._viewport;
|
|
3338
|
-
var camera = this._camera;
|
|
3339
3415
|
if (viewport && viewbox) {
|
|
3340
|
-
var viewportWidth = viewport.width;
|
|
3341
|
-
var viewportHeight = viewport.height;
|
|
3342
3416
|
var viewboxMode = isValidFitMode(viewbox.mode) ? viewbox.mode : "in-pad";
|
|
3343
|
-
var
|
|
3344
|
-
var viewboxHeight = viewbox.height;
|
|
3417
|
+
var fitted = fit(viewbox.width, viewbox.height, viewport.width, viewport.height, viewboxMode);
|
|
3345
3418
|
this.pin({
|
|
3346
|
-
width:
|
|
3347
|
-
height:
|
|
3419
|
+
width: fitted.width,
|
|
3420
|
+
height: fitted.height,
|
|
3421
|
+
scaleX: fitted.scaleX,
|
|
3422
|
+
scaleY: fitted.scaleY,
|
|
3423
|
+
offsetX: -(viewbox.x || 0) * fitted.scaleX,
|
|
3424
|
+
offsetY: -(viewbox.y || 0) * fitted.scaleY
|
|
3348
3425
|
});
|
|
3349
|
-
this.fit(viewportWidth, viewportHeight, viewboxMode);
|
|
3350
|
-
var viewboxX = viewbox.x || 0;
|
|
3351
|
-
var viewboxY = viewbox.y || 0;
|
|
3352
|
-
var cameraZoomX = (camera === null || camera === void 0 ? void 0 : camera.a) || 1;
|
|
3353
|
-
var cameraZoomY = (camera === null || camera === void 0 ? void 0 : camera.d) || 1;
|
|
3354
|
-
var cameraX = (camera === null || camera === void 0 ? void 0 : camera.e) || 0;
|
|
3355
|
-
var cameraY = (camera === null || camera === void 0 ? void 0 : camera.f) || 0;
|
|
3356
|
-
var scaleX = this.pin("scaleX");
|
|
3357
|
-
var scaleY = this.pin("scaleY");
|
|
3358
|
-
this.pin("scaleX", scaleX * cameraZoomX);
|
|
3359
|
-
this.pin("scaleY", scaleY * cameraZoomY);
|
|
3360
|
-
this.pin("offsetX", cameraX - viewboxX * scaleX * cameraZoomX);
|
|
3361
|
-
this.pin("offsetY", cameraY - viewboxY * scaleY * cameraZoomY);
|
|
3362
3426
|
} else if (viewport) {
|
|
3363
3427
|
this.pin({
|
|
3364
3428
|
width: viewport.width,
|
|
@@ -3376,7 +3440,7 @@ var Root = (
|
|
|
3376
3440
|
return this;
|
|
3377
3441
|
};
|
|
3378
3442
|
return Root2;
|
|
3379
|
-
}(Component)
|
|
3443
|
+
})(Component)
|
|
3380
3444
|
);
|
|
3381
3445
|
function anim(frames, fps) {
|
|
3382
3446
|
var anim2 = new Anim();
|
|
@@ -3387,7 +3451,7 @@ function anim(frames, fps) {
|
|
|
3387
3451
|
var FPS = 15;
|
|
3388
3452
|
var Anim = (
|
|
3389
3453
|
/** @class */
|
|
3390
|
-
function(_super) {
|
|
3454
|
+
(function(_super) {
|
|
3391
3455
|
__extends(Anim2, _super);
|
|
3392
3456
|
function Anim2() {
|
|
3393
3457
|
var _this = _super.call(this) || this;
|
|
@@ -3492,14 +3556,14 @@ var Anim = (
|
|
|
3492
3556
|
return this;
|
|
3493
3557
|
};
|
|
3494
3558
|
return Anim2;
|
|
3495
|
-
}(Component)
|
|
3559
|
+
})(Component)
|
|
3496
3560
|
);
|
|
3497
3561
|
function monotype(chars) {
|
|
3498
3562
|
return new Monotype().frames(chars);
|
|
3499
3563
|
}
|
|
3500
3564
|
var Monotype = (
|
|
3501
3565
|
/** @class */
|
|
3502
|
-
function(_super) {
|
|
3566
|
+
(function(_super) {
|
|
3503
3567
|
__extends(Monotype2, _super);
|
|
3504
3568
|
function Monotype2() {
|
|
3505
3569
|
var _this = _super.call(this) || this;
|
|
@@ -3566,7 +3630,7 @@ var Monotype = (
|
|
|
3566
3630
|
return this;
|
|
3567
3631
|
};
|
|
3568
3632
|
return Monotype2;
|
|
3569
|
-
}(Component)
|
|
3633
|
+
})(Component)
|
|
3570
3634
|
);
|
|
3571
3635
|
const Stage = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3572
3636
|
__proto__: null,
|
|
@@ -3606,6 +3670,8 @@ const Stage = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
|
|
|
3606
3670
|
column,
|
|
3607
3671
|
component,
|
|
3608
3672
|
create,
|
|
3673
|
+
fit,
|
|
3674
|
+
getIID,
|
|
3609
3675
|
image: sprite,
|
|
3610
3676
|
isValidFitMode,
|
|
3611
3677
|
layer,
|
|
@@ -3665,6 +3731,8 @@ export {
|
|
|
3665
3731
|
component,
|
|
3666
3732
|
create,
|
|
3667
3733
|
Stage as default,
|
|
3734
|
+
fit,
|
|
3735
|
+
getIID,
|
|
3668
3736
|
sprite as image,
|
|
3669
3737
|
isValidFitMode,
|
|
3670
3738
|
layer,
|