@antv/g 5.0.12 → 5.0.15
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 +1 -0
- package/es/canvas-module.js +7 -15
- package/es/display-objects/Circle.d.ts +3 -1
- package/es/display-objects/DisplayObject.js +6 -2
- package/es/display-objects/Ellipse.d.ts +5 -2
- package/es/display-objects/Group.js +4 -1
- package/es/display-objects/HTML.d.ts +5 -0
- package/es/display-objects/HTML.js +1 -1
- package/es/display-objects/Image.d.ts +7 -4
- package/es/display-objects/Image.js +3 -1
- package/es/display-objects/Rect.d.ts +7 -4
- package/es/display-objects/Rect.js +2 -2
- package/es/display-objects/Text.d.ts +0 -2
- package/es/display-objects/Text.js +2 -2
- package/es/dom/Element.d.ts +4 -4
- package/es/dom/Element.js +2 -1
- package/es/dom/FederatedPointerEvent.d.ts +6 -0
- package/es/dom/FederatedPointerEvent.js +8 -0
- package/es/global-module.d.ts +3 -1
- package/es/global-module.js +30 -70
- package/es/property-handlers/aabb.js +3 -4
- package/es/property-handlers/anchor.js +2 -1
- package/es/property-handlers/dimension.d.ts +2 -1
- package/es/property-handlers/dimension.js +30 -2
- package/es/property-handlers/path.d.ts +1 -1
- package/es/services/SceneGraphService.d.ts +7 -9
- package/es/services/SceneGraphService.js +59 -71
- package/es/services/aabb/CircleUpdater.d.ts +2 -2
- package/es/services/aabb/CircleUpdater.js +19 -9
- package/es/services/aabb/EllipseUpdater.d.ts +2 -2
- package/es/services/aabb/EllipseUpdater.js +26 -11
- package/es/services/aabb/RectUpdater.d.ts +2 -2
- package/es/services/aabb/RectUpdater.js +30 -14
- package/es/services/aabb/interfaces.d.ts +1 -1
- package/es/services/aabb/interfaces.js +1 -1
- package/es/shapes/AABB.d.ts +1 -0
- package/es/shapes/AABB.js +8 -0
- package/es/types.d.ts +0 -3
- package/es/utils/path.d.ts +1 -1
- package/es/utils/path.js +5 -5
- package/lib/Canvas.js +1 -0
- package/lib/canvas-module.js +9 -16
- package/lib/display-objects/Circle.d.ts +3 -1
- package/lib/display-objects/DisplayObject.js +6 -2
- package/lib/display-objects/Ellipse.d.ts +5 -2
- package/lib/display-objects/Group.js +4 -1
- package/lib/display-objects/HTML.d.ts +5 -0
- package/lib/display-objects/HTML.js +1 -1
- package/lib/display-objects/Image.d.ts +7 -4
- package/lib/display-objects/Image.js +3 -1
- package/lib/display-objects/Rect.d.ts +7 -4
- package/lib/display-objects/Rect.js +2 -2
- package/lib/display-objects/Text.d.ts +0 -2
- package/lib/display-objects/Text.js +2 -2
- package/lib/dom/Element.d.ts +4 -4
- package/lib/dom/Element.js +2 -1
- package/lib/dom/FederatedPointerEvent.d.ts +6 -0
- package/lib/dom/FederatedPointerEvent.js +8 -0
- package/lib/global-module.d.ts +3 -1
- package/lib/global-module.js +34 -70
- package/lib/property-handlers/aabb.js +3 -4
- package/lib/property-handlers/anchor.js +3 -1
- package/lib/property-handlers/dimension.d.ts +2 -1
- package/lib/property-handlers/dimension.js +33 -2
- package/lib/property-handlers/path.d.ts +1 -1
- package/lib/services/SceneGraphService.d.ts +7 -9
- package/lib/services/SceneGraphService.js +59 -71
- package/lib/services/aabb/CircleUpdater.d.ts +2 -2
- package/lib/services/aabb/CircleUpdater.js +19 -9
- package/lib/services/aabb/EllipseUpdater.d.ts +2 -2
- package/lib/services/aabb/EllipseUpdater.js +26 -11
- package/lib/services/aabb/RectUpdater.d.ts +2 -2
- package/lib/services/aabb/RectUpdater.js +30 -14
- package/lib/services/aabb/interfaces.d.ts +1 -1
- package/lib/services/aabb/interfaces.js +1 -1
- package/lib/shapes/AABB.d.ts +1 -0
- package/lib/shapes/AABB.js +8 -0
- package/lib/types.d.ts +0 -3
- package/lib/utils/path.d.ts +1 -1
- package/lib/utils/path.js +5 -5
- package/package.json +4 -4
|
@@ -56,72 +56,6 @@ var DefaultSceneGraphService =
|
|
|
56
56
|
function () {
|
|
57
57
|
function DefaultSceneGraphService() {
|
|
58
58
|
var _this = this;
|
|
59
|
-
/**
|
|
60
|
-
* compare two display objects by hierarchy-index and z-index
|
|
61
|
-
*
|
|
62
|
-
* use materialized path
|
|
63
|
-
* @see https://stackoverflow.com/questions/31470730/comparing-tree-nodes
|
|
64
|
-
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
this.sort = function (object1, object2) {
|
|
68
|
-
if (!object1.parentNode) {
|
|
69
|
-
return -1;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (!object2.parentNode) {
|
|
73
|
-
return 1;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
var hierarchyDiff = object1.transformable.graphDepth - object2.transformable.graphDepth;
|
|
77
|
-
var o1 = object1;
|
|
78
|
-
var o2 = object2;
|
|
79
|
-
|
|
80
|
-
if (hierarchyDiff < 0) {
|
|
81
|
-
o2 = object2.getAncestor(-hierarchyDiff);
|
|
82
|
-
|
|
83
|
-
if (o2 === o1) {
|
|
84
|
-
return -1;
|
|
85
|
-
}
|
|
86
|
-
} else if (hierarchyDiff > 0) {
|
|
87
|
-
o1 = object1.getAncestor(hierarchyDiff);
|
|
88
|
-
|
|
89
|
-
if (o2 === o1) {
|
|
90
|
-
return 1;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
while (o1 && o2 && o1.parentNode !== o2.parentNode) {
|
|
95
|
-
o1 = o1.parentNode;
|
|
96
|
-
o2 = o2.parentNode;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
var parent = o1.parentNode;
|
|
100
|
-
|
|
101
|
-
if (parent) {
|
|
102
|
-
var parentSortable = parent.sortable;
|
|
103
|
-
|
|
104
|
-
if (parentSortable) {
|
|
105
|
-
// no need to re-sort, use cached sorted children
|
|
106
|
-
if (!parentSortable.sorted) {
|
|
107
|
-
parentSortable.sorted = parent.childNodes.slice();
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (parentSortable.dirty) {
|
|
111
|
-
parentSortable.sorted = parent.childNodes.slice().sort(sortByZIndex); // parentSortable.sorted.forEach(
|
|
112
|
-
// (child, i) => ((child as Element).sortable.lastSortedIndex = i),
|
|
113
|
-
// );
|
|
114
|
-
|
|
115
|
-
parentSortable.dirty = false;
|
|
116
|
-
} // return (o1 as Element).sortable.lastSortedIndex - (o2 as Element).sortable.lastSortedIndex;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return parentSortable.sorted.indexOf(o1) - parentSortable.sorted.indexOf(o2);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return -1;
|
|
124
|
-
};
|
|
125
59
|
/**
|
|
126
60
|
* rotate in world space
|
|
127
61
|
*/
|
|
@@ -437,6 +371,60 @@ function () {
|
|
|
437
371
|
child.parentNode = null;
|
|
438
372
|
}
|
|
439
373
|
};
|
|
374
|
+
/**
|
|
375
|
+
* compare two display objects by hierarchy-index and z-index
|
|
376
|
+
*
|
|
377
|
+
* use materialized path
|
|
378
|
+
* @see https://stackoverflow.com/questions/31470730/comparing-tree-nodes
|
|
379
|
+
*/
|
|
380
|
+
// sort = (object1: INode, object2: INode): number => {
|
|
381
|
+
// if (!object1.parentNode) {
|
|
382
|
+
// return -1;
|
|
383
|
+
// }
|
|
384
|
+
// if (!object2.parentNode) {
|
|
385
|
+
// return 1;
|
|
386
|
+
// }
|
|
387
|
+
// const hierarchyDiff =
|
|
388
|
+
// (object1 as Element).transformable.graphDepth - (object2 as Element).transformable.graphDepth;
|
|
389
|
+
// let o1 = object1;
|
|
390
|
+
// let o2 = object2;
|
|
391
|
+
// if (hierarchyDiff < 0) {
|
|
392
|
+
// o2 = object2.getAncestor(-hierarchyDiff)!;
|
|
393
|
+
// if (o2 === o1) {
|
|
394
|
+
// return -1;
|
|
395
|
+
// }
|
|
396
|
+
// } else if (hierarchyDiff > 0) {
|
|
397
|
+
// o1 = object1.getAncestor(hierarchyDiff)!;
|
|
398
|
+
// if (o2 === o1) {
|
|
399
|
+
// return 1;
|
|
400
|
+
// }
|
|
401
|
+
// }
|
|
402
|
+
// while (o1 && o2 && o1.parentNode !== o2.parentNode) {
|
|
403
|
+
// o1 = o1.parentNode!;
|
|
404
|
+
// o2 = o2.parentNode!;
|
|
405
|
+
// }
|
|
406
|
+
// const parent = o1.parentNode;
|
|
407
|
+
// if (parent) {
|
|
408
|
+
// const parentSortable = (parent as Element).sortable;
|
|
409
|
+
// if (parentSortable) {
|
|
410
|
+
// // no need to re-sort, use cached sorted children
|
|
411
|
+
// if (!parentSortable.sorted) {
|
|
412
|
+
// parentSortable.sorted = (parent.childNodes as IElement[]).slice();
|
|
413
|
+
// }
|
|
414
|
+
// if (parentSortable.dirty) {
|
|
415
|
+
// parentSortable.sorted = (parent.childNodes as IElement[]).slice().sort(sortByZIndex);
|
|
416
|
+
// // parentSortable.sorted.forEach(
|
|
417
|
+
// // (child, i) => ((child as Element).sortable.lastSortedIndex = i),
|
|
418
|
+
// // );
|
|
419
|
+
// parentSortable.dirty = false;
|
|
420
|
+
// }
|
|
421
|
+
// // return (o1 as Element).sortable.lastSortedIndex - (o2 as Element).sortable.lastSortedIndex;
|
|
422
|
+
// return parentSortable.sorted.indexOf(o1) - parentSortable.sorted.indexOf(o2);
|
|
423
|
+
// }
|
|
424
|
+
// }
|
|
425
|
+
// return -1;
|
|
426
|
+
// };
|
|
427
|
+
|
|
440
428
|
|
|
441
429
|
DefaultSceneGraphService.prototype.getOrigin = function (element) {
|
|
442
430
|
return element.transformable.origin;
|
|
@@ -625,7 +613,7 @@ function () {
|
|
|
625
613
|
|
|
626
614
|
var bounds = this.getGeometryBounds(element, render);
|
|
627
615
|
|
|
628
|
-
if (bounds) {
|
|
616
|
+
if (!AABB.isEmpty(bounds)) {
|
|
629
617
|
var aabb = new AABB();
|
|
630
618
|
aabb.setFromTransformedAABB(bounds, this.getWorldTransform(element));
|
|
631
619
|
return aabb;
|
|
@@ -645,7 +633,7 @@ function () {
|
|
|
645
633
|
|
|
646
634
|
var geometry = element.geometry;
|
|
647
635
|
var bounds = render ? geometry.renderBounds : geometry.contentBounds || null;
|
|
648
|
-
return bounds && new AABB(bounds.center, bounds.halfExtents) ||
|
|
636
|
+
return bounds && new AABB(bounds.center, bounds.halfExtents) || new AABB();
|
|
649
637
|
};
|
|
650
638
|
/**
|
|
651
639
|
* account for children in world space
|
|
@@ -719,7 +707,7 @@ function () {
|
|
|
719
707
|
renderable.boundsDirty = false;
|
|
720
708
|
}
|
|
721
709
|
|
|
722
|
-
return aabb ||
|
|
710
|
+
return aabb || new AABB();
|
|
723
711
|
};
|
|
724
712
|
/**
|
|
725
713
|
* account for children in local space
|
|
@@ -736,7 +724,7 @@ function () {
|
|
|
736
724
|
|
|
737
725
|
var bounds = this.getBounds(element);
|
|
738
726
|
|
|
739
|
-
if (bounds) {
|
|
727
|
+
if (!AABB.isEmpty(bounds)) {
|
|
740
728
|
var localBounds = new AABB();
|
|
741
729
|
localBounds.setFromTransformedAABB(bounds, parentInvert);
|
|
742
730
|
return localBounds;
|
|
@@ -752,7 +740,7 @@ function () {
|
|
|
752
740
|
var aabb;
|
|
753
741
|
var bounds = this.getGeometryBounds(element);
|
|
754
742
|
|
|
755
|
-
if (bounds) {
|
|
743
|
+
if (!AABB.isEmpty(bounds)) {
|
|
756
744
|
aabb = new AABB(); // apply transformation to aabb
|
|
757
745
|
|
|
758
746
|
aabb.setFromTransformedAABB(bounds, this.getWorldTransform(element));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GeometryAABBUpdater } from './interfaces';
|
|
2
|
-
import type { ParsedCircleStyleProps } from '../../display-objects/Circle';
|
|
2
|
+
import type { Circle, ParsedCircleStyleProps } from '../../display-objects/Circle';
|
|
3
3
|
export declare class CircleUpdater implements GeometryAABBUpdater<ParsedCircleStyleProps> {
|
|
4
|
-
update(parsedStyle: ParsedCircleStyleProps): {
|
|
4
|
+
update(parsedStyle: ParsedCircleStyleProps, object: Circle): {
|
|
5
5
|
width: number;
|
|
6
6
|
height: number;
|
|
7
7
|
x: number;
|
|
@@ -8,16 +8,26 @@ var CircleUpdater =
|
|
|
8
8
|
function () {
|
|
9
9
|
function CircleUpdater() {}
|
|
10
10
|
|
|
11
|
-
CircleUpdater.prototype.update = function (parsedStyle) {
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
CircleUpdater.prototype.update = function (parsedStyle, object) {
|
|
12
|
+
var r = parsedStyle.r,
|
|
13
|
+
_a = parsedStyle.x,
|
|
14
|
+
x = _a === void 0 ? 0 : _a,
|
|
15
|
+
_b = parsedStyle.y,
|
|
16
|
+
y = _b === void 0 ? 0 : _b;
|
|
17
|
+
var unit = r.unit,
|
|
18
|
+
value = r.value;
|
|
19
|
+
var width = 0;
|
|
20
|
+
var height = 0;
|
|
21
|
+
|
|
22
|
+
if (unit === '' || unit === 'px') {
|
|
23
|
+
width = value * 2;
|
|
24
|
+
height = value * 2;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
object.parsedStyle.rInPixels = width / 2;
|
|
18
28
|
return {
|
|
19
|
-
width:
|
|
20
|
-
height:
|
|
29
|
+
width: width,
|
|
30
|
+
height: height,
|
|
21
31
|
x: x,
|
|
22
32
|
y: y
|
|
23
33
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GeometryAABBUpdater } from './interfaces';
|
|
2
|
-
import type { ParsedEllipseStyleProps } from '../../display-objects/Ellipse';
|
|
2
|
+
import type { Ellipse, ParsedEllipseStyleProps } from '../../display-objects/Ellipse';
|
|
3
3
|
export declare class EllipseUpdater implements GeometryAABBUpdater<ParsedEllipseStyleProps> {
|
|
4
|
-
update(parsedStyle: ParsedEllipseStyleProps): {
|
|
4
|
+
update(parsedStyle: ParsedEllipseStyleProps, object: Ellipse): {
|
|
5
5
|
width: number;
|
|
6
6
|
height: number;
|
|
7
7
|
x: number;
|
|
@@ -8,18 +8,33 @@ var EllipseUpdater =
|
|
|
8
8
|
function () {
|
|
9
9
|
function EllipseUpdater() {}
|
|
10
10
|
|
|
11
|
-
EllipseUpdater.prototype.update = function (parsedStyle) {
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
EllipseUpdater.prototype.update = function (parsedStyle, object) {
|
|
12
|
+
var rx = parsedStyle.rx,
|
|
13
|
+
ry = parsedStyle.ry,
|
|
14
|
+
_a = parsedStyle.x,
|
|
15
|
+
x = _a === void 0 ? 0 : _a,
|
|
16
|
+
_b = parsedStyle.y,
|
|
17
|
+
y = _b === void 0 ? 0 : _b;
|
|
18
|
+
var rxUnit = rx.unit,
|
|
19
|
+
rxValue = rx.value;
|
|
20
|
+
var ryUnit = ry.unit,
|
|
21
|
+
ryValue = ry.value;
|
|
22
|
+
var width = 0;
|
|
23
|
+
var height = 0;
|
|
24
|
+
|
|
25
|
+
if (rxUnit === '' || rxUnit === 'px') {
|
|
26
|
+
width = rxValue * 2;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (ryUnit === '' || ryUnit === 'px') {
|
|
30
|
+
height = ryValue * 2;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
object.parsedStyle.rxInPixels = width / 2;
|
|
34
|
+
object.parsedStyle.ryInPixels = height / 2;
|
|
20
35
|
return {
|
|
21
|
-
width:
|
|
22
|
-
height:
|
|
36
|
+
width: width,
|
|
37
|
+
height: height,
|
|
23
38
|
x: x,
|
|
24
39
|
y: y
|
|
25
40
|
};
|
|
@@ -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;
|
|
@@ -9,32 +9,45 @@ var RectUpdater =
|
|
|
9
9
|
function () {
|
|
10
10
|
function RectUpdater() {}
|
|
11
11
|
|
|
12
|
-
RectUpdater.prototype.update = function (
|
|
13
|
-
var img =
|
|
14
|
-
_a =
|
|
12
|
+
RectUpdater.prototype.update = function (parsedStyle, object) {
|
|
13
|
+
var img = parsedStyle.img,
|
|
14
|
+
_a = parsedStyle.x,
|
|
15
15
|
x = _a === void 0 ? 0 : _a,
|
|
16
|
-
_b =
|
|
16
|
+
_b = parsedStyle.y,
|
|
17
17
|
y = _b === void 0 ? 0 : _b,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
18
|
+
width = parsedStyle.width,
|
|
19
|
+
height = parsedStyle.height;
|
|
20
|
+
var contentWidth = 0;
|
|
21
|
+
var contentHeight = 0;
|
|
22
|
+
var widthUnit = width.unit,
|
|
23
|
+
widthValue = width.value;
|
|
24
|
+
var heightUnit = height.unit,
|
|
25
|
+
heightValue = height.value;
|
|
26
|
+
|
|
27
|
+
if (widthUnit === '' || widthUnit === 'px') {
|
|
28
|
+
contentWidth = widthValue;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (heightUnit === '' || heightUnit === 'px') {
|
|
32
|
+
contentHeight = heightValue;
|
|
33
|
+
} // resize with HTMLImageElement's size
|
|
34
|
+
|
|
24
35
|
|
|
25
36
|
if (img && !isString(img)) {
|
|
26
|
-
if (!
|
|
37
|
+
if (!contentWidth) {
|
|
27
38
|
contentWidth = img.width;
|
|
28
39
|
}
|
|
29
40
|
|
|
30
|
-
if (!
|
|
41
|
+
if (!contentHeight) {
|
|
31
42
|
contentHeight = img.height;
|
|
32
43
|
}
|
|
33
44
|
}
|
|
34
45
|
|
|
46
|
+
object.parsedStyle.widthInPixels = contentWidth;
|
|
47
|
+
object.parsedStyle.heightInPixels = contentHeight;
|
|
35
48
|
return {
|
|
36
|
-
width: contentWidth
|
|
37
|
-
height: contentHeight
|
|
49
|
+
width: contentWidth,
|
|
50
|
+
height: contentHeight,
|
|
38
51
|
x: x,
|
|
39
52
|
y: y
|
|
40
53
|
};
|
|
@@ -47,6 +60,9 @@ function () {
|
|
|
47
60
|
}, {
|
|
48
61
|
token: GeometryAABBUpdater,
|
|
49
62
|
named: SHAPE.Image
|
|
63
|
+
}, {
|
|
64
|
+
token: GeometryAABBUpdater,
|
|
65
|
+
named: SHAPE.Group
|
|
50
66
|
}]
|
|
51
67
|
})], RectUpdater);
|
|
52
68
|
return RectUpdater;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DisplayObject } from '../../display-objects/DisplayObject';
|
|
2
2
|
import type { ParsedBaseStyleProps } from '../../types';
|
|
3
3
|
export declare const GeometryUpdaterFactory = "GeometryUpdaterFactory";
|
|
4
|
-
export declare const GeometryAABBUpdater = "
|
|
4
|
+
export declare const GeometryAABBUpdater = "GeometryAABBUpdater";
|
|
5
5
|
export interface GeometryAABBUpdater<T extends ParsedBaseStyleProps = any> {
|
|
6
6
|
update: (parsedStyle: T, object: DisplayObject) => {
|
|
7
7
|
width: number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export var GeometryUpdaterFactory = 'GeometryUpdaterFactory';
|
|
2
|
-
export var GeometryAABBUpdater = '
|
|
2
|
+
export var GeometryAABBUpdater = 'GeometryAABBUpdater';
|
package/es/shapes/AABB.d.ts
CHANGED
package/es/shapes/AABB.js
CHANGED
|
@@ -14,6 +14,10 @@ function () {
|
|
|
14
14
|
this.update(center, halfExtents);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
AABB.isEmpty = function (aabb) {
|
|
18
|
+
return !aabb || aabb.halfExtents[0] === 0 && aabb.halfExtents[1] === 0 && aabb.halfExtents[2] === 0;
|
|
19
|
+
};
|
|
20
|
+
|
|
17
21
|
AABB.prototype.update = function (center, halfExtents) {
|
|
18
22
|
this.center = vec3.copy(vec3.create(), center || vec3.create());
|
|
19
23
|
this.halfExtents = vec3.copy(vec3.create(), halfExtents || vec3.fromValues(0, 0, 0));
|
|
@@ -39,6 +43,10 @@ function () {
|
|
|
39
43
|
};
|
|
40
44
|
|
|
41
45
|
AABB.prototype.add = function (aabb) {
|
|
46
|
+
if (AABB.isEmpty(aabb)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
42
50
|
var tc = this.center;
|
|
43
51
|
var tcx = tc[0];
|
|
44
52
|
var tcy = tc[1];
|
package/es/types.d.ts
CHANGED
|
@@ -110,7 +110,6 @@ export interface BaseStyleProps {
|
|
|
110
110
|
*/
|
|
111
111
|
lineDash?: number[] | null;
|
|
112
112
|
lineDashOffset?: number;
|
|
113
|
-
padding?: number[] | number;
|
|
114
113
|
/**
|
|
115
114
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/shadowBlur
|
|
116
115
|
*/
|
|
@@ -135,8 +134,6 @@ export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'fill' | 'str
|
|
|
135
134
|
points?: ParsedPolylineStyleProps;
|
|
136
135
|
x?: number;
|
|
137
136
|
y?: number;
|
|
138
|
-
width?: number;
|
|
139
|
-
height?: number;
|
|
140
137
|
/**
|
|
141
138
|
* x according to definition, eg. Line's x1/x2, Polyline's points
|
|
142
139
|
*/
|
package/es/utils/path.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare function getDrawDirection(pathArray: PathCommand[]): boolean;
|
|
|
5
5
|
export declare function getPathArea(pathArray: PathCommand[]): number;
|
|
6
6
|
export declare function reverseCurve(pathArray: PathCommand[]): PathCommand[];
|
|
7
7
|
export declare function clonePath(pathArray: PathCommand[]): PathCommand[];
|
|
8
|
-
export declare function getRotatedCurve(a: PathCommand[], b: PathCommand[]): (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] | ["
|
|
8
|
+
export declare function getRotatedCurve(a: PathCommand[], b: PathCommand[]): (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])[];
|
|
9
9
|
/**
|
|
10
10
|
* convert object to path, should account for:
|
|
11
11
|
* * transform & origin
|
package/es/utils/path.js
CHANGED
|
@@ -290,7 +290,7 @@ export function convertToPath(object) {
|
|
|
290
290
|
case SHAPE.Circle:
|
|
291
291
|
{
|
|
292
292
|
var _b = object.parsedStyle,
|
|
293
|
-
r = _b.
|
|
293
|
+
r = _b.rInPixels,
|
|
294
294
|
_c = _b.x,
|
|
295
295
|
x_1 = _c === void 0 ? 0 : _c,
|
|
296
296
|
_d = _b.y,
|
|
@@ -302,8 +302,8 @@ export function convertToPath(object) {
|
|
|
302
302
|
case SHAPE.Ellipse:
|
|
303
303
|
{
|
|
304
304
|
var _e = object.parsedStyle,
|
|
305
|
-
rx = _e.
|
|
306
|
-
ry = _e.
|
|
305
|
+
rx = _e.rxInPixels,
|
|
306
|
+
ry = _e.ryInPixels,
|
|
307
307
|
_f = _e.x,
|
|
308
308
|
x_2 = _f === void 0 ? 0 : _f,
|
|
309
309
|
_g = _e.y,
|
|
@@ -320,8 +320,8 @@ export function convertToPath(object) {
|
|
|
320
320
|
|
|
321
321
|
case SHAPE.Rect:
|
|
322
322
|
var _h = object.parsedStyle,
|
|
323
|
-
width = _h.
|
|
324
|
-
height = _h.
|
|
323
|
+
width = _h.widthInPixels,
|
|
324
|
+
height = _h.heightInPixels,
|
|
325
325
|
x = _h.x,
|
|
326
326
|
y = _h.y,
|
|
327
327
|
radius = _h.radius;
|
package/lib/Canvas.js
CHANGED
package/lib/canvas-module.js
CHANGED
|
@@ -19,22 +19,15 @@ var _services = require("./services");
|
|
|
19
19
|
|
|
20
20
|
var _EventPlugin = require("./plugins/EventPlugin");
|
|
21
21
|
|
|
22
|
-
var containerModule = (0, _manaSyringe.Module)(function (register
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}); // culling plugin
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
_manaSyringe.Contribution.register(register, _CullingPlugin.CullingStrategyContribution, {
|
|
35
|
-
cache: false
|
|
36
|
-
});
|
|
37
|
-
} // register built-in rendering plugins
|
|
22
|
+
var containerModule = (0, _manaSyringe.Module)(function (register) {
|
|
23
|
+
_manaSyringe.Contribution.register(register, _services.RenderingPluginContribution, {
|
|
24
|
+
cache: false
|
|
25
|
+
}); // culling plugin
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
_manaSyringe.Contribution.register(register, _CullingPlugin.CullingStrategyContribution, {
|
|
29
|
+
cache: false
|
|
30
|
+
}); // register built-in rendering plugins
|
|
38
31
|
|
|
39
32
|
|
|
40
33
|
register(_services.RenderingService);
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { DisplayObjectConfig } from '../dom/interfaces';
|
|
2
2
|
import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
3
3
|
import { DisplayObject } from './DisplayObject';
|
|
4
|
+
import type { ParsedElement } from '../property-handlers';
|
|
4
5
|
export interface CircleStyleProps extends BaseStyleProps {
|
|
5
6
|
r: number;
|
|
6
7
|
}
|
|
7
8
|
export interface ParsedCircleStyleProps extends ParsedBaseStyleProps {
|
|
8
|
-
r:
|
|
9
|
+
r: ParsedElement;
|
|
10
|
+
rInPixels: number;
|
|
9
11
|
}
|
|
10
12
|
export declare class Circle extends DisplayObject<CircleStyleProps, ParsedCircleStyleProps> {
|
|
11
13
|
constructor({ style, ...rest }: DisplayObjectConfig<CircleStyleProps>);
|
|
@@ -247,7 +247,9 @@ function (_super) {
|
|
|
247
247
|
|
|
248
248
|
this.parseStyleProperty(name, value); // @ts-ignore
|
|
249
249
|
|
|
250
|
-
|
|
250
|
+
var newParsedValue = this.parsedStyle[name]; // @ts-ignore
|
|
251
|
+
|
|
252
|
+
this.updateStyleProperty(name, oldParsedValue, newParsedValue); // inform clip path targets
|
|
251
253
|
|
|
252
254
|
if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
|
|
253
255
|
this.attributes.clipPathTargets.forEach(function (target) {
|
|
@@ -265,7 +267,9 @@ function (_super) {
|
|
|
265
267
|
this.emit(_interfaces.ElementEvent.ATTRIBUTE_CHANGED, {
|
|
266
268
|
attributeName: name,
|
|
267
269
|
oldValue: oldValue,
|
|
268
|
-
newValue: value
|
|
270
|
+
newValue: value,
|
|
271
|
+
oldParsedValue: oldParsedValue,
|
|
272
|
+
newParsedValue: newParsedValue
|
|
269
273
|
});
|
|
270
274
|
}; // #region transformable
|
|
271
275
|
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import type { DisplayObjectConfig } from '../dom/interfaces';
|
|
2
2
|
import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
3
3
|
import { DisplayObject } from './DisplayObject';
|
|
4
|
+
import type { ParsedElement } from '../property-handlers';
|
|
4
5
|
export interface EllipseStyleProps extends BaseStyleProps {
|
|
5
6
|
rx: number;
|
|
6
7
|
ry: number;
|
|
7
8
|
}
|
|
8
9
|
export interface ParsedEllipseStyleProps extends ParsedBaseStyleProps {
|
|
9
|
-
rx:
|
|
10
|
-
ry:
|
|
10
|
+
rx: ParsedElement;
|
|
11
|
+
ry: ParsedElement;
|
|
12
|
+
rxInPixels: number;
|
|
13
|
+
ryInPixels: number;
|
|
11
14
|
}
|
|
12
15
|
export declare class Ellipse extends DisplayObject<EllipseStyleProps, ParsedEllipseStyleProps> {
|
|
13
16
|
constructor({ style, ...rest }: DisplayObjectConfig<EllipseStyleProps>);
|
|
@@ -25,7 +25,10 @@ function (_super) {
|
|
|
25
25
|
|
|
26
26
|
_this = _super.call(this, (0, _tslib.__assign)({
|
|
27
27
|
type: _types.SHAPE.Group,
|
|
28
|
-
style: (0, _tslib.__assign)({
|
|
28
|
+
style: (0, _tslib.__assign)({
|
|
29
|
+
width: 'auto',
|
|
30
|
+
height: 'auto'
|
|
31
|
+
}, style)
|
|
29
32
|
}, rest)) || this;
|
|
30
33
|
return _this;
|
|
31
34
|
}
|
|
@@ -2,14 +2,19 @@ import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
|
2
2
|
import { DisplayObject } from './DisplayObject';
|
|
3
3
|
import type { DisplayObjectConfig } from '../dom';
|
|
4
4
|
import { AABB } from '../shapes';
|
|
5
|
+
import type { ParsedElement } from '../property-handlers';
|
|
5
6
|
export interface HTMLStyleProps extends BaseStyleProps {
|
|
6
7
|
innerHTML: string | HTMLElement;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
7
10
|
className?: string | string[];
|
|
8
11
|
style?: string;
|
|
9
12
|
}
|
|
10
13
|
export interface ParsedHTMLStyleProps extends ParsedBaseStyleProps {
|
|
11
14
|
$el: HTMLElement;
|
|
12
15
|
innerHTML: string | HTMLElement;
|
|
16
|
+
width: ParsedElement;
|
|
17
|
+
height: ParsedElement;
|
|
13
18
|
className?: string | string[];
|
|
14
19
|
style?: string;
|
|
15
20
|
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
2
2
|
import { DisplayObject } from './DisplayObject';
|
|
3
3
|
import type { DisplayObjectConfig } from '../dom';
|
|
4
|
+
import type { ParsedElement } from '../property-handlers';
|
|
4
5
|
export interface ImageStyleProps extends BaseStyleProps {
|
|
5
6
|
img: string | HTMLImageElement;
|
|
6
|
-
width?: number;
|
|
7
|
-
height?: number;
|
|
7
|
+
width?: number | string;
|
|
8
|
+
height?: number | string;
|
|
8
9
|
}
|
|
9
10
|
export interface ParsedImageStyleProps extends ParsedBaseStyleProps {
|
|
10
11
|
img: string | HTMLImageElement;
|
|
11
|
-
width?:
|
|
12
|
-
height?:
|
|
12
|
+
width?: ParsedElement;
|
|
13
|
+
height?: ParsedElement;
|
|
14
|
+
widthInPixels?: number;
|
|
15
|
+
heightInPixels?: number;
|
|
13
16
|
}
|
|
14
17
|
export declare class Image extends DisplayObject<ImageStyleProps, ParsedImageStyleProps> {
|
|
15
18
|
constructor({ style, ...rest }: DisplayObjectConfig<ImageStyleProps>);
|