@antv/g 5.0.1 → 5.0.5
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/LICENSE +21 -0
- package/dist/index.umd.js +2 -2
- package/es/AbstractRenderer.d.ts +7 -7
- package/es/Canvas.d.ts +15 -5
- package/es/Canvas.js +10 -5
- package/es/camera/Camera.js +3 -5
- package/es/components/Geometry.d.ts +1 -1
- package/es/components/Renderable.d.ts +1 -1
- package/es/display-objects/CustomElement.d.ts +7 -8
- package/es/display-objects/CustomElement.js +24 -11
- package/es/display-objects/DisplayObject.d.ts +5 -7
- package/es/display-objects/DisplayObject.js +20 -12
- package/es/display-objects/Group.d.ts +1 -1
- package/es/display-objects/HTML.d.ts +1 -1
- package/es/display-objects/Image.d.ts +1 -1
- package/es/display-objects/Path.d.ts +1 -1
- package/es/display-objects/Polygon.d.ts +1 -1
- package/es/display-objects/Polyline.d.ts +1 -1
- package/es/display-objects/Text.d.ts +1 -1
- package/es/display-objects/Text.js +1 -1
- package/es/dom/Animation.js +9 -4
- package/es/dom/AnimationEffectTiming.d.ts +0 -1
- package/es/dom/AnimationTimeline.js +2 -1
- package/es/dom/CustomElementRegistry.d.ts +1 -1
- package/es/dom/CustomEvent.js +2 -1
- package/es/dom/Document.d.ts +3 -3
- package/es/dom/Document.js +13 -6
- package/es/dom/Element.d.ts +11 -12
- package/es/dom/Element.js +12 -8
- package/es/dom/EventTarget.js +1 -0
- package/es/dom/FederatedEvent.d.ts +1 -1
- package/es/dom/KeyframeEffect.js +1 -1
- package/es/dom/Node.d.ts +10 -10
- package/es/dom/Node.js +11 -5
- package/es/dom/interfaces.d.ts +63 -63
- package/es/global-module.d.ts +4 -0
- package/es/global-module.js +57 -69
- package/es/plugins/CullingPlugin.d.ts +3 -3
- package/es/plugins/DirtyCheckPlugin.d.ts +1 -1
- package/es/plugins/EventPlugin.d.ts +2 -1
- package/es/plugins/FrustumCullingStrategy.d.ts +1 -2
- package/es/plugins/FrustumCullingStrategy.js +31 -32
- package/es/plugins/PrepareRendererPlugin.d.ts +1 -1
- package/es/plugins/PrepareRendererPlugin.js +7 -20
- package/es/property-handlers/aabb.js +16 -19
- package/es/property-handlers/anchor.d.ts +2 -1
- package/es/property-handlers/anchor.js +2 -2
- package/es/property-handlers/clipPath.js +2 -2
- package/es/property-handlers/color.d.ts +3 -4
- package/es/property-handlers/color.js +2 -2
- package/es/property-handlers/filter.d.ts +3 -4
- package/es/property-handlers/filter.js +2 -2
- package/es/property-handlers/interfaces.d.ts +1 -1
- package/es/property-handlers/lineDash.d.ts +1 -2
- package/es/property-handlers/lineDash.js +1 -1
- package/es/property-handlers/path.d.ts +2 -3
- package/es/property-handlers/path.js +2 -2
- package/es/property-handlers/points.d.ts +1 -2
- package/es/property-handlers/points.js +1 -1
- package/es/property-handlers/transform.d.ts +1 -1
- package/es/property-handlers/transform.js +0 -5
- package/es/services/ContextService.d.ts +8 -8
- package/es/services/EventService.d.ts +2 -2
- package/es/services/RenderingContext.d.ts +2 -2
- package/es/services/RenderingService.d.ts +23 -18
- package/es/services/RenderingService.js +18 -4
- package/es/services/SceneGraphSelector.d.ts +5 -5
- package/es/services/SceneGraphSelector.js +3 -2
- package/es/services/SceneGraphService.d.ts +36 -34
- package/es/services/SceneGraphService.js +33 -4
- package/es/services/aabb/PathUpdater.d.ts +1 -2
- package/es/services/aabb/PathUpdater.js +1 -1
- package/es/services/aabb/interfaces.d.ts +1 -1
- package/es/services/text/index.js +1 -1
- package/es/shapes/AABB.d.ts +3 -2
- package/es/shapes/Frustum.d.ts +1 -1
- package/es/shapes/Polygon.d.ts +1 -1
- package/es/shapes/Ray.d.ts +3 -3
- package/es/types.d.ts +1 -2
- package/es/utils/custom-easing.d.ts +3 -5
- package/es/utils/custom-easing.js +2 -1
- package/es/utils/event.d.ts +1 -1
- package/es/utils/interpolation.js +16 -16
- package/es/utils/math.d.ts +2 -1
- package/es/utils/math.js +1 -2
- package/es/utils/path.d.ts +1 -1
- package/es/utils/path.js +4 -7
- package/es/utils/raf.js +2 -1
- package/lib/AbstractRenderer.d.ts +7 -7
- package/lib/Canvas.d.ts +15 -5
- package/lib/Canvas.js +10 -5
- package/lib/camera/Camera.js +4 -5
- package/lib/components/Geometry.d.ts +1 -1
- package/lib/components/Renderable.d.ts +1 -1
- package/lib/display-objects/CustomElement.d.ts +7 -8
- package/lib/display-objects/CustomElement.js +24 -11
- package/lib/display-objects/DisplayObject.d.ts +5 -7
- package/lib/display-objects/DisplayObject.js +19 -11
- package/lib/display-objects/Group.d.ts +1 -1
- package/lib/display-objects/HTML.d.ts +1 -1
- package/lib/display-objects/Image.d.ts +1 -1
- package/lib/display-objects/Path.d.ts +1 -1
- package/lib/display-objects/Polygon.d.ts +1 -1
- package/lib/display-objects/Polyline.d.ts +1 -1
- package/lib/display-objects/Text.d.ts +1 -1
- package/lib/display-objects/Text.js +1 -1
- package/lib/dom/Animation.js +9 -4
- package/lib/dom/AnimationEffectTiming.d.ts +0 -1
- package/lib/dom/AnimationTimeline.js +2 -1
- package/lib/dom/CustomElementRegistry.d.ts +1 -1
- package/lib/dom/CustomEvent.js +1 -1
- package/lib/dom/Document.d.ts +3 -3
- package/lib/dom/Document.js +13 -6
- package/lib/dom/Element.d.ts +11 -12
- package/lib/dom/Element.js +12 -8
- package/lib/dom/EventTarget.js +1 -0
- package/lib/dom/FederatedEvent.d.ts +1 -1
- package/lib/dom/KeyframeEffect.js +1 -1
- package/lib/dom/Node.d.ts +10 -10
- package/lib/dom/Node.js +11 -5
- package/lib/dom/interfaces.d.ts +63 -63
- package/lib/global-module.d.ts +4 -0
- package/lib/global-module.js +57 -69
- package/lib/plugins/CullingPlugin.d.ts +3 -3
- package/lib/plugins/DirtyCheckPlugin.d.ts +1 -1
- package/lib/plugins/EventPlugin.d.ts +2 -1
- package/lib/plugins/FrustumCullingStrategy.d.ts +1 -2
- package/lib/plugins/FrustumCullingStrategy.js +28 -30
- package/lib/plugins/PrepareRendererPlugin.d.ts +1 -1
- package/lib/plugins/PrepareRendererPlugin.js +6 -19
- package/lib/property-handlers/aabb.js +15 -19
- package/lib/property-handlers/anchor.d.ts +2 -1
- package/lib/property-handlers/anchor.js +2 -2
- package/lib/property-handlers/clipPath.js +2 -2
- package/lib/property-handlers/color.d.ts +3 -4
- package/lib/property-handlers/color.js +2 -2
- package/lib/property-handlers/filter.d.ts +3 -4
- package/lib/property-handlers/filter.js +2 -2
- package/lib/property-handlers/interfaces.d.ts +1 -1
- package/lib/property-handlers/lineDash.d.ts +1 -2
- package/lib/property-handlers/lineDash.js +1 -1
- package/lib/property-handlers/path.d.ts +2 -3
- package/lib/property-handlers/path.js +2 -2
- package/lib/property-handlers/points.d.ts +1 -2
- package/lib/property-handlers/points.js +1 -1
- package/lib/property-handlers/transform.d.ts +1 -1
- package/lib/property-handlers/transform.js +0 -4
- package/lib/services/ContextService.d.ts +8 -8
- package/lib/services/EventService.d.ts +2 -2
- package/lib/services/RenderingContext.d.ts +2 -2
- package/lib/services/RenderingService.d.ts +23 -18
- package/lib/services/RenderingService.js +18 -4
- package/lib/services/SceneGraphSelector.d.ts +5 -5
- package/lib/services/SceneGraphSelector.js +3 -2
- package/lib/services/SceneGraphService.d.ts +36 -34
- package/lib/services/SceneGraphService.js +35 -4
- package/lib/services/aabb/PathUpdater.d.ts +1 -2
- package/lib/services/aabb/PathUpdater.js +1 -1
- package/lib/services/aabb/interfaces.d.ts +1 -1
- package/lib/services/text/index.js +1 -1
- package/lib/shapes/AABB.d.ts +3 -2
- package/lib/shapes/Frustum.d.ts +1 -1
- package/lib/shapes/Polygon.d.ts +1 -1
- package/lib/shapes/Ray.d.ts +3 -3
- package/lib/types.d.ts +1 -2
- package/lib/utils/custom-easing.d.ts +3 -5
- package/lib/utils/custom-easing.js +2 -1
- package/lib/utils/event.d.ts +1 -1
- package/lib/utils/interpolation.js +13 -18
- package/lib/utils/math.d.ts +2 -1
- package/lib/utils/math.js +1 -2
- package/lib/utils/path.d.ts +2 -2
- package/lib/utils/path.js +4 -7
- package/lib/utils/raf.js +2 -1
- package/package.json +6 -6
- package/lib/dom/__tests__/utils/easing.d.ts +0 -14
- package/lib/dom/__tests__/utils/keyframe.d.ts +0 -38
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { CullingStrategyContribution } from './CullingPlugin';
|
|
2
|
-
import { DisplayObject } from '../display-objects/DisplayObject';
|
|
2
|
+
import type { DisplayObject } from '../display-objects/DisplayObject';
|
|
3
3
|
export declare class FrustumCullingStrategy implements CullingStrategyContribution {
|
|
4
|
-
private camera;
|
|
5
4
|
isVisible(object: DisplayObject): boolean;
|
|
6
5
|
/**
|
|
7
6
|
*
|
|
@@ -1,40 +1,41 @@
|
|
|
1
|
-
import { __decorate
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { __decorate } from "tslib"; // import { vec3, mat4 } from 'gl-matrix';
|
|
2
|
+
// import { inject, singleton } from 'mana-syringe';
|
|
3
|
+
|
|
4
|
+
import { vec3 } from 'gl-matrix';
|
|
5
|
+
import { singleton } from 'mana-syringe';
|
|
4
6
|
import { CullingStrategyContribution } from './CullingPlugin';
|
|
5
|
-
import { Mask } from '../shapes';
|
|
6
|
-
import { DefaultCamera, Camera } from '../camera/Camera';
|
|
7
|
+
import { Mask } from '../shapes'; // import type { Element } from '../dom';
|
|
7
8
|
|
|
8
9
|
var FrustumCullingStrategy =
|
|
9
10
|
/** @class */
|
|
10
11
|
function () {
|
|
11
|
-
function FrustumCullingStrategy() {}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _a, _b;
|
|
15
|
-
|
|
16
|
-
var entity = object.entity;
|
|
17
|
-
var cullable = object.cullable;
|
|
18
|
-
return true;
|
|
19
|
-
|
|
20
|
-
if (!cullable.enable) {
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
12
|
+
function FrustumCullingStrategy() {} // @inject(DefaultCamera)
|
|
13
|
+
// private camera: Camera;
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
23
15
|
|
|
24
|
-
var renderBounds = object.getRenderBounds();
|
|
25
16
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
17
|
+
FrustumCullingStrategy.prototype.isVisible = function (object) {
|
|
18
|
+
return true; // const entity = object.entity;
|
|
19
|
+
// const cullable = object.cullable;
|
|
20
|
+
// if (!cullable.enable) {
|
|
21
|
+
// return true;
|
|
22
|
+
// }
|
|
23
|
+
// const renderBounds = object.getRenderBounds();
|
|
24
|
+
// if (!renderBounds) {
|
|
25
|
+
// return false;
|
|
26
|
+
// }
|
|
27
|
+
// const viewMatrix = this.camera.getViewTransform();
|
|
28
|
+
// const vpMatrix = mat4.multiply(mat4.create(), this.camera.getPerspective(), viewMatrix);
|
|
29
|
+
// // get VP matrix from camera
|
|
30
|
+
// this.camera.getFrustum().extractFromVPMatrix(vpMatrix);
|
|
31
|
+
// const parentVisibilityPlaneMask = (object.parentNode as Element)?.cullable?.visibilityPlaneMask;
|
|
32
|
+
// cullable.visibilityPlaneMask = this.computeVisibilityWithPlaneMask(
|
|
33
|
+
// renderBounds,
|
|
34
|
+
// parentVisibilityPlaneMask || Mask.INDETERMINATE,
|
|
35
|
+
// this.camera.getFrustum().planes,
|
|
36
|
+
// );
|
|
37
|
+
// cullable.visible = cullable.visibilityPlaneMask !== Mask.OUTSIDE;
|
|
38
|
+
// return cullable.visible;
|
|
38
39
|
};
|
|
39
40
|
/**
|
|
40
41
|
*
|
|
@@ -90,8 +91,6 @@ function () {
|
|
|
90
91
|
return mask;
|
|
91
92
|
};
|
|
92
93
|
|
|
93
|
-
__decorate([inject(DefaultCamera), __metadata("design:type", Camera)], FrustumCullingStrategy.prototype, "camera", void 0);
|
|
94
|
-
|
|
95
94
|
FrustumCullingStrategy = __decorate([singleton({
|
|
96
95
|
contrib: CullingStrategyContribution
|
|
97
96
|
})], FrustumCullingStrategy);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RenderingService, RenderingPlugin } from '../services/RenderingService';
|
|
1
|
+
import type { RenderingService, RenderingPlugin } from '../services/RenderingService';
|
|
2
2
|
export declare class PrepareRendererPlugin implements RenderingPlugin {
|
|
3
3
|
static tag: string;
|
|
4
4
|
private renderingContext;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import { inject, singleton } from 'mana-syringe';
|
|
3
3
|
import { ElementEvent } from '../dom';
|
|
4
|
-
import { RenderingContext, RENDER_REASON, RenderingPluginContribution } from '../services';
|
|
4
|
+
import { RenderingContext, RENDER_REASON, RenderingPluginContribution, dirtifyToRoot } from '../services';
|
|
5
5
|
|
|
6
6
|
var PrepareRendererPlugin =
|
|
7
7
|
/** @class */
|
|
@@ -13,35 +13,22 @@ function () {
|
|
|
13
13
|
PrepareRendererPlugin.prototype.apply = function (renderingService) {
|
|
14
14
|
var _this = this;
|
|
15
15
|
|
|
16
|
-
var handleAttributeChanged = function handleAttributeChanged(
|
|
16
|
+
var handleAttributeChanged = function handleAttributeChanged() {
|
|
17
17
|
_this.renderingContext.renderReasons.add(RENDER_REASON.DisplayObjectChanged);
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
var
|
|
21
|
-
// skip Document & Canvas
|
|
22
|
-
var path = e.composedPath().slice(0, -2);
|
|
23
|
-
path.forEach(function (node) {
|
|
24
|
-
var renderable = node.renderable;
|
|
25
|
-
|
|
26
|
-
if (renderable) {
|
|
27
|
-
renderable.renderBoundsDirty = true;
|
|
28
|
-
renderable.boundsDirty = true;
|
|
29
|
-
renderable.dirty = true;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
20
|
+
var handleBoundsChanged = function handleBoundsChanged() {
|
|
32
21
|
renderingService.dirtify();
|
|
33
22
|
};
|
|
34
23
|
|
|
35
|
-
var handleBoundsChanged = function handleBoundsChanged(e) {
|
|
36
|
-
dirtifyToRoot(e);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
24
|
var handleMounted = function handleMounted(e) {
|
|
40
|
-
dirtifyToRoot(e);
|
|
25
|
+
dirtifyToRoot(e.target);
|
|
26
|
+
renderingService.dirtify();
|
|
41
27
|
};
|
|
42
28
|
|
|
43
29
|
var handleUnmounted = function handleUnmounted(e) {
|
|
44
|
-
dirtifyToRoot(e);
|
|
30
|
+
dirtifyToRoot(e.target);
|
|
31
|
+
renderingService.dirtify();
|
|
45
32
|
};
|
|
46
33
|
|
|
47
34
|
renderingService.hooks.init.tap(PrepareRendererPlugin_1.tag, function () {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { vec3 } from 'gl-matrix';
|
|
2
2
|
import { AABB } from '../shapes';
|
|
3
|
-
import { GeometryUpdaterFactory } from '../services';
|
|
3
|
+
import { dirtifyToRoot, GeometryUpdaterFactory } from '../services';
|
|
4
4
|
import { SHAPE } from '../types';
|
|
5
5
|
import { PARSED_COLOR_TYPE } from './color';
|
|
6
6
|
import { globalContainer } from '../global-module';
|
|
7
|
-
import { ElementEvent } from '../dom';
|
|
8
7
|
export function updateGeometry(oldValue, newValue, object) {
|
|
9
8
|
var geometryUpdaterFactory = globalContainer.get(GeometryUpdaterFactory);
|
|
10
9
|
var geometryUpdater = geometryUpdaterFactory(object.nodeName);
|
|
@@ -59,13 +58,11 @@ export function updateGeometry(oldValue, newValue, object) {
|
|
|
59
58
|
var _h = object.parsedStyle,
|
|
60
59
|
_j = _h.lineWidth,
|
|
61
60
|
lineWidth = _j === void 0 ? 0 : _j,
|
|
62
|
-
_k = _h.
|
|
63
|
-
|
|
64
|
-
_l = _h.anchor,
|
|
65
|
-
anchor = _l === void 0 ? [0, 0] : _l,
|
|
61
|
+
_k = _h.anchor,
|
|
62
|
+
anchor = _k === void 0 ? [0, 0] : _k,
|
|
66
63
|
shadowColor = _h.shadowColor,
|
|
67
|
-
|
|
68
|
-
filter =
|
|
64
|
+
_l = _h.filter,
|
|
65
|
+
filter = _l === void 0 ? [] : _l; // <Text> use textAlign & textBaseline instead of anchor
|
|
69
66
|
|
|
70
67
|
if (object.nodeName === SHAPE.Text) {
|
|
71
68
|
delete object.parsedStyle.anchor;
|
|
@@ -83,16 +80,16 @@ export function updateGeometry(oldValue, newValue, object) {
|
|
|
83
80
|
geometry_1.renderBounds.update(center, halfExtents); // account for shadow, only support constant value now
|
|
84
81
|
|
|
85
82
|
if (shadowColor && shadowColor.type === PARSED_COLOR_TYPE.Constant) {
|
|
86
|
-
var
|
|
87
|
-
min =
|
|
88
|
-
max =
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
shadowBlur =
|
|
92
|
-
|
|
93
|
-
shadowOffsetX =
|
|
94
|
-
|
|
95
|
-
shadowOffsetY =
|
|
83
|
+
var _m = geometry_1.renderBounds,
|
|
84
|
+
min = _m.min,
|
|
85
|
+
max = _m.max;
|
|
86
|
+
var _o = object.parsedStyle,
|
|
87
|
+
_p = _o.shadowBlur,
|
|
88
|
+
shadowBlur = _p === void 0 ? 0 : _p,
|
|
89
|
+
_q = _o.shadowOffsetX,
|
|
90
|
+
shadowOffsetX = _q === void 0 ? 0 : _q,
|
|
91
|
+
_r = _o.shadowOffsetY,
|
|
92
|
+
shadowOffsetY = _r === void 0 ? 0 : _r;
|
|
96
93
|
var shadowLeft = min[0] - shadowBlur + shadowOffsetX;
|
|
97
94
|
var shadowRight = max[0] + shadowBlur + shadowOffsetX;
|
|
98
95
|
var shadowTop = min[1] - shadowBlur + shadowOffsetY;
|
|
@@ -130,6 +127,6 @@ export function updateGeometry(oldValue, newValue, object) {
|
|
|
130
127
|
geometry_1.renderBounds.setMinMax(min, max);
|
|
131
128
|
}
|
|
132
129
|
});
|
|
133
|
-
object
|
|
130
|
+
dirtifyToRoot(object);
|
|
134
131
|
}
|
|
135
132
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { vec2
|
|
1
|
+
import type { vec2 } from 'gl-matrix';
|
|
2
|
+
import { vec3 } from 'gl-matrix';
|
|
2
3
|
import type { DisplayObject } from '../display-objects/DisplayObject';
|
|
3
4
|
export declare function updateAnchor(oldValue: vec2 | vec3, newValue: vec2 | vec3, object: DisplayObject): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __read, __spreadArray } from "tslib";
|
|
2
2
|
import { vec3 } from 'gl-matrix';
|
|
3
|
-
import {
|
|
3
|
+
import { dirtifyToRoot } from '../services';
|
|
4
4
|
import { createVec3 } from '../utils';
|
|
5
5
|
export function updateAnchor(oldValue, newValue, object) {
|
|
6
6
|
var bounds = object.getGeometryBounds();
|
|
@@ -14,7 +14,7 @@ export function updateAnchor(oldValue, newValue, object) {
|
|
|
14
14
|
})), false)), vec3.subtract(vec3.create(), createVec3(newValue || vec3.create()), createVec3(oldValue || vec3.create())));
|
|
15
15
|
geometry.contentBounds.update(vec3.subtract(geometry.contentBounds.center, geometry.contentBounds.center, offset), geometry.contentBounds.halfExtents);
|
|
16
16
|
geometry.renderBounds.update(vec3.subtract(geometry.renderBounds.center, geometry.renderBounds.center, offset), geometry.renderBounds.halfExtents);
|
|
17
|
-
object
|
|
17
|
+
dirtifyToRoot(object);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dirtifyToRoot } from '../services';
|
|
2
2
|
/**
|
|
3
3
|
* @see /zh/docs/api/basic/display-object#clippath
|
|
4
4
|
* @example
|
|
@@ -32,5 +32,5 @@ export function updateClipPath(oldClipPath, newClipPath, object) {
|
|
|
32
32
|
newClipPath.style.clipPathTargets.push(object);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
object
|
|
35
|
+
dirtifyToRoot(object);
|
|
36
36
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { DisplayObject } from '../display-objects/DisplayObject';
|
|
2
1
|
import type { Tuple4Number } from '../types';
|
|
3
|
-
import { ParsedStyleProperty } from '.';
|
|
2
|
+
import type { ParsedStyleProperty } from '.';
|
|
4
3
|
export interface LinearGradient {
|
|
5
4
|
x0: number;
|
|
6
5
|
y0: number;
|
|
@@ -31,5 +30,5 @@ export declare enum PARSED_COLOR_TYPE {
|
|
|
31
30
|
Pattern = 3
|
|
32
31
|
}
|
|
33
32
|
export declare type ParsedColorStyleProperty = ParsedStyleProperty<PARSED_COLOR_TYPE.Constant, Tuple4Number> | ParsedStyleProperty<PARSED_COLOR_TYPE.LinearGradient, LinearGradient> | ParsedStyleProperty<PARSED_COLOR_TYPE.RadialGradient, RadialGradient> | ParsedStyleProperty<PARSED_COLOR_TYPE.Pattern, Pattern>;
|
|
34
|
-
export declare function parseColor(colorStr
|
|
35
|
-
export declare function mergeColors(left: ParsedColorStyleProperty, right: ParsedColorStyleProperty
|
|
33
|
+
export declare function parseColor(colorStr?: string): ParsedColorStyleProperty;
|
|
34
|
+
export declare function mergeColors(left: ParsedColorStyleProperty, right: ParsedColorStyleProperty): [number[], number[], (color: number[]) => string] | undefined;
|
|
@@ -14,7 +14,7 @@ var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
|
|
|
14
14
|
var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
|
|
15
15
|
var regexPR = /^p\s*\(\s*([axyn])\s*\)\s*(.*)/i;
|
|
16
16
|
var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/gi;
|
|
17
|
-
export function parseColor(colorStr
|
|
17
|
+
export function parseColor(colorStr) {
|
|
18
18
|
if (colorStr === void 0) {
|
|
19
19
|
colorStr = '';
|
|
20
20
|
}
|
|
@@ -84,7 +84,7 @@ export function parseColor(colorStr, displayObject) {
|
|
|
84
84
|
formatted: color && "rgba(" + color.r + "," + color.g + "," + color.b + "," + color.opacity + ")" || 'rgba(0,0,0,0)'
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
|
-
export function mergeColors(left, right
|
|
87
|
+
export function mergeColors(left, right) {
|
|
88
88
|
// only support constant value, exclude gradient & pattern
|
|
89
89
|
if (left.type !== PARSED_COLOR_TYPE.Constant || right.type !== PARSED_COLOR_TYPE.Constant) {
|
|
90
90
|
return;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
import { ParsedElement } from './dimension';
|
|
1
|
+
import type { ParsedColorStyleProperty } from './color';
|
|
2
|
+
import type { ParsedElement } from './dimension';
|
|
4
3
|
export interface ParsedFilterStyleProperty {
|
|
5
4
|
name: string;
|
|
6
5
|
params: (ParsedElement | ParsedColorStyleProperty)[];
|
|
7
6
|
}
|
|
8
7
|
export declare const parseParam: any;
|
|
9
|
-
export declare function parseFilter(filterStr
|
|
8
|
+
export declare function parseFilter(filterStr?: string): ParsedFilterStyleProperty[];
|
|
@@ -2,7 +2,7 @@ import { parseColor } from './color';
|
|
|
2
2
|
import { parseDimension } from './dimension';
|
|
3
3
|
export var parseParam = parseDimension.bind(null, /deg|rad|grad|turn|px|%/g);
|
|
4
4
|
var supportedFilters = ['blur', 'brightness', 'drop-shadow', 'contrast', 'grayscale', 'sepia', 'saturate', 'hue-rotate', 'invert'];
|
|
5
|
-
export function parseFilter(filterStr
|
|
5
|
+
export function parseFilter(filterStr) {
|
|
6
6
|
if (filterStr === void 0) {
|
|
7
7
|
filterStr = '';
|
|
8
8
|
}
|
|
@@ -29,7 +29,7 @@ export function parseFilter(filterStr, displayObject) {
|
|
|
29
29
|
result.push({
|
|
30
30
|
name: match[1],
|
|
31
31
|
params: match[2].split(' ').map(function (p) {
|
|
32
|
-
return parseParam(p) || parseColor(p
|
|
32
|
+
return parseParam(p) || parseColor(p);
|
|
33
33
|
})
|
|
34
34
|
});
|
|
35
35
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IElement } from '../dom/interfaces';
|
|
2
|
-
import { SceneGraphService } from '../services/SceneGraphService';
|
|
2
|
+
import type { SceneGraphService } from '../services/SceneGraphService';
|
|
3
3
|
export declare const StylePropertyParser = "StylePropertyParser";
|
|
4
4
|
export declare type StylePropertyParser<Original, Parsed> = (value: Original, displayObject: IElement | null) => Parsed;
|
|
5
5
|
export declare const StylePropertyParserFactory = "StylePropertyParserFactory";
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function parseLineDash(lineDash: number[], displayObject: DisplayObject | null): number[];
|
|
1
|
+
export declare function parseLineDash(lineDash: number[]): number[];
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { DisplayObject } from '../display-objects/DisplayObject';
|
|
2
1
|
import type { PathCommand } from '../types';
|
|
3
2
|
import type { ParsedPathStyleProps } from '../display-objects';
|
|
4
|
-
export declare function parsePath(path: string
|
|
5
|
-
export declare function mergePaths(left: ParsedPathStyleProps, right: ParsedPathStyleProps
|
|
3
|
+
export declare function parsePath(path: string): ParsedPathStyleProps;
|
|
4
|
+
export declare function mergePaths(left: ParsedPathStyleProps, right: ParsedPathStyleProps): ((string[] | ["a" | "A", number, number, number, number, number, number, number] | ["C" | "c", number, number, number, number, number, number] | ["o" | "O", number, number] | ["h" | "H", number] | ["l" | "L", number, number] | ["M" | "m", number, number] | ["r" | "R", number, number, number, number] | ["q" | "Q", number, number, number, number] | ["s" | "S", number, number, number, number, number, number, number] | ["t" | "T", number, number] | ["v" | "V", number] | ["u" | "U", number, number, number])[] | ((pathArray: PathCommand[]) => PathCommand[]))[];
|
|
@@ -3,7 +3,7 @@ import { path2Absolute, path2Segments, path2Curve } from '@antv/path-util';
|
|
|
3
3
|
import { Cubic as CubicUtil } from '@antv/g-math';
|
|
4
4
|
import { clonePath, equalizeSegments, getDrawDirection, getRotatedCurve, reverseCurve } from '../utils/path';
|
|
5
5
|
import { Rect } from '../shapes/Rect';
|
|
6
|
-
export function parsePath(path
|
|
6
|
+
export function parsePath(path) {
|
|
7
7
|
var absolutePath = path2Absolute(path);
|
|
8
8
|
var hasArc = hasArcOrBezier(absolutePath);
|
|
9
9
|
var clonedAbsolutePath = absolutePath.slice();
|
|
@@ -183,7 +183,7 @@ function getPathBBox(segments) {
|
|
|
183
183
|
return new Rect(xTop, yTop, width, height);
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
export function mergePaths(left, right
|
|
186
|
+
export function mergePaths(left, right) {
|
|
187
187
|
var curve1 = left.curve;
|
|
188
188
|
var curve2 = right.curve;
|
|
189
189
|
var curves = [curve1, curve2];
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function parsePoints(points: [number, number][], displayObject: DisplayObject | null): {
|
|
1
|
+
export declare function parsePoints(points: [number, number][]): {
|
|
3
2
|
points: [number, number][];
|
|
4
3
|
totalLength: number;
|
|
5
4
|
segments: [number, number][];
|
|
@@ -136,10 +136,6 @@ export function parseTransform(string) {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
return [];
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function numberToLongString(x) {
|
|
142
|
-
return x.toFixed(6).replace('.000000', '');
|
|
143
139
|
} // function mergeMatrices(left: number[][], right: number[][]): [
|
|
144
140
|
// number[][], number[][], () => string,
|
|
145
141
|
// ] {
|
|
@@ -168,7 +164,6 @@ function numberToLongString(x) {
|
|
|
168
164
|
// }
|
|
169
165
|
// scalex/y/z -> scale
|
|
170
166
|
|
|
171
|
-
|
|
172
167
|
function typeTo2D(type) {
|
|
173
168
|
return type.replace(/[xy]/, '');
|
|
174
169
|
} // scalex/y/z -> scale3d
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Syringe } from 'mana-syringe';
|
|
2
2
|
export declare const ContextService: Syringe.DefinedToken;
|
|
3
3
|
export interface ContextService<Context> {
|
|
4
|
-
init()
|
|
5
|
-
destroy()
|
|
6
|
-
getContext()
|
|
7
|
-
getDomElement()
|
|
8
|
-
getDPR()
|
|
9
|
-
getBoundingClientRect()
|
|
10
|
-
resize(width: number, height: number)
|
|
11
|
-
applyCursorStyle(cursor: string)
|
|
4
|
+
init: () => void;
|
|
5
|
+
destroy: () => void;
|
|
6
|
+
getContext: () => Context | null;
|
|
7
|
+
getDomElement: () => HTMLElement | null;
|
|
8
|
+
getDPR: () => number;
|
|
9
|
+
getBoundingClientRect: () => DOMRect | undefined;
|
|
10
|
+
resize: (width: number, height: number) => void;
|
|
11
|
+
applyCursorStyle: (cursor: string) => void;
|
|
12
12
|
}
|
|
@@ -2,8 +2,8 @@ import { EventEmitter } from 'eventemitter3';
|
|
|
2
2
|
import type { Cursor, EventPosition } from '../types';
|
|
3
3
|
import { CanvasConfig } from '../types';
|
|
4
4
|
import type { FederatedEvent } from '../dom/FederatedEvent';
|
|
5
|
-
import { IEventTarget } from '../dom/interfaces';
|
|
6
|
-
import { PointLike } from '../shapes';
|
|
5
|
+
import type { IEventTarget } from '../dom/interfaces';
|
|
6
|
+
import type { PointLike } from '../shapes';
|
|
7
7
|
declare type Picker = (position: EventPosition) => Promise<IEventTarget | null>;
|
|
8
8
|
export declare type EmitterListeners = Record<string, {
|
|
9
9
|
fn: (...args: any[]) => any;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Syringe } from 'mana-syringe';
|
|
2
2
|
import { SyncHook, SyncWaterfallHook, AsyncSeriesHook, AsyncSeriesWaterfallHook } from 'tapable';
|
|
3
|
-
import { DisplayObject } from '..';
|
|
4
|
-
import { EventPosition, InteractivePointerEvent } from '../types';
|
|
3
|
+
import type { DisplayObject } from '..';
|
|
4
|
+
import type { EventPosition, InteractivePointerEvent } from '../types';
|
|
5
5
|
export interface RenderingPlugin {
|
|
6
|
-
apply(renderer: RenderingService)
|
|
6
|
+
apply: (renderer: RenderingService) => void;
|
|
7
7
|
}
|
|
8
8
|
export declare const RenderingPluginContribution: Syringe.DefinedToken;
|
|
9
9
|
export interface PickingResult {
|
|
@@ -24,27 +24,32 @@ export declare class RenderingService {
|
|
|
24
24
|
private renderingContext;
|
|
25
25
|
private sceneGraphService;
|
|
26
26
|
private inited;
|
|
27
|
+
private stats;
|
|
27
28
|
hooks: {
|
|
28
|
-
init: AsyncSeriesHook<
|
|
29
|
-
prepare: SyncWaterfallHook<DisplayObject<any, any
|
|
29
|
+
init: AsyncSeriesHook<[], import("tapable").UnsetAdditionalOptions>;
|
|
30
|
+
prepare: SyncWaterfallHook<[DisplayObject<any, any>], import("tapable").UnsetAdditionalOptions>;
|
|
30
31
|
/**
|
|
31
32
|
* called at beginning of each frame, won't get called if nothing to re-render
|
|
32
33
|
*/
|
|
33
|
-
beginFrame: SyncHook<
|
|
34
|
-
beforeRender: SyncHook<DisplayObject<any, any
|
|
35
|
-
render: SyncHook<DisplayObject<any, any
|
|
36
|
-
afterRender: SyncHook<DisplayObject<any, any
|
|
37
|
-
endFrame: SyncHook<
|
|
38
|
-
destroy: SyncHook<
|
|
39
|
-
pick: AsyncSeriesWaterfallHook<PickingResult, PickingResult
|
|
40
|
-
pointerDown: SyncHook<InteractivePointerEvent,
|
|
41
|
-
pointerUp: SyncHook<InteractivePointerEvent,
|
|
42
|
-
pointerMove: SyncHook<InteractivePointerEvent,
|
|
43
|
-
pointerOut: SyncHook<InteractivePointerEvent,
|
|
44
|
-
pointerOver: SyncHook<InteractivePointerEvent,
|
|
45
|
-
pointerWheel: SyncHook<InteractivePointerEvent,
|
|
34
|
+
beginFrame: SyncHook<[], void, import("tapable").UnsetAdditionalOptions>;
|
|
35
|
+
beforeRender: SyncHook<[DisplayObject<any, any>], void, import("tapable").UnsetAdditionalOptions>;
|
|
36
|
+
render: SyncHook<[DisplayObject<any, any>], void, import("tapable").UnsetAdditionalOptions>;
|
|
37
|
+
afterRender: SyncHook<[DisplayObject<any, any>], void, import("tapable").UnsetAdditionalOptions>;
|
|
38
|
+
endFrame: SyncHook<[], void, import("tapable").UnsetAdditionalOptions>;
|
|
39
|
+
destroy: SyncHook<[], void, import("tapable").UnsetAdditionalOptions>;
|
|
40
|
+
pick: AsyncSeriesWaterfallHook<[PickingResult], PickingResult>;
|
|
41
|
+
pointerDown: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
|
|
42
|
+
pointerUp: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
|
|
43
|
+
pointerMove: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
|
|
44
|
+
pointerOut: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
|
|
45
|
+
pointerOver: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
|
|
46
|
+
pointerWheel: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
|
|
46
47
|
};
|
|
47
48
|
init(): Promise<void>;
|
|
49
|
+
getStats(): {
|
|
50
|
+
total: number;
|
|
51
|
+
rendered: number;
|
|
52
|
+
};
|
|
48
53
|
render(): void;
|
|
49
54
|
private renderDisplayObject;
|
|
50
55
|
destroy(): void;
|
|
@@ -19,6 +19,10 @@ var RenderingService =
|
|
|
19
19
|
function () {
|
|
20
20
|
function RenderingService() {
|
|
21
21
|
this.inited = false;
|
|
22
|
+
this.stats = {
|
|
23
|
+
total: 0,
|
|
24
|
+
rendered: 0
|
|
25
|
+
};
|
|
22
26
|
this.hooks = {
|
|
23
27
|
init: new AsyncSeriesHook(),
|
|
24
28
|
prepare: new SyncWaterfallHook(['object']),
|
|
@@ -26,12 +30,12 @@ function () {
|
|
|
26
30
|
/**
|
|
27
31
|
* called at beginning of each frame, won't get called if nothing to re-render
|
|
28
32
|
*/
|
|
29
|
-
beginFrame: new SyncHook(),
|
|
33
|
+
beginFrame: new SyncHook([]),
|
|
30
34
|
beforeRender: new SyncHook(['objectToRender']),
|
|
31
35
|
render: new SyncHook(['objectToRender']),
|
|
32
36
|
afterRender: new SyncHook(['objectToRender']),
|
|
33
|
-
endFrame: new SyncHook(),
|
|
34
|
-
destroy: new SyncHook(),
|
|
37
|
+
endFrame: new SyncHook([]),
|
|
38
|
+
destroy: new SyncHook([]),
|
|
35
39
|
pick: new AsyncSeriesWaterfallHook(['result']),
|
|
36
40
|
pointerDown: new SyncHook(['event']),
|
|
37
41
|
pointerUp: new SyncHook(['event']),
|
|
@@ -71,7 +75,13 @@ function () {
|
|
|
71
75
|
});
|
|
72
76
|
};
|
|
73
77
|
|
|
78
|
+
RenderingService.prototype.getStats = function () {
|
|
79
|
+
return this.stats;
|
|
80
|
+
};
|
|
81
|
+
|
|
74
82
|
RenderingService.prototype.render = function () {
|
|
83
|
+
this.stats.total = 0;
|
|
84
|
+
this.stats.rendered = 0;
|
|
75
85
|
this.sceneGraphService.syncHierarchy(this.renderingContext.root);
|
|
76
86
|
|
|
77
87
|
if (this.renderingContext.renderReasons.size && this.inited) {
|
|
@@ -88,7 +98,8 @@ function () {
|
|
|
88
98
|
}
|
|
89
99
|
|
|
90
100
|
this.renderingContext.renderReasons.clear();
|
|
91
|
-
}
|
|
101
|
+
} // console.log('render objects: ', this.stats.count);
|
|
102
|
+
|
|
92
103
|
};
|
|
93
104
|
|
|
94
105
|
RenderingService.prototype.renderDisplayObject = function (displayObject) {
|
|
@@ -96,8 +107,11 @@ function () {
|
|
|
96
107
|
|
|
97
108
|
|
|
98
109
|
var objectToRender = this.hooks.prepare.call(displayObject);
|
|
110
|
+
this.stats.total++;
|
|
99
111
|
|
|
100
112
|
if (objectToRender) {
|
|
113
|
+
this.stats.rendered++;
|
|
114
|
+
|
|
101
115
|
if (!this.renderingContext.dirty) {
|
|
102
116
|
this.renderingContext.dirty = true;
|
|
103
117
|
this.hooks.beginFrame.call();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IElement } from '../dom/interfaces';
|
|
1
|
+
import type { IElement } from '../dom/interfaces';
|
|
2
2
|
export declare const SceneGraphSelectorFactory = "SceneGraphSelectorFactory";
|
|
3
3
|
export declare const SceneGraphSelector = "SceneGraphSelector";
|
|
4
4
|
export interface SceneGraphSelector {
|
|
5
|
-
selectOne<R extends IElement, T extends IElement>(query: string, root: R)
|
|
6
|
-
selectAll<R extends IElement, T extends IElement>(query: string, root: R)
|
|
7
|
-
is<T extends IElement>(query: string, element: T)
|
|
5
|
+
selectOne: <R extends IElement, T extends IElement>(query: string, root: R) => T | null;
|
|
6
|
+
selectAll: <R extends IElement, T extends IElement>(query: string, root: R) => T[];
|
|
7
|
+
is: <T extends IElement>(query: string, element: T) => boolean;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* support following DOM API
|
|
@@ -16,5 +16,5 @@ export interface SceneGraphSelector {
|
|
|
16
16
|
export declare class DefaultSceneGraphSelector implements SceneGraphSelector {
|
|
17
17
|
selectOne<R extends IElement, T extends IElement>(query: string, root: R): T | null;
|
|
18
18
|
selectAll<R extends IElement, T extends IElement>(query: string, root: R): T[];
|
|
19
|
-
is<T extends IElement>(
|
|
19
|
+
is<T extends IElement>(): boolean;
|
|
20
20
|
}
|
|
@@ -50,9 +50,10 @@ function () {
|
|
|
50
50
|
return node.nodeName === query;
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
-
};
|
|
53
|
+
}; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
54
|
+
|
|
54
55
|
|
|
55
|
-
DefaultSceneGraphSelector.prototype.is = function (
|
|
56
|
+
DefaultSceneGraphSelector.prototype.is = function () {
|
|
56
57
|
// TODO: need a simple `matches` implementation
|
|
57
58
|
return true;
|
|
58
59
|
};
|