@antv/g 5.0.15 → 5.0.18
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/index.umd.min.js +18 -2
- package/es/Canvas.d.ts +7 -1
- package/es/Canvas.js +9 -10
- package/es/camera/Camera.d.ts +3 -2
- package/es/camera/Camera.js +16 -8
- package/es/canvas-module.js +4 -2
- package/es/components/Transform.d.ts +0 -1
- package/es/components/Transform.js +0 -1
- package/es/display-objects/Circle.d.ts +1 -1
- package/es/display-objects/Circle.js +8 -3
- package/es/display-objects/CustomElement.d.ts +3 -2
- package/es/display-objects/CustomElement.js +9 -6
- package/es/display-objects/DisplayObject.d.ts +9 -3
- package/es/display-objects/DisplayObject.js +97 -50
- package/es/display-objects/Ellipse.d.ts +1 -1
- package/es/display-objects/Ellipse.js +8 -3
- package/es/display-objects/Group.d.ts +18 -2
- package/es/display-objects/Group.js +11 -9
- package/es/display-objects/HTML.d.ts +1 -1
- package/es/display-objects/HTML.js +9 -4
- package/es/display-objects/Image.d.ts +5 -3
- package/es/display-objects/Image.js +8 -3
- package/es/display-objects/Line.d.ts +1 -1
- package/es/display-objects/Line.js +12 -4
- package/es/display-objects/Path.d.ts +3 -2
- package/es/display-objects/Path.js +10 -5
- package/es/display-objects/Polygon.d.ts +1 -1
- package/es/display-objects/Polygon.js +9 -3
- package/es/display-objects/Polyline.d.ts +1 -1
- package/es/display-objects/Polyline.js +10 -5
- package/es/display-objects/Rect.d.ts +1 -1
- package/es/display-objects/Rect.js +8 -3
- package/es/display-objects/Text.d.ts +32 -4
- package/es/display-objects/Text.js +70 -10
- package/es/dom/Animation.js +2 -2
- package/es/dom/AnimationTimeline.js +1 -2
- package/es/dom/CustomElementRegistry.js +12 -12
- package/es/dom/Document.d.ts +2 -1
- package/es/dom/Document.js +22 -2
- package/es/dom/Element.d.ts +38 -5
- package/es/dom/Element.js +115 -16
- package/es/dom/EventTarget.d.ts +2 -2
- package/es/dom/EventTarget.js +4 -3
- package/es/dom/FederatedEvent.d.ts +4 -1
- package/es/dom/KeyframeList.js +1 -1
- package/es/dom/MutationEvent.d.ts +15 -0
- package/es/dom/MutationEvent.js +29 -0
- package/es/dom/MutationObserver.d.ts +36 -0
- package/es/dom/MutationObserver.js +413 -0
- package/es/dom/MutationRecord.d.ts +14 -0
- package/es/dom/MutationRecord.js +31 -0
- package/es/dom/Node.d.ts +35 -3
- package/es/dom/Node.js +184 -17
- package/es/dom/index.d.ts +3 -0
- package/es/dom/index.js +3 -0
- package/es/dom/interfaces.d.ts +39 -8
- package/es/dom/interfaces.js +23 -5
- package/es/global-module.d.ts +1 -0
- package/es/global-module.js +11 -13
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/plugins/CullingPlugin.d.ts +0 -2
- package/es/plugins/CullingPlugin.js +3 -24
- package/es/plugins/DirtyCheckPlugin.js +2 -2
- package/es/plugins/EventPlugin.d.ts +1 -0
- package/es/plugins/EventPlugin.js +15 -5
- package/es/plugins/FrustumCullingStrategy.d.ts +1 -0
- package/es/plugins/FrustumCullingStrategy.js +41 -33
- package/es/plugins/PrepareRendererPlugin.js +21 -5
- package/es/property-handlers/aabb.js +19 -20
- package/es/property-handlers/color.js +5 -2
- package/es/property-handlers/dimension.d.ts +15 -3
- package/es/property-handlers/dimension.js +50 -9
- package/es/property-handlers/index.d.ts +3 -0
- package/es/property-handlers/index.js +4 -1
- package/es/property-handlers/inherit.d.ts +6 -0
- package/es/property-handlers/inherit.js +25 -0
- package/es/property-handlers/interfaces.d.ts +2 -2
- package/es/property-handlers/lineDash.d.ts +6 -1
- package/es/property-handlers/lineDash.js +23 -4
- package/es/property-handlers/offsetDistance.js +2 -2
- package/es/property-handlers/text.d.ts +2 -0
- package/es/property-handlers/text.js +3 -0
- package/es/property-handlers/textTransform.d.ts +6 -0
- package/es/property-handlers/textTransform.js +19 -0
- package/es/services/EventService.js +11 -7
- package/es/services/RenderingContext.d.ts +5 -8
- package/es/services/RenderingContext.js +6 -7
- package/es/services/RenderingService.d.ts +12 -2
- package/es/services/RenderingService.js +23 -12
- package/es/services/SceneGraphSelector.d.ts +3 -2
- package/es/services/SceneGraphSelector.js +8 -4
- package/es/services/SceneGraphService.d.ts +0 -7
- package/es/services/SceneGraphService.js +17 -87
- package/es/services/aabb/CircleUpdater.js +3 -3
- package/es/services/aabb/EllipseUpdater.js +2 -2
- package/es/services/aabb/LineUpdater.js +2 -2
- package/es/services/aabb/PathUpdater.js +2 -2
- package/es/services/aabb/PolylineUpdater.js +3 -3
- package/es/services/aabb/RectUpdater.js +4 -4
- package/es/services/aabb/TextUpdater.js +31 -10
- package/es/services/text/index.js +19 -21
- package/es/shapes/AABB.js +5 -0
- package/es/types.d.ts +48 -24
- package/es/types.js +50 -31
- package/es/utils/animation.js +1 -1
- package/es/utils/custom-easing.js +1 -1
- package/es/utils/event.js +7 -4
- package/es/utils/index.d.ts +2 -0
- package/es/utils/index.js +3 -1
- package/es/utils/interpolation.d.ts +1 -0
- package/es/utils/interpolation.js +41 -8
- package/es/utils/path.js +11 -11
- package/es/utils/raf.d.ts +1 -1
- package/es/utils/raf.js +0 -2
- package/es/utils/string.d.ts +1 -0
- package/es/utils/string.js +9 -0
- package/es/utils/text.js +3 -3
- package/lib/Canvas.d.ts +7 -1
- package/lib/Canvas.js +7 -8
- package/lib/camera/Camera.d.ts +3 -2
- package/lib/camera/Camera.js +20 -10
- package/lib/canvas-module.js +3 -1
- package/lib/components/Transform.d.ts +0 -1
- package/lib/components/Transform.js +0 -1
- package/lib/display-objects/Circle.d.ts +1 -1
- package/lib/display-objects/Circle.js +7 -2
- package/lib/display-objects/CustomElement.d.ts +3 -2
- package/lib/display-objects/CustomElement.js +9 -6
- package/lib/display-objects/DisplayObject.d.ts +9 -3
- package/lib/display-objects/DisplayObject.js +97 -47
- package/lib/display-objects/Ellipse.d.ts +1 -1
- package/lib/display-objects/Ellipse.js +7 -2
- package/lib/display-objects/Group.d.ts +18 -2
- package/lib/display-objects/Group.js +10 -9
- package/lib/display-objects/HTML.d.ts +1 -1
- package/lib/display-objects/HTML.js +8 -4
- package/lib/display-objects/Image.d.ts +5 -3
- package/lib/display-objects/Image.js +7 -2
- package/lib/display-objects/Line.d.ts +1 -1
- package/lib/display-objects/Line.js +11 -3
- package/lib/display-objects/Path.d.ts +3 -2
- package/lib/display-objects/Path.js +9 -4
- package/lib/display-objects/Polygon.d.ts +1 -1
- package/lib/display-objects/Polygon.js +8 -2
- package/lib/display-objects/Polyline.d.ts +1 -1
- package/lib/display-objects/Polyline.js +9 -4
- package/lib/display-objects/Rect.d.ts +1 -1
- package/lib/display-objects/Rect.js +7 -2
- package/lib/display-objects/Text.d.ts +32 -4
- package/lib/display-objects/Text.js +69 -9
- package/lib/dom/Animation.js +2 -2
- package/lib/dom/AnimationTimeline.js +1 -2
- package/lib/dom/CustomElementRegistry.js +11 -11
- package/lib/dom/Document.d.ts +2 -1
- package/lib/dom/Document.js +24 -3
- package/lib/dom/Element.d.ts +38 -5
- package/lib/dom/Element.js +117 -16
- package/lib/dom/EventTarget.d.ts +2 -2
- package/lib/dom/EventTarget.js +4 -3
- package/lib/dom/FederatedEvent.d.ts +4 -1
- package/lib/dom/KeyframeList.js +1 -1
- package/lib/dom/MutationEvent.d.ts +15 -0
- package/lib/dom/MutationEvent.js +37 -0
- package/lib/dom/MutationObserver.d.ts +36 -0
- package/lib/dom/MutationObserver.js +424 -0
- package/lib/dom/MutationRecord.d.ts +14 -0
- package/lib/dom/MutationRecord.js +38 -0
- package/lib/dom/Node.d.ts +35 -3
- package/lib/dom/Node.js +185 -16
- package/lib/dom/index.d.ts +3 -0
- package/lib/dom/index.js +39 -0
- package/lib/dom/interfaces.d.ts +39 -8
- package/lib/dom/interfaces.js +23 -5
- package/lib/global-module.d.ts +1 -0
- package/lib/global-module.js +12 -8
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/plugins/CullingPlugin.d.ts +0 -2
- package/lib/plugins/CullingPlugin.js +2 -23
- package/lib/plugins/DirtyCheckPlugin.js +1 -1
- package/lib/plugins/EventPlugin.d.ts +1 -0
- package/lib/plugins/EventPlugin.js +13 -5
- package/lib/plugins/FrustumCullingStrategy.d.ts +1 -0
- package/lib/plugins/FrustumCullingStrategy.js +42 -33
- package/lib/plugins/PrepareRendererPlugin.js +24 -4
- package/lib/property-handlers/aabb.js +18 -19
- package/lib/property-handlers/color.js +6 -3
- package/lib/property-handlers/dimension.d.ts +15 -3
- package/lib/property-handlers/dimension.js +50 -8
- package/lib/property-handlers/index.d.ts +3 -0
- package/lib/property-handlers/index.js +39 -0
- package/lib/property-handlers/inherit.d.ts +6 -0
- package/lib/property-handlers/inherit.js +34 -0
- package/lib/property-handlers/interfaces.d.ts +2 -2
- package/lib/property-handlers/lineDash.d.ts +6 -1
- package/lib/property-handlers/lineDash.js +25 -4
- package/lib/property-handlers/offsetDistance.js +1 -1
- package/lib/property-handlers/text.d.ts +2 -0
- package/lib/property-handlers/text.js +10 -0
- package/lib/property-handlers/textTransform.d.ts +6 -0
- package/lib/property-handlers/textTransform.js +27 -0
- package/lib/services/EventService.js +11 -7
- package/lib/services/RenderingContext.d.ts +5 -8
- package/lib/services/RenderingContext.js +8 -9
- package/lib/services/RenderingService.d.ts +12 -2
- package/lib/services/RenderingService.js +23 -11
- package/lib/services/SceneGraphSelector.d.ts +3 -2
- package/lib/services/SceneGraphSelector.js +10 -3
- package/lib/services/SceneGraphService.d.ts +0 -7
- package/lib/services/SceneGraphService.js +18 -91
- package/lib/services/aabb/CircleUpdater.js +2 -2
- package/lib/services/aabb/EllipseUpdater.js +1 -1
- package/lib/services/aabb/LineUpdater.js +1 -1
- package/lib/services/aabb/PathUpdater.js +1 -1
- package/lib/services/aabb/PolylineUpdater.js +2 -2
- package/lib/services/aabb/RectUpdater.js +3 -3
- package/lib/services/aabb/TextUpdater.js +30 -9
- package/lib/services/text/index.js +19 -21
- package/lib/shapes/AABB.js +5 -0
- package/lib/types.d.ts +48 -24
- package/lib/types.js +56 -35
- package/lib/utils/animation.js +1 -1
- package/lib/utils/custom-easing.js +1 -1
- package/lib/utils/event.js +7 -4
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +26 -0
- package/lib/utils/interpolation.d.ts +1 -0
- package/lib/utils/interpolation.js +43 -7
- package/lib/utils/path.js +10 -10
- package/lib/utils/raf.d.ts +1 -1
- package/lib/utils/raf.js +0 -2
- package/lib/utils/string.d.ts +1 -0
- package/lib/utils/string.js +16 -0
- package/lib/utils/text.js +3 -3
- package/package.json +5 -3
|
@@ -24,8 +24,8 @@ var regexCannotStartJaJp = /[)\]}〕〉》」』】〙〗〟'"⦆»ヽヾー
|
|
|
24
24
|
var regexCannotEndJaJp = /[([{〔〈《「『【〘〖〝'"⦅«—...‥〳〴〵]/;
|
|
25
25
|
var regexCannotStartKoKr = /[!%),.:;?\]}¢°'"†‡℃〆〈《「『〕!%),.:;?]}]/;
|
|
26
26
|
var regexCannotEndKoKr = /[$([{£¥'"々〇〉》」〔$([{⦆¥₩#]/;
|
|
27
|
-
var regexCannotStart = new RegExp(regexCannotStartZhCn.source
|
|
28
|
-
var regexCannotEnd = new RegExp(regexCannotEndZhCn.source
|
|
27
|
+
var regexCannotStart = new RegExp("".concat(regexCannotStartZhCn.source, "|").concat(regexCannotStartZhTw.source, "|").concat(regexCannotStartJaJp.source, "|").concat(regexCannotStartKoKr.source));
|
|
28
|
+
var regexCannotEnd = new RegExp("".concat(regexCannotEndZhCn.source, "|").concat(regexCannotEndZhTw.source, "|").concat(regexCannotEndJaJp.source, "|").concat(regexCannotEndKoKr.source));
|
|
29
29
|
|
|
30
30
|
var TextService =
|
|
31
31
|
/** @class */
|
|
@@ -93,7 +93,7 @@ function () {
|
|
|
93
93
|
context.textBaseline = 'alphabetic';
|
|
94
94
|
context.fillStyle = '#000';
|
|
95
95
|
context.fillText(metricsString, 0, baseline);
|
|
96
|
-
var imagedata = context.getImageData(0, 0, width, height).data;
|
|
96
|
+
var imagedata = context.getImageData(0, 0, width || 1, height || 1).data;
|
|
97
97
|
var pixels = imagedata.length;
|
|
98
98
|
var line = width * 4;
|
|
99
99
|
var i = 0;
|
|
@@ -141,29 +141,27 @@ function () {
|
|
|
141
141
|
};
|
|
142
142
|
|
|
143
143
|
TextService.prototype.measureText = function (text, attributes) {
|
|
144
|
-
var
|
|
145
|
-
fontSize = _a === void 0 ? 0 : _a,
|
|
144
|
+
var fontSize = attributes.fontSize,
|
|
146
145
|
wordWrap = attributes.wordWrap,
|
|
147
|
-
|
|
148
|
-
strokeHeight =
|
|
149
|
-
|
|
150
|
-
lineWidth = _c === void 0 ? 0 : _c,
|
|
146
|
+
_a = attributes.lineHeight,
|
|
147
|
+
strokeHeight = _a === void 0 ? 0 : _a,
|
|
148
|
+
lineWidth = attributes.lineWidth,
|
|
151
149
|
textBaseline = attributes.textBaseline,
|
|
152
150
|
textAlign = attributes.textAlign,
|
|
153
|
-
|
|
154
|
-
letterSpacing =
|
|
151
|
+
_b = attributes.letterSpacing,
|
|
152
|
+
letterSpacing = _b === void 0 ? 0 : _b,
|
|
155
153
|
dropShadow = attributes.dropShadow,
|
|
156
|
-
|
|
157
|
-
dropShadowDistance =
|
|
158
|
-
|
|
159
|
-
leading =
|
|
154
|
+
_c = attributes.dropShadowDistance,
|
|
155
|
+
dropShadowDistance = _c === void 0 ? 0 : _c,
|
|
156
|
+
_d = attributes.leading,
|
|
157
|
+
leading = _d === void 0 ? 0 : _d;
|
|
160
158
|
var font = toFontString(attributes);
|
|
161
159
|
var fontProperties = this.measureFont(font); // fallback in case UA disallow canvas data extraction
|
|
162
160
|
// (toDataURI, getImageData functions)
|
|
163
161
|
|
|
164
162
|
if (fontProperties.fontSize === 0) {
|
|
165
|
-
fontProperties.fontSize = fontSize;
|
|
166
|
-
fontProperties.ascent = fontSize;
|
|
163
|
+
fontProperties.fontSize = fontSize.value;
|
|
164
|
+
fontProperties.ascent = fontSize.value;
|
|
167
165
|
}
|
|
168
166
|
|
|
169
167
|
var context = this.offscreenCanvas.getOrCreateContext();
|
|
@@ -179,14 +177,14 @@ function () {
|
|
|
179
177
|
maxLineWidth = Math.max(maxLineWidth, lineWidth_1);
|
|
180
178
|
}
|
|
181
179
|
|
|
182
|
-
var width = maxLineWidth + lineWidth;
|
|
180
|
+
var width = maxLineWidth + lineWidth.value;
|
|
183
181
|
|
|
184
182
|
if (dropShadow) {
|
|
185
183
|
width += dropShadowDistance;
|
|
186
184
|
}
|
|
187
185
|
|
|
188
|
-
var lineHeight = strokeHeight || fontProperties.fontSize + lineWidth;
|
|
189
|
-
var height = Math.max(lineHeight, fontProperties.fontSize + lineWidth) + (lines.length - 1) * (lineHeight + leading);
|
|
186
|
+
var lineHeight = strokeHeight || fontProperties.fontSize + lineWidth.value;
|
|
187
|
+
var height = Math.max(lineHeight, fontProperties.fontSize + lineWidth.value) + (lines.length - 1) * (lineHeight + leading);
|
|
190
188
|
|
|
191
189
|
if (dropShadow) {
|
|
192
190
|
height += dropShadowDistance;
|
|
@@ -222,7 +220,7 @@ function () {
|
|
|
222
220
|
offsetX -= width;
|
|
223
221
|
}
|
|
224
222
|
|
|
225
|
-
return new Rectangle(offsetX - lineWidth / 2, offsetY + i * lineHeight, width + lineWidth, lineHeight);
|
|
223
|
+
return new Rectangle(offsetX - lineWidth.value / 2, offsetY + i * lineHeight, width + lineWidth.value, lineHeight);
|
|
226
224
|
})
|
|
227
225
|
};
|
|
228
226
|
};
|
package/es/shapes/AABB.js
CHANGED
package/es/types.d.ts
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
import type { vec2, vec3 } from 'gl-matrix';
|
|
3
3
|
import type { ParsedPathStyleProps, ParsedPolylineStyleProps } from './display-objects';
|
|
4
4
|
import type { DisplayObject } from './display-objects';
|
|
5
|
-
import type { ParsedColorStyleProperty } from './property-handlers';
|
|
5
|
+
import type { ParsedColorStyleProperty, ParsedElement } from './property-handlers';
|
|
6
6
|
import type { IRenderer } from './AbstractRenderer';
|
|
7
|
-
export declare enum
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
export declare enum Shape {
|
|
8
|
+
GROUP = "g",
|
|
9
|
+
CIRCLE = "circle",
|
|
10
|
+
ELLIPSE = "ellipse",
|
|
11
|
+
IMAGE = "image",
|
|
12
|
+
RECT = "rect",
|
|
13
|
+
LINE = "line",
|
|
14
|
+
POLYLINE = "polyline",
|
|
15
|
+
POLYGON = "polygon",
|
|
16
|
+
TEXT = "text",
|
|
17
|
+
PATH = "path",
|
|
18
18
|
HTML = "html"
|
|
19
19
|
}
|
|
20
20
|
declare type ColorType = string | null;
|
|
@@ -26,17 +26,31 @@ export interface EventPosition {
|
|
|
26
26
|
x: number;
|
|
27
27
|
y: number;
|
|
28
28
|
}
|
|
29
|
-
export declare enum
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
export declare enum LineCap {
|
|
30
|
+
BUTT = "butt",
|
|
31
|
+
ROUND = "round",
|
|
32
|
+
SQUARE = "square"
|
|
33
33
|
}
|
|
34
|
-
export declare enum
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
export declare enum LineJoin {
|
|
35
|
+
BEVEL = "bevel",
|
|
36
|
+
ROUND = "round",
|
|
37
|
+
MITER = "miter"
|
|
38
|
+
}
|
|
39
|
+
export declare enum TextTransform {
|
|
40
|
+
CAPITALIZE = "capitalize",
|
|
41
|
+
UPPERCASE = "uppercase",
|
|
42
|
+
LOWERCASE = "lowercase",
|
|
43
|
+
NONE = "none"
|
|
44
|
+
}
|
|
45
|
+
export declare enum TextAlign {
|
|
46
|
+
START = "start",
|
|
47
|
+
CENTER = "center",
|
|
48
|
+
END = "end",
|
|
49
|
+
LEFT = "left",
|
|
50
|
+
RIGHT = "right"
|
|
38
51
|
}
|
|
39
52
|
export interface BaseStyleProps {
|
|
53
|
+
class?: string;
|
|
40
54
|
/**
|
|
41
55
|
* x in local space
|
|
42
56
|
*/
|
|
@@ -100,11 +114,11 @@ export interface BaseStyleProps {
|
|
|
100
114
|
/** 整体透明度 */
|
|
101
115
|
opacity?: number;
|
|
102
116
|
/** 线宽 */
|
|
103
|
-
lineWidth?: number;
|
|
117
|
+
lineWidth?: string | number;
|
|
104
118
|
/** 指定如何绘制每一条线段末端 */
|
|
105
|
-
lineCap?:
|
|
119
|
+
lineCap?: LineCap;
|
|
106
120
|
/** 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性(长度为0的变形部分,其指定的末端和控制点在同一位置,会被忽略) */
|
|
107
|
-
lineJoin?:
|
|
121
|
+
lineJoin?: LineJoin;
|
|
108
122
|
/**
|
|
109
123
|
* 设置线的虚线样式,可以指定一个数组。一组描述交替绘制线段和间距(坐标空间单位)长度的数字。 如果数组元素的数量是奇数, 数组的元素会被复制并重复。例如, [5, 15, 25] 会变成 [5, 15, 25, 5, 15, 25]。这个属性取决于浏览器是否支持 setLineDash() 函数。
|
|
110
124
|
*/
|
|
@@ -126,14 +140,23 @@ export interface BaseStyleProps {
|
|
|
126
140
|
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter
|
|
127
141
|
*/
|
|
128
142
|
filter?: string;
|
|
143
|
+
/**
|
|
144
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/text-transform
|
|
145
|
+
*/
|
|
146
|
+
textTransform?: TextTransform;
|
|
147
|
+
/**
|
|
148
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/miterLimit
|
|
149
|
+
*/
|
|
150
|
+
miterLimit?: number;
|
|
129
151
|
}
|
|
130
|
-
export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'fill' | 'stroke' | 'path' | 'points'> {
|
|
152
|
+
export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'fill' | 'stroke' | 'path' | 'points' | 'lineWidth' | 'shadowColor'> {
|
|
131
153
|
fill?: ParsedColorStyleProperty;
|
|
132
154
|
stroke?: ParsedColorStyleProperty;
|
|
133
155
|
path?: ParsedPathStyleProps;
|
|
134
156
|
points?: ParsedPolylineStyleProps;
|
|
135
157
|
x?: number;
|
|
136
158
|
y?: number;
|
|
159
|
+
lineWidth?: ParsedElement;
|
|
137
160
|
/**
|
|
138
161
|
* x according to definition, eg. Line's x1/x2, Polyline's points
|
|
139
162
|
*/
|
|
@@ -144,6 +167,7 @@ export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'fill' | 'str
|
|
|
144
167
|
*/
|
|
145
168
|
offsetX?: number;
|
|
146
169
|
offsetY?: number;
|
|
170
|
+
shadowColor?: ParsedColorStyleProperty;
|
|
147
171
|
}
|
|
148
172
|
export declare type Cursor = 'auto' | 'default' | 'none' | 'context-menu' | 'help' | 'pointer' | 'progress' | 'wait' | 'cell' | 'crosshair' | 'text' | 'vertical-text' | 'alias' | 'copy' | 'move' | 'no-drop' | 'not-allowed' | 'grab' | 'grabbing' | 'all-scroll' | 'col-resize' | 'row-resize' | 'n-resize' | 'e-resize' | 's-resize' | 'w-resize' | 'ne-resize' | 'nw-resize' | 'se-resize' | 'sw-resize' | 'ew-resize' | 'ns-resize' | 'nesw-resize' | 'nwse-resize' | 'zoom-in' | 'zoom-out';
|
|
149
173
|
export interface RendererConfig {
|
package/es/types.js
CHANGED
|
@@ -1,33 +1,52 @@
|
|
|
1
|
-
export var
|
|
2
|
-
|
|
3
|
-
(function (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
})(
|
|
16
|
-
|
|
17
|
-
export var
|
|
18
|
-
|
|
19
|
-
(function (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
})(
|
|
24
|
-
|
|
25
|
-
export var
|
|
26
|
-
|
|
27
|
-
(function (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})(
|
|
1
|
+
export var Shape;
|
|
2
|
+
|
|
3
|
+
(function (Shape) {
|
|
4
|
+
Shape["GROUP"] = "g";
|
|
5
|
+
Shape["CIRCLE"] = "circle";
|
|
6
|
+
Shape["ELLIPSE"] = "ellipse";
|
|
7
|
+
Shape["IMAGE"] = "image";
|
|
8
|
+
Shape["RECT"] = "rect";
|
|
9
|
+
Shape["LINE"] = "line";
|
|
10
|
+
Shape["POLYLINE"] = "polyline";
|
|
11
|
+
Shape["POLYGON"] = "polygon";
|
|
12
|
+
Shape["TEXT"] = "text";
|
|
13
|
+
Shape["PATH"] = "path";
|
|
14
|
+
Shape["HTML"] = "html";
|
|
15
|
+
})(Shape || (Shape = {}));
|
|
16
|
+
|
|
17
|
+
export var LineCap;
|
|
18
|
+
|
|
19
|
+
(function (LineCap) {
|
|
20
|
+
LineCap["BUTT"] = "butt";
|
|
21
|
+
LineCap["ROUND"] = "round";
|
|
22
|
+
LineCap["SQUARE"] = "square";
|
|
23
|
+
})(LineCap || (LineCap = {}));
|
|
24
|
+
|
|
25
|
+
export var LineJoin;
|
|
26
|
+
|
|
27
|
+
(function (LineJoin) {
|
|
28
|
+
LineJoin["BEVEL"] = "bevel";
|
|
29
|
+
LineJoin["ROUND"] = "round";
|
|
30
|
+
LineJoin["MITER"] = "miter";
|
|
31
|
+
})(LineJoin || (LineJoin = {}));
|
|
32
|
+
|
|
33
|
+
export var TextTransform;
|
|
34
|
+
|
|
35
|
+
(function (TextTransform) {
|
|
36
|
+
TextTransform["CAPITALIZE"] = "capitalize";
|
|
37
|
+
TextTransform["UPPERCASE"] = "uppercase";
|
|
38
|
+
TextTransform["LOWERCASE"] = "lowercase";
|
|
39
|
+
TextTransform["NONE"] = "none";
|
|
40
|
+
})(TextTransform || (TextTransform = {}));
|
|
41
|
+
|
|
42
|
+
export var TextAlign;
|
|
43
|
+
|
|
44
|
+
(function (TextAlign) {
|
|
45
|
+
TextAlign["START"] = "start";
|
|
46
|
+
TextAlign["CENTER"] = "center";
|
|
47
|
+
TextAlign["END"] = "end";
|
|
48
|
+
TextAlign["LEFT"] = "left";
|
|
49
|
+
TextAlign["RIGHT"] = "right";
|
|
50
|
+
})(TextAlign || (TextAlign = {}));
|
|
32
51
|
|
|
33
52
|
export var CanvasConfig = 'CanvasConfig';
|
package/es/utils/animation.js
CHANGED
|
@@ -82,7 +82,7 @@ function calculatePhase(activeDuration, localTime, timing) {
|
|
|
82
82
|
return PhaseNone;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
var endTime = timing.
|
|
85
|
+
var endTime = timing.endTime;
|
|
86
86
|
|
|
87
87
|
if (localTime < Math.min(timing.delay, endTime)) {
|
|
88
88
|
return PhaseBefore;
|
|
@@ -6,7 +6,7 @@ import { __read, __spreadArray } from "tslib";
|
|
|
6
6
|
import { bezier } from './bezier-easing';
|
|
7
7
|
export var convertToDash = function convertToDash(str) {
|
|
8
8
|
str = str.replace(/([A-Z])/g, function (letter) {
|
|
9
|
-
return "-"
|
|
9
|
+
return "-".concat(letter.toLowerCase());
|
|
10
10
|
}); // Remove first dash
|
|
11
11
|
|
|
12
12
|
return str.charAt(0) === '-' ? str.substr(1) : str;
|
package/es/utils/event.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { isUndefined } from '@antv/util'; // use `self` instead of `window`, account for non-window contexts, such as in Web Workers
|
|
2
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/globalThis
|
|
2
3
|
// @see https://developer.mozilla.org/en-US/docs/Web/API/Window/self
|
|
3
4
|
|
|
4
|
-
export var supportsTouchEvents = !!
|
|
5
|
-
export var supportsPointerEvents = !!
|
|
5
|
+
export var supportsTouchEvents = !!globalThis.TouchEvent;
|
|
6
|
+
export var supportsPointerEvents = !!globalThis.PointerEvent;
|
|
6
7
|
export var MOUSE_POINTER_ID = 1;
|
|
7
8
|
export var TOUCH_TO_POINTER = {
|
|
8
9
|
touchstart: 'pointerdown',
|
|
@@ -15,7 +16,7 @@ export function isTouchEvent(event) {
|
|
|
15
16
|
return supportsTouchEvents && event instanceof TouchEvent;
|
|
16
17
|
}
|
|
17
18
|
export function isMouseEvent(event) {
|
|
18
|
-
return !
|
|
19
|
+
return !globalThis.MouseEvent || event instanceof MouseEvent && (!supportsPointerEvents || !(event instanceof globalThis.PointerEvent));
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
21
22
|
* borrow from pixi/events
|
|
@@ -26,7 +27,9 @@ export function normalizeToPointerEvent(event) {
|
|
|
26
27
|
|
|
27
28
|
if (isTouchEvent(event)) {
|
|
28
29
|
for (var i = 0; i < event.changedTouches.length; i++) {
|
|
29
|
-
var touch = event.changedTouches[i];
|
|
30
|
+
var touch = event.changedTouches[i]; // use changedTouches instead of touches since touchend has no touches
|
|
31
|
+
// @see https://stackoverflow.com/a/10079076
|
|
32
|
+
|
|
30
33
|
if (isUndefined(touch.button)) touch.button = event.touches.length ? 1 : 0;
|
|
31
34
|
if (isUndefined(touch.buttons)) touch.buttons = event.touches.length ? 1 : 0;
|
|
32
35
|
|
package/es/utils/index.d.ts
CHANGED
package/es/utils/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { AnimationEffectTiming } from '../dom';
|
|
2
2
|
import type { IElement } from '../dom/interfaces';
|
|
3
3
|
export declare function convertEffectInput(keyframes: ComputedKeyframe[], timing: AnimationEffectTiming, target: IElement | null): (target: IElement, fraction: number) => void;
|
|
4
|
+
export declare function formatAttribute(name: string, value: any): [string, any];
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { __read, __spreadArray } from "tslib";
|
|
2
|
-
import { stylePropertyMergerFactory, stylePropertyParserFactory } from '../global-module';
|
|
3
|
-
// StylePropertyMergerFactory,
|
|
4
|
-
// StylePropertyParserFactory,
|
|
5
|
-
// } from '../property-handlers/interfaces';
|
|
6
|
-
|
|
2
|
+
import { stylePropertyMergerFactory, stylePropertyParserFactory } from '../global-module';
|
|
7
3
|
import { parseEasingFunction } from './animation';
|
|
4
|
+
import { camelCase } from './string';
|
|
8
5
|
export function convertEffectInput(keyframes, timing, target) {
|
|
9
6
|
var propertySpecificKeyframeGroups = makePropertySpecificKeyframeGroups(keyframes, timing);
|
|
10
7
|
var interpolations = makeInterpolations(propertySpecificKeyframeGroups, target);
|
|
@@ -120,9 +117,9 @@ function propertyInterpolation(property, left, right, target) {
|
|
|
120
117
|
|
|
121
118
|
if (parser) {
|
|
122
119
|
// @ts-ignore
|
|
123
|
-
parsedLeft = parser(left, target); // @ts-ignore
|
|
120
|
+
parsedLeft = parser(left, target, property); // @ts-ignore
|
|
124
121
|
|
|
125
|
-
parsedRight = parser(right, target);
|
|
122
|
+
parsedRight = parser(right, target, property);
|
|
126
123
|
} // merger [left, right, n2string()]
|
|
127
124
|
|
|
128
125
|
|
|
@@ -179,4 +176,40 @@ convertToString) {
|
|
|
179
176
|
return function (f) {
|
|
180
177
|
return convertToString(interpolate(from, to, f));
|
|
181
178
|
};
|
|
182
|
-
};
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
var FORMAT_ATTR_MAP = {
|
|
182
|
+
d: {
|
|
183
|
+
alias: 'path'
|
|
184
|
+
},
|
|
185
|
+
cx: {
|
|
186
|
+
alias: 'x'
|
|
187
|
+
},
|
|
188
|
+
cy: {
|
|
189
|
+
alias: 'y'
|
|
190
|
+
},
|
|
191
|
+
strokeDasharray: {
|
|
192
|
+
alias: 'lineDash'
|
|
193
|
+
},
|
|
194
|
+
strokeWidth: {
|
|
195
|
+
alias: 'lineWidth'
|
|
196
|
+
},
|
|
197
|
+
textAnchor: {
|
|
198
|
+
alias: 'textAlign',
|
|
199
|
+
values: {
|
|
200
|
+
middle: 'center'
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
src: {
|
|
204
|
+
alias: 'img'
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
export function formatAttribute(name, value) {
|
|
208
|
+
var _a;
|
|
209
|
+
|
|
210
|
+
var attributeName = camelCase(name);
|
|
211
|
+
var map = FORMAT_ATTR_MAP[attributeName];
|
|
212
|
+
attributeName = (map === null || map === void 0 ? void 0 : map.alias) || attributeName;
|
|
213
|
+
var attributeValue = ((_a = map === null || map === void 0 ? void 0 : map.values) === null || _a === void 0 ? void 0 : _a[value]) || value;
|
|
214
|
+
return [attributeName, attributeValue];
|
|
215
|
+
}
|
package/es/utils/path.js
CHANGED
|
@@ -6,7 +6,7 @@ import { __read, __spreadArray } from "tslib";
|
|
|
6
6
|
|
|
7
7
|
import { Cubic as CubicUtil } from '@antv/g-math';
|
|
8
8
|
import { vec3 } from 'gl-matrix';
|
|
9
|
-
import {
|
|
9
|
+
import { Shape } from '../types';
|
|
10
10
|
|
|
11
11
|
function midPoint(a, b, t) {
|
|
12
12
|
var ax = a[0];
|
|
@@ -214,7 +214,7 @@ function commandsToPathString(commands, localTransform, anchor, parsedStyle) {
|
|
|
214
214
|
if (cur[0] === 'M' || cur[0] === 'L') {
|
|
215
215
|
var p = vec3.fromValues(cur[1] - x, cur[2] - y, 0);
|
|
216
216
|
vec3.transformMat4(p, p, localTransform);
|
|
217
|
-
path = ""
|
|
217
|
+
path = "".concat(cur[0]).concat(p[0], ",").concat(p[1]);
|
|
218
218
|
} else if (cur[0] === 'Z') {
|
|
219
219
|
path = cur[0];
|
|
220
220
|
} else if (cur[0] === 'C') {
|
|
@@ -224,11 +224,11 @@ function commandsToPathString(commands, localTransform, anchor, parsedStyle) {
|
|
|
224
224
|
vec3.transformMat4(p1, p1, localTransform);
|
|
225
225
|
vec3.transformMat4(p2, p2, localTransform);
|
|
226
226
|
vec3.transformMat4(p3, p3, localTransform);
|
|
227
|
-
path = ""
|
|
227
|
+
path = "".concat(cur[0]).concat(p1[0], ",").concat(p1[1], ",").concat(p2[0], ",").concat(p2[1], ",").concat(p3[0], ",").concat(p3[1]);
|
|
228
228
|
} else if (cur[0] === 'A') {
|
|
229
229
|
var c = vec3.fromValues(cur[6] - x, cur[7] - y, 0);
|
|
230
230
|
vec3.transformMat4(c, c, localTransform);
|
|
231
|
-
path = ""
|
|
231
|
+
path = "".concat(cur[0]).concat(cur[1], ",").concat(cur[2], ",").concat(cur[3], ",").concat(cur[4], ",").concat(cur[5], ",").concat(c[0], ",").concat(c[1]);
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
return prev += path;
|
|
@@ -278,7 +278,7 @@ export function convertToPath(object) {
|
|
|
278
278
|
var commands = [];
|
|
279
279
|
|
|
280
280
|
switch (object.nodeName) {
|
|
281
|
-
case
|
|
281
|
+
case Shape.LINE:
|
|
282
282
|
var _a = object.parsedStyle,
|
|
283
283
|
x1 = _a.x1,
|
|
284
284
|
y1 = _a.y1,
|
|
@@ -287,7 +287,7 @@ export function convertToPath(object) {
|
|
|
287
287
|
commands = lineToCommands(x1, y1, x2, y2);
|
|
288
288
|
break;
|
|
289
289
|
|
|
290
|
-
case
|
|
290
|
+
case Shape.CIRCLE:
|
|
291
291
|
{
|
|
292
292
|
var _b = object.parsedStyle,
|
|
293
293
|
r = _b.rInPixels,
|
|
@@ -299,7 +299,7 @@ export function convertToPath(object) {
|
|
|
299
299
|
break;
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
case
|
|
302
|
+
case Shape.ELLIPSE:
|
|
303
303
|
{
|
|
304
304
|
var _e = object.parsedStyle,
|
|
305
305
|
rx = _e.rxInPixels,
|
|
@@ -312,13 +312,13 @@ export function convertToPath(object) {
|
|
|
312
312
|
break;
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
-
case
|
|
316
|
-
case
|
|
315
|
+
case Shape.POLYLINE:
|
|
316
|
+
case Shape.POLYGON:
|
|
317
317
|
var points = object.parsedStyle.points;
|
|
318
318
|
commands = polygonToCommands(points.points);
|
|
319
319
|
break;
|
|
320
320
|
|
|
321
|
-
case
|
|
321
|
+
case Shape.RECT:
|
|
322
322
|
var _h = object.parsedStyle,
|
|
323
323
|
width = _h.widthInPixels,
|
|
324
324
|
height = _h.heightInPixels,
|
|
@@ -328,7 +328,7 @@ export function convertToPath(object) {
|
|
|
328
328
|
commands = rectToCommands(width, height, x, y, radius);
|
|
329
329
|
break;
|
|
330
330
|
|
|
331
|
-
case
|
|
331
|
+
case Shape.PATH:
|
|
332
332
|
commands = object.parsedStyle.path.curve;
|
|
333
333
|
break;
|
|
334
334
|
}
|
package/es/utils/raf.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* use user-defined raf instead of requestAnimationFrame
|
|
3
3
|
*/
|
|
4
|
-
export declare function patch(requestAFPatch: (callback:
|
|
4
|
+
export declare function patch(requestAFPatch: (callback: (timestamp: number) => void) => number, cancelAFPatch: (id: number) => void): void;
|
|
5
5
|
export declare const requestAnimationFrame: (callback: Function) => number;
|
|
6
6
|
export declare const cancelAnimationFrame: (id: number) => void;
|
package/es/utils/raf.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// import { requestAnimationFrame, cancelAnimationFrame } from 'request-animation-frame-polyfill';
|
|
2
|
-
// export { requestAnimationFrame, cancelAnimationFrame };
|
|
3
1
|
import { requestAnimationFrame as rAF, cancelAnimationFrame as cancelRAF } from 'request-animation-frame-polyfill';
|
|
4
2
|
var requestAF = rAF;
|
|
5
3
|
var cancelAF = cancelRAF;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function camelCase(str?: string): string;
|
package/es/utils/text.js
CHANGED
|
@@ -7,7 +7,7 @@ export function toFontString(attributes) {
|
|
|
7
7
|
fontVariant = attributes.fontVariant,
|
|
8
8
|
fontWeight = attributes.fontWeight; // build canvas api font setting from individual components. Convert a numeric this.fontSize to px
|
|
9
9
|
|
|
10
|
-
var fontSizeString = isNumber(fontSize) ? fontSize
|
|
10
|
+
var fontSizeString = isNumber(fontSize) ? "".concat(fontSize, "px") : "".concat(fontSize.value).concat(fontSize.unit || 'px'); // Clean-up fontFamily property by quoting each font name
|
|
11
11
|
// this will support font names with spaces
|
|
12
12
|
// @ts-ignore
|
|
13
13
|
|
|
@@ -22,11 +22,11 @@ export function toFontString(attributes) {
|
|
|
22
22
|
var fontFamily_1 = fontFamilies[i].trim(); // Check if font already contains strings
|
|
23
23
|
|
|
24
24
|
if (!/([\"\'])[^\'\"]+\1/.test(fontFamily_1) && genericFontFamilies.indexOf(fontFamily_1) < 0) {
|
|
25
|
-
fontFamily_1 = "\""
|
|
25
|
+
fontFamily_1 = "\"".concat(fontFamily_1, "\"");
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
fontFamilies[i] = fontFamily_1;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
return fontStyle
|
|
31
|
+
return "".concat(fontStyle, " ").concat(fontVariant, " ").concat(fontWeight, " ").concat(fontSizeString, " ").concat(fontFamilies.join(','));
|
|
32
32
|
}
|
package/lib/Canvas.d.ts
CHANGED
|
@@ -71,8 +71,14 @@ export declare class Canvas extends EventTarget implements ICanvas {
|
|
|
71
71
|
getRenderingContext(): RenderingContext;
|
|
72
72
|
getStats(): {
|
|
73
73
|
total: number;
|
|
74
|
-
rendered: number;
|
|
74
|
+
rendered: number; /**
|
|
75
|
+
* window.document
|
|
76
|
+
*/
|
|
77
|
+
renderedOnscreen: number;
|
|
75
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Window/getComputedStyle
|
|
81
|
+
*/
|
|
76
82
|
getComputedStyle(node: DisplayObject): any;
|
|
77
83
|
get ready(): Promise<any>;
|
|
78
84
|
destroy(destroyScenegraph?: boolean): void;
|
package/lib/Canvas.js
CHANGED
|
@@ -131,11 +131,6 @@ function (_super) {
|
|
|
131
131
|
* the root node in scene graph
|
|
132
132
|
*/
|
|
133
133
|
root: this.document.documentElement,
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* removed render bounds
|
|
137
|
-
*/
|
|
138
|
-
removedRenderBoundsList: [],
|
|
139
134
|
renderReasons: new Set(),
|
|
140
135
|
force: false,
|
|
141
136
|
dirty: false
|
|
@@ -154,8 +149,8 @@ function (_super) {
|
|
|
154
149
|
var camera = new _camera.Camera().setPosition(width / 2, height / 2, 500).setFocalPoint(width / 2, height / 2, 0).setOrthographic(width / -2, width / 2, height / 2, height / -2, 0.1, 1000); // redraw when camera changed
|
|
155
150
|
|
|
156
151
|
var context = this.container.get(_RenderingContext.RenderingContext);
|
|
157
|
-
camera.on(_camera.
|
|
158
|
-
context.renderReasons.add(_RenderingContext.
|
|
152
|
+
camera.on(_camera.CameraEvent.UPDATED, function () {
|
|
153
|
+
context.renderReasons.add(_RenderingContext.RenderReason.CAMERA_CHANGED);
|
|
159
154
|
}); // bind camera
|
|
160
155
|
|
|
161
156
|
this.container.register({
|
|
@@ -208,6 +203,10 @@ function (_super) {
|
|
|
208
203
|
Canvas.prototype.getStats = function () {
|
|
209
204
|
return this.getRenderingService().getStats();
|
|
210
205
|
};
|
|
206
|
+
/**
|
|
207
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Window/getComputedStyle
|
|
208
|
+
*/
|
|
209
|
+
|
|
211
210
|
|
|
212
211
|
Canvas.prototype.getComputedStyle = function (node) {
|
|
213
212
|
return node.parsedStyle;
|
|
@@ -327,7 +326,7 @@ function (_super) {
|
|
|
327
326
|
|
|
328
327
|
if (this.container.isBound(_RenderingService.RenderingService)) {
|
|
329
328
|
var renderingService = this.container.get(_RenderingService.RenderingService);
|
|
330
|
-
renderingService.render();
|
|
329
|
+
renderingService.render(this.getConfig());
|
|
331
330
|
}
|
|
332
331
|
|
|
333
332
|
this.emit(CanvasEvent.AFTER_RENDER, {});
|