@idraw/renderer 0.4.0-beta.39 → 0.4.0-beta.40
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/esm/calculator.d.ts +43 -0
- package/dist/esm/calculator.js +168 -0
- package/dist/esm/draw/box.d.ts +3 -0
- package/dist/esm/draw/box.js +22 -17
- package/dist/esm/draw/circle.js +0 -2
- package/dist/esm/draw/layout.js +1 -1
- package/dist/esm/draw/text.js +16 -123
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +13 -3
- package/dist/esm/view-visible/index.d.ts +22 -0
- package/dist/esm/view-visible/index.js +63 -0
- package/dist/esm/virtual-flat/index.d.ts +7 -0
- package/dist/esm/virtual-flat/index.js +45 -0
- package/dist/esm/virtual-flat/text.d.ts +2 -0
- package/dist/esm/virtual-flat/text.js +151 -0
- package/dist/index.global.js +999 -198
- package/dist/index.global.min.js +1 -1
- package/package.json +4 -4
package/dist/index.global.js
CHANGED
|
@@ -8,22 +8,22 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
8
8
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
9
9
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
10
10
|
|
|
11
|
-
var _loadFuncMap, _currentLoadItemMap, _storageLoadItemMap, _hasDestroyed, _Loader_instances, registerLoadFunc_fn, getLoadElementSource_fn, createLoadItem_fn, emitLoad_fn, emitError_fn, loadResource_fn, isExistingErrorStorage_fn, _opts, _loader, _hasDestroyed2, _Renderer_instances, init_fn;
|
|
11
|
+
var _loadFuncMap, _currentLoadItemMap, _storageLoadItemMap, _hasDestroyed, _Loader_instances, registerLoadFunc_fn, getLoadElementSource_fn, createLoadItem_fn, emitLoad_fn, emitError_fn, loadResource_fn, isExistingErrorStorage_fn, _opts, _store, _opts2, _loader, _calculator, _hasDestroyed2, _Renderer_instances, init_fn;
|
|
12
12
|
function isColorStr(color2) {
|
|
13
|
-
return typeof color2 === "string" && (
|
|
13
|
+
return typeof color2 === "string" && (/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color2) || /^[a-z]{1,}$/i.test(color2));
|
|
14
14
|
}
|
|
15
15
|
function mergeHexColorAlpha(hex, alpha) {
|
|
16
16
|
if (alpha === 1) {
|
|
17
17
|
return hex;
|
|
18
18
|
}
|
|
19
19
|
let hexAlpha = 1;
|
|
20
|
-
const regHex1 =
|
|
21
|
-
const regHex2 =
|
|
20
|
+
const regHex1 = /^#[0-9a-f]{6,6}$/i;
|
|
21
|
+
const regHex2 = /^#[0-9a-f]{8,8}$/i;
|
|
22
22
|
let result = hex;
|
|
23
23
|
if (regHex1.test(hex)) {
|
|
24
|
-
hexAlpha = parseInt(hex.substring(5, 7).replace(
|
|
24
|
+
hexAlpha = parseInt(hex.substring(5, 7).replace(/^#/, "0x"));
|
|
25
25
|
} else if (regHex2.test(hex)) {
|
|
26
|
-
hexAlpha = parseInt(hex.substring(7, 9).replace(
|
|
26
|
+
hexAlpha = parseInt(hex.substring(7, 9).replace(/^#/, "0x"));
|
|
27
27
|
result = hex.substring(0, 7);
|
|
28
28
|
}
|
|
29
29
|
hexAlpha = hexAlpha * alpha;
|
|
@@ -64,6 +64,46 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
64
64
|
function isAssetId(id) {
|
|
65
65
|
return /^@assets\/[0-9a-z]{8,8}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{12,12}$/.test(`${id}`);
|
|
66
66
|
}
|
|
67
|
+
(function(s, e) {
|
|
68
|
+
var t = {};
|
|
69
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
70
|
+
t[p] = s[p];
|
|
71
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
72
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
73
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
74
|
+
t[p[i]] = s[p[i]];
|
|
75
|
+
}
|
|
76
|
+
return t;
|
|
77
|
+
});
|
|
78
|
+
function deepClone(target) {
|
|
79
|
+
function _clone(t) {
|
|
80
|
+
const type = is$1(t);
|
|
81
|
+
if (["Null", "Number", "String", "Boolean", "Undefined"].indexOf(type) >= 0) {
|
|
82
|
+
return t;
|
|
83
|
+
} else if (type === "Array") {
|
|
84
|
+
const arr = [];
|
|
85
|
+
t.forEach((item) => {
|
|
86
|
+
arr.push(_clone(item));
|
|
87
|
+
});
|
|
88
|
+
return arr;
|
|
89
|
+
} else if (type === "Object") {
|
|
90
|
+
const obj = {};
|
|
91
|
+
const keys = Object.keys(t);
|
|
92
|
+
keys.forEach((key) => {
|
|
93
|
+
obj[key] = _clone(t[key]);
|
|
94
|
+
});
|
|
95
|
+
const symbolKeys = Object.getOwnPropertySymbols(t);
|
|
96
|
+
symbolKeys.forEach((key) => {
|
|
97
|
+
obj[key] = _clone(t[key]);
|
|
98
|
+
});
|
|
99
|
+
return obj;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return _clone(target);
|
|
103
|
+
}
|
|
104
|
+
function is$1(target) {
|
|
105
|
+
return Object.prototype.toString.call(target).replace(/[\]|\[]{1,1}/gi, "").split(" ")[1];
|
|
106
|
+
}
|
|
67
107
|
function parsePrototype(data) {
|
|
68
108
|
const typeStr = Object.prototype.toString.call(data) || "";
|
|
69
109
|
const result = typeStr.replace(/(\[object|\])/gi, "").trim();
|
|
@@ -207,6 +247,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
207
247
|
return image;
|
|
208
248
|
});
|
|
209
249
|
}
|
|
250
|
+
function positiveNum(value) {
|
|
251
|
+
return typeof value === "number" && value >= 0;
|
|
252
|
+
}
|
|
210
253
|
function number(value) {
|
|
211
254
|
return typeof value === "number" && (value > 0 || value <= 0);
|
|
212
255
|
}
|
|
@@ -217,19 +260,19 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
217
260
|
return number(value);
|
|
218
261
|
}
|
|
219
262
|
function w(value) {
|
|
220
|
-
return
|
|
263
|
+
return positiveNum(value);
|
|
221
264
|
}
|
|
222
265
|
function h(value) {
|
|
223
|
-
return
|
|
266
|
+
return positiveNum(value);
|
|
224
267
|
}
|
|
225
268
|
function angle(value) {
|
|
226
269
|
return typeof value === "number" && value >= -360 && value <= 360;
|
|
227
270
|
}
|
|
228
271
|
function borderWidth(value) {
|
|
229
|
-
return
|
|
272
|
+
return positiveNum(value) || Array.isArray(value) && positiveNum(value[0]) && positiveNum(value[1]) && positiveNum(value[2]) && positiveNum(value[3]);
|
|
230
273
|
}
|
|
231
274
|
function borderRadius(value) {
|
|
232
|
-
return
|
|
275
|
+
return positiveNum(value) || Array.isArray(value) && positiveNum(value[0]) && positiveNum(value[1]) && positiveNum(value[2]) && positiveNum(value[3]);
|
|
233
276
|
}
|
|
234
277
|
function color(value) {
|
|
235
278
|
return isColorStr(value);
|
|
@@ -283,6 +326,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
283
326
|
return /^(-?\d+(?:\.\d+)?)$/.test(`${value}`);
|
|
284
327
|
}
|
|
285
328
|
const is = {
|
|
329
|
+
positiveNum,
|
|
286
330
|
x,
|
|
287
331
|
y,
|
|
288
332
|
w,
|
|
@@ -317,13 +361,13 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
317
361
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
318
362
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
319
363
|
});
|
|
320
|
-
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
|
|
364
|
+
var __classPrivateFieldSet$1 = function(receiver, state, value, kind, f) {
|
|
321
365
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
322
366
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
323
367
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
324
368
|
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
325
369
|
};
|
|
326
|
-
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
370
|
+
var __classPrivateFieldGet$1 = function(receiver, state, kind, f) {
|
|
327
371
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
328
372
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
329
373
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -332,20 +376,20 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
332
376
|
class EventEmitter {
|
|
333
377
|
constructor() {
|
|
334
378
|
_EventEmitter_listeners.set(this, void 0);
|
|
335
|
-
__classPrivateFieldSet(this, _EventEmitter_listeners, /* @__PURE__ */ new Map(), "f");
|
|
379
|
+
__classPrivateFieldSet$1(this, _EventEmitter_listeners, /* @__PURE__ */ new Map(), "f");
|
|
336
380
|
}
|
|
337
381
|
on(eventKey, callback) {
|
|
338
|
-
if (__classPrivateFieldGet(this, _EventEmitter_listeners, "f").has(eventKey)) {
|
|
339
|
-
const callbacks = __classPrivateFieldGet(this, _EventEmitter_listeners, "f").get(eventKey) || [];
|
|
382
|
+
if (__classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").has(eventKey)) {
|
|
383
|
+
const callbacks = __classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").get(eventKey) || [];
|
|
340
384
|
callbacks === null || callbacks === void 0 ? void 0 : callbacks.push(callback);
|
|
341
|
-
__classPrivateFieldGet(this, _EventEmitter_listeners, "f").set(eventKey, callbacks);
|
|
385
|
+
__classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").set(eventKey, callbacks);
|
|
342
386
|
} else {
|
|
343
|
-
__classPrivateFieldGet(this, _EventEmitter_listeners, "f").set(eventKey, [callback]);
|
|
387
|
+
__classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").set(eventKey, [callback]);
|
|
344
388
|
}
|
|
345
389
|
}
|
|
346
390
|
off(eventKey, callback) {
|
|
347
|
-
if (__classPrivateFieldGet(this, _EventEmitter_listeners, "f").has(eventKey)) {
|
|
348
|
-
const callbacks = __classPrivateFieldGet(this, _EventEmitter_listeners, "f").get(eventKey);
|
|
391
|
+
if (__classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").has(eventKey)) {
|
|
392
|
+
const callbacks = __classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").get(eventKey);
|
|
349
393
|
if (Array.isArray(callbacks)) {
|
|
350
394
|
for (let i = 0; i < (callbacks === null || callbacks === void 0 ? void 0 : callbacks.length); i++) {
|
|
351
395
|
if (callbacks[i] === callback) {
|
|
@@ -354,11 +398,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
354
398
|
}
|
|
355
399
|
}
|
|
356
400
|
}
|
|
357
|
-
__classPrivateFieldGet(this, _EventEmitter_listeners, "f").set(eventKey, callbacks || []);
|
|
401
|
+
__classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").set(eventKey, callbacks || []);
|
|
358
402
|
}
|
|
359
403
|
}
|
|
360
404
|
trigger(eventKey, e) {
|
|
361
|
-
const callbacks = __classPrivateFieldGet(this, _EventEmitter_listeners, "f").get(eventKey);
|
|
405
|
+
const callbacks = __classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").get(eventKey);
|
|
362
406
|
if (Array.isArray(callbacks)) {
|
|
363
407
|
callbacks.forEach((cb) => {
|
|
364
408
|
cb(e);
|
|
@@ -369,8 +413,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
369
413
|
}
|
|
370
414
|
}
|
|
371
415
|
has(name) {
|
|
372
|
-
if (__classPrivateFieldGet(this, _EventEmitter_listeners, "f").has(name)) {
|
|
373
|
-
const list = __classPrivateFieldGet(this, _EventEmitter_listeners, "f").get(name);
|
|
416
|
+
if (__classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").has(name)) {
|
|
417
|
+
const list = __classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").get(name);
|
|
374
418
|
if (Array.isArray(list) && list.length > 0) {
|
|
375
419
|
return true;
|
|
376
420
|
}
|
|
@@ -381,21 +425,71 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
381
425
|
this.clear();
|
|
382
426
|
}
|
|
383
427
|
clear() {
|
|
384
|
-
__classPrivateFieldGet(this, _EventEmitter_listeners, "f").clear();
|
|
428
|
+
__classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").clear();
|
|
385
429
|
}
|
|
386
430
|
}
|
|
387
431
|
_EventEmitter_listeners = /* @__PURE__ */ new WeakMap();
|
|
388
|
-
|
|
432
|
+
function calcDistance(start, end) {
|
|
433
|
+
const distance = (start.x - end.x) * (start.x - end.x) + (start.y - end.y) * (start.y - end.y);
|
|
434
|
+
return distance === 0 ? distance : Math.sqrt(distance);
|
|
435
|
+
}
|
|
436
|
+
function getCenterFromTwoPoints(p1, p2) {
|
|
437
|
+
return {
|
|
438
|
+
x: p1.x + (p2.x - p1.x) / 2,
|
|
439
|
+
y: p1.y + (p2.y - p1.y) / 2
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
|
|
389
443
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
390
444
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
391
445
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
392
446
|
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
393
|
-
}
|
|
394
|
-
|
|
447
|
+
};
|
|
448
|
+
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
395
449
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
396
450
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
397
451
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
398
|
-
}
|
|
452
|
+
};
|
|
453
|
+
var _Store_instances, _Store_temp, _Store_backUpDefaultStorage, _Store_static, _Store_createTempStorage;
|
|
454
|
+
class Store {
|
|
455
|
+
constructor(opts) {
|
|
456
|
+
_Store_instances.add(this);
|
|
457
|
+
_Store_temp.set(this, void 0);
|
|
458
|
+
_Store_backUpDefaultStorage.set(this, void 0);
|
|
459
|
+
_Store_static.set(this, void 0);
|
|
460
|
+
__classPrivateFieldSet(this, _Store_backUpDefaultStorage, deepClone(opts.defaultStorage), "f");
|
|
461
|
+
__classPrivateFieldSet(this, _Store_temp, __classPrivateFieldGet(this, _Store_instances, "m", _Store_createTempStorage).call(this), "f");
|
|
462
|
+
__classPrivateFieldSet(this, _Store_static, opts.defaultStatic || {}, "f");
|
|
463
|
+
}
|
|
464
|
+
set(name, value) {
|
|
465
|
+
__classPrivateFieldGet(this, _Store_temp, "f")[name] = value;
|
|
466
|
+
}
|
|
467
|
+
get(name) {
|
|
468
|
+
return __classPrivateFieldGet(this, _Store_temp, "f")[name];
|
|
469
|
+
}
|
|
470
|
+
setStatic(name, value) {
|
|
471
|
+
__classPrivateFieldGet(this, _Store_static, "f")[name] = value;
|
|
472
|
+
}
|
|
473
|
+
getStatic(name) {
|
|
474
|
+
return __classPrivateFieldGet(this, _Store_static, "f")[name];
|
|
475
|
+
}
|
|
476
|
+
getSnapshot(opts) {
|
|
477
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.deepClone) === true) {
|
|
478
|
+
return deepClone(__classPrivateFieldGet(this, _Store_temp, "f"));
|
|
479
|
+
}
|
|
480
|
+
return Object.assign({}, __classPrivateFieldGet(this, _Store_temp, "f"));
|
|
481
|
+
}
|
|
482
|
+
clear() {
|
|
483
|
+
__classPrivateFieldSet(this, _Store_temp, __classPrivateFieldGet(this, _Store_instances, "m", _Store_createTempStorage).call(this), "f");
|
|
484
|
+
}
|
|
485
|
+
destroy() {
|
|
486
|
+
__classPrivateFieldSet(this, _Store_temp, null, "f");
|
|
487
|
+
__classPrivateFieldSet(this, _Store_static, null, "f");
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
_Store_temp = /* @__PURE__ */ new WeakMap(), _Store_backUpDefaultStorage = /* @__PURE__ */ new WeakMap(), _Store_static = /* @__PURE__ */ new WeakMap(), _Store_instances = /* @__PURE__ */ new WeakSet(), _Store_createTempStorage = function _Store_createTempStorage2() {
|
|
491
|
+
return deepClone(__classPrivateFieldGet(this, _Store_backUpDefaultStorage, "f"));
|
|
492
|
+
};
|
|
399
493
|
function parseAngleToRadian(angle2) {
|
|
400
494
|
return angle2 / 180 * Math.PI;
|
|
401
495
|
}
|
|
@@ -426,6 +520,238 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
426
520
|
};
|
|
427
521
|
return p;
|
|
428
522
|
}
|
|
523
|
+
function calcElementCenterFromVertexes(ves) {
|
|
524
|
+
const startX = Math.min(ves[0].x, ves[1].x, ves[2].x, ves[3].x);
|
|
525
|
+
const startY = Math.min(ves[0].y, ves[1].y, ves[2].y, ves[3].y);
|
|
526
|
+
const endX = Math.max(ves[0].x, ves[1].x, ves[2].x, ves[3].x);
|
|
527
|
+
const endY = Math.max(ves[0].y, ves[1].y, ves[2].y, ves[3].y);
|
|
528
|
+
const elemSize = {
|
|
529
|
+
x: startX,
|
|
530
|
+
y: startY,
|
|
531
|
+
w: endX - startX,
|
|
532
|
+
h: endY - startY
|
|
533
|
+
};
|
|
534
|
+
return calcElementCenter(elemSize);
|
|
535
|
+
}
|
|
536
|
+
function calcLineRadian(center, p) {
|
|
537
|
+
const x2 = p.x - center.x;
|
|
538
|
+
const y2 = p.y - center.y;
|
|
539
|
+
if (x2 === 0) {
|
|
540
|
+
if (y2 < 0) {
|
|
541
|
+
return 0;
|
|
542
|
+
} else if (y2 > 0) {
|
|
543
|
+
return Math.PI;
|
|
544
|
+
}
|
|
545
|
+
} else if (y2 === 0) {
|
|
546
|
+
if (x2 < 0) {
|
|
547
|
+
return Math.PI * 3 / 2;
|
|
548
|
+
} else if (x2 > 0) {
|
|
549
|
+
return Math.PI / 2;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
if (x2 > 0 && y2 < 0) {
|
|
553
|
+
return Math.atan(Math.abs(x2) / Math.abs(y2));
|
|
554
|
+
} else if (x2 > 0 && y2 > 0) {
|
|
555
|
+
return Math.PI - Math.atan(Math.abs(x2) / Math.abs(y2));
|
|
556
|
+
} else if (x2 < 0 && y2 > 0) {
|
|
557
|
+
return Math.PI + Math.atan(Math.abs(x2) / Math.abs(y2));
|
|
558
|
+
} else if (x2 < 0 && y2 < 0) {
|
|
559
|
+
return 2 * Math.PI - Math.atan(Math.abs(x2) / Math.abs(y2));
|
|
560
|
+
}
|
|
561
|
+
return 0;
|
|
562
|
+
}
|
|
563
|
+
function rotatePoint(center, start, radian) {
|
|
564
|
+
const startRadian = calcLineRadian(center, start);
|
|
565
|
+
const rotateRadian = radian;
|
|
566
|
+
let endRadian = startRadian + rotateRadian;
|
|
567
|
+
if (endRadian > Math.PI * 2) {
|
|
568
|
+
endRadian = endRadian - Math.PI * 2;
|
|
569
|
+
} else if (endRadian < 0 - Math.PI * 2) {
|
|
570
|
+
endRadian = endRadian + Math.PI * 2;
|
|
571
|
+
}
|
|
572
|
+
if (endRadian < 0) {
|
|
573
|
+
endRadian = endRadian + Math.PI * 2;
|
|
574
|
+
}
|
|
575
|
+
const length = calcDistance(center, start);
|
|
576
|
+
let x2 = 0;
|
|
577
|
+
let y2 = 0;
|
|
578
|
+
if (endRadian === 0) {
|
|
579
|
+
x2 = 0;
|
|
580
|
+
y2 = 0 - length;
|
|
581
|
+
} else if (endRadian > 0 && endRadian < Math.PI / 2) {
|
|
582
|
+
x2 = Math.sin(endRadian) * length;
|
|
583
|
+
y2 = 0 - Math.cos(endRadian) * length;
|
|
584
|
+
} else if (endRadian === Math.PI / 2) {
|
|
585
|
+
x2 = length;
|
|
586
|
+
y2 = 0;
|
|
587
|
+
} else if (endRadian > Math.PI / 2 && endRadian < Math.PI) {
|
|
588
|
+
x2 = Math.sin(Math.PI - endRadian) * length;
|
|
589
|
+
y2 = Math.cos(Math.PI - endRadian) * length;
|
|
590
|
+
} else if (endRadian === Math.PI) {
|
|
591
|
+
x2 = 0;
|
|
592
|
+
y2 = length;
|
|
593
|
+
} else if (endRadian > Math.PI && endRadian < 3 / 2 * Math.PI) {
|
|
594
|
+
x2 = 0 - Math.sin(endRadian - Math.PI) * length;
|
|
595
|
+
y2 = Math.cos(endRadian - Math.PI) * length;
|
|
596
|
+
} else if (endRadian === 3 / 2 * Math.PI) {
|
|
597
|
+
x2 = 0 - length;
|
|
598
|
+
y2 = 0;
|
|
599
|
+
} else if (endRadian > 3 / 2 * Math.PI && endRadian < 2 * Math.PI) {
|
|
600
|
+
x2 = 0 - Math.sin(2 * Math.PI - endRadian) * length;
|
|
601
|
+
y2 = 0 - Math.cos(2 * Math.PI - endRadian) * length;
|
|
602
|
+
} else if (endRadian === 2 * Math.PI) {
|
|
603
|
+
x2 = 0;
|
|
604
|
+
y2 = 0 - length;
|
|
605
|
+
}
|
|
606
|
+
x2 += center.x;
|
|
607
|
+
y2 += center.y;
|
|
608
|
+
return { x: x2, y: y2 };
|
|
609
|
+
}
|
|
610
|
+
function getElementRotateVertexes(elemSize, center, angle2) {
|
|
611
|
+
const { x: x2, y: y2, w: w2, h: h2 } = elemSize;
|
|
612
|
+
let p1 = { x: x2, y: y2 };
|
|
613
|
+
let p2 = { x: x2 + w2, y: y2 };
|
|
614
|
+
let p3 = { x: x2 + w2, y: y2 + h2 };
|
|
615
|
+
let p4 = { x: x2, y: y2 + h2 };
|
|
616
|
+
if (angle2 && (angle2 > 0 || angle2 < 0)) {
|
|
617
|
+
const radian = parseAngleToRadian(limitAngle(angle2));
|
|
618
|
+
p1 = rotatePoint(center, p1, radian);
|
|
619
|
+
p2 = rotatePoint(center, p2, radian);
|
|
620
|
+
p3 = rotatePoint(center, p3, radian);
|
|
621
|
+
p4 = rotatePoint(center, p4, radian);
|
|
622
|
+
}
|
|
623
|
+
return [p1, p2, p3, p4];
|
|
624
|
+
}
|
|
625
|
+
function rotateElementVertexes(elemSize) {
|
|
626
|
+
const { angle: angle2 = 0 } = elemSize;
|
|
627
|
+
const center = calcElementCenter(elemSize);
|
|
628
|
+
return getElementRotateVertexes(elemSize, center, angle2);
|
|
629
|
+
}
|
|
630
|
+
function rotateVertexes(center, ves, radian) {
|
|
631
|
+
return [
|
|
632
|
+
rotatePoint(center, { x: ves[0].x, y: ves[0].y }, radian),
|
|
633
|
+
rotatePoint(center, { x: ves[1].x, y: ves[1].y }, radian),
|
|
634
|
+
rotatePoint(center, { x: ves[2].x, y: ves[2].y }, radian),
|
|
635
|
+
rotatePoint(center, { x: ves[3].x, y: ves[3].y }, radian)
|
|
636
|
+
];
|
|
637
|
+
}
|
|
638
|
+
function limitAngle(angle2) {
|
|
639
|
+
if (!(angle2 > 0 || angle2 < 0) || angle2 === 0 || angle2 === 360) {
|
|
640
|
+
return 0;
|
|
641
|
+
}
|
|
642
|
+
let num = angle2 % 360;
|
|
643
|
+
if (num < 0) {
|
|
644
|
+
num += 360;
|
|
645
|
+
} else if (angle2 === 360) {
|
|
646
|
+
num = 0;
|
|
647
|
+
}
|
|
648
|
+
return num;
|
|
649
|
+
}
|
|
650
|
+
function getGroupQueueByElementPosition(elements, position) {
|
|
651
|
+
var _a;
|
|
652
|
+
const groupQueue = [];
|
|
653
|
+
let currentElements = elements;
|
|
654
|
+
if (position.length > 1) {
|
|
655
|
+
for (let i = 0; i < position.length - 1; i++) {
|
|
656
|
+
const index = position[i];
|
|
657
|
+
const group = currentElements[index];
|
|
658
|
+
if ((group === null || group === void 0 ? void 0 : group.type) === "group" && Array.isArray((_a = group === null || group === void 0 ? void 0 : group.detail) === null || _a === void 0 ? void 0 : _a.children)) {
|
|
659
|
+
groupQueue.push(group);
|
|
660
|
+
currentElements = group.detail.children;
|
|
661
|
+
} else {
|
|
662
|
+
return null;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
return groupQueue;
|
|
667
|
+
}
|
|
668
|
+
function findElementFromListByPosition(position, list) {
|
|
669
|
+
let result = null;
|
|
670
|
+
let tempList = list;
|
|
671
|
+
for (let i = 0; i < position.length; i++) {
|
|
672
|
+
const pos = position[i];
|
|
673
|
+
const item = tempList[pos];
|
|
674
|
+
if (i < position.length - 1 && item.type === "group") {
|
|
675
|
+
tempList = item.detail.children;
|
|
676
|
+
} else if (i === position.length - 1) {
|
|
677
|
+
result = item;
|
|
678
|
+
} else {
|
|
679
|
+
break;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
return result;
|
|
683
|
+
}
|
|
684
|
+
function getElementVertexes(elemSize) {
|
|
685
|
+
const { x: x2, y: y2, h: h2, w: w2 } = elemSize;
|
|
686
|
+
return [
|
|
687
|
+
{ x: x2, y: y2 },
|
|
688
|
+
{ x: x2 + w2, y: y2 },
|
|
689
|
+
{ x: x2 + w2, y: y2 + h2 },
|
|
690
|
+
{ x: x2, y: y2 + h2 }
|
|
691
|
+
];
|
|
692
|
+
}
|
|
693
|
+
function calcElementVertexes(elemSize) {
|
|
694
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = elemSize;
|
|
695
|
+
if (angle2 === 0) {
|
|
696
|
+
return getElementVertexes(elemSize);
|
|
697
|
+
}
|
|
698
|
+
return getElementRotateVertexes(elemSize, calcElementCenter({ x: x2, y: y2, w: w2, h: h2 }), angle2);
|
|
699
|
+
}
|
|
700
|
+
function calcElementQueueVertexesQueueInGroup(groupQueue) {
|
|
701
|
+
const vesList = [];
|
|
702
|
+
let totalX = 0;
|
|
703
|
+
let totalY = 0;
|
|
704
|
+
const rotateActionList = [];
|
|
705
|
+
const elemQueue = [...groupQueue];
|
|
706
|
+
for (let i = 0; i < elemQueue.length; i++) {
|
|
707
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = elemQueue[i];
|
|
708
|
+
totalX += x2;
|
|
709
|
+
totalY += y2;
|
|
710
|
+
let ves;
|
|
711
|
+
if (i === 0) {
|
|
712
|
+
const elemSize = { x: totalX, y: totalY, w: w2, h: h2 };
|
|
713
|
+
ves = calcElementVertexes({ x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
714
|
+
rotateActionList.push({
|
|
715
|
+
center: calcElementCenter(elemSize),
|
|
716
|
+
angle: angle2,
|
|
717
|
+
radian: parseAngleToRadian(angle2)
|
|
718
|
+
});
|
|
719
|
+
} else {
|
|
720
|
+
const elemSize = { x: totalX, y: totalY, w: w2, h: h2 };
|
|
721
|
+
ves = getElementVertexes(elemSize);
|
|
722
|
+
for (let aIdx = 0; aIdx < rotateActionList.length; aIdx++) {
|
|
723
|
+
const { center, radian } = rotateActionList[aIdx];
|
|
724
|
+
ves = rotateVertexes(center, ves, radian);
|
|
725
|
+
}
|
|
726
|
+
const vesCenter = calcElementCenterFromVertexes(ves);
|
|
727
|
+
if (angle2 > 0 || angle2 < 0) {
|
|
728
|
+
const radian = parseAngleToRadian(angle2);
|
|
729
|
+
ves = rotateVertexes(vesCenter, ves, radian);
|
|
730
|
+
}
|
|
731
|
+
rotateActionList.push({
|
|
732
|
+
center: vesCenter,
|
|
733
|
+
angle: angle2,
|
|
734
|
+
radian: parseAngleToRadian(angle2)
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
vesList.push(ves);
|
|
738
|
+
}
|
|
739
|
+
return vesList;
|
|
740
|
+
}
|
|
741
|
+
function calcElementVertexesQueueInGroup(targetElem, opts) {
|
|
742
|
+
const { groupQueue } = opts;
|
|
743
|
+
if (!(groupQueue.length > 0)) {
|
|
744
|
+
return [calcElementVertexes(targetElem)];
|
|
745
|
+
}
|
|
746
|
+
const elemQueue = [...groupQueue, ...[targetElem]];
|
|
747
|
+
const vesList = calcElementQueueVertexesQueueInGroup(elemQueue);
|
|
748
|
+
return vesList;
|
|
749
|
+
}
|
|
750
|
+
function calcElementVertexesInGroup(targetElem, opts) {
|
|
751
|
+
const vesList = calcElementVertexesQueueInGroup(targetElem, opts);
|
|
752
|
+
const ves = vesList.pop();
|
|
753
|
+
return ves || null;
|
|
754
|
+
}
|
|
429
755
|
function calcViewElementSize(size, opts) {
|
|
430
756
|
const { viewScaleInfo } = opts;
|
|
431
757
|
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = size;
|
|
@@ -439,6 +765,159 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
439
765
|
};
|
|
440
766
|
return newSize;
|
|
441
767
|
}
|
|
768
|
+
function calcViewPointSize(size, opts) {
|
|
769
|
+
const { viewScaleInfo } = opts;
|
|
770
|
+
const { x: x2, y: y2 } = size;
|
|
771
|
+
const { scale, offsetTop, offsetLeft } = viewScaleInfo;
|
|
772
|
+
const newSize = {
|
|
773
|
+
x: x2 * scale + offsetLeft,
|
|
774
|
+
y: y2 * scale + offsetTop
|
|
775
|
+
};
|
|
776
|
+
return newSize;
|
|
777
|
+
}
|
|
778
|
+
function isViewPointInElement(p, opts) {
|
|
779
|
+
const { context2d: ctx, element: elem, viewScaleInfo } = opts;
|
|
780
|
+
const { angle: angle2 = 0 } = elem;
|
|
781
|
+
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo });
|
|
782
|
+
const vertexes = rotateElementVertexes({ x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
783
|
+
if (vertexes.length >= 2) {
|
|
784
|
+
ctx.beginPath();
|
|
785
|
+
ctx.moveTo(vertexes[0].x, vertexes[0].y);
|
|
786
|
+
for (let i = 1; i < vertexes.length; i++) {
|
|
787
|
+
ctx.lineTo(vertexes[i].x, vertexes[i].y);
|
|
788
|
+
}
|
|
789
|
+
ctx.closePath();
|
|
790
|
+
}
|
|
791
|
+
if (ctx.isPointInPath(p.x, p.y)) {
|
|
792
|
+
return true;
|
|
793
|
+
}
|
|
794
|
+
return false;
|
|
795
|
+
}
|
|
796
|
+
function getViewPointAtElement(p, opts) {
|
|
797
|
+
var _a, _b, _c;
|
|
798
|
+
const { context2d: ctx, data, viewScaleInfo, groupQueue } = opts;
|
|
799
|
+
const result = {
|
|
800
|
+
index: -1,
|
|
801
|
+
element: null,
|
|
802
|
+
groupQueueIndex: -1
|
|
803
|
+
};
|
|
804
|
+
if (groupQueue && Array.isArray(groupQueue) && (groupQueue === null || groupQueue === void 0 ? void 0 : groupQueue.length) > 0) {
|
|
805
|
+
for (let gIdx = groupQueue.length - 1; gIdx >= 0; gIdx--) {
|
|
806
|
+
let totalX = 0;
|
|
807
|
+
let totalY = 0;
|
|
808
|
+
let totalAngle = 0;
|
|
809
|
+
for (let i = 0; i <= gIdx; i++) {
|
|
810
|
+
totalX += groupQueue[i].x;
|
|
811
|
+
totalY += groupQueue[i].y;
|
|
812
|
+
totalAngle += groupQueue[i].angle || 0;
|
|
813
|
+
}
|
|
814
|
+
const lastGroup = groupQueue[gIdx];
|
|
815
|
+
if (lastGroup && lastGroup.type === "group" && Array.isArray((_a = lastGroup.detail) === null || _a === void 0 ? void 0 : _a.children)) {
|
|
816
|
+
for (let i = 0; i < lastGroup.detail.children.length; i++) {
|
|
817
|
+
const child = lastGroup.detail.children[i];
|
|
818
|
+
if (((_b = child === null || child === void 0 ? void 0 : child.operations) === null || _b === void 0 ? void 0 : _b.invisible) === true) {
|
|
819
|
+
continue;
|
|
820
|
+
}
|
|
821
|
+
if (child) {
|
|
822
|
+
const elemSize = {
|
|
823
|
+
x: totalX + child.x,
|
|
824
|
+
y: totalY + child.y,
|
|
825
|
+
w: child.w,
|
|
826
|
+
h: child.h,
|
|
827
|
+
angle: totalAngle + (child.angle || 0)
|
|
828
|
+
};
|
|
829
|
+
if (isViewPointInElement(p, { context2d: ctx, element: elemSize, viewScaleInfo })) {
|
|
830
|
+
result.element = child;
|
|
831
|
+
if (gIdx < groupQueue.length - 1 || child.type !== "group") {
|
|
832
|
+
result.groupQueueIndex = gIdx;
|
|
833
|
+
}
|
|
834
|
+
break;
|
|
835
|
+
}
|
|
836
|
+
} else {
|
|
837
|
+
break;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
if (result.element) {
|
|
842
|
+
break;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
if (result.element) {
|
|
847
|
+
return result;
|
|
848
|
+
}
|
|
849
|
+
for (let i = data.elements.length - 1; i >= 0; i--) {
|
|
850
|
+
const elem = data.elements[i];
|
|
851
|
+
if (((_c = elem === null || elem === void 0 ? void 0 : elem.operations) === null || _c === void 0 ? void 0 : _c.invisible) === true) {
|
|
852
|
+
continue;
|
|
853
|
+
}
|
|
854
|
+
if (isViewPointInElement(p, { context2d: ctx, element: elem, viewScaleInfo })) {
|
|
855
|
+
result.index = i;
|
|
856
|
+
result.element = elem;
|
|
857
|
+
break;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
return result;
|
|
861
|
+
}
|
|
862
|
+
function calcElementOriginRectInfo(elemSize, opts) {
|
|
863
|
+
const { groupQueue } = opts;
|
|
864
|
+
const vertexes = calcElementVertexesInGroup(elemSize, { groupQueue });
|
|
865
|
+
const top = getCenterFromTwoPoints(vertexes[0], vertexes[1]);
|
|
866
|
+
const right = getCenterFromTwoPoints(vertexes[1], vertexes[2]);
|
|
867
|
+
const bottom = getCenterFromTwoPoints(vertexes[2], vertexes[3]);
|
|
868
|
+
const left = getCenterFromTwoPoints(vertexes[3], vertexes[0]);
|
|
869
|
+
const topLeft = vertexes[0];
|
|
870
|
+
const topRight = vertexes[1];
|
|
871
|
+
const bottomRight = vertexes[2];
|
|
872
|
+
const bottomLeft = vertexes[3];
|
|
873
|
+
const maxX = Math.max(topLeft.x, topRight.x, bottomRight.x, bottomLeft.x);
|
|
874
|
+
const maxY = Math.max(topLeft.y, topRight.y, bottomRight.y, bottomLeft.y);
|
|
875
|
+
const minX = Math.min(topLeft.x, topRight.x, bottomRight.x, bottomLeft.x);
|
|
876
|
+
const minY = Math.min(topLeft.y, topRight.y, bottomRight.y, bottomLeft.y);
|
|
877
|
+
const center = {
|
|
878
|
+
x: (maxX + minX) / 2,
|
|
879
|
+
y: (maxY + minY) / 2
|
|
880
|
+
};
|
|
881
|
+
const rectInfo = {
|
|
882
|
+
center,
|
|
883
|
+
topLeft,
|
|
884
|
+
topRight,
|
|
885
|
+
bottomLeft,
|
|
886
|
+
bottomRight,
|
|
887
|
+
top,
|
|
888
|
+
right,
|
|
889
|
+
left,
|
|
890
|
+
bottom
|
|
891
|
+
};
|
|
892
|
+
return rectInfo;
|
|
893
|
+
}
|
|
894
|
+
function originRectInfoToRangeRectInfo(originRectInfo) {
|
|
895
|
+
const rangeMaxX = Math.max(originRectInfo.topLeft.x, originRectInfo.topRight.x, originRectInfo.bottomRight.x, originRectInfo.bottomLeft.x);
|
|
896
|
+
const rangeMaxY = Math.max(originRectInfo.topLeft.y, originRectInfo.topRight.y, originRectInfo.bottomRight.y, originRectInfo.bottomLeft.y);
|
|
897
|
+
const rangeMinX = Math.min(originRectInfo.topLeft.x, originRectInfo.topRight.x, originRectInfo.bottomRight.x, originRectInfo.bottomLeft.x);
|
|
898
|
+
const rangeMinY = Math.min(originRectInfo.topLeft.y, originRectInfo.topRight.y, originRectInfo.bottomRight.y, originRectInfo.bottomLeft.y);
|
|
899
|
+
const rangeCenter = { x: originRectInfo.center.x, y: originRectInfo.center.y };
|
|
900
|
+
const rangeTopLeft = { x: rangeMinX, y: rangeMinY };
|
|
901
|
+
const rangeTopRight = { x: rangeMaxX, y: rangeMinY };
|
|
902
|
+
const rangeBottomRight = { x: rangeMaxX, y: rangeMaxY };
|
|
903
|
+
const rangeBottomLeft = { x: rangeMinX, y: rangeMaxY };
|
|
904
|
+
const rangeTop = getCenterFromTwoPoints(rangeTopLeft, rangeTopRight);
|
|
905
|
+
const rangeBottom = getCenterFromTwoPoints(rangeBottomLeft, rangeBottomRight);
|
|
906
|
+
const rangeLeft = getCenterFromTwoPoints(rangeTopLeft, rangeBottomLeft);
|
|
907
|
+
const rangeRight = getCenterFromTwoPoints(rangeTopRight, rangeBottomRight);
|
|
908
|
+
const rangeRectInfo = {
|
|
909
|
+
center: rangeCenter,
|
|
910
|
+
topLeft: rangeTopLeft,
|
|
911
|
+
topRight: rangeTopRight,
|
|
912
|
+
bottomLeft: rangeBottomLeft,
|
|
913
|
+
bottomRight: rangeBottomRight,
|
|
914
|
+
top: rangeTop,
|
|
915
|
+
right: rangeRight,
|
|
916
|
+
left: rangeLeft,
|
|
917
|
+
bottom: rangeBottom
|
|
918
|
+
};
|
|
919
|
+
return rangeRectInfo;
|
|
920
|
+
}
|
|
442
921
|
function generateSVGPath(commands) {
|
|
443
922
|
let path = "";
|
|
444
923
|
commands.forEach((item) => {
|
|
@@ -474,7 +953,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
474
953
|
function calcViewBoxSize(viewElem, opts) {
|
|
475
954
|
const { viewScaleInfo } = opts;
|
|
476
955
|
const { scale } = viewScaleInfo;
|
|
477
|
-
let { borderRadius: borderRadius2
|
|
956
|
+
let { borderRadius: borderRadius2 } = viewElem.detail;
|
|
957
|
+
const { borderDash } = viewElem.detail;
|
|
478
958
|
const hasBorderDash = Array.isArray(borderDash) && borderDash.length > 0;
|
|
479
959
|
const { boxSizing = defaultElemConfig$1.boxSizing, borderWidth: borderWidth2 } = viewElem.detail;
|
|
480
960
|
if (Array.isArray(borderWidth2)) {
|
|
@@ -597,14 +1077,13 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
597
1077
|
ctx.globalAlpha = opacity;
|
|
598
1078
|
drawBoxBackground(ctx, viewElem, { pattern, viewScaleInfo, viewSizeInfo });
|
|
599
1079
|
renderContent == null ? void 0 : renderContent();
|
|
600
|
-
drawBoxBorder(ctx, viewElem, { viewScaleInfo
|
|
1080
|
+
drawBoxBorder(ctx, viewElem, { viewScaleInfo });
|
|
601
1081
|
ctx.globalAlpha = parentOpacity;
|
|
602
1082
|
};
|
|
603
1083
|
if (clipPath) {
|
|
604
1084
|
drawClipPath(ctx, viewElem, {
|
|
605
1085
|
originElem,
|
|
606
1086
|
calcElemSize,
|
|
607
|
-
viewScaleInfo,
|
|
608
1087
|
viewSizeInfo,
|
|
609
1088
|
renderContent: () => {
|
|
610
1089
|
mainRender();
|
|
@@ -614,7 +1093,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
614
1093
|
drawClipPathStroke(ctx, viewElem, {
|
|
615
1094
|
originElem,
|
|
616
1095
|
calcElemSize,
|
|
617
|
-
viewScaleInfo,
|
|
618
1096
|
viewSizeInfo,
|
|
619
1097
|
parentOpacity
|
|
620
1098
|
});
|
|
@@ -690,8 +1168,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
690
1168
|
const transform = [];
|
|
691
1169
|
if (viewElem.detail.background || pattern) {
|
|
692
1170
|
const { x: x2, y: y2, w: w2, h: h2, radiusList } = calcViewBoxSize(viewElem, {
|
|
693
|
-
viewScaleInfo
|
|
694
|
-
viewSizeInfo
|
|
1171
|
+
viewScaleInfo
|
|
695
1172
|
});
|
|
696
1173
|
ctx.beginPath();
|
|
697
1174
|
ctx.moveTo(x2 + radiusList[0], y2);
|
|
@@ -752,12 +1229,16 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
752
1229
|
if (isColorStr(viewElem.detail.borderColor) === true) {
|
|
753
1230
|
borderColor = viewElem.detail.borderColor;
|
|
754
1231
|
}
|
|
755
|
-
const { borderWidth: borderWidth2, borderRadius: borderRadius2,
|
|
756
|
-
let
|
|
757
|
-
if (
|
|
758
|
-
|
|
1232
|
+
const { borderDash, borderWidth: borderWidth2, borderRadius: borderRadius2, boxSizing = defaultElemConfig.boxSizing } = viewElem.detail;
|
|
1233
|
+
let viewBorderDash = [];
|
|
1234
|
+
if (Array.isArray(borderDash) && borderDash.length > 0) {
|
|
1235
|
+
viewBorderDash = borderDash.map((num) => Math.ceil(num * scale));
|
|
1236
|
+
}
|
|
1237
|
+
if (viewBorderDash.length > 0) {
|
|
1238
|
+
ctx.lineCap = "butt";
|
|
1239
|
+
} else {
|
|
1240
|
+
ctx.lineCap = "square";
|
|
759
1241
|
}
|
|
760
|
-
bw = bw * scale;
|
|
761
1242
|
let radiusList = [0, 0, 0, 0];
|
|
762
1243
|
if (typeof borderRadius2 === "number") {
|
|
763
1244
|
const br = borderRadius2 * scale;
|
|
@@ -765,11 +1246,12 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
765
1246
|
} else if (Array.isArray(borderRadius2) && (borderRadius2 == null ? void 0 : borderRadius2.length) === 4) {
|
|
766
1247
|
radiusList = [borderRadius2[0] * scale, borderRadius2[1] * scale, borderRadius2[2] * scale, borderRadius2[3] * scale];
|
|
767
1248
|
}
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
viewBorderDash = borderDash.map((num) => Math.ceil(num * scale));
|
|
1249
|
+
let bw = 0;
|
|
1250
|
+
if (typeof borderWidth2 === "number") {
|
|
1251
|
+
bw = borderWidth2 || 1;
|
|
772
1252
|
}
|
|
1253
|
+
bw = bw * scale;
|
|
1254
|
+
ctx.strokeStyle = borderColor;
|
|
773
1255
|
let borderTop = 0;
|
|
774
1256
|
let borderRight = 0;
|
|
775
1257
|
let borderBottom = 0;
|
|
@@ -849,11 +1331,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
849
1331
|
w2 = viewElem.w;
|
|
850
1332
|
h2 = viewElem.h;
|
|
851
1333
|
}
|
|
852
|
-
if (viewBorderDash.length > 0) {
|
|
853
|
-
ctx.lineCap = "butt";
|
|
854
|
-
} else {
|
|
855
|
-
ctx.lineCap = "square";
|
|
856
|
-
}
|
|
857
1334
|
w2 = Math.max(w2, 1);
|
|
858
1335
|
h2 = Math.max(h2, 1);
|
|
859
1336
|
radiusList = radiusList.map((r) => {
|
|
@@ -910,7 +1387,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
910
1387
|
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
911
1388
|
drawBoxShadow(ctx, viewElem, {
|
|
912
1389
|
viewScaleInfo,
|
|
913
|
-
viewSizeInfo,
|
|
914
1390
|
renderContent: () => {
|
|
915
1391
|
let a = w2 / 2;
|
|
916
1392
|
let b = h2 / 2;
|
|
@@ -919,10 +1395,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
919
1395
|
const radiusA = a;
|
|
920
1396
|
const radiusB = b;
|
|
921
1397
|
if (bw > 0) {
|
|
922
|
-
if (boxSizing === "content-box")
|
|
923
|
-
|
|
924
|
-
b = b;
|
|
925
|
-
} else if (boxSizing === "center-line") {
|
|
1398
|
+
if (boxSizing === "content-box") ;
|
|
1399
|
+
else if (boxSizing === "center-line") {
|
|
926
1400
|
a = a - bw / 2;
|
|
927
1401
|
b = b - bw / 2;
|
|
928
1402
|
} else {
|
|
@@ -971,7 +1445,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
971
1445
|
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
972
1446
|
drawBoxShadow(ctx, viewElem, {
|
|
973
1447
|
viewScaleInfo,
|
|
974
|
-
viewSizeInfo,
|
|
975
1448
|
renderContent: () => {
|
|
976
1449
|
drawBox(ctx, viewElem, {
|
|
977
1450
|
originElem: elem,
|
|
@@ -994,7 +1467,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
994
1467
|
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
995
1468
|
drawBoxShadow(ctx, viewElem, {
|
|
996
1469
|
viewScaleInfo,
|
|
997
|
-
viewSizeInfo,
|
|
998
1470
|
renderContent: () => {
|
|
999
1471
|
drawBox(ctx, viewElem, {
|
|
1000
1472
|
originElem: elem,
|
|
@@ -1009,8 +1481,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1009
1481
|
if (elem.type === "image" && content) {
|
|
1010
1482
|
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
1011
1483
|
const { x: x22, y: y22, w: w22, h: h22, radiusList } = calcViewBoxSize(viewElem, {
|
|
1012
|
-
viewScaleInfo
|
|
1013
|
-
viewSizeInfo
|
|
1484
|
+
viewScaleInfo
|
|
1014
1485
|
});
|
|
1015
1486
|
const { detail } = elem;
|
|
1016
1487
|
const { scaleMode, originW = 0, originH = 0 } = detail;
|
|
@@ -1074,7 +1545,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1074
1545
|
function drawSVG(ctx, elem, opts) {
|
|
1075
1546
|
const content = opts.loader.getContent(elem);
|
|
1076
1547
|
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
1077
|
-
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo
|
|
1548
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
|
|
1078
1549
|
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
1079
1550
|
if (!content && !opts.loader.isDestroyed()) {
|
|
1080
1551
|
opts.loader.load(elem, opts.elementAssets || {});
|
|
@@ -1089,7 +1560,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1089
1560
|
function drawHTML(ctx, elem, opts) {
|
|
1090
1561
|
const content = opts.loader.getContent(elem);
|
|
1091
1562
|
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
1092
|
-
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo
|
|
1563
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
|
|
1093
1564
|
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
1094
1565
|
if (!content && !opts.loader.isDestroyed()) {
|
|
1095
1566
|
opts.loader.load(elem, opts.elementAssets || {});
|
|
@@ -1101,23 +1572,15 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1101
1572
|
}
|
|
1102
1573
|
});
|
|
1103
1574
|
}
|
|
1104
|
-
const detailConfig = getDefaultElementDetailConfig();
|
|
1105
|
-
function isTextWidthWithinErrorRange(w0, w1, scale) {
|
|
1106
|
-
if (scale < 0.5) {
|
|
1107
|
-
if (w0 < w1 && (w0 - w1) / w0 > -0.15) {
|
|
1108
|
-
return true;
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
return w0 >= w1;
|
|
1112
|
-
}
|
|
1575
|
+
const detailConfig$1 = getDefaultElementDetailConfig();
|
|
1113
1576
|
function drawText(ctx, elem, opts) {
|
|
1114
|
-
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
1577
|
+
const { viewScaleInfo, viewSizeInfo, parentOpacity, calculator } = opts;
|
|
1115
1578
|
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
|
|
1116
1579
|
const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
|
|
1117
1580
|
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
1581
|
+
var _a, _b;
|
|
1118
1582
|
drawBoxShadow(ctx, viewElem, {
|
|
1119
1583
|
viewScaleInfo,
|
|
1120
|
-
viewSizeInfo,
|
|
1121
1584
|
renderContent: () => {
|
|
1122
1585
|
drawBox(ctx, viewElem, {
|
|
1123
1586
|
originElem: elem,
|
|
@@ -1130,132 +1593,40 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1130
1593
|
});
|
|
1131
1594
|
{
|
|
1132
1595
|
const detail = {
|
|
1133
|
-
...detailConfig,
|
|
1596
|
+
...detailConfig$1,
|
|
1134
1597
|
...elem.detail
|
|
1135
1598
|
};
|
|
1136
|
-
const originFontSize = detail.fontSize || detailConfig.fontSize;
|
|
1599
|
+
const originFontSize = detail.fontSize || detailConfig$1.fontSize;
|
|
1137
1600
|
const fontSize2 = originFontSize * viewScaleInfo.scale;
|
|
1138
1601
|
if (fontSize2 < 2) {
|
|
1139
1602
|
return;
|
|
1140
1603
|
}
|
|
1141
|
-
|
|
1142
|
-
const lineHeight2 = originLineHeight * viewScaleInfo.scale;
|
|
1143
|
-
ctx.fillStyle = elem.detail.color || detailConfig.color;
|
|
1604
|
+
ctx.fillStyle = elem.detail.color || detailConfig$1.color;
|
|
1144
1605
|
ctx.textBaseline = "top";
|
|
1145
1606
|
ctx.$setFont({
|
|
1146
1607
|
fontWeight: detail.fontWeight,
|
|
1147
1608
|
fontSize: fontSize2,
|
|
1148
1609
|
fontFamily: enhanceFontFamliy(detail.fontFamily)
|
|
1149
1610
|
});
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
}
|
|
1156
|
-
const fontHeight = lineHeight2;
|
|
1157
|
-
const detailTextList = detailText.split("\n");
|
|
1158
|
-
const lines = [];
|
|
1159
|
-
let lineNum = 0;
|
|
1160
|
-
detailTextList.forEach((itemText, idx) => {
|
|
1161
|
-
if (detail.minInlineSize === "maxContent") {
|
|
1162
|
-
lines.push({
|
|
1163
|
-
text: itemText,
|
|
1164
|
-
width: ctx.$undoPixelRatio(ctx.measureText(itemText).width)
|
|
1165
|
-
});
|
|
1166
|
-
} else {
|
|
1167
|
-
let lineText = "";
|
|
1168
|
-
let splitStr = "";
|
|
1169
|
-
let tempStrList = itemText.split(splitStr);
|
|
1170
|
-
if (detail.wordBreak === "normal") {
|
|
1171
|
-
const splitStr2 = " ";
|
|
1172
|
-
const wordList = itemText.split(splitStr2);
|
|
1173
|
-
tempStrList = [];
|
|
1174
|
-
wordList.forEach((word, idx2) => {
|
|
1175
|
-
tempStrList.push(word);
|
|
1176
|
-
if (idx2 < wordList.length - 1) {
|
|
1177
|
-
tempStrList.push(splitStr2);
|
|
1178
|
-
}
|
|
1179
|
-
});
|
|
1611
|
+
{
|
|
1612
|
+
const virtualTextDetail = calculator.getVirtualFlatItem(elem.uuid);
|
|
1613
|
+
if (Array.isArray(virtualTextDetail == null ? void 0 : virtualTextDetail.textLines) && ((_a = virtualTextDetail == null ? void 0 : virtualTextDetail.textLines) == null ? void 0 : _a.length) > 0) {
|
|
1614
|
+
if (detail.textShadowColor !== void 0 && isColorStr(detail.textShadowColor)) {
|
|
1615
|
+
ctx.shadowColor = detail.textShadowColor;
|
|
1180
1616
|
}
|
|
1181
|
-
if (
|
|
1182
|
-
|
|
1183
|
-
text: tempStrList[0],
|
|
1184
|
-
width: ctx.$undoPixelRatio(ctx.measureText(tempStrList[0]).width)
|
|
1185
|
-
});
|
|
1186
|
-
} else if (tempStrList.length > 0) {
|
|
1187
|
-
for (let i = 0; i < tempStrList.length; i++) {
|
|
1188
|
-
if (isTextWidthWithinErrorRange(ctx.$doPixelRatio(w2), ctx.measureText(lineText + tempStrList[i]).width, viewScaleInfo.scale)) {
|
|
1189
|
-
lineText += tempStrList[i] || "";
|
|
1190
|
-
} else {
|
|
1191
|
-
lines.push({
|
|
1192
|
-
text: lineText,
|
|
1193
|
-
width: ctx.$undoPixelRatio(ctx.measureText(lineText).width)
|
|
1194
|
-
});
|
|
1195
|
-
lineText = tempStrList[i] || "";
|
|
1196
|
-
lineNum++;
|
|
1197
|
-
}
|
|
1198
|
-
if ((lineNum + 1) * fontHeight > h2 && detail.overflow === "hidden") {
|
|
1199
|
-
break;
|
|
1200
|
-
}
|
|
1201
|
-
if (tempStrList.length - 1 === i) {
|
|
1202
|
-
if ((lineNum + 1) * fontHeight <= h2) {
|
|
1203
|
-
lines.push({
|
|
1204
|
-
text: lineText,
|
|
1205
|
-
width: ctx.$undoPixelRatio(ctx.measureText(lineText).width)
|
|
1206
|
-
});
|
|
1207
|
-
if (idx < detailTextList.length - 1) {
|
|
1208
|
-
lineNum++;
|
|
1209
|
-
}
|
|
1210
|
-
break;
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
} else {
|
|
1215
|
-
lines.push({
|
|
1216
|
-
text: "",
|
|
1217
|
-
width: 0
|
|
1218
|
-
});
|
|
1617
|
+
if (detail.textShadowOffsetX !== void 0 && is.number(detail.textShadowOffsetX)) {
|
|
1618
|
+
ctx.shadowOffsetX = detail.textShadowOffsetX;
|
|
1219
1619
|
}
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
let startY = 0;
|
|
1223
|
-
let eachLineStartY = 0;
|
|
1224
|
-
if (fontHeight > fontSize2) {
|
|
1225
|
-
eachLineStartY = (fontHeight - fontSize2) / 2;
|
|
1226
|
-
}
|
|
1227
|
-
if (lines.length * fontHeight < h2) {
|
|
1228
|
-
if (elem.detail.verticalAlign === "top") {
|
|
1229
|
-
startY = 0;
|
|
1230
|
-
} else if (elem.detail.verticalAlign === "bottom") {
|
|
1231
|
-
startY += h2 - lines.length * fontHeight;
|
|
1232
|
-
} else {
|
|
1233
|
-
startY += (h2 - lines.length * fontHeight) / 2;
|
|
1234
|
-
}
|
|
1235
|
-
}
|
|
1236
|
-
{
|
|
1237
|
-
const _y = y2 + startY;
|
|
1238
|
-
if (detail.textShadowColor !== void 0 && isColorStr(detail.textShadowColor)) {
|
|
1239
|
-
ctx.shadowColor = detail.textShadowColor;
|
|
1240
|
-
}
|
|
1241
|
-
if (detail.textShadowOffsetX !== void 0 && is.number(detail.textShadowOffsetX)) {
|
|
1242
|
-
ctx.shadowOffsetX = detail.textShadowOffsetX;
|
|
1243
|
-
}
|
|
1244
|
-
if (detail.textShadowOffsetY !== void 0 && is.number(detail.textShadowOffsetY)) {
|
|
1245
|
-
ctx.shadowOffsetY = detail.textShadowOffsetY;
|
|
1246
|
-
}
|
|
1247
|
-
if (detail.textShadowBlur !== void 0 && is.number(detail.textShadowBlur)) {
|
|
1248
|
-
ctx.shadowBlur = detail.textShadowBlur;
|
|
1249
|
-
}
|
|
1250
|
-
lines.forEach((line, i) => {
|
|
1251
|
-
let _x = x2;
|
|
1252
|
-
if (detail.textAlign === "center") {
|
|
1253
|
-
_x = x2 + (w2 - line.width) / 2;
|
|
1254
|
-
} else if (detail.textAlign === "right") {
|
|
1255
|
-
_x = x2 + (w2 - line.width);
|
|
1620
|
+
if (detail.textShadowOffsetY !== void 0 && is.number(detail.textShadowOffsetY)) {
|
|
1621
|
+
ctx.shadowOffsetY = detail.textShadowOffsetY;
|
|
1256
1622
|
}
|
|
1257
|
-
|
|
1258
|
-
|
|
1623
|
+
if (detail.textShadowBlur !== void 0 && is.number(detail.textShadowBlur)) {
|
|
1624
|
+
ctx.shadowBlur = detail.textShadowBlur;
|
|
1625
|
+
}
|
|
1626
|
+
(_b = virtualTextDetail == null ? void 0 : virtualTextDetail.textLines) == null ? void 0 : _b.forEach((line) => {
|
|
1627
|
+
ctx.fillText(line.text, x2 + line.x * viewScaleInfo.scale, y2 + line.y * viewScaleInfo.scale);
|
|
1628
|
+
});
|
|
1629
|
+
}
|
|
1259
1630
|
}
|
|
1260
1631
|
}
|
|
1261
1632
|
});
|
|
@@ -1310,7 +1681,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1310
1681
|
renderContent: () => {
|
|
1311
1682
|
drawBoxShadow(ctx, viewElem, {
|
|
1312
1683
|
viewScaleInfo,
|
|
1313
|
-
viewSizeInfo,
|
|
1314
1684
|
renderContent: () => {
|
|
1315
1685
|
ctx.save();
|
|
1316
1686
|
ctx.translate(internalX, internalY);
|
|
@@ -1413,7 +1783,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1413
1783
|
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
1414
1784
|
drawBoxShadow(ctx, viewElem, {
|
|
1415
1785
|
viewScaleInfo,
|
|
1416
|
-
viewSizeInfo,
|
|
1417
1786
|
renderContent: () => {
|
|
1418
1787
|
drawBox(ctx, viewElem, {
|
|
1419
1788
|
originElem: elem,
|
|
@@ -1423,8 +1792,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1423
1792
|
parentOpacity,
|
|
1424
1793
|
renderContent: () => {
|
|
1425
1794
|
const { x: x22, y: y22, w: w22, h: h22, radiusList } = calcViewBoxSize(viewElem, {
|
|
1426
|
-
viewScaleInfo
|
|
1427
|
-
viewSizeInfo
|
|
1795
|
+
viewScaleInfo
|
|
1428
1796
|
});
|
|
1429
1797
|
if (elem.detail.overflow === "hidden") {
|
|
1430
1798
|
ctx.save();
|
|
@@ -1522,7 +1890,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1522
1890
|
ctx.globalAlpha = 1;
|
|
1523
1891
|
drawBoxShadow(ctx, viewElem, {
|
|
1524
1892
|
viewScaleInfo,
|
|
1525
|
-
viewSizeInfo,
|
|
1526
1893
|
renderContent: () => {
|
|
1527
1894
|
drawBoxBackground(ctx, viewElem, { viewScaleInfo, viewSizeInfo });
|
|
1528
1895
|
}
|
|
@@ -1533,8 +1900,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1533
1900
|
const viewElemSize = calcViewElementSize(elem2, { viewScaleInfo: viewScaleInfo2 }) || elem2;
|
|
1534
1901
|
const viewElem2 = { ...elem2, ...viewElemSize };
|
|
1535
1902
|
const { x: x22, y: y22, w: w22, h: h22, radiusList } = calcViewBoxSize(viewElem2, {
|
|
1536
|
-
viewScaleInfo: viewScaleInfo2
|
|
1537
|
-
viewSizeInfo: viewSizeInfo2
|
|
1903
|
+
viewScaleInfo: viewScaleInfo2
|
|
1538
1904
|
});
|
|
1539
1905
|
ctx.save();
|
|
1540
1906
|
ctx.fillStyle = "transparent";
|
|
@@ -1552,7 +1918,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1552
1918
|
if (layout.detail.overflow === "hidden") {
|
|
1553
1919
|
ctx.restore();
|
|
1554
1920
|
}
|
|
1555
|
-
drawBoxBorder(ctx, viewElem, { viewScaleInfo
|
|
1921
|
+
drawBoxBorder(ctx, viewElem, { viewScaleInfo });
|
|
1556
1922
|
ctx.globalAlpha = parentOpacity;
|
|
1557
1923
|
}
|
|
1558
1924
|
function drawGlobalBackground(ctx, global, opts) {
|
|
@@ -1755,14 +2121,432 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1755
2121
|
}
|
|
1756
2122
|
return false;
|
|
1757
2123
|
};
|
|
2124
|
+
const detailConfig = getDefaultElementDetailConfig();
|
|
2125
|
+
function isTextWidthWithinErrorRange(w0, w1, scale) {
|
|
2126
|
+
return w0 >= w1;
|
|
2127
|
+
}
|
|
2128
|
+
function calcVirtualTextDetail(elem, opts) {
|
|
2129
|
+
const { w: w2, h: h2 } = elem;
|
|
2130
|
+
const x2 = 0;
|
|
2131
|
+
const y2 = 0;
|
|
2132
|
+
const ctx = opts.tempContext;
|
|
2133
|
+
const lines = [];
|
|
2134
|
+
const detail = {
|
|
2135
|
+
...detailConfig,
|
|
2136
|
+
...elem.detail
|
|
2137
|
+
};
|
|
2138
|
+
const originFontSize = detail.fontSize || detailConfig.fontSize;
|
|
2139
|
+
const fontSize2 = originFontSize;
|
|
2140
|
+
if (fontSize2 < 2) {
|
|
2141
|
+
return {};
|
|
2142
|
+
}
|
|
2143
|
+
const originLineHeight = detail.lineHeight || originFontSize;
|
|
2144
|
+
const lineHeight2 = originLineHeight;
|
|
2145
|
+
ctx.textBaseline = "top";
|
|
2146
|
+
ctx.$setFont({
|
|
2147
|
+
fontWeight: detail.fontWeight,
|
|
2148
|
+
fontSize: fontSize2,
|
|
2149
|
+
fontFamily: enhanceFontFamliy(detail.fontFamily)
|
|
2150
|
+
});
|
|
2151
|
+
let detailText = detail.text.replace(/\r\n/gi, "\n");
|
|
2152
|
+
if (detail.textTransform === "lowercase") {
|
|
2153
|
+
detailText = detailText.toLowerCase();
|
|
2154
|
+
} else if (detail.textTransform === "uppercase") {
|
|
2155
|
+
detailText = detailText.toUpperCase();
|
|
2156
|
+
}
|
|
2157
|
+
const fontHeight = lineHeight2;
|
|
2158
|
+
const detailTextList = detailText.split("\n");
|
|
2159
|
+
let lineNum = 0;
|
|
2160
|
+
detailTextList.forEach((itemText, idx) => {
|
|
2161
|
+
if (detail.minInlineSize === "maxContent") {
|
|
2162
|
+
lines.push({
|
|
2163
|
+
x: x2,
|
|
2164
|
+
y: 0,
|
|
2165
|
+
// TODO
|
|
2166
|
+
text: itemText,
|
|
2167
|
+
width: ctx.$undoPixelRatio(ctx.measureText(itemText).width)
|
|
2168
|
+
});
|
|
2169
|
+
} else {
|
|
2170
|
+
let lineText = "";
|
|
2171
|
+
let splitStr = "";
|
|
2172
|
+
let tempStrList = itemText.split(splitStr);
|
|
2173
|
+
if (detail.wordBreak === "normal") {
|
|
2174
|
+
splitStr = " ";
|
|
2175
|
+
const wordList = itemText.split(splitStr);
|
|
2176
|
+
tempStrList = [];
|
|
2177
|
+
wordList.forEach((word, idx2) => {
|
|
2178
|
+
tempStrList.push(word);
|
|
2179
|
+
if (idx2 < wordList.length - 1) {
|
|
2180
|
+
tempStrList.push(splitStr);
|
|
2181
|
+
}
|
|
2182
|
+
});
|
|
2183
|
+
}
|
|
2184
|
+
if (tempStrList.length === 1 && detail.overflow === "visible") {
|
|
2185
|
+
lines.push({
|
|
2186
|
+
x: x2,
|
|
2187
|
+
y: 0,
|
|
2188
|
+
// TODO
|
|
2189
|
+
text: tempStrList[0],
|
|
2190
|
+
width: ctx.$undoPixelRatio(ctx.measureText(tempStrList[0]).width)
|
|
2191
|
+
});
|
|
2192
|
+
} else if (tempStrList.length > 0) {
|
|
2193
|
+
for (let i = 0; i < tempStrList.length; i++) {
|
|
2194
|
+
if (isTextWidthWithinErrorRange(ctx.$doPixelRatio(w2), ctx.measureText(lineText + tempStrList[i]).width)) {
|
|
2195
|
+
lineText += tempStrList[i] || "";
|
|
2196
|
+
} else {
|
|
2197
|
+
lines.push({
|
|
2198
|
+
x: x2,
|
|
2199
|
+
y: 0,
|
|
2200
|
+
// TODO
|
|
2201
|
+
text: lineText,
|
|
2202
|
+
width: ctx.$undoPixelRatio(ctx.measureText(lineText).width)
|
|
2203
|
+
});
|
|
2204
|
+
lineText = tempStrList[i] || "";
|
|
2205
|
+
lineNum++;
|
|
2206
|
+
}
|
|
2207
|
+
if ((lineNum + 1) * fontHeight > h2 && detail.overflow === "hidden") {
|
|
2208
|
+
break;
|
|
2209
|
+
}
|
|
2210
|
+
if (tempStrList.length - 1 === i) {
|
|
2211
|
+
if ((lineNum + 1) * fontHeight <= h2) {
|
|
2212
|
+
lines.push({
|
|
2213
|
+
x: x2,
|
|
2214
|
+
y: 0,
|
|
2215
|
+
// TODO
|
|
2216
|
+
text: lineText,
|
|
2217
|
+
width: ctx.$undoPixelRatio(ctx.measureText(lineText).width)
|
|
2218
|
+
});
|
|
2219
|
+
if (idx < detailTextList.length - 1) {
|
|
2220
|
+
lineNum++;
|
|
2221
|
+
}
|
|
2222
|
+
break;
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
} else {
|
|
2227
|
+
lines.push({
|
|
2228
|
+
x: x2,
|
|
2229
|
+
y: 0,
|
|
2230
|
+
// TODO
|
|
2231
|
+
text: "",
|
|
2232
|
+
width: 0
|
|
2233
|
+
});
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
});
|
|
2237
|
+
let startY = 0;
|
|
2238
|
+
let eachLineStartY = 0;
|
|
2239
|
+
if (fontHeight > fontSize2) {
|
|
2240
|
+
eachLineStartY = (fontHeight - fontSize2) / 2;
|
|
2241
|
+
}
|
|
2242
|
+
if (lines.length * fontHeight < h2) {
|
|
2243
|
+
if (elem.detail.verticalAlign === "top") {
|
|
2244
|
+
startY = 0;
|
|
2245
|
+
} else if (elem.detail.verticalAlign === "bottom") {
|
|
2246
|
+
startY += h2 - lines.length * fontHeight;
|
|
2247
|
+
} else {
|
|
2248
|
+
startY += (h2 - lines.length * fontHeight) / 2;
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
{
|
|
2252
|
+
const _y = y2 + startY;
|
|
2253
|
+
lines.forEach((line, i) => {
|
|
2254
|
+
let _x = x2;
|
|
2255
|
+
if (detail.textAlign === "center") {
|
|
2256
|
+
_x = x2 + (w2 - line.width) / 2;
|
|
2257
|
+
} else if (detail.textAlign === "right") {
|
|
2258
|
+
_x = x2 + (w2 - line.width);
|
|
2259
|
+
}
|
|
2260
|
+
lines[i].x = _x;
|
|
2261
|
+
lines[i].y = _y + fontHeight * i + eachLineStartY;
|
|
2262
|
+
});
|
|
2263
|
+
}
|
|
2264
|
+
const virtualTextDetail = {
|
|
2265
|
+
textLines: lines
|
|
2266
|
+
};
|
|
2267
|
+
return virtualTextDetail;
|
|
2268
|
+
}
|
|
2269
|
+
function calcVirtualFlatDetail(elem, opts) {
|
|
2270
|
+
let virtualDetail = {};
|
|
2271
|
+
if (elem.type === "text") {
|
|
2272
|
+
virtualDetail = calcVirtualTextDetail(elem, opts);
|
|
2273
|
+
}
|
|
2274
|
+
return virtualDetail;
|
|
2275
|
+
}
|
|
2276
|
+
function elementsToVirtualFlatMap(elements, opts) {
|
|
2277
|
+
const virtualFlatMap = {};
|
|
2278
|
+
const currentPosition = [];
|
|
2279
|
+
const _walk = (elem) => {
|
|
2280
|
+
const baseInfo = {
|
|
2281
|
+
type: elem.type,
|
|
2282
|
+
isVisibleInView: true,
|
|
2283
|
+
position: [...currentPosition]
|
|
2284
|
+
};
|
|
2285
|
+
let originRectInfo = null;
|
|
2286
|
+
const groupQueue = getGroupQueueByElementPosition(elements, currentPosition);
|
|
2287
|
+
originRectInfo = calcElementOriginRectInfo(elem, {
|
|
2288
|
+
groupQueue: groupQueue || []
|
|
2289
|
+
});
|
|
2290
|
+
const virtualItem = {
|
|
2291
|
+
...baseInfo,
|
|
2292
|
+
...{
|
|
2293
|
+
originRectInfo,
|
|
2294
|
+
rangeRectInfo: is.angle(elem.angle) ? originRectInfoToRangeRectInfo(originRectInfo) : originRectInfo
|
|
2295
|
+
},
|
|
2296
|
+
...calcVirtualFlatDetail(elem, opts)
|
|
2297
|
+
};
|
|
2298
|
+
virtualFlatMap[elem.uuid] = virtualItem;
|
|
2299
|
+
if (elem.type === "group") {
|
|
2300
|
+
elem.detail.children.forEach((ele, i) => {
|
|
2301
|
+
currentPosition.push(i);
|
|
2302
|
+
_walk(ele);
|
|
2303
|
+
currentPosition.pop();
|
|
2304
|
+
});
|
|
2305
|
+
}
|
|
2306
|
+
};
|
|
2307
|
+
elements.forEach((elem, index) => {
|
|
2308
|
+
currentPosition.push(index);
|
|
2309
|
+
_walk(elem);
|
|
2310
|
+
currentPosition.pop();
|
|
2311
|
+
});
|
|
2312
|
+
return virtualFlatMap;
|
|
2313
|
+
}
|
|
2314
|
+
function sortElementsViewVisiableInfoMap(elements, opts) {
|
|
2315
|
+
const { viewScaleInfo, viewSizeInfo, tempContext } = opts;
|
|
2316
|
+
const visibleInfoMap = elementsToVirtualFlatMap(elements, { tempContext });
|
|
2317
|
+
return updateVirtualFlatItemMapStatus(visibleInfoMap, { viewScaleInfo, viewSizeInfo });
|
|
2318
|
+
}
|
|
2319
|
+
function isRangeRectInfoCollide(info1, info2) {
|
|
2320
|
+
const rect1MinX = Math.min(info1.topLeft.x, info1.topRight.x, info1.bottomLeft.x, info1.bottomRight.x);
|
|
2321
|
+
const rect1MaxX = Math.max(info1.topLeft.x, info1.topRight.x, info1.bottomLeft.x, info1.bottomRight.x);
|
|
2322
|
+
const rect1MinY = Math.min(info1.topLeft.y, info1.topRight.y, info1.bottomLeft.y, info1.bottomRight.y);
|
|
2323
|
+
const rect1MaxY = Math.max(info1.topLeft.y, info1.topRight.y, info1.bottomLeft.y, info1.bottomRight.y);
|
|
2324
|
+
const rect2MinX = Math.min(info2.topLeft.x, info2.topRight.x, info2.bottomLeft.x, info2.bottomRight.x);
|
|
2325
|
+
const rect2MaxX = Math.max(info2.topLeft.x, info2.topRight.x, info2.bottomLeft.x, info2.bottomRight.x);
|
|
2326
|
+
const rect2MinY = Math.min(info2.topLeft.y, info2.topRight.y, info2.bottomLeft.y, info2.bottomRight.y);
|
|
2327
|
+
const rect2MaxY = Math.max(info2.topLeft.y, info2.topRight.y, info2.bottomLeft.y, info2.bottomRight.y);
|
|
2328
|
+
if (rect1MinX <= rect2MaxX && rect1MaxX >= rect2MinX && rect1MinY <= rect2MaxY && rect1MaxY >= rect2MinY || rect2MaxX <= rect1MaxY && rect2MaxX >= rect1MaxY && rect2MaxX <= rect1MaxY && rect2MaxX >= rect1MaxY) {
|
|
2329
|
+
return true;
|
|
2330
|
+
}
|
|
2331
|
+
return false;
|
|
2332
|
+
}
|
|
2333
|
+
function updateVirtualFlatItemMapStatus(virtualFlatItemMap, opts) {
|
|
2334
|
+
const canvasRectInfo = calcVisibleOriginCanvasRectInfo(opts);
|
|
2335
|
+
let visibleCount = 0;
|
|
2336
|
+
let invisibleCount = 0;
|
|
2337
|
+
Object.keys(virtualFlatItemMap).forEach((uuid) => {
|
|
2338
|
+
const info = virtualFlatItemMap[uuid];
|
|
2339
|
+
info.isVisibleInView = isRangeRectInfoCollide(info.rangeRectInfo, canvasRectInfo);
|
|
2340
|
+
info.isVisibleInView ? visibleCount++ : invisibleCount++;
|
|
2341
|
+
});
|
|
2342
|
+
return { virtualFlatItemMap, visibleCount, invisibleCount };
|
|
2343
|
+
}
|
|
2344
|
+
function calcVisibleOriginCanvasRectInfo(opts) {
|
|
2345
|
+
const { viewScaleInfo, viewSizeInfo } = opts;
|
|
2346
|
+
const { scale, offsetTop, offsetLeft } = viewScaleInfo;
|
|
2347
|
+
const { width, height } = viewSizeInfo;
|
|
2348
|
+
const x2 = 0 - offsetLeft / scale;
|
|
2349
|
+
const y2 = 0 - offsetTop / scale;
|
|
2350
|
+
const w2 = width / scale;
|
|
2351
|
+
const h2 = height / scale;
|
|
2352
|
+
const center = calcElementCenter({ x: x2, y: y2, w: w2, h: h2 });
|
|
2353
|
+
const topLeft = { x: x2, y: y2 };
|
|
2354
|
+
const topRight = { x: x2 + w2, y: y2 };
|
|
2355
|
+
const bottomLeft = { x: x2, y: y2 + h2 };
|
|
2356
|
+
const bottomRight = { x: x2 + w2, y: y2 + h2 };
|
|
2357
|
+
const left = { x: x2, y: center.y };
|
|
2358
|
+
const top = { x: center.x, y: y2 };
|
|
2359
|
+
const right = { x: x2 + w2, y: center.y };
|
|
2360
|
+
const bottom = { x: center.x, y: y2 + h2 };
|
|
2361
|
+
const rectInfo = {
|
|
2362
|
+
center,
|
|
2363
|
+
topLeft,
|
|
2364
|
+
topRight,
|
|
2365
|
+
bottomLeft,
|
|
2366
|
+
bottomRight,
|
|
2367
|
+
left,
|
|
2368
|
+
top,
|
|
2369
|
+
right,
|
|
2370
|
+
bottom
|
|
2371
|
+
};
|
|
2372
|
+
return rectInfo;
|
|
2373
|
+
}
|
|
2374
|
+
class Calculator {
|
|
2375
|
+
constructor(opts) {
|
|
2376
|
+
__privateAdd(this, _opts);
|
|
2377
|
+
__privateAdd(this, _store);
|
|
2378
|
+
__privateSet(this, _opts, opts);
|
|
2379
|
+
__privateSet(this, _store, new Store({
|
|
2380
|
+
defaultStorage: {
|
|
2381
|
+
virtualFlatItemMap: {},
|
|
2382
|
+
visibleCount: 0,
|
|
2383
|
+
invisibleCount: 0
|
|
2384
|
+
}
|
|
2385
|
+
}));
|
|
2386
|
+
}
|
|
2387
|
+
toGridNum(num, opts) {
|
|
2388
|
+
if ((opts == null ? void 0 : opts.ignore) === true) {
|
|
2389
|
+
return num;
|
|
2390
|
+
}
|
|
2391
|
+
return Math.round(num);
|
|
2392
|
+
}
|
|
2393
|
+
destroy() {
|
|
2394
|
+
__privateSet(this, _opts, null);
|
|
2395
|
+
}
|
|
2396
|
+
needRender(elem) {
|
|
2397
|
+
const virtualFlatItemMap = __privateGet(this, _store).get("virtualFlatItemMap");
|
|
2398
|
+
const info = virtualFlatItemMap[elem.uuid];
|
|
2399
|
+
if (!info) {
|
|
2400
|
+
return true;
|
|
2401
|
+
}
|
|
2402
|
+
return info.isVisibleInView;
|
|
2403
|
+
}
|
|
2404
|
+
getPointElement(p, opts) {
|
|
2405
|
+
const context2d = __privateGet(this, _opts).tempContext;
|
|
2406
|
+
return getViewPointAtElement(p, { ...opts, ...{ context2d } });
|
|
2407
|
+
}
|
|
2408
|
+
resetVirtualFlatItemMap(data, opts) {
|
|
2409
|
+
if (data) {
|
|
2410
|
+
const { virtualFlatItemMap, invisibleCount, visibleCount } = sortElementsViewVisiableInfoMap(data.elements, {
|
|
2411
|
+
...opts,
|
|
2412
|
+
...{
|
|
2413
|
+
tempContext: __privateGet(this, _opts).tempContext
|
|
2414
|
+
}
|
|
2415
|
+
});
|
|
2416
|
+
__privateGet(this, _store).set("virtualFlatItemMap", virtualFlatItemMap);
|
|
2417
|
+
__privateGet(this, _store).set("invisibleCount", invisibleCount);
|
|
2418
|
+
__privateGet(this, _store).set("visibleCount", visibleCount);
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
updateVisiableStatus(opts) {
|
|
2422
|
+
const { virtualFlatItemMap, invisibleCount, visibleCount } = updateVirtualFlatItemMapStatus(
|
|
2423
|
+
__privateGet(this, _store).get("virtualFlatItemMap"),
|
|
2424
|
+
opts
|
|
2425
|
+
);
|
|
2426
|
+
__privateGet(this, _store).set("virtualFlatItemMap", virtualFlatItemMap);
|
|
2427
|
+
__privateGet(this, _store).set("invisibleCount", invisibleCount);
|
|
2428
|
+
__privateGet(this, _store).set("visibleCount", visibleCount);
|
|
2429
|
+
}
|
|
2430
|
+
calcViewRectInfoFromOrigin(uuid, opts) {
|
|
2431
|
+
const infoData = __privateGet(this, _store).get("virtualFlatItemMap")[uuid];
|
|
2432
|
+
if (!(infoData == null ? void 0 : infoData.originRectInfo)) {
|
|
2433
|
+
return null;
|
|
2434
|
+
}
|
|
2435
|
+
const { checkVisible, viewScaleInfo, viewSizeInfo } = opts;
|
|
2436
|
+
const { center, left, right, bottom, top, topLeft, topRight, bottomLeft, bottomRight } = infoData.originRectInfo;
|
|
2437
|
+
if (checkVisible === true && infoData.isVisibleInView === false) {
|
|
2438
|
+
return null;
|
|
2439
|
+
}
|
|
2440
|
+
const calcOpts = { viewScaleInfo };
|
|
2441
|
+
const viewRectInfo = {
|
|
2442
|
+
center: calcViewPointSize(center, calcOpts),
|
|
2443
|
+
left: calcViewPointSize(left, calcOpts),
|
|
2444
|
+
right: calcViewPointSize(right, calcOpts),
|
|
2445
|
+
bottom: calcViewPointSize(bottom, calcOpts),
|
|
2446
|
+
top: calcViewPointSize(top, calcOpts),
|
|
2447
|
+
topLeft: calcViewPointSize(topLeft, calcOpts),
|
|
2448
|
+
topRight: calcViewPointSize(topRight, calcOpts),
|
|
2449
|
+
bottomLeft: calcViewPointSize(bottomLeft, calcOpts),
|
|
2450
|
+
bottomRight: calcViewPointSize(bottomRight, calcOpts)
|
|
2451
|
+
};
|
|
2452
|
+
return viewRectInfo;
|
|
2453
|
+
}
|
|
2454
|
+
calcViewRectInfoFromRange(uuid, opts) {
|
|
2455
|
+
const infoData = __privateGet(this, _store).get("virtualFlatItemMap")[uuid];
|
|
2456
|
+
if (!(infoData == null ? void 0 : infoData.originRectInfo)) {
|
|
2457
|
+
return null;
|
|
2458
|
+
}
|
|
2459
|
+
const { checkVisible, viewScaleInfo, viewSizeInfo } = opts;
|
|
2460
|
+
const { center, left, right, bottom, top, topLeft, topRight, bottomLeft, bottomRight } = infoData.rangeRectInfo;
|
|
2461
|
+
if (checkVisible === true && infoData.isVisibleInView === false) {
|
|
2462
|
+
return null;
|
|
2463
|
+
}
|
|
2464
|
+
const calcOpts = { viewScaleInfo };
|
|
2465
|
+
const viewRectInfo = {
|
|
2466
|
+
center: calcViewPointSize(center, calcOpts),
|
|
2467
|
+
left: calcViewPointSize(left, calcOpts),
|
|
2468
|
+
right: calcViewPointSize(right, calcOpts),
|
|
2469
|
+
bottom: calcViewPointSize(bottom, calcOpts),
|
|
2470
|
+
top: calcViewPointSize(top, calcOpts),
|
|
2471
|
+
topLeft: calcViewPointSize(topLeft, calcOpts),
|
|
2472
|
+
topRight: calcViewPointSize(topRight, calcOpts),
|
|
2473
|
+
bottomLeft: calcViewPointSize(bottomLeft, calcOpts),
|
|
2474
|
+
bottomRight: calcViewPointSize(bottomRight, calcOpts)
|
|
2475
|
+
};
|
|
2476
|
+
return viewRectInfo;
|
|
2477
|
+
}
|
|
2478
|
+
modifyVirtualFlatItemMap(data, opts) {
|
|
2479
|
+
const { modifyOptions, viewScaleInfo, viewSizeInfo } = opts;
|
|
2480
|
+
const { type, content } = modifyOptions;
|
|
2481
|
+
const list = data.elements;
|
|
2482
|
+
const virtualFlatItemMap = __privateGet(this, _store).get("virtualFlatItemMap");
|
|
2483
|
+
if (type === "deleteElement") {
|
|
2484
|
+
const { element } = content;
|
|
2485
|
+
const uuids = [];
|
|
2486
|
+
const _walk = (e) => {
|
|
2487
|
+
uuids.push(e.uuid);
|
|
2488
|
+
if (e.type === "group" && Array.isArray(e.detail.children)) {
|
|
2489
|
+
e.detail.children.forEach((child) => {
|
|
2490
|
+
_walk(child);
|
|
2491
|
+
});
|
|
2492
|
+
}
|
|
2493
|
+
};
|
|
2494
|
+
_walk(element);
|
|
2495
|
+
uuids.forEach((uuid) => {
|
|
2496
|
+
delete virtualFlatItemMap[uuid];
|
|
2497
|
+
});
|
|
2498
|
+
__privateGet(this, _store).set("virtualFlatItemMap", virtualFlatItemMap);
|
|
2499
|
+
} else if (type === "addElement" || type === "updateElement") {
|
|
2500
|
+
const { position } = content;
|
|
2501
|
+
const element = findElementFromListByPosition(position, data.elements);
|
|
2502
|
+
const groupQueue = getGroupQueueByElementPosition(list, position);
|
|
2503
|
+
if (element) {
|
|
2504
|
+
if (type === "updateElement" && element.type === "group") {
|
|
2505
|
+
this.resetVirtualFlatItemMap(data, { viewScaleInfo, viewSizeInfo });
|
|
2506
|
+
} else {
|
|
2507
|
+
const originRectInfo = calcElementOriginRectInfo(element, {
|
|
2508
|
+
groupQueue: groupQueue || []
|
|
2509
|
+
});
|
|
2510
|
+
const newVirtualFlatItem = {
|
|
2511
|
+
type: element.type,
|
|
2512
|
+
originRectInfo,
|
|
2513
|
+
rangeRectInfo: is.angle(element.angle) ? originRectInfoToRangeRectInfo(originRectInfo) : originRectInfo,
|
|
2514
|
+
isVisibleInView: true,
|
|
2515
|
+
position: [...position],
|
|
2516
|
+
...calcVirtualFlatDetail(element, {
|
|
2517
|
+
tempContext: __privateGet(this, _opts).tempContext
|
|
2518
|
+
})
|
|
2519
|
+
};
|
|
2520
|
+
virtualFlatItemMap[element.uuid] = newVirtualFlatItem;
|
|
2521
|
+
__privateGet(this, _store).set("virtualFlatItemMap", virtualFlatItemMap);
|
|
2522
|
+
if (type === "updateElement") {
|
|
2523
|
+
this.updateVisiableStatus({ viewScaleInfo, viewSizeInfo });
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
} else if (type === "moveElement") {
|
|
2528
|
+
this.resetVirtualFlatItemMap(data, { viewScaleInfo, viewSizeInfo });
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
getVirtualFlatItem(uuid) {
|
|
2532
|
+
const itemMap = __privateGet(this, _store).get("virtualFlatItemMap");
|
|
2533
|
+
return itemMap[uuid] || null;
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
_opts = new WeakMap();
|
|
2537
|
+
_store = new WeakMap();
|
|
1758
2538
|
class Renderer extends EventEmitter {
|
|
1759
2539
|
constructor(opts) {
|
|
1760
2540
|
super();
|
|
1761
2541
|
__privateAdd(this, _Renderer_instances);
|
|
1762
|
-
__privateAdd(this,
|
|
2542
|
+
__privateAdd(this, _opts2);
|
|
1763
2543
|
__privateAdd(this, _loader, new Loader());
|
|
2544
|
+
__privateAdd(this, _calculator);
|
|
1764
2545
|
__privateAdd(this, _hasDestroyed2, false);
|
|
1765
|
-
__privateSet(this,
|
|
2546
|
+
__privateSet(this, _opts2, opts);
|
|
2547
|
+
__privateSet(this, _calculator, new Calculator({
|
|
2548
|
+
tempContext: opts.tempContext
|
|
2549
|
+
}));
|
|
1766
2550
|
__privateMethod(this, _Renderer_instances, init_fn).call(this);
|
|
1767
2551
|
}
|
|
1768
2552
|
isDestroyed() {
|
|
@@ -1770,18 +2554,19 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1770
2554
|
}
|
|
1771
2555
|
destroy() {
|
|
1772
2556
|
this.clear();
|
|
1773
|
-
__privateSet(this,
|
|
2557
|
+
__privateSet(this, _opts2, null);
|
|
1774
2558
|
__privateGet(this, _loader).destroy();
|
|
1775
2559
|
__privateSet(this, _loader, null);
|
|
1776
2560
|
__privateSet(this, _hasDestroyed2, true);
|
|
1777
2561
|
}
|
|
1778
2562
|
updateOptions(opts) {
|
|
1779
|
-
__privateSet(this,
|
|
2563
|
+
__privateSet(this, _opts2, opts);
|
|
1780
2564
|
}
|
|
1781
2565
|
drawData(data, opts) {
|
|
1782
2566
|
const loader = __privateGet(this, _loader);
|
|
1783
|
-
const
|
|
1784
|
-
const
|
|
2567
|
+
const calculator = __privateGet(this, _calculator);
|
|
2568
|
+
const { sharer } = __privateGet(this, _opts2);
|
|
2569
|
+
const viewContext = __privateGet(this, _opts2).viewContext;
|
|
1785
2570
|
viewContext.clearRect(0, 0, viewContext.canvas.width, viewContext.canvas.height);
|
|
1786
2571
|
const parentElementSize = {
|
|
1787
2572
|
x: 0,
|
|
@@ -1808,11 +2593,22 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1808
2593
|
}
|
|
1809
2594
|
}
|
|
1810
2595
|
scale(num) {
|
|
1811
|
-
const { sharer } = __privateGet(this,
|
|
2596
|
+
const { sharer } = __privateGet(this, _opts2);
|
|
1812
2597
|
if (!sharer) {
|
|
1813
2598
|
return;
|
|
1814
2599
|
}
|
|
1815
|
-
const {
|
|
2600
|
+
const {
|
|
2601
|
+
data,
|
|
2602
|
+
offsetTop,
|
|
2603
|
+
offsetBottom,
|
|
2604
|
+
offsetLeft,
|
|
2605
|
+
offsetRight,
|
|
2606
|
+
width,
|
|
2607
|
+
height,
|
|
2608
|
+
contextHeight,
|
|
2609
|
+
contextWidth,
|
|
2610
|
+
devicePixelRatio
|
|
2611
|
+
} = sharer.getActiveStoreSnapshot();
|
|
1816
2612
|
if (data) {
|
|
1817
2613
|
this.drawData(data, {
|
|
1818
2614
|
viewScaleInfo: {
|
|
@@ -1841,9 +2637,13 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1841
2637
|
getLoader() {
|
|
1842
2638
|
return __privateGet(this, _loader);
|
|
1843
2639
|
}
|
|
2640
|
+
getCalculator() {
|
|
2641
|
+
return __privateGet(this, _calculator);
|
|
2642
|
+
}
|
|
1844
2643
|
}
|
|
1845
|
-
|
|
2644
|
+
_opts2 = new WeakMap();
|
|
1846
2645
|
_loader = new WeakMap();
|
|
2646
|
+
_calculator = new WeakMap();
|
|
1847
2647
|
_hasDestroyed2 = new WeakMap();
|
|
1848
2648
|
_Renderer_instances = new WeakSet();
|
|
1849
2649
|
init_fn = function() {
|
|
@@ -1855,6 +2655,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1855
2655
|
console.error(e);
|
|
1856
2656
|
});
|
|
1857
2657
|
};
|
|
2658
|
+
exports.Calculator = Calculator;
|
|
1858
2659
|
exports.Renderer = Renderer;
|
|
1859
2660
|
exports.drawCircle = drawCircle;
|
|
1860
2661
|
exports.drawElement = drawElement;
|