@antv/g 5.0.24 → 5.1.2
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 +2 -2
- package/es/Canvas.js +2 -0
- package/es/css/CSS.d.ts +4 -2
- package/es/css/CSS.js +6 -2
- package/es/css/CSSProperty.d.ts +2 -1
- package/es/css/StyleValueRegistry.d.ts +24 -55
- package/es/css/StyleValueRegistry.js +120 -138
- package/es/css/interfaces.d.ts +110 -0
- package/es/css/interfaces.js +75 -0
- package/es/css/parser/color.d.ts +1 -1
- package/es/css/parser/color.js +2 -2
- package/es/css/parser/dimension.js +5 -1
- package/es/css/parser/path.d.ts +2 -2
- package/es/css/parser/path.js +9 -2
- package/es/css/parser/points.d.ts +8 -1
- package/es/css/parser/points.js +33 -3
- package/es/css/parser/transform.js +1 -1
- package/es/css/properties/CSSPropertyClipPath.js +7 -1
- package/es/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -2
- package/es/css/properties/CSSPropertyLengthOrPercentage.js +34 -14
- package/es/css/properties/CSSPropertyLengthOrPercentage12.d.ts +15 -0
- package/es/css/properties/CSSPropertyLengthOrPercentage12.js +38 -0
- package/es/css/properties/CSSPropertyLengthOrPercentage14.d.ts +25 -0
- package/es/css/properties/CSSPropertyLengthOrPercentage14.js +42 -0
- package/es/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
- package/es/css/properties/CSSPropertyLocalPosition.js +59 -20
- package/es/css/properties/CSSPropertyPath.d.ts +3 -3
- package/es/css/properties/CSSPropertyPath.js +11 -6
- package/es/css/properties/CSSPropertyPoints.js +7 -5
- package/es/css/properties/CSSPropertyTransform.d.ts +1 -1
- package/es/css/properties/CSSPropertyTransform.js +76 -104
- package/es/css/properties/index.d.ts +2 -2
- package/es/css/properties/index.js +2 -2
- package/es/display-objects/Circle.d.ts +4 -0
- package/es/display-objects/Circle.js +2 -0
- package/es/display-objects/CustomElement.d.ts +6 -2
- package/es/display-objects/CustomElement.js +15 -5
- package/es/display-objects/DisplayObject.d.ts +1 -7
- package/es/display-objects/DisplayObject.js +6 -26
- package/es/display-objects/Ellipse.d.ts +4 -0
- package/es/display-objects/Ellipse.js +2 -0
- package/es/display-objects/Group.d.ts +4 -0
- package/es/display-objects/Group.js +2 -0
- package/es/display-objects/HTML.d.ts +4 -4
- package/es/display-objects/HTML.js +5 -3
- package/es/display-objects/Image.d.ts +4 -0
- package/es/display-objects/Image.js +2 -0
- package/es/display-objects/Line.js +2 -0
- package/es/display-objects/Polygon.js +1 -1
- package/es/display-objects/Polyline.js +1 -1
- package/es/display-objects/Rect.d.ts +11 -4
- package/es/display-objects/Rect.js +2 -0
- package/es/display-objects/Text.d.ts +4 -0
- package/es/display-objects/Text.js +4 -2
- package/es/dom/Element.js +1 -0
- package/es/global-module.js +4 -4
- package/es/services/EventService.js +10 -2
- package/es/services/SceneGraphService.d.ts +2 -0
- package/es/services/SceneGraphService.js +9 -0
- package/es/services/aabb/CircleUpdater.d.ts +0 -2
- package/es/services/aabb/CircleUpdater.js +2 -6
- package/es/services/aabb/EllipseUpdater.d.ts +0 -2
- package/es/services/aabb/EllipseUpdater.js +2 -6
- package/es/services/aabb/LineUpdater.d.ts +0 -2
- package/es/services/aabb/LineUpdater.js +1 -3
- package/es/services/aabb/PathUpdater.d.ts +0 -2
- package/es/services/aabb/PathUpdater.js +1 -5
- package/es/services/aabb/PolylineUpdater.d.ts +0 -2
- package/es/services/aabb/PolylineUpdater.js +1 -3
- package/es/services/aabb/RectUpdater.d.ts +0 -2
- package/es/services/aabb/RectUpdater.js +1 -5
- package/es/services/aabb/TextUpdater.d.ts +7 -0
- package/es/services/aabb/TextUpdater.js +0 -4
- package/es/services/aabb/interfaces.d.ts +0 -3
- package/es/types.d.ts +6 -19
- package/es/types.js +1 -0
- package/es/utils/interpolation.js +5 -10
- package/es/utils/math.js +4 -3
- package/es/utils/path.d.ts +2 -2
- package/es/utils/path.js +76 -26
- package/lib/Canvas.js +2 -0
- package/lib/css/CSS.d.ts +4 -2
- package/lib/css/CSS.js +6 -2
- package/lib/css/CSSProperty.d.ts +2 -1
- package/lib/css/StyleValueRegistry.d.ts +24 -55
- package/lib/css/StyleValueRegistry.js +120 -137
- package/lib/css/interfaces.d.ts +110 -0
- package/lib/css/interfaces.js +76 -1
- package/lib/css/parser/color.d.ts +1 -1
- package/lib/css/parser/color.js +1 -1
- package/lib/css/parser/dimension.js +4 -0
- package/lib/css/parser/path.d.ts +2 -2
- package/lib/css/parser/path.js +9 -2
- package/lib/css/parser/points.d.ts +8 -1
- package/lib/css/parser/points.js +33 -3
- package/lib/css/parser/transform.js +1 -1
- package/lib/css/properties/CSSPropertyClipPath.js +8 -1
- package/lib/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -2
- package/lib/css/properties/CSSPropertyLengthOrPercentage.js +34 -14
- package/lib/css/properties/CSSPropertyLengthOrPercentage12.d.ts +15 -0
- package/lib/css/properties/CSSPropertyLengthOrPercentage12.js +48 -0
- package/lib/css/properties/CSSPropertyLengthOrPercentage14.d.ts +25 -0
- package/lib/css/properties/CSSPropertyLengthOrPercentage14.js +52 -0
- package/lib/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
- package/lib/css/properties/CSSPropertyLocalPosition.js +60 -20
- package/lib/css/properties/CSSPropertyPath.d.ts +3 -3
- package/lib/css/properties/CSSPropertyPath.js +12 -6
- package/lib/css/properties/CSSPropertyPoints.js +8 -5
- package/lib/css/properties/CSSPropertyTransform.d.ts +1 -1
- package/lib/css/properties/CSSPropertyTransform.js +75 -103
- package/lib/css/properties/index.d.ts +2 -2
- package/lib/css/properties/index.js +17 -17
- package/lib/display-objects/Circle.d.ts +4 -0
- package/lib/display-objects/Circle.js +2 -0
- package/lib/display-objects/CustomElement.d.ts +6 -2
- package/lib/display-objects/CustomElement.js +13 -4
- package/lib/display-objects/DisplayObject.d.ts +1 -7
- package/lib/display-objects/DisplayObject.js +6 -27
- package/lib/display-objects/Ellipse.d.ts +4 -0
- package/lib/display-objects/Ellipse.js +2 -0
- package/lib/display-objects/Group.d.ts +4 -0
- package/lib/display-objects/Group.js +2 -0
- package/lib/display-objects/HTML.d.ts +4 -4
- package/lib/display-objects/HTML.js +5 -3
- package/lib/display-objects/Image.d.ts +4 -0
- package/lib/display-objects/Image.js +2 -0
- package/lib/display-objects/Line.js +2 -0
- package/lib/display-objects/Polygon.js +1 -1
- package/lib/display-objects/Polyline.js +1 -1
- package/lib/display-objects/Rect.d.ts +11 -4
- package/lib/display-objects/Rect.js +2 -0
- package/lib/display-objects/Text.d.ts +4 -0
- package/lib/display-objects/Text.js +4 -2
- package/lib/dom/Element.js +1 -0
- package/lib/global-module.js +3 -3
- package/lib/services/EventService.js +10 -2
- package/lib/services/SceneGraphService.d.ts +2 -0
- package/lib/services/SceneGraphService.js +12 -0
- package/lib/services/aabb/CircleUpdater.d.ts +0 -2
- package/lib/services/aabb/CircleUpdater.js +2 -6
- package/lib/services/aabb/EllipseUpdater.d.ts +0 -2
- package/lib/services/aabb/EllipseUpdater.js +2 -6
- package/lib/services/aabb/LineUpdater.d.ts +0 -2
- package/lib/services/aabb/LineUpdater.js +1 -3
- package/lib/services/aabb/PathUpdater.d.ts +0 -2
- package/lib/services/aabb/PathUpdater.js +1 -5
- package/lib/services/aabb/PolylineUpdater.d.ts +0 -2
- package/lib/services/aabb/PolylineUpdater.js +1 -3
- package/lib/services/aabb/RectUpdater.d.ts +0 -2
- package/lib/services/aabb/RectUpdater.js +1 -5
- package/lib/services/aabb/TextUpdater.d.ts +7 -0
- package/lib/services/aabb/TextUpdater.js +0 -4
- package/lib/services/aabb/interfaces.d.ts +0 -3
- package/lib/types.d.ts +6 -19
- package/lib/types.js +1 -0
- package/lib/utils/interpolation.js +6 -10
- package/lib/utils/math.js +4 -3
- package/lib/utils/path.d.ts +2 -2
- package/lib/utils/path.js +70 -26
- package/package.json +3 -3
- package/es/css/properties/CSSPropertyAnchor.d.ts +0 -8
- package/es/css/properties/CSSPropertyAnchor.js +0 -25
- package/es/css/properties/CSSPropertyLineDash.d.ts +0 -9
- package/es/css/properties/CSSPropertyLineDash.js +0 -25
- package/lib/css/properties/CSSPropertyAnchor.d.ts +0 -8
- package/lib/css/properties/CSSPropertyAnchor.js +0 -35
- package/lib/css/properties/CSSPropertyLineDash.d.ts +0 -9
- package/lib/css/properties/CSSPropertyLineDash.js +0 -34
package/es/global-module.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Module, injectable, decorate } from 'mana-syringe';
|
|
|
3
3
|
import { EventEmitter } from 'eventemitter3';
|
|
4
4
|
import { DisplayObjectPool } from './DisplayObjectPool';
|
|
5
5
|
import { CircleUpdater, EllipseUpdater, GeometryAABBUpdater, GeometryUpdaterFactory, LineUpdater, PathUpdater, PolylineUpdater, RectUpdater, TextUpdater, TextService, OffscreenCanvasCreator, DefaultSceneGraphService, DefaultSceneGraphSelector, SceneGraphSelector, SceneGraphSelectorFactory } from './services';
|
|
6
|
-
import { LayoutRegistry, CSSPropertyLocalPosition, CSSPropertyLengthOrPercentage,
|
|
6
|
+
import { LayoutRegistry, CSSPropertyLocalPosition, CSSPropertyLengthOrPercentage, CSSPropertyClipPath, CSSPropertyColor, CSSPropertyFilter, CSSPropertyLengthOrPercentage12, CSSPropertyOffsetDistance, CSSPropertyOffsetPath, CSSPropertyOpacity, CSSPropertyPath, CSSPropertyPoints, CSSPropertyText, CSSPropertyTextTransform, CSSPropertyTransform, CSSPropertyTransformOrigin, CSSPropertyZIndex, CSSPropertyShadowBlur, CSSPropertyLengthOrPercentage14, DefaultStyleValueRegistry } from './css';
|
|
7
7
|
import { ContextNode, FragmentResult, FragmentResultFactory, FragmentResultOptions, LayoutChildren, LayoutChildrenFactory, LayoutChildrenOptions, LayoutContext, LayoutContextFactory, LayoutContextOptions, LayoutEdges, LayoutEdgesFactory, LayoutEdgesOptions, LayoutEngine, LayoutFragment, LayoutFragmentFactory, LayoutFragmentOptions } from './css/layout';
|
|
8
8
|
export var containerModule = Module(function (register) {
|
|
9
9
|
decorate(injectable(), EventEmitter); // bind DisplayObject pool
|
|
@@ -55,11 +55,10 @@ export var containerModule = Module(function (register) {
|
|
|
55
55
|
register(CSSPropertyOpacity);
|
|
56
56
|
register(CSSPropertyColor);
|
|
57
57
|
register(CSSPropertyFilter);
|
|
58
|
-
register(
|
|
58
|
+
register(CSSPropertyLengthOrPercentage12);
|
|
59
59
|
register(CSSPropertyShadowBlur);
|
|
60
60
|
register(CSSPropertyOffsetPath);
|
|
61
61
|
register(CSSPropertyOffsetDistance);
|
|
62
|
-
register(CSSPropertyAnchor);
|
|
63
62
|
register(CSSPropertyZIndex);
|
|
64
63
|
register(CSSPropertyTransform);
|
|
65
64
|
register(CSSPropertyTransformOrigin);
|
|
@@ -67,7 +66,8 @@ export var containerModule = Module(function (register) {
|
|
|
67
66
|
register(CSSPropertyPoints);
|
|
68
67
|
register(CSSPropertyClipPath);
|
|
69
68
|
register(CSSPropertyText);
|
|
70
|
-
register(CSSPropertyTextTransform);
|
|
69
|
+
register(CSSPropertyTextTransform);
|
|
70
|
+
register(CSSPropertyLengthOrPercentage14); // bind layout engine
|
|
71
71
|
|
|
72
72
|
register(LayoutEngine);
|
|
73
73
|
register(LayoutEdges);
|
|
@@ -355,7 +355,11 @@ function (_super) {
|
|
|
355
355
|
while (leaveEvent.target && !e.composedPath().includes(leaveEvent.target)) {
|
|
356
356
|
leaveEvent.currentTarget = leaveEvent.target;
|
|
357
357
|
this.notifyTarget(leaveEvent);
|
|
358
|
-
|
|
358
|
+
|
|
359
|
+
if (isMouse) {
|
|
360
|
+
// console.error(leaveEvent.target);
|
|
361
|
+
this.notifyTarget(leaveEvent, 'mouseleave');
|
|
362
|
+
}
|
|
359
363
|
|
|
360
364
|
if (Node.isNode(leaveEvent.target)) {
|
|
361
365
|
leaveEvent.target = leaveEvent.target.parentNode;
|
|
@@ -460,7 +464,11 @@ function (_super) {
|
|
|
460
464
|
while (leaveEvent.target && leaveEvent.target !== (Node.isNode(this.rootTarget) && this.rootTarget.parentNode)) {
|
|
461
465
|
leaveEvent.currentTarget = leaveEvent.target;
|
|
462
466
|
this.notifyTarget(leaveEvent);
|
|
463
|
-
|
|
467
|
+
|
|
468
|
+
if (isMouse) {
|
|
469
|
+
// console.error(leaveEvent.target, 'out');
|
|
470
|
+
this.notifyTarget(leaveEvent, 'mouseleave');
|
|
471
|
+
}
|
|
464
472
|
|
|
465
473
|
if (Node.isNode(leaveEvent.target)) {
|
|
466
474
|
leaveEvent.target = leaveEvent.target.parentNode;
|
|
@@ -35,6 +35,7 @@ export interface SceneGraphService {
|
|
|
35
35
|
getLocalRotation: (element: INode) => quat;
|
|
36
36
|
getWorldTransform: (element: INode, transform?: Transform) => mat4;
|
|
37
37
|
getLocalTransform: (element: INode, transform?: Transform) => mat4;
|
|
38
|
+
setLocalTransform: (element: INode, transform: mat4) => void;
|
|
38
39
|
resetLocalTransform: (element: INode) => void;
|
|
39
40
|
getBounds: (element: INode, render?: boolean) => AABB;
|
|
40
41
|
getLocalBounds: (element: INode, render?: boolean) => AABB;
|
|
@@ -129,6 +130,7 @@ export declare class DefaultSceneGraphService implements SceneGraphService {
|
|
|
129
130
|
getLocalRotation(element: INode): import("gl-matrix").vec4;
|
|
130
131
|
getLocalScale(element: INode): vec3;
|
|
131
132
|
getLocalTransform(element: INode): mat4;
|
|
133
|
+
setLocalTransform(element: INode, transform: mat4): void;
|
|
132
134
|
resetLocalTransform(element: INode): void;
|
|
133
135
|
private getTransformedGeometryBounds;
|
|
134
136
|
/**
|
|
@@ -554,6 +554,15 @@ function () {
|
|
|
554
554
|
return transform.localTransform;
|
|
555
555
|
};
|
|
556
556
|
|
|
557
|
+
DefaultSceneGraphService.prototype.setLocalTransform = function (element, transform) {
|
|
558
|
+
var t = mat4.getTranslation(vec3.create(), transform);
|
|
559
|
+
var r = mat4.getRotation(quat.create(), transform);
|
|
560
|
+
var s = mat4.getScaling(vec3.create(), transform);
|
|
561
|
+
this.setLocalScale(element, s);
|
|
562
|
+
this.setLocalPosition(element, t);
|
|
563
|
+
this.setLocalRotation(element, r);
|
|
564
|
+
};
|
|
565
|
+
|
|
557
566
|
DefaultSceneGraphService.prototype.resetLocalTransform = function (element) {
|
|
558
567
|
this.setLocalScale(element, [1, 1, 1]);
|
|
559
568
|
this.setLocalPosition(element, [0, 0, 0]);
|
|
@@ -9,16 +9,12 @@ function () {
|
|
|
9
9
|
function CircleUpdater() {}
|
|
10
10
|
|
|
11
11
|
CircleUpdater.prototype.update = function (parsedStyle, object) {
|
|
12
|
-
var r = parsedStyle.r
|
|
13
|
-
x = parsedStyle.x,
|
|
14
|
-
y = parsedStyle.y;
|
|
12
|
+
var r = parsedStyle.r;
|
|
15
13
|
var width = r.value * 2;
|
|
16
14
|
var height = r.value * 2;
|
|
17
15
|
return {
|
|
18
16
|
width: width,
|
|
19
|
-
height: height
|
|
20
|
-
x: x.value || 0,
|
|
21
|
-
y: y.value || 0
|
|
17
|
+
height: height
|
|
22
18
|
};
|
|
23
19
|
};
|
|
24
20
|
|
|
@@ -10,16 +10,12 @@ function () {
|
|
|
10
10
|
|
|
11
11
|
EllipseUpdater.prototype.update = function (parsedStyle, object) {
|
|
12
12
|
var rx = parsedStyle.rx,
|
|
13
|
-
ry = parsedStyle.ry
|
|
14
|
-
x = parsedStyle.x,
|
|
15
|
-
y = parsedStyle.y;
|
|
13
|
+
ry = parsedStyle.ry;
|
|
16
14
|
var width = rx.value * 2;
|
|
17
15
|
var height = ry.value * 2;
|
|
18
16
|
return {
|
|
19
17
|
width: width,
|
|
20
|
-
height: height
|
|
21
|
-
x: x.value || 0,
|
|
22
|
-
y: y.value || 0
|
|
18
|
+
height: height
|
|
23
19
|
};
|
|
24
20
|
};
|
|
25
21
|
|
|
@@ -11,15 +11,11 @@ function () {
|
|
|
11
11
|
PathUpdater.prototype.update = function (parsedStyle) {
|
|
12
12
|
var path = parsedStyle.path;
|
|
13
13
|
var _a = path.rect,
|
|
14
|
-
minX = _a.x,
|
|
15
|
-
minY = _a.y,
|
|
16
14
|
width = _a.width,
|
|
17
15
|
height = _a.height;
|
|
18
16
|
return {
|
|
19
17
|
width: width,
|
|
20
|
-
height: height
|
|
21
|
-
x: minX,
|
|
22
|
-
y: minY
|
|
18
|
+
height: height
|
|
23
19
|
};
|
|
24
20
|
};
|
|
25
21
|
|
|
@@ -12,8 +12,6 @@ function () {
|
|
|
12
12
|
|
|
13
13
|
RectUpdater.prototype.update = function (parsedStyle, object) {
|
|
14
14
|
var img = parsedStyle.img,
|
|
15
|
-
x = parsedStyle.x,
|
|
16
|
-
y = parsedStyle.y,
|
|
17
15
|
width = parsedStyle.width,
|
|
18
16
|
height = parsedStyle.height;
|
|
19
17
|
var contentWidth = 0;
|
|
@@ -52,9 +50,7 @@ function () {
|
|
|
52
50
|
|
|
53
51
|
return {
|
|
54
52
|
width: contentWidth,
|
|
55
|
-
height: contentHeight
|
|
56
|
-
x: x.value || 0,
|
|
57
|
-
y: y.value || 0
|
|
53
|
+
height: contentHeight
|
|
58
54
|
};
|
|
59
55
|
};
|
|
60
56
|
|
|
@@ -10,5 +10,12 @@ export declare class TextUpdater implements GeometryAABBUpdater<ParsedTextStyleP
|
|
|
10
10
|
y: number;
|
|
11
11
|
offsetX: number;
|
|
12
12
|
offsetY: number;
|
|
13
|
+
} | {
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
offsetX: number;
|
|
17
|
+
offsetY: number;
|
|
18
|
+
x?: undefined;
|
|
19
|
+
y?: undefined;
|
|
13
20
|
};
|
|
14
21
|
}
|
|
@@ -29,8 +29,6 @@ function () {
|
|
|
29
29
|
textAlign = parsedStyle.textAlign,
|
|
30
30
|
lineWidth = parsedStyle.lineWidth,
|
|
31
31
|
textBaseline = parsedStyle.textBaseline,
|
|
32
|
-
x = parsedStyle.x,
|
|
33
|
-
y = parsedStyle.y,
|
|
34
32
|
dx = parsedStyle.dx,
|
|
35
33
|
dy = parsedStyle.dy;
|
|
36
34
|
var offscreenCanvas = (((_b = (_a = object === null || object === void 0 ? void 0 : object.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) === null || _b === void 0 ? void 0 : _b.getConfig()) || {}).offscreenCanvas;
|
|
@@ -119,8 +117,6 @@ function () {
|
|
|
119
117
|
return {
|
|
120
118
|
width: halfExtents[0] * 2,
|
|
121
119
|
height: halfExtents[1] * 2,
|
|
122
|
-
x: x.value || 0,
|
|
123
|
-
y: y.value || 0,
|
|
124
120
|
offsetX: lineXOffset,
|
|
125
121
|
offsetY: lineYOffset
|
|
126
122
|
};
|
package/es/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { vec2, vec3 } from 'gl-matrix';
|
|
3
3
|
import type { DisplayObject } from './display-objects';
|
|
4
4
|
import type { IRenderer } from './AbstractRenderer';
|
|
5
|
-
import type { CSSGlobalKeywords, CSSGradientValue, CSSKeywordValue, CSSRGB, CSSUnitValue } from './css';
|
|
5
|
+
import type { CSSGlobalKeywords, CSSGradientValue, CSSKeywordValue, CSSRGB, CSSUnitValue, ParsedTransform } from './css';
|
|
6
6
|
import { Syringe } from 'mana-syringe';
|
|
7
7
|
export declare enum Shape {
|
|
8
8
|
GROUP = "g",
|
|
@@ -15,7 +15,8 @@ export declare enum Shape {
|
|
|
15
15
|
POLYGON = "polygon",
|
|
16
16
|
TEXT = "text",
|
|
17
17
|
PATH = "path",
|
|
18
|
-
HTML = "html"
|
|
18
|
+
HTML = "html",
|
|
19
|
+
MESH = "mesh"
|
|
19
20
|
}
|
|
20
21
|
declare type ColorType = string | null;
|
|
21
22
|
export interface EventPosition {
|
|
@@ -51,18 +52,6 @@ export declare enum TextAlign {
|
|
|
51
52
|
}
|
|
52
53
|
export interface BaseStyleProps {
|
|
53
54
|
class?: string;
|
|
54
|
-
/**
|
|
55
|
-
* x in local space
|
|
56
|
-
*/
|
|
57
|
-
x?: number | string;
|
|
58
|
-
/**
|
|
59
|
-
* y in local space
|
|
60
|
-
*/
|
|
61
|
-
y?: number | string;
|
|
62
|
-
/**
|
|
63
|
-
* z in local space
|
|
64
|
-
*/
|
|
65
|
-
z?: number | string;
|
|
66
55
|
/**
|
|
67
56
|
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/transform
|
|
68
57
|
*/
|
|
@@ -163,7 +152,7 @@ export interface BaseStyleProps {
|
|
|
163
152
|
miterLimit?: number;
|
|
164
153
|
display?: string;
|
|
165
154
|
}
|
|
166
|
-
export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'anchor' | 'x' | 'y' | 'z' | 'opacity' | 'strokeOpacity' | 'fillOpacity' | 'fill' | 'stroke' | 'lineWidth' | 'increasedLineWidthForHitTesting' | 'lineJoin' | 'lineCap' | 'lineDash' | 'lineDashOffset' | 'path' | 'points' | 'shadowColor' | 'shadowBlur' | 'shadowOffsetX' | 'shadowOffsetY' | 'visibility' | 'pointerEvents' | 'zIndex' | 'transformOrigin' | 'textTransform'> {
|
|
155
|
+
export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'anchor' | 'x' | 'y' | 'z' | 'opacity' | 'strokeOpacity' | 'fillOpacity' | 'fill' | 'stroke' | 'lineWidth' | 'increasedLineWidthForHitTesting' | 'lineJoin' | 'lineCap' | 'lineDash' | 'lineDashOffset' | 'path' | 'points' | 'shadowColor' | 'shadowBlur' | 'shadowOffsetX' | 'shadowOffsetY' | 'visibility' | 'pointerEvents' | 'zIndex' | 'transform' | 'transformOrigin' | 'textTransform'> {
|
|
167
156
|
zIndex?: CSSUnitValue;
|
|
168
157
|
visibility?: CSSKeywordValue;
|
|
169
158
|
pointerEvents?: CSSKeywordValue;
|
|
@@ -177,10 +166,8 @@ export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'anchor' | 'x
|
|
|
177
166
|
lineJoin?: CSSKeywordValue;
|
|
178
167
|
lineDashOffset?: CSSUnitValue;
|
|
179
168
|
anchor?: [CSSUnitValue, CSSUnitValue, CSSUnitValue];
|
|
169
|
+
transform: ParsedTransform[];
|
|
180
170
|
transformOrigin?: [CSSUnitValue, CSSUnitValue, CSSUnitValue];
|
|
181
|
-
x?: CSSUnitValue;
|
|
182
|
-
y?: CSSUnitValue;
|
|
183
|
-
z?: CSSUnitValue;
|
|
184
171
|
width?: CSSUnitValue;
|
|
185
172
|
height?: CSSUnitValue;
|
|
186
173
|
lineWidth?: CSSUnitValue;
|
|
@@ -247,7 +234,7 @@ export interface CanvasConfig {
|
|
|
247
234
|
/**
|
|
248
235
|
* replace `new window.Image()`
|
|
249
236
|
*/
|
|
250
|
-
createImage?: () => HTMLImageElement;
|
|
237
|
+
createImage?: (src: string) => HTMLImageElement;
|
|
251
238
|
/**
|
|
252
239
|
* limits query
|
|
253
240
|
*/
|
package/es/types.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __read, __spreadArray } from "tslib";
|
|
2
2
|
import { GlobalContainer } from 'mana-syringe';
|
|
3
3
|
import { StyleValueRegistry } from '../css/interfaces';
|
|
4
|
+
import { PROPERTY_HANDLERS } from '../css/StyleValueRegistry';
|
|
4
5
|
import { parseEasingFunction } from './animation';
|
|
5
6
|
import { camelCase } from './string';
|
|
6
7
|
export function convertEffectInput(keyframes, timing, target) {
|
|
@@ -116,13 +117,13 @@ function propertyInterpolation(property, left, right, target) {
|
|
|
116
117
|
var registry = GlobalContainer.get(StyleValueRegistry);
|
|
117
118
|
var metadata = registry.getMetadata(property);
|
|
118
119
|
|
|
119
|
-
if (metadata && metadata.
|
|
120
|
-
var propertyHandler = GlobalContainer.get(metadata.
|
|
120
|
+
if (metadata && metadata.syntax && metadata.interpolable && PROPERTY_HANDLERS[metadata.syntax]) {
|
|
121
|
+
var propertyHandler = GlobalContainer.get(PROPERTY_HANDLERS[metadata.syntax]);
|
|
121
122
|
|
|
122
123
|
if (propertyHandler) {
|
|
123
124
|
if (propertyHandler.parser) {
|
|
124
|
-
parsedLeft = propertyHandler.parser(left);
|
|
125
|
-
parsedRight = propertyHandler.parser(right);
|
|
125
|
+
parsedLeft = propertyHandler.parser(left, target);
|
|
126
|
+
parsedRight = propertyHandler.parser(right, target);
|
|
126
127
|
} // if (propertyHandler.calculator) {
|
|
127
128
|
// parsedLeft = propertyHandler.calculator(parsedLeft);
|
|
128
129
|
// // parsedLeft = handler.calculator
|
|
@@ -184,12 +185,6 @@ var FORMAT_ATTR_MAP = {
|
|
|
184
185
|
d: {
|
|
185
186
|
alias: 'path'
|
|
186
187
|
},
|
|
187
|
-
cx: {
|
|
188
|
-
alias: 'x'
|
|
189
|
-
},
|
|
190
|
-
cy: {
|
|
191
|
-
alias: 'y'
|
|
192
|
-
},
|
|
193
188
|
strokeDasharray: {
|
|
194
189
|
alias: 'lineDash'
|
|
195
190
|
},
|
package/es/utils/math.js
CHANGED
|
@@ -199,8 +199,8 @@ export function makePerspective(out, left, right, top, bottom, near, far) {
|
|
|
199
199
|
}
|
|
200
200
|
export function decompose(mat) {
|
|
201
201
|
var row0x = mat[0];
|
|
202
|
-
var row0y = mat[
|
|
203
|
-
var row1x = mat[
|
|
202
|
+
var row0y = mat[1];
|
|
203
|
+
var row1x = mat[3];
|
|
204
204
|
var row1y = mat[4]; // decompose 3x3 matrix
|
|
205
205
|
// @see https://www.w3.org/TR/css-transforms-1/#decomposing-a-2d-matrix
|
|
206
206
|
|
|
@@ -230,6 +230,7 @@ export function decompose(mat) {
|
|
|
230
230
|
} // Compute rotation and renormalize matrix.
|
|
231
231
|
|
|
232
232
|
|
|
233
|
-
var
|
|
233
|
+
var rotation = Math.atan2(row0y, row0x);
|
|
234
|
+
var angle = rad2deg(rotation);
|
|
234
235
|
return [mat[6], mat[7], scalingX, scalingY, angle];
|
|
235
236
|
}
|
package/es/utils/path.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Circle, Ellipse, Line, Path, Polyline, Polygon, Rect } from '../display-objects';
|
|
2
2
|
import type { PathCommand } from '../types';
|
|
3
3
|
export declare function equalizeSegments(path1: PathCommand[], path2: PathCommand[], TL?: number): PathCommand[][];
|
|
4
4
|
export declare function getDrawDirection(pathArray: PathCommand[]): boolean;
|
|
@@ -12,4 +12,4 @@ export declare function getRotatedCurve(a: PathCommand[], b: PathCommand[]): (st
|
|
|
12
12
|
* * anchor
|
|
13
13
|
* * lineWidth
|
|
14
14
|
*/
|
|
15
|
-
export declare function convertToPath(object:
|
|
15
|
+
export declare function convertToPath(object: Circle | Ellipse | Rect | Line | Polyline | Polygon | Path, applyLocalTransform?: boolean): string;
|
package/es/utils/path.js
CHANGED
|
@@ -205,17 +205,32 @@ export function getRotatedCurve(a, b) {
|
|
|
205
205
|
return rotations[computedIndex];
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
function commandsToPathString(commands,
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
208
|
+
function commandsToPathString(commands, object, applyLocalTransform) {
|
|
209
|
+
if (applyLocalTransform === void 0) {
|
|
210
|
+
applyLocalTransform = true;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
var transform;
|
|
214
|
+
|
|
215
|
+
if (applyLocalTransform) {
|
|
216
|
+
transform = object.getLocalTransform();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
var _a = object.parsedStyle,
|
|
220
|
+
_b = _a.defX,
|
|
221
|
+
defX = _b === void 0 ? 0 : _b,
|
|
222
|
+
_c = _a.defY,
|
|
223
|
+
defY = _c === void 0 ? 0 : _c;
|
|
213
224
|
return commands.reduce(function (prev, cur) {
|
|
214
225
|
var path = '';
|
|
215
226
|
|
|
216
227
|
if (cur[0] === 'M' || cur[0] === 'L') {
|
|
217
228
|
var p = vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
|
|
218
|
-
|
|
229
|
+
|
|
230
|
+
if (applyLocalTransform) {
|
|
231
|
+
vec3.transformMat4(p, p, transform);
|
|
232
|
+
}
|
|
233
|
+
|
|
219
234
|
path = "".concat(cur[0]).concat(p[0], ",").concat(p[1]);
|
|
220
235
|
} else if (cur[0] === 'Z') {
|
|
221
236
|
path = cur[0];
|
|
@@ -223,13 +238,21 @@ function commandsToPathString(commands, localTransform, anchor, parsedStyle) {
|
|
|
223
238
|
var p1 = vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
|
|
224
239
|
var p2 = vec3.fromValues(cur[3] - defX, cur[4] - defY, 0);
|
|
225
240
|
var p3 = vec3.fromValues(cur[5] - defX, cur[6] - defY, 0);
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
241
|
+
|
|
242
|
+
if (applyLocalTransform) {
|
|
243
|
+
vec3.transformMat4(p1, p1, transform);
|
|
244
|
+
vec3.transformMat4(p2, p2, transform);
|
|
245
|
+
vec3.transformMat4(p3, p3, transform);
|
|
246
|
+
}
|
|
247
|
+
|
|
229
248
|
path = "".concat(cur[0]).concat(p1[0], ",").concat(p1[1], ",").concat(p2[0], ",").concat(p2[1], ",").concat(p3[0], ",").concat(p3[1]);
|
|
230
249
|
} else if (cur[0] === 'A') {
|
|
231
250
|
var c = vec3.fromValues(cur[6] - defX, cur[7] - defY, 0);
|
|
232
|
-
|
|
251
|
+
|
|
252
|
+
if (applyLocalTransform) {
|
|
253
|
+
vec3.transformMat4(c, c, transform);
|
|
254
|
+
}
|
|
255
|
+
|
|
233
256
|
path = "".concat(cur[0]).concat(cur[1], ",").concat(cur[2], ",").concat(cur[3], ",").concat(cur[4], ",").concat(cur[5], ",").concat(c[0], ",").concat(c[1]);
|
|
234
257
|
}
|
|
235
258
|
|
|
@@ -252,16 +275,30 @@ function ellipseToCommands(rx, ry, cx, cy) {
|
|
|
252
275
|
return [['M', left, cy], ['C', left, cy - dy, cx - dx, top, cx, top], ['C', cx + dx, top, right, cy - dy, right, cy], ['C', right, cy + dy, cx + dx, bottom, cx, bottom], ['C', cx - dx, bottom, left, cy + dy, left, cy], ['Z']];
|
|
253
276
|
}
|
|
254
277
|
|
|
255
|
-
function polygonToCommands(points) {
|
|
256
|
-
|
|
278
|
+
function polygonToCommands(points, closed) {
|
|
279
|
+
var result = points.map(function (point, i) {
|
|
257
280
|
return [i === 0 ? 'M' : 'L', point[0], point[1]];
|
|
258
281
|
});
|
|
282
|
+
|
|
283
|
+
if (closed) {
|
|
284
|
+
result.push(['Z']);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return result;
|
|
259
288
|
}
|
|
260
289
|
|
|
261
290
|
function rectToCommands(width, height, x, y, radius) {
|
|
262
291
|
// @see https://gist.github.com/danielpquinn/dd966af424030d47e476
|
|
263
292
|
if (radius) {
|
|
264
|
-
|
|
293
|
+
var _a = __read(radius, 4),
|
|
294
|
+
tlr = _a[0],
|
|
295
|
+
trr = _a[1],
|
|
296
|
+
brr = _a[2],
|
|
297
|
+
blr = _a[3];
|
|
298
|
+
|
|
299
|
+
return [['M', x, tlr + y], tlr ? ['A', tlr, tlr, 0, 0, 1, tlr + x, y] : null, ['L', width - trr + x, y], trr ? ['A', trr, trr, 0, 0, 1, width + x, trr + y] : null, ['L', width + x, height - brr + y], brr ? ['A', brr, brr, 0, 0, 1, width - brr + x, height + y] : null, ['L', blr + x, height + y], blr ? ['A', blr, blr, 0, 0, 1, x, height - blr + y] : null, ['Z']].filter(function (command) {
|
|
300
|
+
return command;
|
|
301
|
+
});
|
|
265
302
|
}
|
|
266
303
|
|
|
267
304
|
return [['M', x, y], ['L', x + width, y], ['L', x + width, y + height], ['L', x, y + height], ['Z']];
|
|
@@ -274,9 +311,11 @@ function rectToCommands(width, height, x, y, radius) {
|
|
|
274
311
|
*/
|
|
275
312
|
|
|
276
313
|
|
|
277
|
-
export function convertToPath(object) {
|
|
278
|
-
|
|
279
|
-
|
|
314
|
+
export function convertToPath(object, applyLocalTransform) {
|
|
315
|
+
if (applyLocalTransform === void 0) {
|
|
316
|
+
applyLocalTransform = true;
|
|
317
|
+
}
|
|
318
|
+
|
|
280
319
|
var commands = [];
|
|
281
320
|
|
|
282
321
|
switch (object.nodeName) {
|
|
@@ -293,9 +332,9 @@ export function convertToPath(object) {
|
|
|
293
332
|
{
|
|
294
333
|
var _b = object.parsedStyle,
|
|
295
334
|
r = _b.r,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
commands = ellipseToCommands(r.value, r.value,
|
|
335
|
+
cx = _b.cx,
|
|
336
|
+
cy = _b.cy;
|
|
337
|
+
commands = ellipseToCommands(r.value, r.value, cx.value, cy.value);
|
|
299
338
|
break;
|
|
300
339
|
}
|
|
301
340
|
|
|
@@ -304,16 +343,16 @@ export function convertToPath(object) {
|
|
|
304
343
|
var _c = object.parsedStyle,
|
|
305
344
|
rx = _c.rx,
|
|
306
345
|
ry = _c.ry,
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
commands = ellipseToCommands(rx.value, ry.value,
|
|
346
|
+
cx = _c.cx,
|
|
347
|
+
cy = _c.cy;
|
|
348
|
+
commands = ellipseToCommands(rx.value, ry.value, cx.value, cy.value);
|
|
310
349
|
break;
|
|
311
350
|
}
|
|
312
351
|
|
|
313
352
|
case Shape.POLYLINE:
|
|
314
353
|
case Shape.POLYGON:
|
|
315
354
|
var points = object.parsedStyle.points;
|
|
316
|
-
commands = polygonToCommands(points.points);
|
|
355
|
+
commands = polygonToCommands(points.points, object.nodeName === Shape.POLYGON);
|
|
317
356
|
break;
|
|
318
357
|
|
|
319
358
|
case Shape.RECT:
|
|
@@ -323,15 +362,26 @@ export function convertToPath(object) {
|
|
|
323
362
|
x = _d.x,
|
|
324
363
|
y = _d.y,
|
|
325
364
|
radius = _d.radius;
|
|
326
|
-
|
|
365
|
+
var hasRadius = radius && radius.some(function (r) {
|
|
366
|
+
return r.value !== 0;
|
|
367
|
+
});
|
|
368
|
+
commands = rectToCommands(width.value, height.value, x.value, y.value, hasRadius && radius.map(function (r) {
|
|
369
|
+
return r.value;
|
|
370
|
+
}));
|
|
327
371
|
break;
|
|
328
372
|
|
|
329
373
|
case Shape.PATH:
|
|
330
|
-
|
|
374
|
+
var _e = object.parsedStyle.path,
|
|
375
|
+
curve = _e.curve,
|
|
376
|
+
zCommandIndexes = _e.zCommandIndexes;
|
|
377
|
+
commands = __spreadArray([], __read(curve), false);
|
|
378
|
+
zCommandIndexes.forEach(function (zIndex, index) {
|
|
379
|
+
commands.splice(zIndex + index, 1, ['Z']);
|
|
380
|
+
});
|
|
331
381
|
break;
|
|
332
382
|
}
|
|
333
383
|
|
|
334
384
|
if (commands.length) {
|
|
335
|
-
return commandsToPathString(commands,
|
|
385
|
+
return commandsToPathString(commands, object, applyLocalTransform);
|
|
336
386
|
}
|
|
337
387
|
}
|
package/lib/Canvas.js
CHANGED
|
@@ -116,6 +116,8 @@ function (_super) {
|
|
|
116
116
|
/**
|
|
117
117
|
* limits query
|
|
118
118
|
*/
|
|
119
|
+
// the following feature-detect from hammer.js
|
|
120
|
+
// @see https://github.com/hammerjs/hammer.js/blob/master/src/inputjs/input-consts.js#L5
|
|
119
121
|
|
|
120
122
|
_this.supportTouchEvent = supportTouchEvent !== null && supportTouchEvent !== void 0 ? supportTouchEvent : 'ontouchstart' in globalThis;
|
|
121
123
|
_this.supportPointerEvent = supportPointerEvent !== null && supportPointerEvent !== void 0 ? supportPointerEvent : !!globalThis.PointerEvent;
|
package/lib/css/CSS.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CSSUnitValue } from './cssom';
|
|
2
|
+
import type { PropertySyntax } from './interfaces';
|
|
2
3
|
import type { LayoutDefinitionCtor } from './layout';
|
|
3
4
|
/**
|
|
4
5
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSS/RegisterProperty#parameters
|
|
@@ -8,11 +9,12 @@ export interface PropertyDefinition {
|
|
|
8
9
|
/**
|
|
9
10
|
* representing the expected syntax of the defined property. Defaults to "*".
|
|
10
11
|
*/
|
|
11
|
-
syntax
|
|
12
|
+
syntax: PropertySyntax;
|
|
12
13
|
/**
|
|
13
14
|
* A boolean value defining whether the defined property should be inherited (true), or not (false). Defaults to false.
|
|
14
15
|
*/
|
|
15
|
-
inherits
|
|
16
|
+
inherits?: boolean;
|
|
17
|
+
interpolable?: boolean;
|
|
16
18
|
initialValue?: string;
|
|
17
19
|
}
|
|
18
20
|
/**
|