@antv/g 5.0.14 → 5.0.17
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/es/AbstractRenderer.js +1 -3
- package/es/Canvas.d.ts +3 -0
- package/es/Canvas.js +10 -12
- package/es/DisplayObjectPool.js +1 -3
- package/es/camera/Camera.d.ts +3 -2
- package/es/camera/Camera.js +17 -11
- package/es/camera/Landmark.js +1 -3
- package/es/canvas-module.js +11 -17
- package/es/components/Cullable.js +1 -3
- package/es/components/Geometry.js +1 -3
- package/es/components/Renderable.js +1 -3
- package/es/components/Sortable.js +1 -3
- package/es/components/Transform.d.ts +0 -1
- package/es/components/Transform.js +1 -4
- package/es/display-objects/Circle.d.ts +4 -2
- package/es/display-objects/Circle.js +9 -6
- package/es/display-objects/CustomElement.d.ts +3 -2
- package/es/display-objects/CustomElement.js +10 -9
- package/es/display-objects/DisplayObject.d.ts +9 -3
- package/es/display-objects/DisplayObject.js +98 -50
- package/es/display-objects/Ellipse.d.ts +6 -3
- package/es/display-objects/Ellipse.js +9 -6
- package/es/display-objects/Group.d.ts +18 -2
- package/es/display-objects/Group.js +15 -12
- package/es/display-objects/HTML.d.ts +6 -1
- package/es/display-objects/HTML.js +8 -6
- package/es/display-objects/Image.d.ts +12 -7
- package/es/display-objects/Image.js +11 -6
- package/es/display-objects/Line.d.ts +1 -1
- package/es/display-objects/Line.js +13 -7
- package/es/display-objects/Path.d.ts +3 -2
- package/es/display-objects/Path.js +11 -8
- package/es/display-objects/Polygon.d.ts +1 -1
- package/es/display-objects/Polygon.js +10 -6
- package/es/display-objects/Polyline.d.ts +1 -1
- package/es/display-objects/Polyline.js +11 -8
- package/es/display-objects/Rect.d.ts +8 -5
- package/es/display-objects/Rect.js +10 -7
- package/es/display-objects/TSpan.d.ts +1 -0
- package/es/display-objects/TSpan.js +0 -0
- package/es/display-objects/Text.d.ts +32 -4
- package/es/display-objects/Text.js +71 -14
- package/es/dom/Animation.js +2 -4
- package/es/dom/AnimationEffectTiming.js +1 -3
- package/es/dom/AnimationEvent.js +1 -3
- package/es/dom/AnimationTimeline.js +2 -5
- package/es/dom/CustomElementRegistry.js +13 -15
- package/es/dom/CustomEvent.js +1 -3
- package/es/dom/Document.d.ts +2 -1
- package/es/dom/Document.js +23 -5
- package/es/dom/Element.d.ts +36 -9
- package/es/dom/Element.js +103 -15
- package/es/dom/EventTarget.d.ts +2 -2
- package/es/dom/EventTarget.js +3 -4
- package/es/dom/FederatedEvent.d.ts +5 -2
- package/es/dom/FederatedEvent.js +1 -3
- package/es/dom/FederatedMouseEvent.js +1 -3
- package/es/dom/FederatedPointerEvent.js +1 -3
- package/es/dom/FederatedWheelEvent.js +1 -3
- package/es/dom/KeyframeEffect.js +1 -3
- package/es/dom/MutationEvent.d.ts +15 -0
- package/es/dom/MutationEvent.js +27 -0
- package/es/dom/MutationObserver.d.ts +36 -0
- package/es/dom/MutationObserver.js +406 -0
- package/es/dom/MutationRecord.d.ts +14 -0
- package/es/dom/MutationRecord.js +29 -0
- package/es/dom/Node.d.ts +35 -3
- package/es/dom/Node.js +185 -20
- 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 +36 -79
- 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 +4 -27
- package/es/plugins/DirtyCheckPlugin.js +3 -5
- package/es/plugins/EventPlugin.d.ts +2 -1
- package/es/plugins/EventPlugin.js +16 -8
- package/es/plugins/FrustumCullingStrategy.d.ts +1 -0
- package/es/plugins/FrustumCullingStrategy.js +40 -35
- package/es/plugins/PrepareRendererPlugin.js +22 -8
- package/es/property-handlers/aabb.js +22 -24
- package/es/property-handlers/anchor.js +2 -1
- package/es/property-handlers/color.js +3 -0
- 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 +2 -6
- package/es/services/RenderingContext.d.ts +5 -8
- package/es/services/RenderingContext.js +6 -7
- package/es/services/RenderingService.js +3 -11
- package/es/services/SceneGraphSelector.d.ts +3 -2
- package/es/services/SceneGraphSelector.js +9 -7
- package/es/services/SceneGraphService.d.ts +7 -14
- package/es/services/SceneGraphService.js +15 -85
- package/es/services/aabb/CircleUpdater.d.ts +2 -2
- package/es/services/aabb/CircleUpdater.js +22 -14
- package/es/services/aabb/EllipseUpdater.d.ts +2 -2
- package/es/services/aabb/EllipseUpdater.js +29 -16
- package/es/services/aabb/LineUpdater.js +3 -5
- package/es/services/aabb/PathUpdater.js +3 -5
- package/es/services/aabb/PolylineUpdater.js +4 -6
- package/es/services/aabb/RectUpdater.d.ts +2 -2
- package/es/services/aabb/RectUpdater.js +32 -21
- package/es/services/aabb/TextUpdater.js +20 -13
- package/es/services/text/OffscreenCanvasCreator.js +1 -3
- package/es/services/text/index.js +18 -22
- package/es/shapes/AABB.d.ts +1 -0
- package/es/shapes/AABB.js +9 -3
- package/es/shapes/BoundingSphere.js +1 -3
- package/es/shapes/Frustum.js +1 -3
- package/es/shapes/Plane.js +1 -3
- package/es/shapes/Point.js +1 -3
- package/es/shapes/Polygon.js +1 -3
- package/es/shapes/Ray.js +1 -3
- package/es/shapes/Rect.js +1 -3
- package/es/shapes/Rectangle.js +1 -3
- package/es/types.d.ts +48 -26
- package/es/types.js +50 -31
- package/es/utils/animation.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 +13 -13
- 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 +1 -1
- package/lib/AbstractRenderer.js +1 -3
- package/lib/Canvas.d.ts +3 -0
- package/lib/Canvas.js +9 -11
- package/lib/DisplayObjectPool.js +1 -3
- package/lib/camera/Camera.d.ts +3 -2
- package/lib/camera/Camera.js +21 -13
- package/lib/camera/Landmark.js +1 -3
- package/lib/canvas-module.js +10 -15
- package/lib/components/Cullable.js +2 -4
- package/lib/components/Geometry.js +1 -3
- package/lib/components/Renderable.js +1 -3
- package/lib/components/Sortable.js +1 -3
- package/lib/components/Transform.d.ts +0 -1
- package/lib/components/Transform.js +1 -4
- package/lib/display-objects/Circle.d.ts +4 -2
- package/lib/display-objects/Circle.js +8 -5
- package/lib/display-objects/CustomElement.d.ts +3 -2
- package/lib/display-objects/CustomElement.js +10 -9
- package/lib/display-objects/DisplayObject.d.ts +9 -3
- package/lib/display-objects/DisplayObject.js +98 -47
- package/lib/display-objects/Ellipse.d.ts +6 -3
- package/lib/display-objects/Ellipse.js +8 -5
- package/lib/display-objects/Group.d.ts +18 -2
- package/lib/display-objects/Group.js +14 -12
- package/lib/display-objects/HTML.d.ts +6 -1
- package/lib/display-objects/HTML.js +7 -5
- package/lib/display-objects/Image.d.ts +12 -7
- package/lib/display-objects/Image.js +10 -5
- package/lib/display-objects/Line.d.ts +1 -1
- package/lib/display-objects/Line.js +12 -6
- package/lib/display-objects/Path.d.ts +3 -2
- package/lib/display-objects/Path.js +10 -7
- package/lib/display-objects/Polygon.d.ts +1 -1
- package/lib/display-objects/Polygon.js +9 -5
- package/lib/display-objects/Polyline.d.ts +1 -1
- package/lib/display-objects/Polyline.js +10 -7
- package/lib/display-objects/Rect.d.ts +8 -5
- package/lib/display-objects/Rect.js +9 -6
- package/lib/display-objects/TSpan.d.ts +1 -0
- package/lib/display-objects/TSpan.js +1 -0
- package/lib/display-objects/Text.d.ts +32 -4
- package/lib/display-objects/Text.js +71 -13
- package/lib/dom/Animation.js +2 -4
- package/lib/dom/AnimationEffectTiming.js +1 -3
- package/lib/dom/AnimationEvent.js +1 -3
- package/lib/dom/AnimationTimeline.js +3 -6
- package/lib/dom/CustomElementRegistry.js +12 -14
- package/lib/dom/CustomEvent.js +1 -3
- package/lib/dom/Document.d.ts +2 -1
- package/lib/dom/Document.js +25 -6
- package/lib/dom/Element.d.ts +36 -9
- package/lib/dom/Element.js +105 -15
- package/lib/dom/EventTarget.d.ts +2 -2
- package/lib/dom/EventTarget.js +3 -4
- package/lib/dom/FederatedEvent.d.ts +5 -2
- package/lib/dom/FederatedEvent.js +1 -3
- package/lib/dom/FederatedMouseEvent.js +1 -3
- package/lib/dom/FederatedPointerEvent.js +1 -3
- package/lib/dom/FederatedWheelEvent.js +1 -3
- package/lib/dom/KeyframeEffect.js +2 -4
- package/lib/dom/MutationEvent.d.ts +15 -0
- package/lib/dom/MutationEvent.js +35 -0
- package/lib/dom/MutationObserver.d.ts +36 -0
- package/lib/dom/MutationObserver.js +417 -0
- package/lib/dom/MutationRecord.d.ts +14 -0
- package/lib/dom/MutationRecord.js +36 -0
- package/lib/dom/Node.d.ts +35 -3
- package/lib/dom/Node.js +186 -19
- 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 +42 -76
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/lib/plugins/CullingPlugin.d.ts +0 -2
- package/lib/plugins/CullingPlugin.js +4 -27
- package/lib/plugins/DirtyCheckPlugin.js +2 -4
- package/lib/plugins/EventPlugin.d.ts +2 -1
- package/lib/plugins/EventPlugin.js +14 -8
- package/lib/plugins/FrustumCullingStrategy.d.ts +1 -0
- package/lib/plugins/FrustumCullingStrategy.js +41 -35
- package/lib/plugins/PrepareRendererPlugin.js +25 -7
- package/lib/property-handlers/aabb.js +21 -23
- package/lib/property-handlers/anchor.js +3 -1
- package/lib/property-handlers/color.js +5 -2
- package/lib/property-handlers/dimension.d.ts +15 -2
- package/lib/property-handlers/dimension.js +84 -12
- 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/interfaces.js +1 -1
- package/lib/property-handlers/lineDash.d.ts +6 -1
- package/lib/property-handlers/lineDash.js +25 -4
- package/lib/property-handlers/numeric.js +3 -3
- package/lib/property-handlers/offsetDistance.js +1 -1
- package/lib/property-handlers/path.d.ts +1 -1
- package/lib/property-handlers/path.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/property-handlers/transform.js +1 -1
- package/lib/services/EventService.js +2 -6
- package/lib/services/RenderingContext.d.ts +5 -8
- package/lib/services/RenderingContext.js +8 -9
- package/lib/services/RenderingService.js +2 -10
- package/lib/services/SceneGraphSelector.d.ts +3 -2
- package/lib/services/SceneGraphSelector.js +12 -7
- package/lib/services/SceneGraphService.d.ts +7 -14
- package/lib/services/SceneGraphService.js +18 -87
- package/lib/services/aabb/CircleUpdater.d.ts +2 -2
- package/lib/services/aabb/CircleUpdater.js +21 -13
- package/lib/services/aabb/EllipseUpdater.d.ts +2 -2
- package/lib/services/aabb/EllipseUpdater.js +28 -15
- package/lib/services/aabb/LineUpdater.js +2 -4
- package/lib/services/aabb/PathUpdater.js +2 -4
- package/lib/services/aabb/PolylineUpdater.js +3 -5
- package/lib/services/aabb/RectUpdater.d.ts +2 -2
- package/lib/services/aabb/RectUpdater.js +31 -20
- package/lib/services/aabb/TextUpdater.js +19 -12
- package/lib/services/aabb/index.js +10 -10
- package/lib/services/aabb/interfaces.js +1 -1
- package/lib/services/text/OffscreenCanvasCreator.js +1 -3
- package/lib/services/text/index.js +18 -22
- package/lib/shapes/AABB.d.ts +1 -0
- package/lib/shapes/AABB.js +9 -3
- package/lib/shapes/BoundingSphere.js +1 -3
- package/lib/shapes/Frustum.js +2 -4
- package/lib/shapes/Plane.js +1 -3
- package/lib/shapes/Point.js +1 -3
- package/lib/shapes/Polygon.js +1 -3
- package/lib/shapes/Ray.js +1 -3
- package/lib/shapes/Rect.js +1 -3
- package/lib/shapes/Rectangle.js +1 -3
- package/lib/types.d.ts +48 -26
- package/lib/types.js +56 -35
- package/lib/utils/animation.js +3 -4
- package/lib/utils/bezier-easing.js +1 -1
- package/lib/utils/custom-easing.js +1 -1
- package/lib/utils/event.js +7 -6
- 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/math.js +5 -5
- 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 +1 -4
- package/lib/utils/string.d.ts +1 -0
- package/lib/utils/string.js +16 -0
- package/lib/utils/text.js +1 -1
- package/package.json +6 -4
- package/dist/index.umd.min.js +0 -15
|
@@ -1,25 +1,38 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { singleton } from 'mana-syringe';
|
|
3
3
|
import { GeometryAABBUpdater } from './interfaces';
|
|
4
|
-
import {
|
|
4
|
+
import { Shape } from '../../types';
|
|
5
5
|
|
|
6
|
-
var EllipseUpdater =
|
|
7
|
-
/** @class */
|
|
8
|
-
function () {
|
|
6
|
+
var EllipseUpdater = function () {
|
|
9
7
|
function EllipseUpdater() {}
|
|
10
8
|
|
|
11
|
-
EllipseUpdater.prototype.update = function (parsedStyle) {
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
EllipseUpdater.prototype.update = function (parsedStyle, object) {
|
|
10
|
+
var rx = parsedStyle.rx,
|
|
11
|
+
ry = parsedStyle.ry,
|
|
12
|
+
_a = parsedStyle.x,
|
|
13
|
+
x = _a === void 0 ? 0 : _a,
|
|
14
|
+
_b = parsedStyle.y,
|
|
15
|
+
y = _b === void 0 ? 0 : _b;
|
|
16
|
+
var rxUnit = rx.unit,
|
|
17
|
+
rxValue = rx.value;
|
|
18
|
+
var ryUnit = ry.unit,
|
|
19
|
+
ryValue = ry.value;
|
|
20
|
+
var width = 0;
|
|
21
|
+
var height = 0;
|
|
22
|
+
|
|
23
|
+
if (rxUnit === '' || rxUnit === 'px') {
|
|
24
|
+
width = rxValue * 2;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (ryUnit === '' || ryUnit === 'px') {
|
|
28
|
+
height = ryValue * 2;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
object.parsedStyle.rxInPixels = width / 2;
|
|
32
|
+
object.parsedStyle.ryInPixels = height / 2;
|
|
20
33
|
return {
|
|
21
|
-
width:
|
|
22
|
-
height:
|
|
34
|
+
width: width,
|
|
35
|
+
height: height,
|
|
23
36
|
x: x,
|
|
24
37
|
y: y
|
|
25
38
|
};
|
|
@@ -28,7 +41,7 @@ function () {
|
|
|
28
41
|
EllipseUpdater = __decorate([singleton({
|
|
29
42
|
token: {
|
|
30
43
|
token: GeometryAABBUpdater,
|
|
31
|
-
named:
|
|
44
|
+
named: Shape.ELLIPSE
|
|
32
45
|
}
|
|
33
46
|
})], EllipseUpdater);
|
|
34
47
|
return EllipseUpdater;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { singleton } from 'mana-syringe';
|
|
3
3
|
import { GeometryAABBUpdater } from './interfaces';
|
|
4
|
-
import {
|
|
4
|
+
import { Shape } from '../../types';
|
|
5
5
|
|
|
6
|
-
var LineUpdater =
|
|
7
|
-
/** @class */
|
|
8
|
-
function () {
|
|
6
|
+
var LineUpdater = function () {
|
|
9
7
|
function LineUpdater() {}
|
|
10
8
|
|
|
11
9
|
LineUpdater.prototype.update = function (parsedStyle) {
|
|
@@ -30,7 +28,7 @@ function () {
|
|
|
30
28
|
LineUpdater = __decorate([singleton({
|
|
31
29
|
token: {
|
|
32
30
|
token: GeometryAABBUpdater,
|
|
33
|
-
named:
|
|
31
|
+
named: Shape.LINE
|
|
34
32
|
}
|
|
35
33
|
})], LineUpdater);
|
|
36
34
|
return LineUpdater;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { singleton } from 'mana-syringe';
|
|
3
3
|
import { GeometryAABBUpdater } from './interfaces';
|
|
4
|
-
import {
|
|
4
|
+
import { Shape } from '../../types';
|
|
5
5
|
|
|
6
|
-
var PathUpdater =
|
|
7
|
-
/** @class */
|
|
8
|
-
function () {
|
|
6
|
+
var PathUpdater = function () {
|
|
9
7
|
function PathUpdater() {}
|
|
10
8
|
|
|
11
9
|
PathUpdater.prototype.update = function (parsedStyle) {
|
|
@@ -26,7 +24,7 @@ function () {
|
|
|
26
24
|
PathUpdater = __decorate([singleton({
|
|
27
25
|
token: {
|
|
28
26
|
token: GeometryAABBUpdater,
|
|
29
|
-
named:
|
|
27
|
+
named: Shape.PATH
|
|
30
28
|
}
|
|
31
29
|
})], PathUpdater);
|
|
32
30
|
return PathUpdater;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { __decorate, __read, __spreadArray } from "tslib";
|
|
2
2
|
import { singleton } from 'mana-syringe';
|
|
3
3
|
import { GeometryAABBUpdater } from './interfaces';
|
|
4
|
-
import {
|
|
4
|
+
import { Shape } from '../../types';
|
|
5
5
|
|
|
6
|
-
var PolylineUpdater =
|
|
7
|
-
/** @class */
|
|
8
|
-
function () {
|
|
6
|
+
var PolylineUpdater = function () {
|
|
9
7
|
function PolylineUpdater() {}
|
|
10
8
|
|
|
11
9
|
PolylineUpdater.prototype.update = function (parsedStyle) {
|
|
@@ -36,10 +34,10 @@ function () {
|
|
|
36
34
|
PolylineUpdater = __decorate([singleton({
|
|
37
35
|
token: [{
|
|
38
36
|
token: GeometryAABBUpdater,
|
|
39
|
-
named:
|
|
37
|
+
named: Shape.POLYLINE
|
|
40
38
|
}, {
|
|
41
39
|
token: GeometryAABBUpdater,
|
|
42
|
-
named:
|
|
40
|
+
named: Shape.POLYGON
|
|
43
41
|
}]
|
|
44
42
|
})], PolylineUpdater);
|
|
45
43
|
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;
|
|
@@ -2,39 +2,50 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import { singleton } from 'mana-syringe';
|
|
3
3
|
import { isString } from '@antv/util';
|
|
4
4
|
import { GeometryAABBUpdater } from './interfaces';
|
|
5
|
-
import {
|
|
5
|
+
import { Shape } from '../../types';
|
|
6
6
|
|
|
7
|
-
var RectUpdater =
|
|
8
|
-
/** @class */
|
|
9
|
-
function () {
|
|
7
|
+
var RectUpdater = function () {
|
|
10
8
|
function RectUpdater() {}
|
|
11
9
|
|
|
12
|
-
RectUpdater.prototype.update = function (
|
|
13
|
-
var img =
|
|
14
|
-
_a =
|
|
10
|
+
RectUpdater.prototype.update = function (parsedStyle, object) {
|
|
11
|
+
var img = parsedStyle.img,
|
|
12
|
+
_a = parsedStyle.x,
|
|
15
13
|
x = _a === void 0 ? 0 : _a,
|
|
16
|
-
_b =
|
|
14
|
+
_b = parsedStyle.y,
|
|
17
15
|
y = _b === void 0 ? 0 : _b,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
16
|
+
width = parsedStyle.width,
|
|
17
|
+
height = parsedStyle.height;
|
|
18
|
+
var contentWidth = 0;
|
|
19
|
+
var contentHeight = 0;
|
|
20
|
+
var widthUnit = width.unit,
|
|
21
|
+
widthValue = width.value;
|
|
22
|
+
var heightUnit = height.unit,
|
|
23
|
+
heightValue = height.value;
|
|
24
|
+
|
|
25
|
+
if (widthUnit === '' || widthUnit === 'px') {
|
|
26
|
+
contentWidth = widthValue;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (heightUnit === '' || heightUnit === 'px') {
|
|
30
|
+
contentHeight = heightValue;
|
|
31
|
+
} // resize with HTMLImageElement's size
|
|
32
|
+
|
|
24
33
|
|
|
25
34
|
if (img && !isString(img)) {
|
|
26
|
-
if (!
|
|
35
|
+
if (!contentWidth) {
|
|
27
36
|
contentWidth = img.width;
|
|
28
37
|
}
|
|
29
38
|
|
|
30
|
-
if (!
|
|
39
|
+
if (!contentHeight) {
|
|
31
40
|
contentHeight = img.height;
|
|
32
41
|
}
|
|
33
42
|
}
|
|
34
43
|
|
|
44
|
+
object.parsedStyle.widthInPixels = contentWidth;
|
|
45
|
+
object.parsedStyle.heightInPixels = contentHeight;
|
|
35
46
|
return {
|
|
36
|
-
width: contentWidth
|
|
37
|
-
height: contentHeight
|
|
47
|
+
width: contentWidth,
|
|
48
|
+
height: contentHeight,
|
|
38
49
|
x: x,
|
|
39
50
|
y: y
|
|
40
51
|
};
|
|
@@ -43,13 +54,13 @@ function () {
|
|
|
43
54
|
RectUpdater = __decorate([singleton({
|
|
44
55
|
token: [{
|
|
45
56
|
token: GeometryAABBUpdater,
|
|
46
|
-
named:
|
|
57
|
+
named: Shape.RECT
|
|
47
58
|
}, {
|
|
48
59
|
token: GeometryAABBUpdater,
|
|
49
|
-
named:
|
|
60
|
+
named: Shape.IMAGE
|
|
50
61
|
}, {
|
|
51
62
|
token: GeometryAABBUpdater,
|
|
52
|
-
named:
|
|
63
|
+
named: Shape.GROUP
|
|
53
64
|
}]
|
|
54
65
|
})], RectUpdater);
|
|
55
66
|
return RectUpdater;
|
|
@@ -3,24 +3,23 @@ import { vec3 } from 'gl-matrix';
|
|
|
3
3
|
import { singleton, inject } from 'mana-syringe';
|
|
4
4
|
import { GeometryAABBUpdater } from './interfaces';
|
|
5
5
|
import { TextService } from '../text';
|
|
6
|
-
import {
|
|
6
|
+
import { Shape } from '../../types';
|
|
7
7
|
|
|
8
|
-
var TextUpdater =
|
|
9
|
-
/** @class */
|
|
10
|
-
function () {
|
|
8
|
+
var TextUpdater = function () {
|
|
11
9
|
function TextUpdater() {}
|
|
12
10
|
|
|
13
11
|
TextUpdater.prototype.update = function (parsedStyle) {
|
|
14
12
|
var _a = parsedStyle.text,
|
|
15
13
|
text = _a === void 0 ? '' : _a,
|
|
16
14
|
textAlign = parsedStyle.textAlign,
|
|
17
|
-
|
|
18
|
-
lineWidth = _b === void 0 ? 0 : _b,
|
|
15
|
+
lineWidth = parsedStyle.lineWidth,
|
|
19
16
|
textBaseline = parsedStyle.textBaseline,
|
|
20
|
-
|
|
21
|
-
x =
|
|
22
|
-
|
|
23
|
-
y =
|
|
17
|
+
_b = parsedStyle.x,
|
|
18
|
+
x = _b === void 0 ? 0 : _b,
|
|
19
|
+
_c = parsedStyle.y,
|
|
20
|
+
y = _c === void 0 ? 0 : _c,
|
|
21
|
+
dx = parsedStyle.dx,
|
|
22
|
+
dy = parsedStyle.dy;
|
|
24
23
|
var metrics = this.textService.measureText(text, parsedStyle);
|
|
25
24
|
parsedStyle.metrics = metrics;
|
|
26
25
|
var width = metrics.width,
|
|
@@ -34,10 +33,10 @@ function () {
|
|
|
34
33
|
var lineXOffset = 0;
|
|
35
34
|
|
|
36
35
|
if (textAlign === 'center') {
|
|
37
|
-
lineXOffset = lineWidth / 2;
|
|
36
|
+
lineXOffset = lineWidth.value / 2;
|
|
38
37
|
anchor = [0.5, 1];
|
|
39
38
|
} else if (textAlign === 'right' || textAlign === 'end') {
|
|
40
|
-
lineXOffset = lineWidth;
|
|
39
|
+
lineXOffset = lineWidth.value;
|
|
41
40
|
anchor = [1, 1];
|
|
42
41
|
} // update anchor
|
|
43
42
|
|
|
@@ -57,6 +56,14 @@ function () {
|
|
|
57
56
|
} // TODO: ideographic & bottom
|
|
58
57
|
|
|
59
58
|
|
|
59
|
+
if (dx && dx.unit === 'px') {
|
|
60
|
+
lineXOffset += dx.value;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (dy && dy.unit === 'px') {
|
|
64
|
+
lineYOffset += dy.value;
|
|
65
|
+
}
|
|
66
|
+
|
|
60
67
|
return {
|
|
61
68
|
width: halfExtents[0] * 2,
|
|
62
69
|
height: halfExtents[1] * 2,
|
|
@@ -72,7 +79,7 @@ function () {
|
|
|
72
79
|
TextUpdater = __decorate([singleton({
|
|
73
80
|
token: {
|
|
74
81
|
token: GeometryAABBUpdater,
|
|
75
|
-
named:
|
|
82
|
+
named: Shape.TEXT
|
|
76
83
|
}
|
|
77
84
|
})], TextUpdater);
|
|
78
85
|
return TextUpdater;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { singleton } from 'mana-syringe';
|
|
3
3
|
|
|
4
|
-
var OffscreenCanvasCreator =
|
|
5
|
-
/** @class */
|
|
6
|
-
function () {
|
|
4
|
+
var OffscreenCanvasCreator = function () {
|
|
7
5
|
function OffscreenCanvasCreator() {}
|
|
8
6
|
|
|
9
7
|
OffscreenCanvasCreator.prototype.getOrCreateCanvas = function () {
|
|
@@ -27,9 +27,7 @@ var regexCannotEndKoKr = /[$([{£¥'"々〇〉》」〔$([{⦆¥₩#]/;
|
|
|
27
27
|
var regexCannotStart = new RegExp(regexCannotStartZhCn.source + "|" + regexCannotStartZhTw.source + "|" + regexCannotStartJaJp.source + "|" + regexCannotStartKoKr.source);
|
|
28
28
|
var regexCannotEnd = new RegExp(regexCannotEndZhCn.source + "|" + regexCannotEndZhTw.source + "|" + regexCannotEndJaJp.source + "|" + regexCannotEndKoKr.source);
|
|
29
29
|
|
|
30
|
-
var TextService =
|
|
31
|
-
/** @class */
|
|
32
|
-
function () {
|
|
30
|
+
var TextService = function () {
|
|
33
31
|
function TextService() {
|
|
34
32
|
var _this = this;
|
|
35
33
|
|
|
@@ -93,7 +91,7 @@ function () {
|
|
|
93
91
|
context.textBaseline = 'alphabetic';
|
|
94
92
|
context.fillStyle = '#000';
|
|
95
93
|
context.fillText(metricsString, 0, baseline);
|
|
96
|
-
var imagedata = context.getImageData(0, 0, width, height).data;
|
|
94
|
+
var imagedata = context.getImageData(0, 0, width || 1, height || 1).data;
|
|
97
95
|
var pixels = imagedata.length;
|
|
98
96
|
var line = width * 4;
|
|
99
97
|
var i = 0;
|
|
@@ -141,29 +139,27 @@ function () {
|
|
|
141
139
|
};
|
|
142
140
|
|
|
143
141
|
TextService.prototype.measureText = function (text, attributes) {
|
|
144
|
-
var
|
|
145
|
-
fontSize = _a === void 0 ? 0 : _a,
|
|
142
|
+
var fontSize = attributes.fontSize,
|
|
146
143
|
wordWrap = attributes.wordWrap,
|
|
147
|
-
|
|
148
|
-
strokeHeight =
|
|
149
|
-
|
|
150
|
-
lineWidth = _c === void 0 ? 0 : _c,
|
|
144
|
+
_a = attributes.lineHeight,
|
|
145
|
+
strokeHeight = _a === void 0 ? 0 : _a,
|
|
146
|
+
lineWidth = attributes.lineWidth,
|
|
151
147
|
textBaseline = attributes.textBaseline,
|
|
152
148
|
textAlign = attributes.textAlign,
|
|
153
|
-
|
|
154
|
-
letterSpacing =
|
|
149
|
+
_b = attributes.letterSpacing,
|
|
150
|
+
letterSpacing = _b === void 0 ? 0 : _b,
|
|
155
151
|
dropShadow = attributes.dropShadow,
|
|
156
|
-
|
|
157
|
-
dropShadowDistance =
|
|
158
|
-
|
|
159
|
-
leading =
|
|
152
|
+
_c = attributes.dropShadowDistance,
|
|
153
|
+
dropShadowDistance = _c === void 0 ? 0 : _c,
|
|
154
|
+
_d = attributes.leading,
|
|
155
|
+
leading = _d === void 0 ? 0 : _d;
|
|
160
156
|
var font = toFontString(attributes);
|
|
161
157
|
var fontProperties = this.measureFont(font); // fallback in case UA disallow canvas data extraction
|
|
162
158
|
// (toDataURI, getImageData functions)
|
|
163
159
|
|
|
164
160
|
if (fontProperties.fontSize === 0) {
|
|
165
|
-
fontProperties.fontSize = fontSize;
|
|
166
|
-
fontProperties.ascent = fontSize;
|
|
161
|
+
fontProperties.fontSize = fontSize.value;
|
|
162
|
+
fontProperties.ascent = fontSize.value;
|
|
167
163
|
}
|
|
168
164
|
|
|
169
165
|
var context = this.offscreenCanvas.getOrCreateContext();
|
|
@@ -179,14 +175,14 @@ function () {
|
|
|
179
175
|
maxLineWidth = Math.max(maxLineWidth, lineWidth_1);
|
|
180
176
|
}
|
|
181
177
|
|
|
182
|
-
var width = maxLineWidth + lineWidth;
|
|
178
|
+
var width = maxLineWidth + lineWidth.value;
|
|
183
179
|
|
|
184
180
|
if (dropShadow) {
|
|
185
181
|
width += dropShadowDistance;
|
|
186
182
|
}
|
|
187
183
|
|
|
188
|
-
var lineHeight = strokeHeight || fontProperties.fontSize + lineWidth;
|
|
189
|
-
var height = Math.max(lineHeight, fontProperties.fontSize + lineWidth) + (lines.length - 1) * (lineHeight + leading);
|
|
184
|
+
var lineHeight = strokeHeight || fontProperties.fontSize + lineWidth.value;
|
|
185
|
+
var height = Math.max(lineHeight, fontProperties.fontSize + lineWidth.value) + (lines.length - 1) * (lineHeight + leading);
|
|
190
186
|
|
|
191
187
|
if (dropShadow) {
|
|
192
188
|
height += dropShadowDistance;
|
|
@@ -222,7 +218,7 @@ function () {
|
|
|
222
218
|
offsetX -= width;
|
|
223
219
|
}
|
|
224
220
|
|
|
225
|
-
return new Rectangle(offsetX - lineWidth / 2, offsetY + i * lineHeight, width + lineWidth, lineHeight);
|
|
221
|
+
return new Rectangle(offsetX - lineWidth.value / 2, offsetY + i * lineHeight, width + lineWidth.value, lineHeight);
|
|
226
222
|
})
|
|
227
223
|
};
|
|
228
224
|
};
|
package/es/shapes/AABB.d.ts
CHANGED
package/es/shapes/AABB.js
CHANGED
|
@@ -5,15 +5,17 @@ import { vec3 } from 'gl-matrix';
|
|
|
5
5
|
* @see https://github.com/antvis/GWebGPUEngine/issues/3
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
var AABB =
|
|
9
|
-
/** @class */
|
|
10
|
-
function () {
|
|
8
|
+
var AABB = function () {
|
|
11
9
|
function AABB(center, halfExtents) {
|
|
12
10
|
this.min = vec3.create();
|
|
13
11
|
this.max = vec3.create();
|
|
14
12
|
this.update(center, halfExtents);
|
|
15
13
|
}
|
|
16
14
|
|
|
15
|
+
AABB.isEmpty = function (aabb) {
|
|
16
|
+
return !aabb || aabb.halfExtents[0] === 0 && aabb.halfExtents[1] === 0 && aabb.halfExtents[2] === 0;
|
|
17
|
+
};
|
|
18
|
+
|
|
17
19
|
AABB.prototype.update = function (center, halfExtents) {
|
|
18
20
|
this.center = vec3.copy(vec3.create(), center || vec3.create());
|
|
19
21
|
this.halfExtents = vec3.copy(vec3.create(), halfExtents || vec3.fromValues(0, 0, 0));
|
|
@@ -39,6 +41,10 @@ function () {
|
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
AABB.prototype.add = function (aabb) {
|
|
44
|
+
if (AABB.isEmpty(aabb)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
42
48
|
var tc = this.center;
|
|
43
49
|
var tcx = tc[0];
|
|
44
50
|
var tcy = tc[1];
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { vec3 } from 'gl-matrix';
|
|
2
2
|
var tmpVecA = vec3.create();
|
|
3
3
|
|
|
4
|
-
var BoundingSphere =
|
|
5
|
-
/** @class */
|
|
6
|
-
function () {
|
|
4
|
+
var BoundingSphere = function () {
|
|
7
5
|
function BoundingSphere(center, radius) {
|
|
8
6
|
this.center = center || vec3.create();
|
|
9
7
|
this.radius = radius || 0.5;
|
package/es/shapes/Frustum.js
CHANGED
package/es/shapes/Plane.js
CHANGED
package/es/shapes/Point.js
CHANGED
package/es/shapes/Polygon.js
CHANGED
package/es/shapes/Ray.js
CHANGED
|
@@ -11,9 +11,7 @@ var tmpVecE = vec3.create();
|
|
|
11
11
|
* @see https://github.com/mrdoob/three.js/blob/dev/src/math/Ray.js
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
var Ray =
|
|
15
|
-
/** @class */
|
|
16
|
-
function () {
|
|
14
|
+
var Ray = function () {
|
|
17
15
|
function Ray(origin, direction) {
|
|
18
16
|
this.origin = origin || vec3.create();
|
|
19
17
|
this.direction = direction || vec3.fromValues(0, 0, -1);
|
package/es/shapes/Rect.js
CHANGED
package/es/shapes/Rectangle.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,16 +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;
|
|
137
|
-
|
|
138
|
-
height?: number;
|
|
159
|
+
lineWidth?: ParsedElement;
|
|
139
160
|
/**
|
|
140
161
|
* x according to definition, eg. Line's x1/x2, Polyline's points
|
|
141
162
|
*/
|
|
@@ -146,6 +167,7 @@ export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'fill' | 'str
|
|
|
146
167
|
*/
|
|
147
168
|
offsetX?: number;
|
|
148
169
|
offsetY?: number;
|
|
170
|
+
shadowColor?: ParsedColorStyleProperty;
|
|
149
171
|
}
|
|
150
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';
|
|
151
173
|
export interface RendererConfig {
|