@realsee/dnalogel 2.1.0-alpha.20 → 2.1.0-alpha.22
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/components/index.js +569 -242
- package/dist/index.es.js +8980 -8566
- package/dist/index.js +8980 -8566
- package/docs/assets/search.js +1 -1
- package/docs/classes/CruisePluginController.html +1 -1
- package/docs/classes/Magnifier.html +1 -1
- package/docs/classes/ModelRoomLabelController.html +1 -1
- package/docs/classes/Object3DHelperController.html +1 -1
- package/docs/classes/PaintBrush.html +1 -1
- package/docs/classes/PanoTagPluginController.html +3 -3
- package/docs/enums/CameraMovementEffect.html +1 -1
- package/docs/enums/ContentType.html +1 -1
- package/docs/enums/DIRECTION.html +1 -1
- package/docs/enums/DISPLAY_STRATEGY_TYPE.html +1 -1
- package/docs/enums/DimensionType.html +1 -1
- package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
- package/docs/enums/ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.html +1 -1
- package/docs/enums/LinkType.html +1 -1
- package/docs/enums/PaintBrushTypeEnum.html +1 -1
- package/docs/enums/PointType.html +1 -1
- package/docs/enums/Rotation.html +1 -1
- package/docs/index.html +2 -2
- package/docs/interfaces/CSS3DRenderPluginEventMap.html +1 -1
- package/docs/interfaces/CSS3DRenderPluginState.html +1 -1
- package/docs/interfaces/CameraMovementPluginExportType.html +1 -1
- package/docs/interfaces/ContentTypeMap.html +23 -0
- package/docs/interfaces/FloorplanBounding.html +1 -1
- package/docs/interfaces/FloorplanData.html +1 -1
- package/docs/interfaces/FloorplanEntrance.html +1 -1
- package/docs/interfaces/FloorplanExtraObject.html +1 -1
- package/docs/interfaces/FloorplanExtraObject3D.html +1 -1
- package/docs/interfaces/FloorplanFloorData.html +1 -1
- package/docs/interfaces/FloorplanImagePosition.html +1 -1
- package/docs/interfaces/FloorplanObserver.html +1 -1
- package/docs/interfaces/FloorplanOutlineItem.html +1 -1
- package/docs/interfaces/FloorplanPosition.html +1 -1
- package/docs/interfaces/FloorplanRoomItem.html +1 -1
- package/docs/interfaces/FloorplanRoomLabelItem.html +1 -1
- package/docs/interfaces/FloorplanServerBounding.html +1 -1
- package/docs/interfaces/FloorplanServerComputedData.html +1 -1
- package/docs/interfaces/FloorplanServerData.html +1 -1
- package/docs/interfaces/FloorplanServerDoorItem.html +1 -1
- package/docs/interfaces/FloorplanServerDoorPosition.html +1 -1
- package/docs/interfaces/FloorplanServerEntrance.html +1 -1
- package/docs/interfaces/FloorplanServerFloorData.html +1 -1
- package/docs/interfaces/FloorplanServerImagePosition.html +1 -1
- package/docs/interfaces/FloorplanServerObserver.html +1 -1
- package/docs/interfaces/FloorplanServerOutlineItem.html +1 -1
- package/docs/interfaces/FloorplanServerPosition.html +1 -1
- package/docs/interfaces/FloorplanServerRoomItem.html +1 -1
- package/docs/interfaces/FloorplanServerRoomLabelItem.html +1 -1
- package/docs/interfaces/ItemLabelPluginData.html +1 -1
- package/docs/interfaces/ItemLabelPluginExportReturnsType.html +1 -1
- package/docs/interfaces/ItemLabelPluginParametersType.html +1 -1
- package/docs/interfaces/LineJson.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
- package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
- package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
- package/docs/interfaces/ModelItemLabelPluginData.html +1 -1
- package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -1
- package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -1
- package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginData.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -1
- package/docs/interfaces/ModelViewPluginExportType.html +1 -1
- package/docs/interfaces/Object3DHelperState.html +1 -1
- package/docs/interfaces/OpenParameter.html +1 -1
- package/docs/interfaces/PaintBrushAction.html +1 -1
- package/docs/interfaces/PaintBrushConfigs.html +1 -1
- package/docs/interfaces/PaintBrushState.html +1 -1
- package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +1 -1
- package/docs/interfaces/PanoCursorRaycasterPluginParameterType.html +1 -1
- package/docs/interfaces/PanoMeasureParameterType.html +1 -1
- package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
- package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
- package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
- package/docs/interfaces/PanoRulerProPluginExportType.html +1 -1
- package/docs/interfaces/PanoRulerProPluginOptions.html +1 -1
- package/docs/interfaces/PanoRulerProPluginParameterType.html +1 -1
- package/docs/interfaces/PanoRulerProPluginState.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginContentEvent.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginContentReplacement.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginDataElement.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginOriginElement.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginPointElement.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginTagElement.html +1 -1
- package/docs/interfaces/Point.html +1 -1
- package/docs/interfaces/PointJson.html +1 -1
- package/docs/interfaces/Room.html +1 -1
- package/docs/interfaces/RoomInfo.html +1 -1
- package/docs/interfaces/RoomLabel.html +1 -1
- package/docs/interfaces/RoomRules.html +1 -1
- package/docs/interfaces/Rooms.html +1 -1
- package/docs/interfaces/Scissor.html +1 -1
- package/docs/interfaces/TagConfig.html +1 -1
- package/docs/interfaces/Tags.html +1 -1
- package/docs/modules.html +3 -3
- package/libs/CameraMovementPlugin/CameraMovementPlugin.js +5 -5
- package/libs/CameraMovementPlugin/index.js +1 -1
- package/libs/PanoCompassPlugin/Controller.js +1 -1
- package/libs/PanoCompassPlugin/index.js +1 -1
- package/libs/PanoMeasurePlugin/Controller/index.js +1 -1
- package/libs/PanoMeasurePlugin/Modules/rangePiece/index.js +3 -3
- package/libs/PanoMeasurePlugin/index.js +1 -1
- package/libs/PanoTagPlugin/Assets/Icon.d.ts +2 -1
- package/libs/PanoTagPlugin/Assets/Icon.js +3 -2
- package/libs/PanoTagPlugin/Components/Common/Media.js +558 -548
- package/libs/PanoTagPlugin/Components/Common/MediaItem.js +107 -57
- package/libs/PanoTagPlugin/Components/Common/MultiLineText.js +85 -79
- package/libs/PanoTagPlugin/Components/Common/Point/PointSwitch.js +65 -69
- package/libs/PanoTagPlugin/Components/PointTag.js +1 -1
- package/libs/PanoTagPlugin/Components/Tag/AudioTag.js +42 -42
- package/libs/PanoTagPlugin/Components/Tag/ImageTextTag.js +91 -93
- package/libs/PanoTagPlugin/Components/Tag/MarketingTag.js +54 -58
- package/libs/PanoTagPlugin/Components/Tag/MediaPlane.js +43 -40
- package/libs/PanoTagPlugin/Components/Tag/TextTag.js +56 -56
- package/libs/PanoTagPlugin/Components/Tag/index.js +1 -1
- package/libs/PanoTagPlugin/Components/TagWrapper.js +1 -1
- package/libs/PanoTagPlugin/controller/TagComputer.d.ts +1 -0
- package/libs/PanoTagPlugin/controller/TagComputer.js +1 -1
- package/libs/PanoTagPlugin/controller/index.js +24 -30
- package/libs/PanoTagPlugin/index.js +2 -2
- package/libs/PanoTagPlugin/tag.config.js +1 -2
- package/libs/PanoTagPlugin/typings/tag.d.ts +1 -1
- package/libs/PanoTagPlugin/utils/doUtil.d.ts +1 -0
- package/libs/PanoTagPlugin/utils/doUtil.js +12 -0
- package/libs/{TagComputer.5bd7014b.js → TagComputer.0920083a.js} +108 -90
- package/libs/components/PaintBrush/Controller.js +1 -1
- package/libs/components/PaintBrush/index.js +1 -1
- package/libs/components/PaintBrush/tween.js +5 -5
- package/libs/components/index.js +1 -1
- package/libs/index.js +3 -3
- package/libs/shared-utils/animationFrame/BetterTween.js +1 -1
- package/libs/shared-utils/animationFrame/tween.js +17 -17
- package/libs/tween.esm.bad2b2b4.js +340 -0
- package/package.json +4 -6
- package/dist/index.cjs.js +0 -556
- package/dist/index.umd.js +0 -556
- package/libs/PanoTagPlugin/utils/nullishCoalescing.d.ts +0 -2
- package/libs/PanoTagPlugin/utils/nullishCoalescing.js +0 -7
package/components/index.js
CHANGED
|
@@ -1,102 +1,429 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var g = (
|
|
4
|
-
|
|
5
|
-
function U() {
|
|
1
|
+
var q = Object.defineProperty;
|
|
2
|
+
var H = (t, i, e) => i in t ? q(t, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[i] = e;
|
|
3
|
+
var g = (t, i, e) => (H(t, typeof i != "symbol" ? i + "" : i, e), e);
|
|
4
|
+
function N() {
|
|
6
5
|
}
|
|
7
|
-
const
|
|
6
|
+
const U = () => Promise.resolve(), F = {
|
|
8
7
|
__queue: Promise.resolve()
|
|
9
8
|
};
|
|
10
|
-
function
|
|
11
|
-
|
|
9
|
+
function W(t = U) {
|
|
10
|
+
F.__queue = F.__queue.then(t).catch(U);
|
|
12
11
|
}
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
return { x:
|
|
12
|
+
function I(t, i, e) {
|
|
13
|
+
const n = t.x, r = t.y, s = Math.floor(n / i * 1e4) / 1e4, o = Math.floor(r / e * 1e4) / 1e4;
|
|
14
|
+
return { x: s, y: o };
|
|
16
15
|
}
|
|
17
|
-
function
|
|
18
|
-
const { x:
|
|
19
|
-
return { x:
|
|
16
|
+
function R(t, i, e) {
|
|
17
|
+
const { x: n, y: r } = t, s = n * i, o = r * e;
|
|
18
|
+
return { x: s, y: o };
|
|
20
19
|
}
|
|
21
|
-
function
|
|
22
|
-
if (
|
|
20
|
+
function M(t) {
|
|
21
|
+
if (t.length < 2)
|
|
23
22
|
return {};
|
|
24
|
-
const
|
|
25
|
-
x: (
|
|
26
|
-
y: (
|
|
23
|
+
const i = t.slice(-2), e = i[0], n = {
|
|
24
|
+
x: (i[0].x + i[1].x) / 2,
|
|
25
|
+
y: (i[0].y + i[1].y) / 2
|
|
27
26
|
};
|
|
28
|
-
return { control:
|
|
27
|
+
return { control: e, end: n };
|
|
29
28
|
}
|
|
30
|
-
function
|
|
31
|
-
new Promise((
|
|
29
|
+
function $(t, i, e = N) {
|
|
30
|
+
new Promise((n) => {
|
|
32
31
|
setTimeout(() => {
|
|
33
|
-
|
|
34
|
-
},
|
|
32
|
+
e(), n(!0);
|
|
33
|
+
}, i * t);
|
|
35
34
|
});
|
|
36
35
|
}
|
|
37
|
-
const
|
|
38
|
-
function D(
|
|
39
|
-
|
|
36
|
+
const z = window, j = window.requestAnimationFrame || z.webkitRequestAnimationFrame || ((t) => setTimeout(t, 16));
|
|
37
|
+
function D(t, i = 0) {
|
|
38
|
+
i <= 0 ? j(t) : j(() => D(t, i - 1));
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
var m = {
|
|
41
|
+
Linear: {
|
|
42
|
+
None: function(t) {
|
|
43
|
+
return t;
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
Quadratic: {
|
|
47
|
+
In: function(t) {
|
|
48
|
+
return t * t;
|
|
49
|
+
},
|
|
50
|
+
Out: function(t) {
|
|
51
|
+
return t * (2 - t);
|
|
52
|
+
},
|
|
53
|
+
InOut: function(t) {
|
|
54
|
+
return (t *= 2) < 1 ? 0.5 * t * t : -0.5 * (--t * (t - 2) - 1);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
Cubic: {
|
|
58
|
+
In: function(t) {
|
|
59
|
+
return t * t * t;
|
|
60
|
+
},
|
|
61
|
+
Out: function(t) {
|
|
62
|
+
return --t * t * t + 1;
|
|
63
|
+
},
|
|
64
|
+
InOut: function(t) {
|
|
65
|
+
return (t *= 2) < 1 ? 0.5 * t * t * t : 0.5 * ((t -= 2) * t * t + 2);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
Quartic: {
|
|
69
|
+
In: function(t) {
|
|
70
|
+
return t * t * t * t;
|
|
71
|
+
},
|
|
72
|
+
Out: function(t) {
|
|
73
|
+
return 1 - --t * t * t * t;
|
|
74
|
+
},
|
|
75
|
+
InOut: function(t) {
|
|
76
|
+
return (t *= 2) < 1 ? 0.5 * t * t * t * t : -0.5 * ((t -= 2) * t * t * t - 2);
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
Quintic: {
|
|
80
|
+
In: function(t) {
|
|
81
|
+
return t * t * t * t * t;
|
|
82
|
+
},
|
|
83
|
+
Out: function(t) {
|
|
84
|
+
return --t * t * t * t * t + 1;
|
|
85
|
+
},
|
|
86
|
+
InOut: function(t) {
|
|
87
|
+
return (t *= 2) < 1 ? 0.5 * t * t * t * t * t : 0.5 * ((t -= 2) * t * t * t * t + 2);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
Sinusoidal: {
|
|
91
|
+
In: function(t) {
|
|
92
|
+
return 1 - Math.cos(t * Math.PI / 2);
|
|
93
|
+
},
|
|
94
|
+
Out: function(t) {
|
|
95
|
+
return Math.sin(t * Math.PI / 2);
|
|
96
|
+
},
|
|
97
|
+
InOut: function(t) {
|
|
98
|
+
return 0.5 * (1 - Math.cos(Math.PI * t));
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
Exponential: {
|
|
102
|
+
In: function(t) {
|
|
103
|
+
return t === 0 ? 0 : Math.pow(1024, t - 1);
|
|
104
|
+
},
|
|
105
|
+
Out: function(t) {
|
|
106
|
+
return t === 1 ? 1 : 1 - Math.pow(2, -10 * t);
|
|
107
|
+
},
|
|
108
|
+
InOut: function(t) {
|
|
109
|
+
return t === 0 ? 0 : t === 1 ? 1 : (t *= 2) < 1 ? 0.5 * Math.pow(1024, t - 1) : 0.5 * (-Math.pow(2, -10 * (t - 1)) + 2);
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
Circular: {
|
|
113
|
+
In: function(t) {
|
|
114
|
+
return 1 - Math.sqrt(1 - t * t);
|
|
115
|
+
},
|
|
116
|
+
Out: function(t) {
|
|
117
|
+
return Math.sqrt(1 - --t * t);
|
|
118
|
+
},
|
|
119
|
+
InOut: function(t) {
|
|
120
|
+
return (t *= 2) < 1 ? -0.5 * (Math.sqrt(1 - t * t) - 1) : 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1);
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
Elastic: {
|
|
124
|
+
In: function(t) {
|
|
125
|
+
return t === 0 ? 0 : t === 1 ? 1 : -Math.pow(2, 10 * (t - 1)) * Math.sin((t - 1.1) * 5 * Math.PI);
|
|
126
|
+
},
|
|
127
|
+
Out: function(t) {
|
|
128
|
+
return t === 0 ? 0 : t === 1 ? 1 : Math.pow(2, -10 * t) * Math.sin((t - 0.1) * 5 * Math.PI) + 1;
|
|
129
|
+
},
|
|
130
|
+
InOut: function(t) {
|
|
131
|
+
return t === 0 ? 0 : t === 1 ? 1 : (t *= 2, t < 1 ? -0.5 * Math.pow(2, 10 * (t - 1)) * Math.sin((t - 1.1) * 5 * Math.PI) : 0.5 * Math.pow(2, -10 * (t - 1)) * Math.sin((t - 1.1) * 5 * Math.PI) + 1);
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
Back: {
|
|
135
|
+
In: function(t) {
|
|
136
|
+
var i = 1.70158;
|
|
137
|
+
return t * t * ((i + 1) * t - i);
|
|
138
|
+
},
|
|
139
|
+
Out: function(t) {
|
|
140
|
+
var i = 1.70158;
|
|
141
|
+
return --t * t * ((i + 1) * t + i) + 1;
|
|
142
|
+
},
|
|
143
|
+
InOut: function(t) {
|
|
144
|
+
var i = 2.5949095;
|
|
145
|
+
return (t *= 2) < 1 ? 0.5 * (t * t * ((i + 1) * t - i)) : 0.5 * ((t -= 2) * t * ((i + 1) * t + i) + 2);
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
Bounce: {
|
|
149
|
+
In: function(t) {
|
|
150
|
+
return 1 - m.Bounce.Out(1 - t);
|
|
151
|
+
},
|
|
152
|
+
Out: function(t) {
|
|
153
|
+
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;
|
|
154
|
+
},
|
|
155
|
+
InOut: function(t) {
|
|
156
|
+
return t < 0.5 ? m.Bounce.In(t * 2) * 0.5 : m.Bounce.Out(t * 2 - 1) * 0.5 + 0.5;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}, T;
|
|
160
|
+
typeof self > "u" && typeof process < "u" && process.hrtime ? T = function() {
|
|
161
|
+
var t = process.hrtime();
|
|
162
|
+
return t[0] * 1e3 + t[1] / 1e6;
|
|
163
|
+
} : typeof self < "u" && self.performance !== void 0 && self.performance.now !== void 0 ? T = self.performance.now.bind(self.performance) : Date.now !== void 0 ? T = Date.now : T = function() {
|
|
164
|
+
return new Date().getTime();
|
|
165
|
+
};
|
|
166
|
+
var C = T, X = function() {
|
|
167
|
+
function t() {
|
|
168
|
+
this._tweens = {}, this._tweensAddedDuringUpdate = {};
|
|
169
|
+
}
|
|
170
|
+
return t.prototype.getAll = function() {
|
|
171
|
+
var i = this;
|
|
172
|
+
return Object.keys(this._tweens).map(function(e) {
|
|
173
|
+
return i._tweens[e];
|
|
174
|
+
});
|
|
175
|
+
}, t.prototype.removeAll = function() {
|
|
176
|
+
this._tweens = {};
|
|
177
|
+
}, t.prototype.add = function(i) {
|
|
178
|
+
this._tweens[i.getId()] = i, this._tweensAddedDuringUpdate[i.getId()] = i;
|
|
179
|
+
}, t.prototype.remove = function(i) {
|
|
180
|
+
delete this._tweens[i.getId()], delete this._tweensAddedDuringUpdate[i.getId()];
|
|
181
|
+
}, t.prototype.update = function(i, e) {
|
|
182
|
+
i === void 0 && (i = C()), e === void 0 && (e = !1);
|
|
183
|
+
var n = Object.keys(this._tweens);
|
|
184
|
+
if (n.length === 0)
|
|
185
|
+
return !1;
|
|
186
|
+
for (; n.length > 0; ) {
|
|
187
|
+
this._tweensAddedDuringUpdate = {};
|
|
188
|
+
for (var r = 0; r < n.length; r++) {
|
|
189
|
+
var s = this._tweens[n[r]], o = !e;
|
|
190
|
+
s && s.update(i, o) === !1 && !e && delete this._tweens[n[r]];
|
|
191
|
+
}
|
|
192
|
+
n = Object.keys(this._tweensAddedDuringUpdate);
|
|
193
|
+
}
|
|
194
|
+
return !0;
|
|
195
|
+
}, t;
|
|
196
|
+
}(), S = {
|
|
197
|
+
Linear: function(t, i) {
|
|
198
|
+
var e = t.length - 1, n = e * i, r = Math.floor(n), s = S.Utils.Linear;
|
|
199
|
+
return i < 0 ? s(t[0], t[1], n) : i > 1 ? s(t[e], t[e - 1], e - n) : s(t[r], t[r + 1 > e ? e : r + 1], n - r);
|
|
200
|
+
},
|
|
201
|
+
Bezier: function(t, i) {
|
|
202
|
+
for (var e = 0, n = t.length - 1, r = Math.pow, s = S.Utils.Bernstein, o = 0; o <= n; o++)
|
|
203
|
+
e += r(1 - i, n - o) * r(i, o) * t[o] * s(n, o);
|
|
204
|
+
return e;
|
|
205
|
+
},
|
|
206
|
+
CatmullRom: function(t, i) {
|
|
207
|
+
var e = t.length - 1, n = e * i, r = Math.floor(n), s = S.Utils.CatmullRom;
|
|
208
|
+
return t[0] === t[e] ? (i < 0 && (r = Math.floor(n = e * (1 + i))), s(t[(r - 1 + e) % e], t[r], t[(r + 1) % e], t[(r + 2) % e], n - r)) : i < 0 ? t[0] - (s(t[0], t[0], t[1], t[1], -n) - t[0]) : i > 1 ? t[e] - (s(t[e], t[e], t[e - 1], t[e - 1], n - e) - t[e]) : s(t[r ? r - 1 : 0], t[r], t[e < r + 1 ? e : r + 1], t[e < r + 2 ? e : r + 2], n - r);
|
|
209
|
+
},
|
|
210
|
+
Utils: {
|
|
211
|
+
Linear: function(t, i, e) {
|
|
212
|
+
return (i - t) * e + t;
|
|
213
|
+
},
|
|
214
|
+
Bernstein: function(t, i) {
|
|
215
|
+
var e = S.Utils.Factorial;
|
|
216
|
+
return e(t) / e(i) / e(t - i);
|
|
217
|
+
},
|
|
218
|
+
Factorial: function() {
|
|
219
|
+
var t = [1];
|
|
220
|
+
return function(i) {
|
|
221
|
+
var e = 1;
|
|
222
|
+
if (t[i])
|
|
223
|
+
return t[i];
|
|
224
|
+
for (var n = i; n > 1; n--)
|
|
225
|
+
e *= n;
|
|
226
|
+
return t[i] = e, e;
|
|
227
|
+
};
|
|
228
|
+
}(),
|
|
229
|
+
CatmullRom: function(t, i, e, n, r) {
|
|
230
|
+
var s = (e - t) * 0.5, o = (n - i) * 0.5, a = r * r, c = r * a;
|
|
231
|
+
return (2 * i - 2 * e + s + o) * c + (-3 * i + 3 * e - 2 * s - o) * a + s * r + i;
|
|
232
|
+
}
|
|
45
233
|
}
|
|
46
|
-
|
|
234
|
+
}, A = function() {
|
|
235
|
+
function t() {
|
|
236
|
+
}
|
|
237
|
+
return t.nextId = function() {
|
|
238
|
+
return t._nextId++;
|
|
239
|
+
}, t._nextId = 0, t;
|
|
240
|
+
}(), L = new X(), Y = function() {
|
|
241
|
+
function t(i, e) {
|
|
242
|
+
e === void 0 && (e = L), this._object = i, this._group = e, this._isPaused = !1, this._pauseStart = 0, this._valuesStart = {}, this._valuesEnd = {}, this._valuesStartRepeat = {}, this._duration = 1e3, this._initialRepeat = 0, this._repeat = 0, this._yoyo = !1, this._isPlaying = !1, this._reversed = !1, this._delayTime = 0, this._startTime = 0, this._easingFunction = m.Linear.None, this._interpolationFunction = S.Linear, this._chainedTweens = [], this._onStartCallbackFired = !1, this._id = A.nextId(), this._isChainStopped = !1, this._goToEnd = !1;
|
|
243
|
+
}
|
|
244
|
+
return t.prototype.getId = function() {
|
|
245
|
+
return this._id;
|
|
246
|
+
}, t.prototype.isPlaying = function() {
|
|
247
|
+
return this._isPlaying;
|
|
248
|
+
}, t.prototype.isPaused = function() {
|
|
249
|
+
return this._isPaused;
|
|
250
|
+
}, t.prototype.to = function(i, e) {
|
|
251
|
+
return this._valuesEnd = Object.create(i), e !== void 0 && (this._duration = e), this;
|
|
252
|
+
}, t.prototype.duration = function(i) {
|
|
253
|
+
return this._duration = i, this;
|
|
254
|
+
}, t.prototype.start = function(i) {
|
|
255
|
+
if (this._isPlaying)
|
|
256
|
+
return this;
|
|
257
|
+
if (this._group && this._group.add(this), this._repeat = this._initialRepeat, this._reversed) {
|
|
258
|
+
this._reversed = !1;
|
|
259
|
+
for (var e in this._valuesStartRepeat)
|
|
260
|
+
this._swapEndStartRepeatValues(e), this._valuesStart[e] = this._valuesStartRepeat[e];
|
|
261
|
+
}
|
|
262
|
+
return this._isPlaying = !0, this._isPaused = !1, this._onStartCallbackFired = !1, this._isChainStopped = !1, this._startTime = i !== void 0 ? typeof i == "string" ? C() + parseFloat(i) : i : C(), this._startTime += this._delayTime, this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat), this;
|
|
263
|
+
}, t.prototype._setupProperties = function(i, e, n, r) {
|
|
264
|
+
for (var s in n) {
|
|
265
|
+
var o = i[s], a = Array.isArray(o), c = a ? "array" : typeof o, d = !a && Array.isArray(n[s]);
|
|
266
|
+
if (!(c === "undefined" || c === "function")) {
|
|
267
|
+
if (d) {
|
|
268
|
+
var _ = n[s];
|
|
269
|
+
if (_.length === 0)
|
|
270
|
+
continue;
|
|
271
|
+
_ = _.map(this._handleRelativeValue.bind(this, o)), n[s] = [o].concat(_);
|
|
272
|
+
}
|
|
273
|
+
if ((c === "object" || a) && o && !d) {
|
|
274
|
+
e[s] = a ? [] : {};
|
|
275
|
+
for (var l in o)
|
|
276
|
+
e[s][l] = o[l];
|
|
277
|
+
r[s] = a ? [] : {}, this._setupProperties(o, e[s], n[s], r[s]);
|
|
278
|
+
} else
|
|
279
|
+
typeof e[s] > "u" && (e[s] = o), a || (e[s] *= 1), d ? r[s] = n[s].slice().reverse() : r[s] = e[s] || 0;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}, t.prototype.stop = function() {
|
|
283
|
+
return this._isChainStopped || (this._isChainStopped = !0, this.stopChainedTweens()), this._isPlaying ? (this._group && this._group.remove(this), this._isPlaying = !1, this._isPaused = !1, this._onStopCallback && this._onStopCallback(this._object), this) : this;
|
|
284
|
+
}, t.prototype.end = function() {
|
|
285
|
+
return this._goToEnd = !0, this.update(1 / 0), this;
|
|
286
|
+
}, t.prototype.pause = function(i) {
|
|
287
|
+
return i === void 0 && (i = C()), this._isPaused || !this._isPlaying ? this : (this._isPaused = !0, this._pauseStart = i, this._group && this._group.remove(this), this);
|
|
288
|
+
}, t.prototype.resume = function(i) {
|
|
289
|
+
return i === void 0 && (i = C()), !this._isPaused || !this._isPlaying ? this : (this._isPaused = !1, this._startTime += i - this._pauseStart, this._pauseStart = 0, this._group && this._group.add(this), this);
|
|
290
|
+
}, t.prototype.stopChainedTweens = function() {
|
|
291
|
+
for (var i = 0, e = this._chainedTweens.length; i < e; i++)
|
|
292
|
+
this._chainedTweens[i].stop();
|
|
293
|
+
return this;
|
|
294
|
+
}, t.prototype.group = function(i) {
|
|
295
|
+
return this._group = i, this;
|
|
296
|
+
}, t.prototype.delay = function(i) {
|
|
297
|
+
return this._delayTime = i, this;
|
|
298
|
+
}, t.prototype.repeat = function(i) {
|
|
299
|
+
return this._initialRepeat = i, this._repeat = i, this;
|
|
300
|
+
}, t.prototype.repeatDelay = function(i) {
|
|
301
|
+
return this._repeatDelayTime = i, this;
|
|
302
|
+
}, t.prototype.yoyo = function(i) {
|
|
303
|
+
return this._yoyo = i, this;
|
|
304
|
+
}, t.prototype.easing = function(i) {
|
|
305
|
+
return this._easingFunction = i, this;
|
|
306
|
+
}, t.prototype.interpolation = function(i) {
|
|
307
|
+
return this._interpolationFunction = i, this;
|
|
308
|
+
}, t.prototype.chain = function() {
|
|
309
|
+
for (var i = [], e = 0; e < arguments.length; e++)
|
|
310
|
+
i[e] = arguments[e];
|
|
311
|
+
return this._chainedTweens = i, this;
|
|
312
|
+
}, t.prototype.onStart = function(i) {
|
|
313
|
+
return this._onStartCallback = i, this;
|
|
314
|
+
}, t.prototype.onUpdate = function(i) {
|
|
315
|
+
return this._onUpdateCallback = i, this;
|
|
316
|
+
}, t.prototype.onRepeat = function(i) {
|
|
317
|
+
return this._onRepeatCallback = i, this;
|
|
318
|
+
}, t.prototype.onComplete = function(i) {
|
|
319
|
+
return this._onCompleteCallback = i, this;
|
|
320
|
+
}, t.prototype.onStop = function(i) {
|
|
321
|
+
return this._onStopCallback = i, this;
|
|
322
|
+
}, t.prototype.update = function(i, e) {
|
|
323
|
+
if (i === void 0 && (i = C()), e === void 0 && (e = !0), this._isPaused)
|
|
324
|
+
return !0;
|
|
325
|
+
var n, r, s = this._startTime + this._duration;
|
|
326
|
+
if (!this._goToEnd && !this._isPlaying) {
|
|
327
|
+
if (i > s)
|
|
328
|
+
return !1;
|
|
329
|
+
e && this.start(i);
|
|
330
|
+
}
|
|
331
|
+
if (this._goToEnd = !1, i < this._startTime)
|
|
332
|
+
return !0;
|
|
333
|
+
this._onStartCallbackFired === !1 && (this._onStartCallback && this._onStartCallback(this._object), this._onStartCallbackFired = !0), r = (i - this._startTime) / this._duration, r = this._duration === 0 || r > 1 ? 1 : r;
|
|
334
|
+
var o = this._easingFunction(r);
|
|
335
|
+
if (this._updateProperties(this._object, this._valuesStart, this._valuesEnd, o), this._onUpdateCallback && this._onUpdateCallback(this._object, r), r === 1)
|
|
336
|
+
if (this._repeat > 0) {
|
|
337
|
+
isFinite(this._repeat) && this._repeat--;
|
|
338
|
+
for (n in this._valuesStartRepeat)
|
|
339
|
+
!this._yoyo && typeof this._valuesEnd[n] == "string" && (this._valuesStartRepeat[n] = this._valuesStartRepeat[n] + parseFloat(this._valuesEnd[n])), this._yoyo && this._swapEndStartRepeatValues(n), this._valuesStart[n] = this._valuesStartRepeat[n];
|
|
340
|
+
return this._yoyo && (this._reversed = !this._reversed), this._repeatDelayTime !== void 0 ? this._startTime = i + this._repeatDelayTime : this._startTime = i + this._delayTime, this._onRepeatCallback && this._onRepeatCallback(this._object), !0;
|
|
341
|
+
} else {
|
|
342
|
+
this._onCompleteCallback && this._onCompleteCallback(this._object);
|
|
343
|
+
for (var a = 0, c = this._chainedTweens.length; a < c; a++)
|
|
344
|
+
this._chainedTweens[a].start(this._startTime + this._duration);
|
|
345
|
+
return this._isPlaying = !1, !1;
|
|
346
|
+
}
|
|
347
|
+
return !0;
|
|
348
|
+
}, t.prototype._updateProperties = function(i, e, n, r) {
|
|
349
|
+
for (var s in n)
|
|
350
|
+
if (e[s] !== void 0) {
|
|
351
|
+
var o = e[s] || 0, a = n[s], c = Array.isArray(i[s]), d = Array.isArray(a), _ = !c && d;
|
|
352
|
+
_ ? i[s] = this._interpolationFunction(a, r) : typeof a == "object" && a ? this._updateProperties(i[s], o, a, r) : (a = this._handleRelativeValue(o, a), typeof a == "number" && (i[s] = o + (a - o) * r));
|
|
353
|
+
}
|
|
354
|
+
}, t.prototype._handleRelativeValue = function(i, e) {
|
|
355
|
+
return typeof e != "string" ? e : e.charAt(0) === "+" || e.charAt(0) === "-" ? i + parseFloat(e) : parseFloat(e);
|
|
356
|
+
}, t.prototype._swapEndStartRepeatValues = function(i) {
|
|
357
|
+
var e = this._valuesStartRepeat[i], n = this._valuesEnd[i];
|
|
358
|
+
typeof n == "string" ? this._valuesStartRepeat[i] = this._valuesStartRepeat[i] + parseFloat(n) : this._valuesStartRepeat[i] = this._valuesEnd[i], this._valuesEnd[i] = e;
|
|
359
|
+
}, t;
|
|
360
|
+
}();
|
|
361
|
+
A.nextId;
|
|
362
|
+
var v = L;
|
|
363
|
+
v.getAll.bind(v);
|
|
364
|
+
v.removeAll.bind(v);
|
|
365
|
+
v.add.bind(v);
|
|
366
|
+
v.remove.bind(v);
|
|
367
|
+
v.update.bind(v);
|
|
368
|
+
function Q(t, i, e, n = m.Linear.None) {
|
|
369
|
+
const r = new Y(t).to(i, e).easing(n).start();
|
|
370
|
+
function s(o) {
|
|
371
|
+
!r.update(o) || requestAnimationFrame(s);
|
|
372
|
+
}
|
|
373
|
+
return requestAnimationFrame(s), r;
|
|
47
374
|
}
|
|
48
|
-
var
|
|
49
|
-
const
|
|
50
|
-
function
|
|
51
|
-
return
|
|
375
|
+
var w = /* @__PURE__ */ ((t) => (t.Drawline = "Drawline", t.Undo = "Undo", t.Exit = "Exit", t))(w || {});
|
|
376
|
+
const E = Symbol("$$PAINT_BRUSH_EVENT$$");
|
|
377
|
+
function P(t) {
|
|
378
|
+
return t[E] || (t[E] = {}), t[E];
|
|
52
379
|
}
|
|
53
|
-
function
|
|
54
|
-
|
|
380
|
+
function G(t) {
|
|
381
|
+
t[E] || delete t[E];
|
|
55
382
|
}
|
|
56
|
-
class
|
|
57
|
-
hasListener(
|
|
58
|
-
const
|
|
59
|
-
return
|
|
383
|
+
class J {
|
|
384
|
+
hasListener(i) {
|
|
385
|
+
const e = P(this);
|
|
386
|
+
return e && e[i] && e[i].length > 0;
|
|
60
387
|
}
|
|
61
|
-
on(
|
|
62
|
-
const
|
|
63
|
-
return
|
|
388
|
+
on(i, e, n) {
|
|
389
|
+
const r = P(this);
|
|
390
|
+
return r[i] || (r[i] = []), r[i].push([e, n || !1]), () => this.off(i, e);
|
|
64
391
|
}
|
|
65
|
-
once(
|
|
66
|
-
return this.on(
|
|
392
|
+
once(i, e) {
|
|
393
|
+
return this.on(i, e, !0);
|
|
67
394
|
}
|
|
68
|
-
off(
|
|
69
|
-
if (
|
|
70
|
-
|
|
395
|
+
off(i, e) {
|
|
396
|
+
if (i === void 0) {
|
|
397
|
+
G(this);
|
|
71
398
|
return;
|
|
72
399
|
}
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
|
|
400
|
+
const n = P(this);
|
|
401
|
+
if (n[i] || (n[i] = []), e === void 0) {
|
|
402
|
+
n[i].length = 0;
|
|
76
403
|
return;
|
|
77
404
|
}
|
|
78
|
-
let
|
|
79
|
-
for (;
|
|
405
|
+
let r = 0;
|
|
406
|
+
for (; r < n[i].length && n[i][r][0] !== e; r++)
|
|
80
407
|
;
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
emit(
|
|
84
|
-
let
|
|
85
|
-
const
|
|
86
|
-
for (let
|
|
87
|
-
const [
|
|
88
|
-
|
|
408
|
+
r < n[i].length && n[i].splice(r, 1);
|
|
409
|
+
}
|
|
410
|
+
emit(i, ...e) {
|
|
411
|
+
let n = !1;
|
|
412
|
+
const s = P(this)[i] || [];
|
|
413
|
+
for (let o of s.slice()) {
|
|
414
|
+
const [a, c = !1] = o, d = a(...e);
|
|
415
|
+
c && this.off(i, a), d === !1 && (n = !0);
|
|
89
416
|
}
|
|
90
|
-
return
|
|
417
|
+
return n;
|
|
91
418
|
}
|
|
92
419
|
}
|
|
93
|
-
function
|
|
420
|
+
function y() {
|
|
94
421
|
return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
|
|
95
422
|
}
|
|
96
|
-
function
|
|
97
|
-
return (
|
|
423
|
+
function Z() {
|
|
424
|
+
return (y() + y() + "-" + y() + "-4" + y().substr(0, 3) + "-" + y() + "-" + y() + y() + y()).toLowerCase();
|
|
98
425
|
}
|
|
99
|
-
const
|
|
426
|
+
const K = `
|
|
100
427
|
<style type="text/css">
|
|
101
428
|
|
|
102
429
|
#_gl_paintBrush {
|
|
@@ -197,21 +524,21 @@ transition: all 500ms;
|
|
|
197
524
|
|
|
198
525
|
</style>
|
|
199
526
|
`;
|
|
200
|
-
class
|
|
201
|
-
constructor(
|
|
527
|
+
class V extends J {
|
|
528
|
+
constructor(e) {
|
|
202
529
|
super();
|
|
203
530
|
g(this, "configs");
|
|
204
531
|
g(this, "clientWidth");
|
|
205
532
|
g(this, "clientHeight");
|
|
206
533
|
g(this, "ready", !1);
|
|
207
|
-
g(this, "uuid",
|
|
534
|
+
g(this, "uuid", Z());
|
|
208
535
|
g(this, "tween");
|
|
209
536
|
g(this, "tweening", !1);
|
|
210
537
|
g(this, "container");
|
|
211
538
|
g(this, "canvas");
|
|
212
539
|
g(this, "data", {});
|
|
213
540
|
g(this, "tempLine", {});
|
|
214
|
-
this.configs =
|
|
541
|
+
this.configs = e, this.clientWidth = document.body.clientWidth, this.clientHeight = document.body.clientHeight, this.container = this.ifInsertToDOM(), this.canvas = {}, this.initCtrl();
|
|
215
542
|
}
|
|
216
543
|
get color() {
|
|
217
544
|
return this.configs.currentColor;
|
|
@@ -230,293 +557,293 @@ class X extends P {
|
|
|
230
557
|
else if (document.getElementById("_gl_paintBrush"))
|
|
231
558
|
this.container = document.getElementById("_gl_paintBrush");
|
|
232
559
|
else {
|
|
233
|
-
const
|
|
234
|
-
|
|
560
|
+
const e = document.createElement("div");
|
|
561
|
+
e.id = "_gl_paintBrush", document.body.appendChild(e), this.container = e;
|
|
235
562
|
}
|
|
236
|
-
return this.container.innerHTML =
|
|
563
|
+
return this.container.innerHTML = K, this.container;
|
|
237
564
|
}
|
|
238
|
-
initCanvas(
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
const
|
|
242
|
-
if (!!
|
|
243
|
-
return
|
|
565
|
+
initCanvas(e) {
|
|
566
|
+
const n = document.createElement("canvas");
|
|
567
|
+
n.className = e, n.width = this.clientWidth, n.height = this.clientHeight;
|
|
568
|
+
const r = n.getContext("2d");
|
|
569
|
+
if (!!r)
|
|
570
|
+
return r.lineWidth = 5 * this.dpr, r.lineCap = "round", r.lineJoin = "round", this.container.appendChild(n), n;
|
|
244
571
|
}
|
|
245
572
|
initCtrl() {
|
|
246
|
-
const t = document.createElement("div");
|
|
247
|
-
t.className = "_paintBrush-ctrl";
|
|
248
573
|
const e = document.createElement("div");
|
|
249
|
-
e.className = "_paintBrush-
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
574
|
+
e.className = "_paintBrush-ctrl";
|
|
575
|
+
const n = document.createElement("div");
|
|
576
|
+
n.className = "_paintBrush-ctrlinner";
|
|
577
|
+
const r = document.createElement("a");
|
|
578
|
+
r.className = "_paintBrush-ctrlitem _paintBrush-ctrlitem--undo", r.addEventListener("click", (a) => {
|
|
579
|
+
var u;
|
|
580
|
+
if (a.stopPropagation(), this.configs.onClickUndo && this.configs.onClickUndo(), !this.canvas[this.uuid] || !this.data[this.uuid] || this.data[this.uuid].length === 0)
|
|
254
581
|
return;
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
type:
|
|
582
|
+
const c = this.data[this.uuid].pop();
|
|
583
|
+
c && this.emitStateChange({
|
|
584
|
+
type: w.Undo,
|
|
258
585
|
color: this.color,
|
|
259
586
|
ready: this.ready,
|
|
260
|
-
state:
|
|
587
|
+
state: c,
|
|
261
588
|
uuid: this.uuid
|
|
262
589
|
});
|
|
263
|
-
const
|
|
590
|
+
const d = (u = this.canvas[this.uuid]) == null ? void 0 : u.getContext("2d");
|
|
264
591
|
if (!this.canvas[this.uuid])
|
|
265
592
|
return;
|
|
266
|
-
const { width:
|
|
267
|
-
|
|
593
|
+
const { width: _, height: l } = this.canvas[this.uuid];
|
|
594
|
+
d && d.clearRect(0, 0, _, l), this.data[this.uuid].forEach((h) => this.handleDrawLine(this.uuid, h, { withUndo: !0 }));
|
|
268
595
|
});
|
|
269
|
-
const
|
|
270
|
-
return
|
|
271
|
-
|
|
272
|
-
}), [
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
}),
|
|
596
|
+
const s = document.createElement("a");
|
|
597
|
+
return s.className = "_paintBrush-ctrlitem _paintBrush-ctrlitem--close", s.addEventListener("click", (a) => {
|
|
598
|
+
a.stopPropagation(), this.closeBrush(), this.configs.onClickClose && this.configs.onClickClose();
|
|
599
|
+
}), [r, s].forEach((a) => {
|
|
600
|
+
const c = document.createElement("i");
|
|
601
|
+
c.className = "brush-icon";
|
|
602
|
+
const d = document.createElement("span");
|
|
603
|
+
d.className = "brush-txt", d.innerText = a.className.endsWith("undo") ? this.configs.onUndoText : this.configs.onExitText, a.appendChild(c), a.appendChild(d);
|
|
604
|
+
}), n.appendChild(r), n.appendChild(s), e.appendChild(n), this.container.appendChild(e), e;
|
|
278
605
|
}
|
|
279
606
|
openBrush() {
|
|
280
607
|
if (this.ready)
|
|
281
608
|
return;
|
|
282
609
|
this.canvas[this.uuid] || (this.canvas[this.uuid] = this.initCanvas("_paintBrush-canvas")), this.container.className = "brushing";
|
|
283
|
-
const
|
|
284
|
-
|
|
610
|
+
const e = this.canvas[this.uuid];
|
|
611
|
+
e.getContext("2d").clearRect(0, 0, e.width, e.height), this.openBrushHandle(), this.ready = !0, this.emit("readyChange", !0);
|
|
285
612
|
}
|
|
286
613
|
closeBrush() {
|
|
287
|
-
!this.ready || (this.container.className = "", this.data = {}, this.tempLine = {}, Object.keys(this.canvas).forEach((
|
|
288
|
-
this.canvas[
|
|
289
|
-
const
|
|
290
|
-
|
|
614
|
+
!this.ready || (this.container.className = "", this.data = {}, this.tempLine = {}, Object.keys(this.canvas).forEach((e) => {
|
|
615
|
+
this.canvas[e].ontouchstart = () => !1, this.canvas[e].ontouchmove = () => !1, this.canvas[e].ontouchend = () => !1, this.canvas[e].ontouchcancel = () => !1;
|
|
616
|
+
const n = this.canvas[e].getContext("2d");
|
|
617
|
+
n && n.clearRect(0, 0, this.canvas[e].width, this.canvas[e].height);
|
|
291
618
|
}), this.ready = !1, this.emit("readyChange", !1), this.emitStateChange({
|
|
292
|
-
type:
|
|
619
|
+
type: w.Exit,
|
|
293
620
|
color: this.color,
|
|
294
621
|
ready: !1,
|
|
295
622
|
uuid: this.uuid
|
|
296
623
|
}));
|
|
297
624
|
}
|
|
298
|
-
updateCurrentColor(
|
|
299
|
-
const
|
|
300
|
-
if (!
|
|
625
|
+
updateCurrentColor(e) {
|
|
626
|
+
const n = this.canvas[this.uuid];
|
|
627
|
+
if (!n)
|
|
301
628
|
return;
|
|
302
|
-
const
|
|
303
|
-
!
|
|
629
|
+
const r = n.getContext("2d");
|
|
630
|
+
!r || (this.configs.currentColor = e, r.strokeStyle = e);
|
|
304
631
|
}
|
|
305
632
|
openBrushHandle() {
|
|
306
|
-
const
|
|
307
|
-
if (!t)
|
|
308
|
-
return;
|
|
309
|
-
const e = t.getContext("2d");
|
|
633
|
+
const e = this.canvas[this.uuid];
|
|
310
634
|
if (!e)
|
|
311
635
|
return;
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const
|
|
636
|
+
const n = e.getContext("2d");
|
|
637
|
+
if (!n)
|
|
638
|
+
return;
|
|
639
|
+
const r = this.color || "#6D92FF";
|
|
640
|
+
n.strokeStyle = r;
|
|
641
|
+
let s = null, o = [], a, c = [], d = 0;
|
|
642
|
+
const _ = (l, u, h) => {
|
|
316
643
|
const p = this.color || "#ff0000";
|
|
317
|
-
|
|
644
|
+
n.strokeStyle = p, n.beginPath(), n.moveTo(l.x, l.y), n.quadraticCurveTo(u.x, u.y, h.x, h.y), n.stroke();
|
|
318
645
|
};
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
},
|
|
324
|
-
if (
|
|
646
|
+
e.onmousedown = (l) => {
|
|
647
|
+
l.preventDefault(), d = Date.now();
|
|
648
|
+
const u = l.clientX, h = l.clientY;
|
|
649
|
+
o = [], o.push({ x: u, y: h }), s = { x: u, y: h }, a = I({ x: u, y: h }, this.clientWidth, this.clientHeight), c = [];
|
|
650
|
+
}, e.onmousemove = (l) => {
|
|
651
|
+
if (l.preventDefault(), !s)
|
|
325
652
|
return;
|
|
326
|
-
const
|
|
327
|
-
if (Math.abs(
|
|
653
|
+
const u = Number(l.clientX), h = Number(l.clientY);
|
|
654
|
+
if (Math.abs(u - s.x) < 5 && Math.abs(h - s.y) < 5 || (o.push({ x: u, y: h }), c.push(I({ x: u, y: h }, this.clientWidth, this.clientHeight)), o.length < 3))
|
|
328
655
|
return;
|
|
329
|
-
const { control: p, end:
|
|
330
|
-
!p || !
|
|
331
|
-
},
|
|
332
|
-
if (
|
|
656
|
+
const { control: p, end: f } = M(o);
|
|
657
|
+
!p || !f || (_(s, p, f), s = f);
|
|
658
|
+
}, e.onmouseup = (l) => {
|
|
659
|
+
if (l.preventDefault(), s = null, o.length < 3)
|
|
333
660
|
return;
|
|
334
661
|
this.data[this.uuid] || (this.data[this.uuid] = []);
|
|
335
|
-
const
|
|
336
|
-
move: Object.assign({},
|
|
662
|
+
const u = Date.now() - d, h = {
|
|
663
|
+
move: Object.assign({}, a),
|
|
337
664
|
uuid: this.uuid,
|
|
338
|
-
line: [...
|
|
665
|
+
line: [...c],
|
|
339
666
|
color: this.color,
|
|
340
|
-
duration:
|
|
667
|
+
duration: u < 1280 ? u : u < 2e3 ? 1280 : 0
|
|
341
668
|
};
|
|
342
|
-
this.data[this.uuid].push(
|
|
669
|
+
this.data[this.uuid].push(h), D(() => {
|
|
343
670
|
this.emitStateChange({
|
|
344
|
-
type:
|
|
671
|
+
type: w.Drawline,
|
|
345
672
|
color: this.color,
|
|
346
673
|
ready: this.ready,
|
|
347
|
-
state:
|
|
674
|
+
state: h,
|
|
348
675
|
uuid: this.uuid
|
|
349
676
|
});
|
|
350
677
|
});
|
|
351
|
-
},
|
|
352
|
-
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
},
|
|
356
|
-
if (
|
|
678
|
+
}, e.ontouchstart = (l) => {
|
|
679
|
+
l.preventDefault(), d = Date.now();
|
|
680
|
+
const u = l.touches[0].clientX, h = l.touches[0].clientY;
|
|
681
|
+
o = [], o.push({ x: u, y: h }), s = { x: u, y: h }, console.log("ontouchstart", u, h, s), a = I({ x: u, y: h }, this.clientWidth, this.clientHeight), c = [];
|
|
682
|
+
}, e.ontouchmove = (l) => {
|
|
683
|
+
if (l.preventDefault(), !s)
|
|
357
684
|
return;
|
|
358
|
-
const
|
|
359
|
-
if (Math.abs(
|
|
685
|
+
const u = Number(l.touches[0].clientX), h = Number(l.touches[0].clientY);
|
|
686
|
+
if (Math.abs(u - s.x) < 5 && Math.abs(h - s.y) < 5 || (o.push({ x: u, y: h }), c.push(I({ x: u, y: h }, this.clientWidth, this.clientHeight)), o.length < 3))
|
|
360
687
|
return;
|
|
361
|
-
const { control: p, end:
|
|
362
|
-
!p || !
|
|
363
|
-
},
|
|
364
|
-
if (
|
|
688
|
+
const { control: p, end: f } = M(o);
|
|
689
|
+
!p || !f || (_(s, p, f), s = f);
|
|
690
|
+
}, e.ontouchend = e.ontouchcancel = (l) => {
|
|
691
|
+
if (l.preventDefault(), s = null, o.length < 3)
|
|
365
692
|
return;
|
|
366
693
|
this.data[this.uuid] || (this.data[this.uuid] = []);
|
|
367
|
-
const
|
|
368
|
-
move: Object.assign({},
|
|
369
|
-
line: [...
|
|
694
|
+
const u = Date.now() - d, h = {
|
|
695
|
+
move: Object.assign({}, a),
|
|
696
|
+
line: [...c],
|
|
370
697
|
uuid: this.uuid,
|
|
371
698
|
color: this.color,
|
|
372
|
-
duration:
|
|
699
|
+
duration: u < 1280 ? u : u < 2e3 ? 1280 : 0
|
|
373
700
|
};
|
|
374
|
-
this.data[this.uuid].push(
|
|
701
|
+
this.data[this.uuid].push(h), D(() => {
|
|
375
702
|
this.emitStateChange({
|
|
376
|
-
type:
|
|
703
|
+
type: w.Drawline,
|
|
377
704
|
color: this.color,
|
|
378
705
|
ready: this.ready,
|
|
379
|
-
state:
|
|
706
|
+
state: h,
|
|
380
707
|
uuid: this.uuid
|
|
381
708
|
});
|
|
382
709
|
});
|
|
383
710
|
};
|
|
384
711
|
}
|
|
385
|
-
emitStateChange(
|
|
386
|
-
if (
|
|
387
|
-
this.emit("stateChange",
|
|
712
|
+
emitStateChange(e, n = !0) {
|
|
713
|
+
if (e.type !== w.Drawline) {
|
|
714
|
+
this.emit("stateChange", e, n);
|
|
388
715
|
return;
|
|
389
716
|
}
|
|
390
|
-
const
|
|
391
|
-
if (!
|
|
717
|
+
const r = Date.now(), s = e.state;
|
|
718
|
+
if (!s || !s.line)
|
|
392
719
|
return;
|
|
393
|
-
const
|
|
394
|
-
for (let
|
|
395
|
-
const
|
|
720
|
+
const o = Math.ceil(s.line.length / 100);
|
|
721
|
+
for (let a = 0; a < o; a++) {
|
|
722
|
+
const c = {
|
|
396
723
|
uuid: this.uuid,
|
|
397
724
|
color: this.color,
|
|
398
725
|
ready: this.ready,
|
|
399
|
-
type:
|
|
726
|
+
type: e.type,
|
|
400
727
|
state: {
|
|
401
728
|
uuid: this.uuid,
|
|
402
|
-
move:
|
|
403
|
-
duration:
|
|
729
|
+
move: s.move,
|
|
730
|
+
duration: s.duration,
|
|
404
731
|
color: this.color,
|
|
405
|
-
line:
|
|
732
|
+
line: s.line.slice(a * 100, (a + 1) * 100)
|
|
406
733
|
},
|
|
407
|
-
timestamp:
|
|
408
|
-
end:
|
|
734
|
+
timestamp: r,
|
|
735
|
+
end: a === o - 1
|
|
409
736
|
};
|
|
410
|
-
|
|
411
|
-
this.emit("stateChange",
|
|
737
|
+
$(a, 20, () => {
|
|
738
|
+
this.emit("stateChange", c, n);
|
|
412
739
|
});
|
|
413
740
|
}
|
|
414
741
|
}
|
|
415
|
-
action(
|
|
416
|
-
const { ready:
|
|
417
|
-
if (!
|
|
742
|
+
action(e) {
|
|
743
|
+
const { ready: n, type: r, uuid: s } = e;
|
|
744
|
+
if (!n && this.ready) {
|
|
418
745
|
this.closeBrush();
|
|
419
746
|
return;
|
|
420
747
|
}
|
|
421
|
-
if (
|
|
748
|
+
if (n && !this.ready) {
|
|
422
749
|
this.openBrush();
|
|
423
750
|
return;
|
|
424
751
|
}
|
|
425
752
|
if (!!this.ready)
|
|
426
|
-
switch (
|
|
427
|
-
case
|
|
428
|
-
const { state:
|
|
429
|
-
if (!
|
|
753
|
+
switch (r) {
|
|
754
|
+
case w.Drawline:
|
|
755
|
+
const { state: o, timestamp: a, end: c } = e;
|
|
756
|
+
if (!a || !o)
|
|
430
757
|
return;
|
|
431
|
-
this.tempLine[
|
|
758
|
+
this.tempLine[a] = [].concat(this.tempLine[a] || [], o.line), c && (Object.assign(o, { line: this.tempLine[a] }), this.handleDrawLine(s, o, {}, () => delete this.tempLine[a]));
|
|
432
759
|
break;
|
|
433
|
-
case
|
|
434
|
-
this.handleUndo(
|
|
760
|
+
case w.Undo:
|
|
761
|
+
this.handleUndo(s);
|
|
435
762
|
break;
|
|
436
763
|
}
|
|
437
764
|
}
|
|
438
|
-
handleDrawLine(
|
|
439
|
-
!
|
|
440
|
-
if (
|
|
765
|
+
handleDrawLine(e, n, { withUndo: r = !1 }, s = N) {
|
|
766
|
+
!n || Object.prototype.toString.call(n) != "[object Object]" || Object.keys(n).length === 0 || (console.log("handleDrawLine", n, n.line), W(() => new Promise((o) => {
|
|
767
|
+
if (r || (this.canvas[e] || (this.canvas[e] = this.initCanvas("_paintBrush-canvas--sync")), this.data[e] || (this.data[e] = []), this.data[e].push(n)), !this.canvas[e])
|
|
441
768
|
return;
|
|
442
|
-
const
|
|
443
|
-
if (!
|
|
769
|
+
const a = this.canvas[e].getContext("2d");
|
|
770
|
+
if (!a)
|
|
444
771
|
return;
|
|
445
|
-
const { line:
|
|
446
|
-
let
|
|
447
|
-
if (
|
|
772
|
+
const { line: c = [], color: d = "black", duration: _ = 0, uuid: l } = n, u = R(n.move || {}, this.clientWidth, this.clientHeight);
|
|
773
|
+
let h = [u];
|
|
774
|
+
if (a.strokeStyle = d, a.beginPath(), a.moveTo(u.x, u.y), _ && !r) {
|
|
448
775
|
let p = [];
|
|
449
|
-
const
|
|
450
|
-
|
|
451
|
-
var
|
|
452
|
-
if (
|
|
453
|
-
return
|
|
454
|
-
const
|
|
455
|
-
if (!p.find((
|
|
456
|
-
if (p.push(
|
|
776
|
+
const f = this;
|
|
777
|
+
f.tween = Q({ step: 0 }, { step: c.length - 1 }, _).onUpdate(({ step: b }) => {
|
|
778
|
+
var k;
|
|
779
|
+
if (f.tweening = !0, !f.ready)
|
|
780
|
+
return a.clearRect(0, 0, f.canvas[l].width, f.canvas[l].height), (k = f.tween) == null ? void 0 : k.stop();
|
|
781
|
+
const x = Math.floor(b);
|
|
782
|
+
if (!p.find((B) => B === x)) {
|
|
783
|
+
if (p.push(x), console.log("__debug__", c, c[x], x), h.push(R(c[x], f.clientWidth, f.clientHeight)), h.length < 3)
|
|
457
784
|
return;
|
|
458
|
-
const { control:
|
|
459
|
-
if (!
|
|
785
|
+
const { control: B, end: O } = M(h);
|
|
786
|
+
if (!B || !O)
|
|
460
787
|
return;
|
|
461
|
-
|
|
788
|
+
a.quadraticCurveTo(B.x, B.y, O.x, O.y), a.stroke();
|
|
462
789
|
}
|
|
463
|
-
}).onComplete((
|
|
464
|
-
|
|
790
|
+
}).onComplete((b) => {
|
|
791
|
+
f.tween = void 0, f.tweening = !1, p = [], h = [], s && s(), o();
|
|
465
792
|
});
|
|
466
793
|
} else {
|
|
467
|
-
for (let p = 0; p <
|
|
468
|
-
if (
|
|
794
|
+
for (let p = 0; p < c.length; p++) {
|
|
795
|
+
if (h.push(R(c[p], this.clientWidth, this.clientHeight)), h.length < 3)
|
|
469
796
|
continue;
|
|
470
|
-
const { control:
|
|
471
|
-
!
|
|
797
|
+
const { control: f, end: b } = M(h);
|
|
798
|
+
!f || !b || a.quadraticCurveTo(f.x, f.y, b.x, b.y);
|
|
472
799
|
}
|
|
473
|
-
|
|
800
|
+
a.stroke(), h = [], s && s(), o();
|
|
474
801
|
}
|
|
475
802
|
})));
|
|
476
803
|
}
|
|
477
|
-
handleUndo(
|
|
478
|
-
if (console.log("handleUndo",
|
|
804
|
+
handleUndo(e) {
|
|
805
|
+
if (console.log("handleUndo", e, this.canvas[e]), !this.canvas[e] || !this.data[e] || this.data[e].length === 0)
|
|
479
806
|
return;
|
|
480
|
-
this.data[
|
|
481
|
-
const
|
|
482
|
-
var
|
|
483
|
-
const
|
|
484
|
-
|
|
807
|
+
this.data[e].pop();
|
|
808
|
+
const n = () => {
|
|
809
|
+
var s;
|
|
810
|
+
const r = (s = this.canvas[e]) == null ? void 0 : s.getContext("2d");
|
|
811
|
+
r && r.clearRect(0, 0, this.canvas[e].width, this.canvas[e].height), this.data[e].forEach((o) => this.handleDrawLine(e, o, { withUndo: !0 }));
|
|
485
812
|
};
|
|
486
813
|
if (this.tween && this.tweening) {
|
|
487
|
-
this.tween.stop(), D(
|
|
814
|
+
this.tween.stop(), D(n, 60);
|
|
488
815
|
return;
|
|
489
816
|
}
|
|
490
|
-
|
|
817
|
+
n();
|
|
491
818
|
}
|
|
492
819
|
destroyBrush() {
|
|
493
820
|
this.closeBrush(), this.ready = !1, this.emit("readyChange", !0);
|
|
494
821
|
}
|
|
495
822
|
}
|
|
496
|
-
class
|
|
497
|
-
constructor(
|
|
823
|
+
class et {
|
|
824
|
+
constructor(i = {}) {
|
|
498
825
|
g(this, "controller");
|
|
499
|
-
const
|
|
826
|
+
const e = Object.assign({
|
|
500
827
|
currentColor: "#f44336",
|
|
501
828
|
onUndoText: "\u56DE\u9000",
|
|
502
829
|
onExitText: "\u5173\u95ED"
|
|
503
|
-
},
|
|
504
|
-
this.controller = new
|
|
830
|
+
}, i);
|
|
831
|
+
this.controller = new V(e);
|
|
505
832
|
}
|
|
506
|
-
on(
|
|
507
|
-
this.controller.on(
|
|
833
|
+
on(i, e) {
|
|
834
|
+
this.controller.on(i, e);
|
|
508
835
|
}
|
|
509
|
-
off(
|
|
510
|
-
this.controller.off(
|
|
836
|
+
off(i, e) {
|
|
837
|
+
this.controller.off(i, e);
|
|
511
838
|
}
|
|
512
|
-
once(
|
|
513
|
-
this.controller.once(
|
|
839
|
+
once(i, e) {
|
|
840
|
+
this.controller.once(i, e);
|
|
514
841
|
}
|
|
515
842
|
show() {
|
|
516
843
|
this.controller.openBrush();
|
|
517
844
|
}
|
|
518
|
-
action(
|
|
519
|
-
this.controller.action(
|
|
845
|
+
action(i) {
|
|
846
|
+
this.controller.action(i);
|
|
520
847
|
}
|
|
521
848
|
get state() {
|
|
522
849
|
return this.controller.state;
|
|
@@ -527,11 +854,11 @@ class J {
|
|
|
527
854
|
dispose() {
|
|
528
855
|
return this.controller.destroyBrush();
|
|
529
856
|
}
|
|
530
|
-
setCurrentColor(
|
|
531
|
-
this.controller.updateCurrentColor(
|
|
857
|
+
setCurrentColor(i) {
|
|
858
|
+
this.controller.updateCurrentColor(i);
|
|
532
859
|
}
|
|
533
860
|
}
|
|
534
861
|
export {
|
|
535
|
-
|
|
536
|
-
|
|
862
|
+
et as PaintBrush,
|
|
863
|
+
w as PaintBrushTypeEnum
|
|
537
864
|
};
|