@antv/g 5.0.13 → 5.0.16
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 +3 -0
- package/es/Canvas.js +9 -9
- package/es/camera/Camera.d.ts +3 -2
- package/es/camera/Camera.js +16 -8
- package/es/canvas-module.js +11 -17
- package/es/components/Transform.d.ts +0 -1
- package/es/components/Transform.js +0 -1
- package/es/display-objects/Circle.d.ts +4 -2
- 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 +4 -3
- package/es/display-objects/DisplayObject.js +80 -49
- package/es/display-objects/Ellipse.d.ts +6 -3
- package/es/display-objects/Ellipse.js +8 -3
- package/es/display-objects/Group.d.ts +18 -2
- package/es/display-objects/Group.js +14 -9
- package/es/display-objects/HTML.d.ts +6 -1
- package/es/display-objects/HTML.js +10 -5
- package/es/display-objects/Image.d.ts +12 -7
- package/es/display-objects/Image.js +10 -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 +8 -5
- package/es/display-objects/Rect.js +9 -4
- package/es/display-objects/Text.d.ts +9 -6
- package/es/display-objects/Text.js +15 -10
- package/es/dom/Animation.js +1 -1
- package/es/dom/AnimationTimeline.js +1 -2
- package/es/dom/CustomElementRegistry.js +12 -12
- package/es/dom/Document.d.ts +1 -0
- package/es/dom/Document.js +21 -1
- package/es/dom/Element.d.ts +14 -9
- package/es/dom/Element.js +41 -14
- package/es/dom/EventTarget.d.ts +2 -2
- package/es/dom/EventTarget.js +4 -3
- 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 +36 -8
- package/es/dom/interfaces.js +23 -5
- package/es/global-module.d.ts +4 -1
- package/es/global-module.js +38 -80
- 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/FrustumCullingStrategy.d.ts +1 -0
- package/es/plugins/FrustumCullingStrategy.js +40 -33
- package/es/plugins/PrepareRendererPlugin.js +21 -5
- package/es/property-handlers/aabb.js +22 -24
- package/es/property-handlers/anchor.js +2 -1
- package/es/property-handlers/color.js +5 -2
- package/es/property-handlers/dimension.d.ts +15 -2
- package/es/property-handlers/dimension.js +77 -8
- 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/path.d.ts +1 -1
- 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 +3 -5
- package/es/services/RenderingContext.d.ts +5 -8
- package/es/services/RenderingContext.js +6 -7
- package/es/services/RenderingService.js +2 -8
- package/es/services/SceneGraphSelector.d.ts +3 -2
- package/es/services/SceneGraphSelector.js +8 -4
- package/es/services/SceneGraphService.d.ts +7 -14
- package/es/services/SceneGraphService.js +14 -82
- package/es/services/aabb/CircleUpdater.d.ts +2 -2
- package/es/services/aabb/CircleUpdater.js +21 -11
- package/es/services/aabb/EllipseUpdater.d.ts +2 -2
- package/es/services/aabb/EllipseUpdater.js +28 -13
- 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.d.ts +2 -2
- package/es/services/aabb/RectUpdater.js +33 -17
- package/es/services/aabb/TextUpdater.js +19 -10
- package/es/services/aabb/interfaces.d.ts +1 -1
- package/es/services/aabb/interfaces.js +1 -1
- package/es/services/text/index.js +19 -21
- package/es/shapes/AABB.d.ts +1 -0
- package/es/shapes/AABB.js +8 -0
- package/es/types.d.ts +48 -27
- package/es/types.js +50 -31
- package/es/utils/custom-easing.js +1 -1
- package/es/utils/event.js +5 -3
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +2 -1
- package/es/utils/interpolation.d.ts +1 -0
- package/es/utils/interpolation.js +41 -8
- package/es/utils/path.d.ts +1 -1
- package/es/utils/path.js +16 -16
- 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 +3 -0
- package/lib/Canvas.js +7 -7
- package/lib/camera/Camera.d.ts +3 -2
- package/lib/camera/Camera.js +20 -10
- package/lib/canvas-module.js +10 -15
- package/lib/components/Transform.d.ts +0 -1
- package/lib/components/Transform.js +0 -1
- package/lib/display-objects/Circle.d.ts +4 -2
- 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 +4 -3
- package/lib/display-objects/DisplayObject.js +79 -46
- package/lib/display-objects/Ellipse.d.ts +6 -3
- package/lib/display-objects/Ellipse.js +7 -2
- package/lib/display-objects/Group.d.ts +18 -2
- package/lib/display-objects/Group.js +13 -9
- package/lib/display-objects/HTML.d.ts +6 -1
- package/lib/display-objects/HTML.js +9 -5
- package/lib/display-objects/Image.d.ts +12 -7
- package/lib/display-objects/Image.js +9 -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 +8 -5
- package/lib/display-objects/Rect.js +8 -3
- package/lib/display-objects/Text.d.ts +9 -6
- package/lib/display-objects/Text.js +14 -9
- package/lib/dom/Animation.js +1 -1
- package/lib/dom/AnimationTimeline.js +1 -2
- package/lib/dom/CustomElementRegistry.js +11 -11
- package/lib/dom/Document.d.ts +1 -0
- package/lib/dom/Document.js +22 -1
- package/lib/dom/Element.d.ts +14 -9
- package/lib/dom/Element.js +43 -14
- package/lib/dom/EventTarget.d.ts +2 -2
- package/lib/dom/EventTarget.js +4 -3
- 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 +36 -8
- package/lib/dom/interfaces.js +23 -5
- package/lib/global-module.d.ts +4 -1
- package/lib/global-module.js +44 -76
- 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/FrustumCullingStrategy.d.ts +1 -0
- package/lib/plugins/FrustumCullingStrategy.js +41 -33
- package/lib/plugins/PrepareRendererPlugin.js +24 -4
- package/lib/property-handlers/aabb.js +21 -23
- package/lib/property-handlers/anchor.js +3 -1
- package/lib/property-handlers/color.js +6 -3
- package/lib/property-handlers/dimension.d.ts +15 -2
- package/lib/property-handlers/dimension.js +80 -7
- 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/path.d.ts +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 +3 -5
- package/lib/services/RenderingContext.d.ts +5 -8
- package/lib/services/RenderingContext.js +8 -9
- package/lib/services/RenderingService.js +1 -7
- package/lib/services/SceneGraphSelector.d.ts +3 -2
- package/lib/services/SceneGraphSelector.js +10 -3
- package/lib/services/SceneGraphService.d.ts +7 -14
- package/lib/services/SceneGraphService.js +15 -82
- package/lib/services/aabb/CircleUpdater.d.ts +2 -2
- package/lib/services/aabb/CircleUpdater.js +20 -10
- package/lib/services/aabb/EllipseUpdater.d.ts +2 -2
- package/lib/services/aabb/EllipseUpdater.js +27 -12
- 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.d.ts +2 -2
- package/lib/services/aabb/RectUpdater.js +32 -16
- package/lib/services/aabb/TextUpdater.js +18 -9
- package/lib/services/aabb/interfaces.d.ts +1 -1
- package/lib/services/aabb/interfaces.js +1 -1
- package/lib/services/text/index.js +19 -21
- package/lib/shapes/AABB.d.ts +1 -0
- package/lib/shapes/AABB.js +8 -0
- package/lib/types.d.ts +48 -27
- package/lib/types.js +56 -35
- package/lib/utils/custom-easing.js +1 -1
- package/lib/utils/event.js +5 -3
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +13 -0
- package/lib/utils/interpolation.d.ts +1 -0
- package/lib/utils/interpolation.js +43 -7
- package/lib/utils/path.d.ts +1 -1
- package/lib/utils/path.js +15 -15
- 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 +6 -4
|
@@ -46,10 +46,10 @@ function () {
|
|
|
46
46
|
PolylineUpdater = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)({
|
|
47
47
|
token: [{
|
|
48
48
|
token: _interfaces.GeometryAABBUpdater,
|
|
49
|
-
named: _types.
|
|
49
|
+
named: _types.Shape.POLYLINE
|
|
50
50
|
}, {
|
|
51
51
|
token: _interfaces.GeometryAABBUpdater,
|
|
52
|
-
named: _types.
|
|
52
|
+
named: _types.Shape.POLYGON
|
|
53
53
|
}]
|
|
54
54
|
})], PolylineUpdater);
|
|
55
55
|
return PolylineUpdater;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GeometryAABBUpdater } from './interfaces';
|
|
2
|
-
import type { ParsedImageStyleProps } from '../../display-objects/Image';
|
|
2
|
+
import type { Image, ParsedImageStyleProps } from '../../display-objects/Image';
|
|
3
3
|
export declare class RectUpdater implements GeometryAABBUpdater<ParsedImageStyleProps> {
|
|
4
|
-
update(
|
|
4
|
+
update(parsedStyle: ParsedImageStyleProps, object: Image): {
|
|
5
5
|
width: number;
|
|
6
6
|
height: number;
|
|
7
7
|
x: number;
|
|
@@ -20,32 +20,45 @@ var RectUpdater =
|
|
|
20
20
|
function () {
|
|
21
21
|
function RectUpdater() {}
|
|
22
22
|
|
|
23
|
-
RectUpdater.prototype.update = function (
|
|
24
|
-
var img =
|
|
25
|
-
_a =
|
|
23
|
+
RectUpdater.prototype.update = function (parsedStyle, object) {
|
|
24
|
+
var img = parsedStyle.img,
|
|
25
|
+
_a = parsedStyle.x,
|
|
26
26
|
x = _a === void 0 ? 0 : _a,
|
|
27
|
-
_b =
|
|
27
|
+
_b = parsedStyle.y,
|
|
28
28
|
y = _b === void 0 ? 0 : _b,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var
|
|
34
|
-
|
|
29
|
+
width = parsedStyle.width,
|
|
30
|
+
height = parsedStyle.height;
|
|
31
|
+
var contentWidth = 0;
|
|
32
|
+
var contentHeight = 0;
|
|
33
|
+
var widthUnit = width.unit,
|
|
34
|
+
widthValue = width.value;
|
|
35
|
+
var heightUnit = height.unit,
|
|
36
|
+
heightValue = height.value;
|
|
37
|
+
|
|
38
|
+
if (widthUnit === '' || widthUnit === 'px') {
|
|
39
|
+
contentWidth = widthValue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (heightUnit === '' || heightUnit === 'px') {
|
|
43
|
+
contentHeight = heightValue;
|
|
44
|
+
} // resize with HTMLImageElement's size
|
|
45
|
+
|
|
35
46
|
|
|
36
47
|
if (img && !(0, _util.isString)(img)) {
|
|
37
|
-
if (!
|
|
48
|
+
if (!contentWidth) {
|
|
38
49
|
contentWidth = img.width;
|
|
39
50
|
}
|
|
40
51
|
|
|
41
|
-
if (!
|
|
52
|
+
if (!contentHeight) {
|
|
42
53
|
contentHeight = img.height;
|
|
43
54
|
}
|
|
44
55
|
}
|
|
45
56
|
|
|
57
|
+
object.parsedStyle.widthInPixels = contentWidth;
|
|
58
|
+
object.parsedStyle.heightInPixels = contentHeight;
|
|
46
59
|
return {
|
|
47
|
-
width: contentWidth
|
|
48
|
-
height: contentHeight
|
|
60
|
+
width: contentWidth,
|
|
61
|
+
height: contentHeight,
|
|
49
62
|
x: x,
|
|
50
63
|
y: y
|
|
51
64
|
};
|
|
@@ -54,10 +67,13 @@ function () {
|
|
|
54
67
|
RectUpdater = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)({
|
|
55
68
|
token: [{
|
|
56
69
|
token: _interfaces.GeometryAABBUpdater,
|
|
57
|
-
named: _types.
|
|
70
|
+
named: _types.Shape.RECT
|
|
71
|
+
}, {
|
|
72
|
+
token: _interfaces.GeometryAABBUpdater,
|
|
73
|
+
named: _types.Shape.IMAGE
|
|
58
74
|
}, {
|
|
59
75
|
token: _interfaces.GeometryAABBUpdater,
|
|
60
|
-
named: _types.
|
|
76
|
+
named: _types.Shape.GROUP
|
|
61
77
|
}]
|
|
62
78
|
})], RectUpdater);
|
|
63
79
|
return RectUpdater;
|
|
@@ -26,13 +26,14 @@ function () {
|
|
|
26
26
|
var _a = parsedStyle.text,
|
|
27
27
|
text = _a === void 0 ? '' : _a,
|
|
28
28
|
textAlign = parsedStyle.textAlign,
|
|
29
|
-
|
|
30
|
-
lineWidth = _b === void 0 ? 0 : _b,
|
|
29
|
+
lineWidth = parsedStyle.lineWidth,
|
|
31
30
|
textBaseline = parsedStyle.textBaseline,
|
|
32
|
-
|
|
33
|
-
x =
|
|
34
|
-
|
|
35
|
-
y =
|
|
31
|
+
_b = parsedStyle.x,
|
|
32
|
+
x = _b === void 0 ? 0 : _b,
|
|
33
|
+
_c = parsedStyle.y,
|
|
34
|
+
y = _c === void 0 ? 0 : _c,
|
|
35
|
+
dx = parsedStyle.dx,
|
|
36
|
+
dy = parsedStyle.dy;
|
|
36
37
|
var metrics = this.textService.measureText(text, parsedStyle);
|
|
37
38
|
parsedStyle.metrics = metrics;
|
|
38
39
|
var width = metrics.width,
|
|
@@ -47,10 +48,10 @@ function () {
|
|
|
47
48
|
var lineXOffset = 0;
|
|
48
49
|
|
|
49
50
|
if (textAlign === 'center') {
|
|
50
|
-
lineXOffset = lineWidth / 2;
|
|
51
|
+
lineXOffset = lineWidth.value / 2;
|
|
51
52
|
anchor = [0.5, 1];
|
|
52
53
|
} else if (textAlign === 'right' || textAlign === 'end') {
|
|
53
|
-
lineXOffset = lineWidth;
|
|
54
|
+
lineXOffset = lineWidth.value;
|
|
54
55
|
anchor = [1, 1];
|
|
55
56
|
} // update anchor
|
|
56
57
|
|
|
@@ -70,6 +71,14 @@ function () {
|
|
|
70
71
|
} // TODO: ideographic & bottom
|
|
71
72
|
|
|
72
73
|
|
|
74
|
+
if (dx && dx.unit === 'px') {
|
|
75
|
+
lineXOffset += dx.value;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (dy && dy.unit === 'px') {
|
|
79
|
+
lineYOffset += dy.value;
|
|
80
|
+
}
|
|
81
|
+
|
|
73
82
|
return {
|
|
74
83
|
width: halfExtents[0] * 2,
|
|
75
84
|
height: halfExtents[1] * 2,
|
|
@@ -84,7 +93,7 @@ function () {
|
|
|
84
93
|
TextUpdater = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)({
|
|
85
94
|
token: {
|
|
86
95
|
token: _interfaces.GeometryAABBUpdater,
|
|
87
|
-
named: _types.
|
|
96
|
+
named: _types.Shape.TEXT
|
|
88
97
|
}
|
|
89
98
|
})], TextUpdater);
|
|
90
99
|
return TextUpdater;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DisplayObject } from '../../display-objects/DisplayObject';
|
|
2
2
|
import type { ParsedBaseStyleProps } from '../../types';
|
|
3
3
|
export declare const GeometryUpdaterFactory = "GeometryUpdaterFactory";
|
|
4
|
-
export declare const GeometryAABBUpdater = "
|
|
4
|
+
export declare const GeometryAABBUpdater = "GeometryAABBUpdater";
|
|
5
5
|
export interface GeometryAABBUpdater<T extends ParsedBaseStyleProps = any> {
|
|
6
6
|
update: (parsedStyle: T, object: DisplayObject) => {
|
|
7
7
|
width: number;
|
|
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.GeometryUpdaterFactory = exports.GeometryAABBUpdater = void 0;
|
|
7
7
|
var GeometryUpdaterFactory = 'GeometryUpdaterFactory';
|
|
8
8
|
exports.GeometryUpdaterFactory = GeometryUpdaterFactory;
|
|
9
|
-
var GeometryAABBUpdater = '
|
|
9
|
+
var GeometryAABBUpdater = 'GeometryAABBUpdater';
|
|
10
10
|
exports.GeometryAABBUpdater = GeometryAABBUpdater;
|
|
@@ -36,8 +36,8 @@ var regexCannotStartJaJp = /[)\]}〕〉》」』】〙〗〟'"⦆»ヽヾー
|
|
|
36
36
|
var regexCannotEndJaJp = /[([{〔〈《「『【〘〖〝'"⦅«—...‥〳〴〵]/;
|
|
37
37
|
var regexCannotStartKoKr = /[!%),.:;?\]}¢°'"†‡℃〆〈《「『〕!%),.:;?]}]/;
|
|
38
38
|
var regexCannotEndKoKr = /[$([{£¥'"々〇〉》」〔$([{⦆¥₩#]/;
|
|
39
|
-
var regexCannotStart = new RegExp(regexCannotStartZhCn.source
|
|
40
|
-
var regexCannotEnd = new RegExp(regexCannotEndZhCn.source
|
|
39
|
+
var regexCannotStart = new RegExp("".concat(regexCannotStartZhCn.source, "|").concat(regexCannotStartZhTw.source, "|").concat(regexCannotStartJaJp.source, "|").concat(regexCannotStartKoKr.source));
|
|
40
|
+
var regexCannotEnd = new RegExp("".concat(regexCannotEndZhCn.source, "|").concat(regexCannotEndZhTw.source, "|").concat(regexCannotEndJaJp.source, "|").concat(regexCannotEndKoKr.source));
|
|
41
41
|
|
|
42
42
|
var TextService =
|
|
43
43
|
/** @class */
|
|
@@ -104,7 +104,7 @@ function () {
|
|
|
104
104
|
context.textBaseline = 'alphabetic';
|
|
105
105
|
context.fillStyle = '#000';
|
|
106
106
|
context.fillText(metricsString, 0, baseline);
|
|
107
|
-
var imagedata = context.getImageData(0, 0, width, height).data;
|
|
107
|
+
var imagedata = context.getImageData(0, 0, width || 1, height || 1).data;
|
|
108
108
|
var pixels = imagedata.length;
|
|
109
109
|
var line = width * 4;
|
|
110
110
|
var i = 0;
|
|
@@ -152,29 +152,27 @@ function () {
|
|
|
152
152
|
};
|
|
153
153
|
|
|
154
154
|
TextService.prototype.measureText = function (text, attributes) {
|
|
155
|
-
var
|
|
156
|
-
fontSize = _a === void 0 ? 0 : _a,
|
|
155
|
+
var fontSize = attributes.fontSize,
|
|
157
156
|
wordWrap = attributes.wordWrap,
|
|
158
|
-
|
|
159
|
-
strokeHeight =
|
|
160
|
-
|
|
161
|
-
lineWidth = _c === void 0 ? 0 : _c,
|
|
157
|
+
_a = attributes.lineHeight,
|
|
158
|
+
strokeHeight = _a === void 0 ? 0 : _a,
|
|
159
|
+
lineWidth = attributes.lineWidth,
|
|
162
160
|
textBaseline = attributes.textBaseline,
|
|
163
161
|
textAlign = attributes.textAlign,
|
|
164
|
-
|
|
165
|
-
letterSpacing =
|
|
162
|
+
_b = attributes.letterSpacing,
|
|
163
|
+
letterSpacing = _b === void 0 ? 0 : _b,
|
|
166
164
|
dropShadow = attributes.dropShadow,
|
|
167
|
-
|
|
168
|
-
dropShadowDistance =
|
|
169
|
-
|
|
170
|
-
leading =
|
|
165
|
+
_c = attributes.dropShadowDistance,
|
|
166
|
+
dropShadowDistance = _c === void 0 ? 0 : _c,
|
|
167
|
+
_d = attributes.leading,
|
|
168
|
+
leading = _d === void 0 ? 0 : _d;
|
|
171
169
|
var font = (0, _text.toFontString)(attributes);
|
|
172
170
|
var fontProperties = this.measureFont(font); // fallback in case UA disallow canvas data extraction
|
|
173
171
|
// (toDataURI, getImageData functions)
|
|
174
172
|
|
|
175
173
|
if (fontProperties.fontSize === 0) {
|
|
176
|
-
fontProperties.fontSize = fontSize;
|
|
177
|
-
fontProperties.ascent = fontSize;
|
|
174
|
+
fontProperties.fontSize = fontSize.value;
|
|
175
|
+
fontProperties.ascent = fontSize.value;
|
|
178
176
|
}
|
|
179
177
|
|
|
180
178
|
var context = this.offscreenCanvas.getOrCreateContext();
|
|
@@ -190,14 +188,14 @@ function () {
|
|
|
190
188
|
maxLineWidth = Math.max(maxLineWidth, lineWidth_1);
|
|
191
189
|
}
|
|
192
190
|
|
|
193
|
-
var width = maxLineWidth + lineWidth;
|
|
191
|
+
var width = maxLineWidth + lineWidth.value;
|
|
194
192
|
|
|
195
193
|
if (dropShadow) {
|
|
196
194
|
width += dropShadowDistance;
|
|
197
195
|
}
|
|
198
196
|
|
|
199
|
-
var lineHeight = strokeHeight || fontProperties.fontSize + lineWidth;
|
|
200
|
-
var height = Math.max(lineHeight, fontProperties.fontSize + lineWidth) + (lines.length - 1) * (lineHeight + leading);
|
|
197
|
+
var lineHeight = strokeHeight || fontProperties.fontSize + lineWidth.value;
|
|
198
|
+
var height = Math.max(lineHeight, fontProperties.fontSize + lineWidth.value) + (lines.length - 1) * (lineHeight + leading);
|
|
201
199
|
|
|
202
200
|
if (dropShadow) {
|
|
203
201
|
height += dropShadowDistance;
|
|
@@ -233,7 +231,7 @@ function () {
|
|
|
233
231
|
offsetX -= width;
|
|
234
232
|
}
|
|
235
233
|
|
|
236
|
-
return new _shapes.Rectangle(offsetX - lineWidth / 2, offsetY + i * lineHeight, width + lineWidth, lineHeight);
|
|
234
|
+
return new _shapes.Rectangle(offsetX - lineWidth.value / 2, offsetY + i * lineHeight, width + lineWidth.value, lineHeight);
|
|
237
235
|
})
|
|
238
236
|
};
|
|
239
237
|
};
|
package/lib/shapes/AABB.d.ts
CHANGED
package/lib/shapes/AABB.js
CHANGED
|
@@ -21,6 +21,10 @@ function () {
|
|
|
21
21
|
this.update(center, halfExtents);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
AABB.isEmpty = function (aabb) {
|
|
25
|
+
return !aabb || aabb.halfExtents[0] === 0 && aabb.halfExtents[1] === 0 && aabb.halfExtents[2] === 0;
|
|
26
|
+
};
|
|
27
|
+
|
|
24
28
|
AABB.prototype.update = function (center, halfExtents) {
|
|
25
29
|
this.center = _glMatrix.vec3.copy(_glMatrix.vec3.create(), center || _glMatrix.vec3.create());
|
|
26
30
|
this.halfExtents = _glMatrix.vec3.copy(_glMatrix.vec3.create(), halfExtents || _glMatrix.vec3.fromValues(0, 0, 0));
|
|
@@ -51,6 +55,10 @@ function () {
|
|
|
51
55
|
};
|
|
52
56
|
|
|
53
57
|
AABB.prototype.add = function (aabb) {
|
|
58
|
+
if (AABB.isEmpty(aabb)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
54
62
|
var tc = this.center;
|
|
55
63
|
var tcx = tc[0];
|
|
56
64
|
var tcy = tc[1];
|
package/lib/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,17 +114,16 @@ 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
|
*/
|
|
111
125
|
lineDash?: number[] | null;
|
|
112
126
|
lineDashOffset?: number;
|
|
113
|
-
padding?: number[] | number;
|
|
114
127
|
/**
|
|
115
128
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/shadowBlur
|
|
116
129
|
*/
|
|
@@ -127,16 +140,23 @@ export interface BaseStyleProps {
|
|
|
127
140
|
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter
|
|
128
141
|
*/
|
|
129
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;
|
|
130
151
|
}
|
|
131
|
-
export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'fill' | 'stroke' | 'path' | 'points'> {
|
|
152
|
+
export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'fill' | 'stroke' | 'path' | 'points' | 'lineWidth' | 'shadowColor'> {
|
|
132
153
|
fill?: ParsedColorStyleProperty;
|
|
133
154
|
stroke?: ParsedColorStyleProperty;
|
|
134
155
|
path?: ParsedPathStyleProps;
|
|
135
156
|
points?: ParsedPolylineStyleProps;
|
|
136
157
|
x?: number;
|
|
137
158
|
y?: number;
|
|
138
|
-
|
|
139
|
-
height?: number;
|
|
159
|
+
lineWidth?: ParsedElement;
|
|
140
160
|
/**
|
|
141
161
|
* x according to definition, eg. Line's x1/x2, Polyline's points
|
|
142
162
|
*/
|
|
@@ -147,6 +167,7 @@ export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'fill' | 'str
|
|
|
147
167
|
*/
|
|
148
168
|
offsetX?: number;
|
|
149
169
|
offsetY?: number;
|
|
170
|
+
shadowColor?: ParsedColorStyleProperty;
|
|
150
171
|
}
|
|
151
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';
|
|
152
173
|
export interface RendererConfig {
|
package/lib/types.js
CHANGED
|
@@ -3,41 +3,62 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
var
|
|
8
|
-
exports.
|
|
9
|
-
|
|
10
|
-
(function (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
})(
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
-
exports.
|
|
26
|
-
|
|
27
|
-
(function (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})(
|
|
32
|
-
|
|
33
|
-
var
|
|
34
|
-
exports.
|
|
35
|
-
|
|
36
|
-
(function (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
})(
|
|
6
|
+
exports.TextTransform = exports.TextAlign = exports.Shape = exports.LineJoin = exports.LineCap = exports.CanvasConfig = void 0;
|
|
7
|
+
var Shape;
|
|
8
|
+
exports.Shape = Shape;
|
|
9
|
+
|
|
10
|
+
(function (Shape) {
|
|
11
|
+
Shape["GROUP"] = "g";
|
|
12
|
+
Shape["CIRCLE"] = "circle";
|
|
13
|
+
Shape["ELLIPSE"] = "ellipse";
|
|
14
|
+
Shape["IMAGE"] = "image";
|
|
15
|
+
Shape["RECT"] = "rect";
|
|
16
|
+
Shape["LINE"] = "line";
|
|
17
|
+
Shape["POLYLINE"] = "polyline";
|
|
18
|
+
Shape["POLYGON"] = "polygon";
|
|
19
|
+
Shape["TEXT"] = "text";
|
|
20
|
+
Shape["PATH"] = "path";
|
|
21
|
+
Shape["HTML"] = "html";
|
|
22
|
+
})(Shape || (exports.Shape = Shape = {}));
|
|
23
|
+
|
|
24
|
+
var LineCap;
|
|
25
|
+
exports.LineCap = LineCap;
|
|
26
|
+
|
|
27
|
+
(function (LineCap) {
|
|
28
|
+
LineCap["BUTT"] = "butt";
|
|
29
|
+
LineCap["ROUND"] = "round";
|
|
30
|
+
LineCap["SQUARE"] = "square";
|
|
31
|
+
})(LineCap || (exports.LineCap = LineCap = {}));
|
|
32
|
+
|
|
33
|
+
var LineJoin;
|
|
34
|
+
exports.LineJoin = LineJoin;
|
|
35
|
+
|
|
36
|
+
(function (LineJoin) {
|
|
37
|
+
LineJoin["BEVEL"] = "bevel";
|
|
38
|
+
LineJoin["ROUND"] = "round";
|
|
39
|
+
LineJoin["MITER"] = "miter";
|
|
40
|
+
})(LineJoin || (exports.LineJoin = LineJoin = {}));
|
|
41
|
+
|
|
42
|
+
var TextTransform;
|
|
43
|
+
exports.TextTransform = TextTransform;
|
|
44
|
+
|
|
45
|
+
(function (TextTransform) {
|
|
46
|
+
TextTransform["CAPITALIZE"] = "capitalize";
|
|
47
|
+
TextTransform["UPPERCASE"] = "uppercase";
|
|
48
|
+
TextTransform["LOWERCASE"] = "lowercase";
|
|
49
|
+
TextTransform["NONE"] = "none";
|
|
50
|
+
})(TextTransform || (exports.TextTransform = TextTransform = {}));
|
|
51
|
+
|
|
52
|
+
var TextAlign;
|
|
53
|
+
exports.TextAlign = TextAlign;
|
|
54
|
+
|
|
55
|
+
(function (TextAlign) {
|
|
56
|
+
TextAlign["START"] = "start";
|
|
57
|
+
TextAlign["CENTER"] = "center";
|
|
58
|
+
TextAlign["END"] = "end";
|
|
59
|
+
TextAlign["LEFT"] = "left";
|
|
60
|
+
TextAlign["RIGHT"] = "right";
|
|
61
|
+
})(TextAlign || (exports.TextAlign = TextAlign = {}));
|
|
41
62
|
|
|
42
63
|
var CanvasConfig = 'CanvasConfig';
|
|
43
64
|
exports.CanvasConfig = CanvasConfig;
|
|
@@ -14,7 +14,7 @@ var _bezierEasing = require("./bezier-easing");
|
|
|
14
14
|
*/
|
|
15
15
|
var convertToDash = function convertToDash(str) {
|
|
16
16
|
str = str.replace(/([A-Z])/g, function (letter) {
|
|
17
|
-
return "-"
|
|
17
|
+
return "-".concat(letter.toLowerCase());
|
|
18
18
|
}); // Remove first dash
|
|
19
19
|
|
|
20
20
|
return str.charAt(0) === '-' ? str.substr(1) : str;
|
package/lib/utils/event.js
CHANGED
|
@@ -45,9 +45,11 @@ function normalizeToPointerEvent(event) {
|
|
|
45
45
|
|
|
46
46
|
if (isTouchEvent(event)) {
|
|
47
47
|
for (var i = 0; i < event.changedTouches.length; i++) {
|
|
48
|
-
var touch = event.changedTouches[i];
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
var touch = event.changedTouches[i]; // use changedTouches instead of touches since touchend has no touches
|
|
49
|
+
// @see https://stackoverflow.com/a/10079076
|
|
50
|
+
|
|
51
|
+
if ((0, _util.isUndefined)(touch.button)) touch.button = event.changedTouches.length ? 1 : 0;
|
|
52
|
+
if ((0, _util.isUndefined)(touch.buttons)) touch.buttons = event.changedTouches.length ? 1 : 0;
|
|
51
53
|
|
|
52
54
|
if ((0, _util.isUndefined)(touch.isPrimary)) {
|
|
53
55
|
touch.isPrimary = event.touches.length === 1 && event.type === 'touchstart';
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
|
@@ -67,4 +67,17 @@ Object.keys(_text).forEach(function (key) {
|
|
|
67
67
|
return _text[key];
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
var _string = require("./string");
|
|
73
|
+
|
|
74
|
+
Object.keys(_string).forEach(function (key) {
|
|
75
|
+
if (key === "default" || key === "__esModule") return;
|
|
76
|
+
if (key in exports && exports[key] === _string[key]) return;
|
|
77
|
+
Object.defineProperty(exports, key, {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function get() {
|
|
80
|
+
return _string[key];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
70
83
|
});
|
|
@@ -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];
|