zrender-nightly 5.7.0-dev.20250620 → 5.7.0-dev.20250621
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/README.md +1 -1
- package/build/prepublish.js +20 -0
- package/dist/zrender.js +563 -277
- package/dist/zrender.js.map +1 -1
- package/dist/zrender.min.js +1 -1
- package/lib/Element.d.ts +4 -0
- package/lib/Element.js +34 -16
- package/lib/Handler.js +1 -1
- package/lib/Storage.js +20 -20
- package/lib/canvas/graphic.js +1 -1
- package/lib/contain/text.d.ts +14 -2
- package/lib/contain/text.js +65 -15
- package/lib/core/BoundingRect.d.ts +25 -3
- package/lib/core/BoundingRect.js +182 -76
- package/lib/core/OrientedBoundingRect.d.ts +2 -2
- package/lib/core/OrientedBoundingRect.js +50 -34
- package/lib/core/PathProxy.d.ts +1 -0
- package/lib/core/PathProxy.js +16 -1
- package/lib/core/dom.d.ts +1 -0
- package/lib/core/dom.js +17 -0
- package/lib/core/env.js +15 -10
- package/lib/core/types.d.ts +1 -0
- package/lib/core/util.d.ts +1 -0
- package/lib/core/util.js +2 -1
- package/lib/graphic/Displayable.js +1 -1
- package/lib/graphic/Text.d.ts +4 -2
- package/lib/graphic/Text.js +23 -14
- package/lib/graphic/helper/parseText.d.ts +13 -4
- package/lib/graphic/helper/parseText.js +110 -54
- package/lib/svg-legacy/helper/ClippathManager.js +6 -6
- package/lib/tool/color.d.ts +3 -1
- package/lib/tool/color.js +6 -6
- package/lib/tool/parseSVG.js +11 -0
- package/lib/tool/path.js +7 -4
- package/lib/zrender.d.ts +1 -1
- package/lib/zrender.js +1 -1
- package/package.json +3 -2
- package/src/Element.ts +69 -16
- package/src/Handler.ts +1 -1
- package/src/Storage.ts +25 -24
- package/src/canvas/graphic.ts +1 -1
- package/src/canvas/helper.ts +1 -1
- package/src/contain/text.ts +103 -19
- package/src/core/BoundingRect.ts +308 -87
- package/src/core/OrientedBoundingRect.ts +86 -46
- package/src/core/PathProxy.ts +17 -1
- package/src/core/Transformable.ts +2 -0
- package/src/core/dom.ts +24 -0
- package/src/core/env.ts +31 -24
- package/src/core/matrix.ts +2 -1
- package/src/core/types.ts +2 -0
- package/src/core/util.ts +4 -2
- package/src/graphic/Displayable.ts +1 -3
- package/src/graphic/Group.ts +2 -0
- package/src/graphic/Text.ts +68 -21
- package/src/graphic/helper/parseText.ts +211 -83
- package/src/svg-legacy/helper/ClippathManager.ts +5 -5
- package/src/tool/color.ts +15 -11
- package/src/tool/parseSVG.ts +12 -1
- package/src/tool/path.ts +9 -4
- package/src/zrender.ts +1 -1
package/lib/Element.d.ts
CHANGED
@@ -36,6 +36,7 @@ export interface ElementTextConfig {
|
|
36
36
|
outsideFill?: string;
|
37
37
|
outsideStroke?: string;
|
38
38
|
inside?: boolean;
|
39
|
+
autoOverflowArea?: boolean;
|
39
40
|
}
|
40
41
|
export interface ElementTextGuideLineConfig {
|
41
42
|
anchor?: Point;
|
@@ -85,6 +86,7 @@ export interface ElementProps extends Partial<ElementEventHandlerProps>, Partial
|
|
85
86
|
isGroup?: boolean;
|
86
87
|
draggable?: boolean | 'horizontal' | 'vertical';
|
87
88
|
silent?: boolean;
|
89
|
+
ignoreHostSilent?: boolean;
|
88
90
|
ignoreClip?: boolean;
|
89
91
|
globalScaleRatio?: number;
|
90
92
|
textConfig?: ElementTextConfig;
|
@@ -114,6 +116,7 @@ declare class Element<Props extends ElementProps = ElementProps> {
|
|
114
116
|
name: string;
|
115
117
|
ignore: boolean;
|
116
118
|
silent: boolean;
|
119
|
+
ignoreHostSilent: boolean;
|
117
120
|
isGroup: boolean;
|
118
121
|
draggable: boolean | 'horizontal' | 'vertical';
|
119
122
|
dragging: boolean;
|
@@ -125,6 +128,7 @@ declare class Element<Props extends ElementProps = ElementProps> {
|
|
125
128
|
__dirty: number;
|
126
129
|
__isRendered: boolean;
|
127
130
|
__inHover: boolean;
|
131
|
+
__clipPaths?: Path[];
|
128
132
|
private _clipPath?;
|
129
133
|
private _textContent?;
|
130
134
|
private _textGuide?;
|
package/lib/Element.js
CHANGED
@@ -7,6 +7,7 @@ import { guid, isObject, keys, extend, indexOf, logError, mixin, isArrayLike, is
|
|
7
7
|
import { LIGHT_LABEL_COLOR, DARK_LABEL_COLOR } from './config.js';
|
8
8
|
import { parse, stringify } from './tool/color.js';
|
9
9
|
import { REDRAW_BIT } from './graphic/constants.js';
|
10
|
+
import { invert } from './core/matrix.js';
|
10
11
|
export var PRESERVED_NORMAL_STATE = '__zr_normal__';
|
11
12
|
var PRIMARY_STATES_KEYS = TRANSFORMABLE_PROPS.concat(['ignore']);
|
12
13
|
var DEFAULT_ANIMATABLE_MAP = reduce(TRANSFORMABLE_PROPS, function (obj, key) {
|
@@ -15,6 +16,7 @@ var DEFAULT_ANIMATABLE_MAP = reduce(TRANSFORMABLE_PROPS, function (obj, key) {
|
|
15
16
|
}, { ignore: false });
|
16
17
|
var tmpTextPosCalcRes = {};
|
17
18
|
var tmpBoundingRect = new BoundingRect(0, 0, 0, 0);
|
19
|
+
var tmpInnerTextTrans = [];
|
18
20
|
var Element = (function () {
|
19
21
|
function Element(props) {
|
20
22
|
this.id = guid();
|
@@ -67,8 +69,11 @@ var Element = (function () {
|
|
67
69
|
innerTransformable.parent = isLocal ? this : null;
|
68
70
|
var innerOrigin = false;
|
69
71
|
innerTransformable.copyTransform(textEl);
|
70
|
-
|
71
|
-
|
72
|
+
var hasPosition = textConfig.position != null;
|
73
|
+
var autoOverflowArea = textConfig.autoOverflowArea;
|
74
|
+
var layoutRect = void 0;
|
75
|
+
if (autoOverflowArea || hasPosition) {
|
76
|
+
layoutRect = tmpBoundingRect;
|
72
77
|
if (textConfig.layoutRect) {
|
73
78
|
layoutRect.copy(textConfig.layoutRect);
|
74
79
|
}
|
@@ -78,6 +83,8 @@ var Element = (function () {
|
|
78
83
|
if (!isLocal) {
|
79
84
|
layoutRect.applyTransform(this.transform);
|
80
85
|
}
|
86
|
+
}
|
87
|
+
if (hasPosition) {
|
81
88
|
if (this.calculateTextPosition) {
|
82
89
|
this.calculateTextPosition(tmpTextPosCalcRes, textConfig, layoutRect);
|
83
90
|
}
|
@@ -117,10 +124,21 @@ var Element = (function () {
|
|
117
124
|
innerTransformable.originY = -textOffset[1];
|
118
125
|
}
|
119
126
|
}
|
127
|
+
var innerTextDefaultStyle = this._innerTextDefaultStyle || (this._innerTextDefaultStyle = {});
|
128
|
+
if (autoOverflowArea) {
|
129
|
+
var overflowRect = innerTextDefaultStyle.overflowRect =
|
130
|
+
innerTextDefaultStyle.overflowRect || new BoundingRect(0, 0, 0, 0);
|
131
|
+
innerTransformable.getLocalTransform(tmpInnerTextTrans);
|
132
|
+
invert(tmpInnerTextTrans, tmpInnerTextTrans);
|
133
|
+
BoundingRect.copy(overflowRect, layoutRect);
|
134
|
+
overflowRect.applyTransform(tmpInnerTextTrans);
|
135
|
+
}
|
136
|
+
else {
|
137
|
+
innerTextDefaultStyle.overflowRect = null;
|
138
|
+
}
|
120
139
|
var isInside = textConfig.inside == null
|
121
140
|
? (typeof textConfig.position === 'string' && textConfig.position.indexOf('inside') >= 0)
|
122
141
|
: textConfig.inside;
|
123
|
-
var innerTextDefaultStyle = this._innerTextDefaultStyle || (this._innerTextDefaultStyle = {});
|
124
142
|
var textFill = void 0;
|
125
143
|
var textStroke = void 0;
|
126
144
|
var autoStroke = void 0;
|
@@ -401,16 +419,15 @@ var Element = (function () {
|
|
401
419
|
}
|
402
420
|
};
|
403
421
|
Element.prototype.isSilent = function () {
|
404
|
-
var
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
isSilent = true;
|
409
|
-
break;
|
422
|
+
var el = this;
|
423
|
+
while (el) {
|
424
|
+
if (el.silent) {
|
425
|
+
return true;
|
410
426
|
}
|
411
|
-
|
427
|
+
var hostEl = el.__hostTarget;
|
428
|
+
el = hostEl ? (el.ignoreHostSilent ? null : hostEl) : el.parent;
|
412
429
|
}
|
413
|
-
return
|
430
|
+
return false;
|
414
431
|
};
|
415
432
|
Element.prototype._updateAnimationTargets = function () {
|
416
433
|
for (var i = 0; i < this.animators.length; i++) {
|
@@ -776,11 +793,12 @@ var Element = (function () {
|
|
776
793
|
elProto.name = '';
|
777
794
|
elProto.ignore =
|
778
795
|
elProto.silent =
|
779
|
-
elProto.
|
780
|
-
elProto.
|
781
|
-
elProto.
|
782
|
-
elProto.
|
783
|
-
elProto.
|
796
|
+
elProto.ignoreHostSilent =
|
797
|
+
elProto.isGroup =
|
798
|
+
elProto.draggable =
|
799
|
+
elProto.dragging =
|
800
|
+
elProto.ignoreClip =
|
801
|
+
elProto.__inHover = false;
|
784
802
|
elProto.__dirty = REDRAW_BIT;
|
785
803
|
var logs = {};
|
786
804
|
function logDeprecatedError(key, xKey, yKey) {
|
package/lib/Handler.js
CHANGED
@@ -267,7 +267,7 @@ function isHover(displayable, x, y) {
|
|
267
267
|
isSilent = true;
|
268
268
|
}
|
269
269
|
var hostEl = el.__hostTarget;
|
270
|
-
el = hostEl ? hostEl : el.parent;
|
270
|
+
el = hostEl ? (el.ignoreHostSilent ? null : hostEl) : el.parent;
|
271
271
|
}
|
272
272
|
return isSilent ? SILENT : true;
|
273
273
|
}
|
package/lib/Storage.js
CHANGED
@@ -48,7 +48,7 @@ var Storage = (function () {
|
|
48
48
|
displayList.length = this._displayListLen;
|
49
49
|
timsort(displayList, shapeCompareFunc);
|
50
50
|
};
|
51
|
-
Storage.prototype._updateAndAddDisplayable = function (el,
|
51
|
+
Storage.prototype._updateAndAddDisplayable = function (el, parentClipPaths, includeIgnore) {
|
52
52
|
if (el.ignore && !includeIgnore) {
|
53
53
|
return;
|
54
54
|
}
|
@@ -56,26 +56,32 @@ var Storage = (function () {
|
|
56
56
|
el.update();
|
57
57
|
el.afterUpdate();
|
58
58
|
var userSetClipPath = el.getClipPath();
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
59
|
+
var parentHasClipPaths = parentClipPaths && parentClipPaths.length;
|
60
|
+
var clipPathIdx = 0;
|
61
|
+
var thisClipPaths = el.__clipPaths;
|
62
|
+
if (!el.ignoreClip
|
63
|
+
&& (parentHasClipPaths || userSetClipPath)) {
|
64
|
+
if (!thisClipPaths) {
|
65
|
+
thisClipPaths = el.__clipPaths = [];
|
65
66
|
}
|
66
|
-
|
67
|
-
|
67
|
+
if (parentHasClipPaths) {
|
68
|
+
for (var idx = 0; idx < parentClipPaths.length; idx++) {
|
69
|
+
thisClipPaths[clipPathIdx++] = parentClipPaths[idx];
|
70
|
+
}
|
68
71
|
}
|
69
72
|
var currentClipPath = userSetClipPath;
|
70
73
|
var parentClipPath = el;
|
71
74
|
while (currentClipPath) {
|
72
75
|
currentClipPath.parent = parentClipPath;
|
73
76
|
currentClipPath.updateTransform();
|
74
|
-
|
77
|
+
thisClipPaths[clipPathIdx++] = currentClipPath;
|
75
78
|
parentClipPath = currentClipPath;
|
76
79
|
currentClipPath = currentClipPath.getClipPath();
|
77
80
|
}
|
78
81
|
}
|
82
|
+
if (thisClipPaths) {
|
83
|
+
thisClipPaths.length = clipPathIdx;
|
84
|
+
}
|
79
85
|
if (el.childrenRef) {
|
80
86
|
var children = el.childrenRef();
|
81
87
|
for (var i = 0; i < children.length; i++) {
|
@@ -83,18 +89,12 @@ var Storage = (function () {
|
|
83
89
|
if (el.__dirty) {
|
84
90
|
child.__dirty |= REDRAW_BIT;
|
85
91
|
}
|
86
|
-
this._updateAndAddDisplayable(child,
|
92
|
+
this._updateAndAddDisplayable(child, thisClipPaths, includeIgnore);
|
87
93
|
}
|
88
94
|
el.__dirty = 0;
|
89
95
|
}
|
90
96
|
else {
|
91
97
|
var disp = el;
|
92
|
-
if (clipPaths && clipPaths.length) {
|
93
|
-
disp.__clipPaths = clipPaths;
|
94
|
-
}
|
95
|
-
else if (disp.__clipPaths && disp.__clipPaths.length > 0) {
|
96
|
-
disp.__clipPaths = [];
|
97
|
-
}
|
98
98
|
if (isNaN(disp.z)) {
|
99
99
|
logInvalidZError();
|
100
100
|
disp.z = 0;
|
@@ -111,15 +111,15 @@ var Storage = (function () {
|
|
111
111
|
}
|
112
112
|
var decalEl = el.getDecalElement && el.getDecalElement();
|
113
113
|
if (decalEl) {
|
114
|
-
this._updateAndAddDisplayable(decalEl,
|
114
|
+
this._updateAndAddDisplayable(decalEl, thisClipPaths, includeIgnore);
|
115
115
|
}
|
116
116
|
var textGuide = el.getTextGuideLine();
|
117
117
|
if (textGuide) {
|
118
|
-
this._updateAndAddDisplayable(textGuide,
|
118
|
+
this._updateAndAddDisplayable(textGuide, thisClipPaths, includeIgnore);
|
119
119
|
}
|
120
120
|
var textEl = el.getTextContent();
|
121
121
|
if (textEl) {
|
122
|
-
this._updateAndAddDisplayable(textEl,
|
122
|
+
this._updateAndAddDisplayable(textEl, thisClipPaths, includeIgnore);
|
123
123
|
}
|
124
124
|
};
|
125
125
|
Storage.prototype.addRoot = function (el) {
|
package/lib/canvas/graphic.js
CHANGED
@@ -108,7 +108,7 @@ function brushPath(ctx, el, style, inBatch) {
|
|
108
108
|
strokePattern = (dirtyFlag || !el.__canvasStrokePattern)
|
109
109
|
? createCanvasPattern(ctx, stroke, el)
|
110
110
|
: el.__canvasStrokePattern;
|
111
|
-
el.__canvasStrokePattern =
|
111
|
+
el.__canvasStrokePattern = strokePattern;
|
112
112
|
}
|
113
113
|
if (hasFillGradient) {
|
114
114
|
ctx.fillStyle = fillGradient;
|
package/lib/contain/text.d.ts
CHANGED
@@ -1,10 +1,22 @@
|
|
1
1
|
import BoundingRect, { RectLike } from '../core/BoundingRect';
|
2
2
|
import { TextAlign, TextVerticalAlign, BuiltinTextPosition } from '../core/types';
|
3
|
+
import LRU from '../core/LRU';
|
3
4
|
export declare function getWidth(text: string, font: string): number;
|
5
|
+
export interface FontMeasureInfo {
|
6
|
+
font: string;
|
7
|
+
strWidthCache: LRU<number>;
|
8
|
+
asciiWidthMap: number[] | null | undefined;
|
9
|
+
asciiWidthMapTried: boolean;
|
10
|
+
stWideCharWidth: number;
|
11
|
+
asciiCharWidth: number;
|
12
|
+
}
|
13
|
+
export declare function ensureFontMeasureInfo(font: string): FontMeasureInfo;
|
14
|
+
export declare function measureCharWidth(fontMeasureInfo: FontMeasureInfo, charCode: number): number;
|
15
|
+
export declare function measureWidth(fontMeasureInfo: FontMeasureInfo, text: string): number;
|
4
16
|
export declare function innerGetBoundingRect(text: string, font: string, textAlign?: TextAlign, textBaseline?: TextVerticalAlign): BoundingRect;
|
5
17
|
export declare function getBoundingRect(text: string, font: string, textAlign?: TextAlign, textBaseline?: TextVerticalAlign): BoundingRect;
|
6
|
-
export declare function adjustTextX(x: number, width: number, textAlign: TextAlign): number;
|
7
|
-
export declare function adjustTextY(y: number, height: number, verticalAlign: TextVerticalAlign): number;
|
18
|
+
export declare function adjustTextX(x: number, width: number, textAlign: TextAlign, inverse?: boolean): number;
|
19
|
+
export declare function adjustTextY(y: number, height: number, verticalAlign: TextVerticalAlign, inverse?: boolean): number;
|
8
20
|
export declare function getLineHeight(font?: string): number;
|
9
21
|
export declare function measureText(text: string, font?: string): {
|
10
22
|
width: number;
|
package/lib/contain/text.js
CHANGED
@@ -1,22 +1,72 @@
|
|
1
1
|
import BoundingRect from '../core/BoundingRect.js';
|
2
2
|
import LRU from '../core/LRU.js';
|
3
3
|
import { DEFAULT_FONT, platformApi } from '../core/platform.js';
|
4
|
-
var textWidthCache = {};
|
5
4
|
export function getWidth(text, font) {
|
5
|
+
return measureWidth(ensureFontMeasureInfo(font), text);
|
6
|
+
}
|
7
|
+
export function ensureFontMeasureInfo(font) {
|
8
|
+
if (!_fontMeasureInfoCache) {
|
9
|
+
_fontMeasureInfoCache = new LRU(100);
|
10
|
+
}
|
11
|
+
font = font || DEFAULT_FONT;
|
12
|
+
var measureInfo = _fontMeasureInfoCache.get(font);
|
13
|
+
if (!measureInfo) {
|
14
|
+
measureInfo = {
|
15
|
+
font: font,
|
16
|
+
strWidthCache: new LRU(500),
|
17
|
+
asciiWidthMap: null,
|
18
|
+
asciiWidthMapTried: false,
|
19
|
+
stWideCharWidth: platformApi.measureText('国', font).width,
|
20
|
+
asciiCharWidth: platformApi.measureText('a', font).width
|
21
|
+
};
|
22
|
+
_fontMeasureInfoCache.put(font, measureInfo);
|
23
|
+
}
|
24
|
+
return measureInfo;
|
25
|
+
}
|
26
|
+
var _fontMeasureInfoCache;
|
27
|
+
function tryCreateASCIIWidthMap(font) {
|
28
|
+
if (_getASCIIWidthMapLongCount >= GET_ASCII_WIDTH_LONG_COUNT_MAX) {
|
29
|
+
return;
|
30
|
+
}
|
6
31
|
font = font || DEFAULT_FONT;
|
7
|
-
var
|
8
|
-
|
9
|
-
|
32
|
+
var asciiWidthMap = [];
|
33
|
+
var start = +(new Date());
|
34
|
+
for (var code = 0; code <= 127; code++) {
|
35
|
+
asciiWidthMap[code] = platformApi.measureText(String.fromCharCode(code), font).width;
|
10
36
|
}
|
11
|
-
var
|
37
|
+
var cost = +(new Date()) - start;
|
38
|
+
if (cost > 16) {
|
39
|
+
_getASCIIWidthMapLongCount = GET_ASCII_WIDTH_LONG_COUNT_MAX;
|
40
|
+
}
|
41
|
+
else if (cost > 2) {
|
42
|
+
_getASCIIWidthMapLongCount++;
|
43
|
+
}
|
44
|
+
return asciiWidthMap;
|
45
|
+
}
|
46
|
+
var _getASCIIWidthMapLongCount = 0;
|
47
|
+
var GET_ASCII_WIDTH_LONG_COUNT_MAX = 5;
|
48
|
+
export function measureCharWidth(fontMeasureInfo, charCode) {
|
49
|
+
if (!fontMeasureInfo.asciiWidthMapTried) {
|
50
|
+
fontMeasureInfo.asciiWidthMap = tryCreateASCIIWidthMap(fontMeasureInfo.font);
|
51
|
+
fontMeasureInfo.asciiWidthMapTried = true;
|
52
|
+
}
|
53
|
+
return (0 <= charCode && charCode <= 127)
|
54
|
+
? (fontMeasureInfo.asciiWidthMap != null
|
55
|
+
? fontMeasureInfo.asciiWidthMap[charCode]
|
56
|
+
: fontMeasureInfo.asciiCharWidth)
|
57
|
+
: fontMeasureInfo.stWideCharWidth;
|
58
|
+
}
|
59
|
+
export function measureWidth(fontMeasureInfo, text) {
|
60
|
+
var strWidthCache = fontMeasureInfo.strWidthCache;
|
61
|
+
var width = strWidthCache.get(text);
|
12
62
|
if (width == null) {
|
13
|
-
width = platformApi.measureText(text, font).width;
|
14
|
-
|
63
|
+
width = platformApi.measureText(text, fontMeasureInfo.font).width;
|
64
|
+
strWidthCache.put(text, width);
|
15
65
|
}
|
16
66
|
return width;
|
17
67
|
}
|
18
68
|
export function innerGetBoundingRect(text, font, textAlign, textBaseline) {
|
19
|
-
var width =
|
69
|
+
var width = measureWidth(ensureFontMeasureInfo(font), text);
|
20
70
|
var height = getLineHeight(font);
|
21
71
|
var x = adjustTextX(0, width, textAlign);
|
22
72
|
var y = adjustTextY(0, height, textBaseline);
|
@@ -38,26 +88,26 @@ export function getBoundingRect(text, font, textAlign, textBaseline) {
|
|
38
88
|
return uniondRect;
|
39
89
|
}
|
40
90
|
}
|
41
|
-
export function adjustTextX(x, width, textAlign) {
|
91
|
+
export function adjustTextX(x, width, textAlign, inverse) {
|
42
92
|
if (textAlign === 'right') {
|
43
|
-
x -= width;
|
93
|
+
!inverse ? (x -= width) : (x += width);
|
44
94
|
}
|
45
95
|
else if (textAlign === 'center') {
|
46
|
-
x -= width / 2;
|
96
|
+
!inverse ? (x -= width / 2) : (x += width / 2);
|
47
97
|
}
|
48
98
|
return x;
|
49
99
|
}
|
50
|
-
export function adjustTextY(y, height, verticalAlign) {
|
100
|
+
export function adjustTextY(y, height, verticalAlign, inverse) {
|
51
101
|
if (verticalAlign === 'middle') {
|
52
|
-
y -= height / 2;
|
102
|
+
!inverse ? (y -= height / 2) : (y += height / 2);
|
53
103
|
}
|
54
104
|
else if (verticalAlign === 'bottom') {
|
55
|
-
y -= height;
|
105
|
+
!inverse ? (y -= height) : (y += height);
|
56
106
|
}
|
57
107
|
return y;
|
58
108
|
}
|
59
109
|
export function getLineHeight(font) {
|
60
|
-
return
|
110
|
+
return ensureFontMeasureInfo(font).stWideCharWidth;
|
61
111
|
}
|
62
112
|
export function measureText(text, font) {
|
63
113
|
return platformApi.measureText(text, font);
|
@@ -1,15 +1,19 @@
|
|
1
1
|
import * as matrix from './matrix';
|
2
|
-
import { PointLike } from './Point';
|
2
|
+
import Point, { PointLike } from './Point';
|
3
|
+
import { NullUndefined } from './types';
|
3
4
|
declare class BoundingRect {
|
4
5
|
x: number;
|
5
6
|
y: number;
|
6
7
|
width: number;
|
7
8
|
height: number;
|
8
9
|
constructor(x: number, y: number, width: number, height: number);
|
10
|
+
static set<TTarget extends RectLike>(target: TTarget, x: number, y: number, width: number, height: number): TTarget;
|
9
11
|
union(other: BoundingRect): void;
|
10
12
|
applyTransform(m: matrix.MatrixArray): void;
|
11
13
|
calculateTransform(b: RectLike): matrix.MatrixArray;
|
12
|
-
intersect(b: RectLike, mtv?: PointLike): boolean;
|
14
|
+
intersect(b: RectLike, mtv?: PointLike, opt?: BoundingRectIntersectOpt): boolean;
|
15
|
+
static intersect(a: RectLike, b: RectLike, mtv?: PointLike, opt?: BoundingRectIntersectOpt): boolean;
|
16
|
+
static contain(rect: RectLike, x: number, y: number): boolean;
|
13
17
|
contain(x: number, y: number): boolean;
|
14
18
|
clone(): BoundingRect;
|
15
19
|
copy(other: RectLike): void;
|
@@ -17,7 +21,7 @@ declare class BoundingRect {
|
|
17
21
|
isFinite(): boolean;
|
18
22
|
isZero(): boolean;
|
19
23
|
static create(rect: RectLike): BoundingRect;
|
20
|
-
static copy(target:
|
24
|
+
static copy<TTarget extends RectLike>(target: TTarget, source: RectLike): TTarget;
|
21
25
|
static applyTransform(target: RectLike, source: RectLike, m: matrix.MatrixArray): void;
|
22
26
|
}
|
23
27
|
export declare type RectLike = {
|
@@ -26,4 +30,22 @@ export declare type RectLike = {
|
|
26
30
|
width: number;
|
27
31
|
height: number;
|
28
32
|
};
|
33
|
+
export interface BoundingRectIntersectOpt {
|
34
|
+
direction?: number;
|
35
|
+
bidirectional?: boolean;
|
36
|
+
touchThreshold?: number;
|
37
|
+
outIntersectRect?: RectLike;
|
38
|
+
clamp?: boolean;
|
39
|
+
}
|
40
|
+
export declare function createIntersectContext(): {
|
41
|
+
minTv: Point;
|
42
|
+
maxTv: Point;
|
43
|
+
useDir: boolean;
|
44
|
+
dirMinTv: Point;
|
45
|
+
touchThreshold: number;
|
46
|
+
bidirectional: boolean;
|
47
|
+
negativeSize: boolean;
|
48
|
+
reset(opt: BoundingRectIntersectOpt | NullUndefined, useMTV: boolean): void;
|
49
|
+
calcDirMTV(): void;
|
50
|
+
};
|
29
51
|
export default BoundingRect;
|