@antv/g 5.0.24 → 5.1.0
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/CSSProperty.d.ts +2 -1
- package/es/css/StyleValueRegistry.d.ts +2 -1
- package/es/css/StyleValueRegistry.js +68 -72
- 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/CSSPropertyLocalPosition.d.ts +0 -9
- package/es/css/properties/CSSPropertyLocalPosition.js +64 -20
- package/es/css/properties/CSSPropertyPath.d.ts +2 -2
- package/es/css/properties/CSSPropertyPath.js +7 -5
- package/es/css/properties/CSSPropertyPoints.js +3 -4
- package/es/css/properties/CSSPropertyTransform.d.ts +1 -1
- package/es/css/properties/CSSPropertyTransform.js +76 -104
- package/es/display-objects/Circle.d.ts +4 -0
- package/es/display-objects/Circle.js +2 -0
- 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/Path.d.ts +2 -2
- package/es/display-objects/Polygon.js +1 -1
- package/es/display-objects/Polyline.js +1 -1
- package/es/display-objects/Rect.d.ts +6 -2
- package/es/display-objects/Rect.js +2 -0
- package/es/display-objects/Text.d.ts +4 -0
- package/es/display-objects/Text.js +2 -0
- package/es/dom/Element.js +1 -0
- 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 +2 -8
- package/es/utils/math.js +4 -3
- package/es/utils/path.d.ts +2 -2
- package/es/utils/path.js +61 -24
- package/lib/Canvas.js +2 -0
- package/lib/css/CSSProperty.d.ts +2 -1
- package/lib/css/StyleValueRegistry.d.ts +2 -1
- package/lib/css/StyleValueRegistry.js +67 -71
- 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/CSSPropertyLocalPosition.d.ts +0 -9
- package/lib/css/properties/CSSPropertyLocalPosition.js +65 -20
- package/lib/css/properties/CSSPropertyPath.d.ts +2 -2
- package/lib/css/properties/CSSPropertyPath.js +7 -5
- package/lib/css/properties/CSSPropertyPoints.js +3 -4
- package/lib/css/properties/CSSPropertyTransform.d.ts +1 -1
- package/lib/css/properties/CSSPropertyTransform.js +75 -103
- package/lib/display-objects/Circle.d.ts +4 -0
- package/lib/display-objects/Circle.js +2 -0
- 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/Path.d.ts +2 -2
- package/lib/display-objects/Polygon.js +1 -1
- package/lib/display-objects/Polyline.js +1 -1
- package/lib/display-objects/Rect.d.ts +6 -2
- package/lib/display-objects/Rect.js +2 -0
- package/lib/display-objects/Text.d.ts +4 -0
- package/lib/display-objects/Text.js +2 -0
- package/lib/dom/Element.js +1 -0
- 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 +2 -8
- package/lib/utils/math.js +4 -3
- package/lib/utils/path.d.ts +2 -2
- package/lib/utils/path.js +55 -24
- package/package.json +3 -3
|
@@ -37,7 +37,8 @@ var PropertySyntax = {
|
|
|
37
37
|
NUMBER: '<number>',
|
|
38
38
|
LENGTH: '<length>',
|
|
39
39
|
PERCENTAGE: '<percentage>',
|
|
40
|
-
LENGTH_PERCENTAGE: '<length> | <percentage>'
|
|
40
|
+
LENGTH_PERCENTAGE: '<length> | <percentage>',
|
|
41
|
+
LIST_OF_POINTS: '<list-of-points>'
|
|
41
42
|
};
|
|
42
43
|
/**
|
|
43
44
|
* Blink used them in code generation(css_properties.json5)
|
|
@@ -51,29 +52,6 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
51
52
|
*/
|
|
52
53
|
name: 'display',
|
|
53
54
|
keywords: ['none']
|
|
54
|
-
}, {
|
|
55
|
-
// x in local space
|
|
56
|
-
name: 'x',
|
|
57
|
-
interpolable: true,
|
|
58
|
-
alias: ['cx'],
|
|
59
|
-
defaultValue: '0',
|
|
60
|
-
syntax: PropertySyntax.LENGTH_PERCENTAGE,
|
|
61
|
-
handler: _properties.CSSPropertyLocalPosition
|
|
62
|
-
}, {
|
|
63
|
-
// y in local space
|
|
64
|
-
name: 'y',
|
|
65
|
-
interpolable: true,
|
|
66
|
-
alias: ['cy'],
|
|
67
|
-
defaultValue: '0',
|
|
68
|
-
syntax: PropertySyntax.LENGTH_PERCENTAGE,
|
|
69
|
-
handler: _properties.CSSPropertyLocalPosition
|
|
70
|
-
}, {
|
|
71
|
-
// z in local space
|
|
72
|
-
name: 'z',
|
|
73
|
-
interpolable: true,
|
|
74
|
-
defaultValue: '0',
|
|
75
|
-
syntax: PropertySyntax.LENGTH_PERCENTAGE,
|
|
76
|
-
handler: _properties.CSSPropertyLocalPosition
|
|
77
55
|
}, {
|
|
78
56
|
/**
|
|
79
57
|
* range [0.0, 1.0]
|
|
@@ -246,6 +224,7 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
246
224
|
handler: _properties.CSSPropertyClipPath
|
|
247
225
|
}, {
|
|
248
226
|
name: 'transform',
|
|
227
|
+
parsePriority: 100,
|
|
249
228
|
interpolable: true,
|
|
250
229
|
keywords: ['none'],
|
|
251
230
|
defaultValue: 'none',
|
|
@@ -262,8 +241,20 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
262
241
|
parsePriority: 99,
|
|
263
242
|
layoutDependent: true,
|
|
264
243
|
handler: _properties.CSSPropertyAnchor
|
|
265
|
-
}, //
|
|
244
|
+
}, // <circle> & <ellipse>
|
|
266
245
|
{
|
|
246
|
+
name: 'cx',
|
|
247
|
+
interpolable: true,
|
|
248
|
+
defaultValue: '0',
|
|
249
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE,
|
|
250
|
+
handler: _properties.CSSPropertyLocalPosition
|
|
251
|
+
}, {
|
|
252
|
+
name: 'cy',
|
|
253
|
+
interpolable: true,
|
|
254
|
+
defaultValue: '0',
|
|
255
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE,
|
|
256
|
+
handler: _properties.CSSPropertyLocalPosition
|
|
257
|
+
}, {
|
|
267
258
|
name: 'r',
|
|
268
259
|
interpolable: true,
|
|
269
260
|
layoutDependent: true,
|
|
@@ -281,8 +272,29 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
281
272
|
layoutDependent: true,
|
|
282
273
|
defaultValue: 'auto',
|
|
283
274
|
handler: _properties.CSSPropertyLengthOrPercentage
|
|
284
|
-
}, // Rect Image
|
|
275
|
+
}, // Rect Image Group
|
|
285
276
|
{
|
|
277
|
+
// x in local space
|
|
278
|
+
name: 'x',
|
|
279
|
+
interpolable: true,
|
|
280
|
+
defaultValue: '0',
|
|
281
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE,
|
|
282
|
+
handler: _properties.CSSPropertyLocalPosition
|
|
283
|
+
}, {
|
|
284
|
+
// y in local space
|
|
285
|
+
name: 'y',
|
|
286
|
+
interpolable: true,
|
|
287
|
+
defaultValue: '0',
|
|
288
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE,
|
|
289
|
+
handler: _properties.CSSPropertyLocalPosition
|
|
290
|
+
}, {
|
|
291
|
+
// z in local space
|
|
292
|
+
name: 'z',
|
|
293
|
+
interpolable: true,
|
|
294
|
+
defaultValue: '0',
|
|
295
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE,
|
|
296
|
+
handler: _properties.CSSPropertyLocalPosition
|
|
297
|
+
}, {
|
|
286
298
|
name: 'width',
|
|
287
299
|
interpolable: true,
|
|
288
300
|
layoutDependent: true,
|
|
@@ -347,11 +359,13 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
347
359
|
interpolable: true,
|
|
348
360
|
layoutDependent: true,
|
|
349
361
|
defaultValue: '',
|
|
362
|
+
alias: ['d'],
|
|
350
363
|
handler: _properties.CSSPropertyPath
|
|
351
|
-
}, // Polyline
|
|
364
|
+
}, // Polyline & Polygon
|
|
352
365
|
{
|
|
353
366
|
name: 'points',
|
|
354
367
|
layoutDependent: true,
|
|
368
|
+
syntax: PropertySyntax.LIST_OF_POINTS,
|
|
355
369
|
handler: _properties.CSSPropertyPoints
|
|
356
370
|
}, // Text
|
|
357
371
|
{
|
|
@@ -548,7 +562,7 @@ function () {
|
|
|
548
562
|
|
|
549
563
|
if (!skipParse) {
|
|
550
564
|
sortedNames.forEach(function (name) {
|
|
551
|
-
object.computedStyle[name] = _this.parseProperty(name, object.attributes[name]);
|
|
565
|
+
object.computedStyle[name] = _this.parseProperty(name, object.attributes[name], object);
|
|
552
566
|
});
|
|
553
567
|
}
|
|
554
568
|
|
|
@@ -592,11 +606,11 @@ function () {
|
|
|
592
606
|
*/
|
|
593
607
|
|
|
594
608
|
|
|
595
|
-
DefaultStyleValueRegistry.prototype.parseProperty = function (name, value) {
|
|
609
|
+
DefaultStyleValueRegistry.prototype.parseProperty = function (name, value, object) {
|
|
596
610
|
var metadata = this.getMetadata(name);
|
|
597
611
|
var computed = value;
|
|
598
612
|
|
|
599
|
-
if (value === '') {
|
|
613
|
+
if (value === '' || (0, _utils.isNil)(value)) {
|
|
600
614
|
value = 'unset';
|
|
601
615
|
}
|
|
602
616
|
|
|
@@ -615,7 +629,7 @@ function () {
|
|
|
615
629
|
|
|
616
630
|
if (propertyHandler && propertyHandler.parser) {
|
|
617
631
|
// try to parse it to CSSStyleValue, eg. '10px' -> CSS.px(10)
|
|
618
|
-
computed = propertyHandler.parser(value);
|
|
632
|
+
computed = propertyHandler.parser(value, object);
|
|
619
633
|
}
|
|
620
634
|
}
|
|
621
635
|
}
|
|
@@ -654,8 +668,8 @@ function () {
|
|
|
654
668
|
|
|
655
669
|
if (value === 'initial') {
|
|
656
670
|
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/initial
|
|
657
|
-
if (defaultValue) {
|
|
658
|
-
computed = this.parseProperty(name, defaultValue);
|
|
671
|
+
if (!(0, _utils.isNil)(defaultValue)) {
|
|
672
|
+
computed = this.parseProperty(name, defaultValue, object);
|
|
659
673
|
}
|
|
660
674
|
} else if (value === 'inherit') {
|
|
661
675
|
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit
|
|
@@ -794,42 +808,24 @@ function () {
|
|
|
794
808
|
height = _b.height,
|
|
795
809
|
_c = _b.depth,
|
|
796
810
|
depth = _c === void 0 ? 0 : _c,
|
|
797
|
-
_d = _b.
|
|
798
|
-
|
|
799
|
-
_e = _b.
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
// z = 0,
|
|
804
|
-
offsetX = _f === void 0 ? 0 : _f,
|
|
805
|
-
_g = _b.offsetY,
|
|
806
|
-
offsetY = _g === void 0 ? 0 : _g,
|
|
807
|
-
_h = _b.offsetZ,
|
|
808
|
-
offsetZ = _h === void 0 ? 0 : _h;
|
|
809
|
-
|
|
810
|
-
if (object.nodeName === _types.Shape.LINE || object.nodeName === _types.Shape.POLYLINE || object.nodeName === _types.Shape.POLYGON || object.nodeName === _types.Shape.PATH) {
|
|
811
|
-
parsedStyle.offsetX = x - (parsedStyle.defX || 0);
|
|
812
|
-
parsedStyle.offsetY = y - (parsedStyle.defY || 0);
|
|
813
|
-
parsedStyle.defX = x;
|
|
814
|
-
parsedStyle.defY = y; // modify x/y/z
|
|
815
|
-
|
|
816
|
-
object.attributes.x += parsedStyle.offsetX;
|
|
817
|
-
object.attributes.y += parsedStyle.offsetY;
|
|
818
|
-
parsedStyle.x = parsedStyle.x.add(new _cssom.CSSUnitValue(parsedStyle.offsetX, 'px'));
|
|
819
|
-
parsedStyle.y = parsedStyle.y.add(new _cssom.CSSUnitValue(parsedStyle.offsetY, 'px'));
|
|
820
|
-
} // init with content box
|
|
811
|
+
_d = _b.offsetX,
|
|
812
|
+
offsetX = _d === void 0 ? 0 : _d,
|
|
813
|
+
_e = _b.offsetY,
|
|
814
|
+
offsetY = _e === void 0 ? 0 : _e,
|
|
815
|
+
_f = _b.offsetZ,
|
|
816
|
+
offsetZ = _f === void 0 ? 0 : _f; // init with content box
|
|
821
817
|
|
|
822
818
|
|
|
823
819
|
var halfExtents = _glMatrix.vec3.fromValues(width / 2, height / 2, depth / 2); // anchor is center by default, don't account for lineWidth here
|
|
824
820
|
|
|
825
821
|
|
|
826
|
-
var
|
|
827
|
-
lineWidth =
|
|
828
|
-
increasedLineWidthForHitTesting =
|
|
829
|
-
shadowColor =
|
|
830
|
-
|
|
831
|
-
filter =
|
|
832
|
-
transformOrigin =
|
|
822
|
+
var _g = parsedStyle,
|
|
823
|
+
lineWidth = _g.lineWidth,
|
|
824
|
+
increasedLineWidthForHitTesting = _g.increasedLineWidthForHitTesting,
|
|
825
|
+
shadowColor = _g.shadowColor,
|
|
826
|
+
_h = _g.filter,
|
|
827
|
+
filter = _h === void 0 ? [] : _h,
|
|
828
|
+
transformOrigin = _g.transformOrigin;
|
|
833
829
|
var anchor = parsedStyle.anchor; // <Text> use textAlign & textBaseline instead of anchor
|
|
834
830
|
|
|
835
831
|
if (object.nodeName === _types.Shape.TEXT) {
|
|
@@ -847,13 +843,13 @@ function () {
|
|
|
847
843
|
geometry_1.renderBounds.update(center, halfExtents); // account for shadow, only support constant value now
|
|
848
844
|
|
|
849
845
|
if (shadowColor) {
|
|
850
|
-
var
|
|
851
|
-
min =
|
|
852
|
-
max =
|
|
853
|
-
var
|
|
854
|
-
shadowBlur =
|
|
855
|
-
shadowOffsetX =
|
|
856
|
-
shadowOffsetY =
|
|
846
|
+
var _j = geometry_1.renderBounds,
|
|
847
|
+
min = _j.min,
|
|
848
|
+
max = _j.max;
|
|
849
|
+
var _k = parsedStyle,
|
|
850
|
+
shadowBlur = _k.shadowBlur,
|
|
851
|
+
shadowOffsetX = _k.shadowOffsetX,
|
|
852
|
+
shadowOffsetY = _k.shadowOffsetY;
|
|
857
853
|
var shadowBlurInPixels = shadowBlur && shadowBlur.value || 0;
|
|
858
854
|
var shadowOffsetXInPixels = shadowOffsetX && shadowOffsetX.value || 0;
|
|
859
855
|
var shadowOffsetYInPixels = shadowOffsetY && shadowOffsetY.value || 0;
|
|
@@ -2,5 +2,5 @@ import { CSSRGB, CSSGradientValue } from '../cssom';
|
|
|
2
2
|
/**
|
|
3
3
|
* @see https://github.com/WebKit/WebKit/blob/main/Source/WebCore/css/parser/CSSParser.cpp#L97
|
|
4
4
|
*/
|
|
5
|
-
export declare function parseColor(colorStr
|
|
5
|
+
export declare function parseColor(colorStr: string): CSSRGB | CSSGradientValue;
|
|
6
6
|
export declare function mergeColors(left: CSSRGB | CSSGradientValue, right: CSSRGB | CSSGradientValue): [number[], number[], (color: number[]) => string] | undefined;
|
package/lib/css/parser/color.js
CHANGED
|
@@ -19,6 +19,10 @@ var _utils = require("../../utils");
|
|
|
19
19
|
var _cssom = require("../cssom");
|
|
20
20
|
|
|
21
21
|
function parseDimension(unitRegExp, string) {
|
|
22
|
+
if ((0, _utils.isNil)(string)) {
|
|
23
|
+
return new _cssom.CSSUnitValue(0, 'px');
|
|
24
|
+
}
|
|
25
|
+
|
|
22
26
|
string = "".concat(string).trim().toLowerCase();
|
|
23
27
|
|
|
24
28
|
if (isFinite(Number(string))) {
|
package/lib/css/parser/path.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PathCommand } from '../../types';
|
|
2
|
-
import type { ParsedPathStyleProps } from '../../display-objects';
|
|
2
|
+
import type { ParsedPathStyleProps, DisplayObject } from '../../display-objects';
|
|
3
3
|
import type { IElement } from '../../dom';
|
|
4
|
-
export declare function parsePath(path: string): ParsedPathStyleProps['path'];
|
|
4
|
+
export declare function parsePath(path: string, object: DisplayObject): ParsedPathStyleProps['path'];
|
|
5
5
|
export declare function mergePaths(left: ParsedPathStyleProps['path'], right: ParsedPathStyleProps['path'], object: IElement): [PathCommand[], PathCommand[], (b: PathCommand[]) => PathCommand[]];
|
package/lib/css/parser/path.js
CHANGED
|
@@ -16,7 +16,7 @@ var _path = require("../../utils/path");
|
|
|
16
16
|
|
|
17
17
|
var _Rectangle = require("../../shapes/Rectangle");
|
|
18
18
|
|
|
19
|
-
function parsePath(path) {
|
|
19
|
+
function parsePath(path, object) {
|
|
20
20
|
var absolutePath = (0, _util.path2Absolute)(path);
|
|
21
21
|
var hasArc = hasArcOrBezier(absolutePath);
|
|
22
22
|
var clonedAbsolutePath = absolutePath.slice();
|
|
@@ -37,6 +37,13 @@ function parsePath(path) {
|
|
|
37
37
|
totalLength = _c.totalLength,
|
|
38
38
|
curveSegments = _c.curveSegments;
|
|
39
39
|
|
|
40
|
+
var rect = getPathBBox(curve);
|
|
41
|
+
|
|
42
|
+
if (object) {
|
|
43
|
+
object.parsedStyle.defX = rect.x;
|
|
44
|
+
object.parsedStyle.defY = rect.y;
|
|
45
|
+
}
|
|
46
|
+
|
|
40
47
|
return {
|
|
41
48
|
absolutePath: absolutePath,
|
|
42
49
|
hasArc: hasArc,
|
|
@@ -47,7 +54,7 @@ function parsePath(path) {
|
|
|
47
54
|
totalLength: totalLength,
|
|
48
55
|
curveSegments: curveSegments,
|
|
49
56
|
zCommandIndexes: zCommandIndexes,
|
|
50
|
-
rect:
|
|
57
|
+
rect: rect
|
|
51
58
|
};
|
|
52
59
|
}
|
|
53
60
|
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DisplayObject } from '../..';
|
|
2
|
+
/**
|
|
3
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/points
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* points="100,10 250,150 200,110"
|
|
7
|
+
*/
|
|
8
|
+
export declare function parsePoints(pointsOrStr: string | [number, number][], object: DisplayObject): {
|
|
2
9
|
points: [number, number][];
|
|
3
10
|
totalLength: number;
|
|
4
11
|
segments: [number, number][];
|
package/lib/css/parser/points.js
CHANGED
|
@@ -5,13 +5,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.parsePoints = parsePoints;
|
|
7
7
|
|
|
8
|
+
var _tslib = require("tslib");
|
|
9
|
+
|
|
8
10
|
var _gMath = require("@antv/g-math");
|
|
9
11
|
|
|
10
12
|
var _utils = require("../../utils");
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/points
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* points="100,10 250,150 200,110"
|
|
19
|
+
*/
|
|
20
|
+
function parsePoints(pointsOrStr, object) {
|
|
21
|
+
var points;
|
|
22
|
+
|
|
23
|
+
if ((0, _utils.isString)(pointsOrStr)) {
|
|
24
|
+
points = pointsOrStr.split(' ').map(function (pointStr) {
|
|
25
|
+
var _a = (0, _tslib.__read)(pointStr.split(','), 2),
|
|
26
|
+
x = _a[0],
|
|
27
|
+
y = _a[1];
|
|
28
|
+
|
|
29
|
+
return [Number(x), Number(y)];
|
|
30
|
+
});
|
|
31
|
+
} else {
|
|
32
|
+
points = pointsOrStr;
|
|
15
33
|
}
|
|
16
34
|
|
|
17
35
|
var segments = [];
|
|
@@ -31,6 +49,18 @@ function parsePoints(points) {
|
|
|
31
49
|
segments.push(segmentT);
|
|
32
50
|
}
|
|
33
51
|
});
|
|
52
|
+
var minX = Math.min.apply(Math, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(points.map(function (point) {
|
|
53
|
+
return point[0];
|
|
54
|
+
})), false));
|
|
55
|
+
var minY = Math.min.apply(Math, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(points.map(function (point) {
|
|
56
|
+
return point[1];
|
|
57
|
+
})), false));
|
|
58
|
+
|
|
59
|
+
if (object) {
|
|
60
|
+
object.parsedStyle.defX = minX;
|
|
61
|
+
object.parsedStyle.defY = minY;
|
|
62
|
+
}
|
|
63
|
+
|
|
34
64
|
return {
|
|
35
65
|
points: points,
|
|
36
66
|
totalLength: totalLength,
|
|
@@ -11,6 +11,8 @@ var _manaSyringe = require("mana-syringe");
|
|
|
11
11
|
|
|
12
12
|
var _services = require("../../services");
|
|
13
13
|
|
|
14
|
+
var _cssom = require("../cssom");
|
|
15
|
+
|
|
14
16
|
/**
|
|
15
17
|
* @see /zh/docs/api/basic/display-object#clippath
|
|
16
18
|
* @example
|
|
@@ -34,7 +36,12 @@ function () {
|
|
|
34
36
|
function CSSPropertyClipPath() {}
|
|
35
37
|
|
|
36
38
|
CSSPropertyClipPath.prototype.calculator = function (name, oldClipPath, newClipPath, object) {
|
|
37
|
-
//
|
|
39
|
+
// unset
|
|
40
|
+
if (newClipPath instanceof _cssom.CSSKeywordValue) {
|
|
41
|
+
newClipPath = null;
|
|
42
|
+
} // clear ref to old clip path
|
|
43
|
+
|
|
44
|
+
|
|
38
45
|
if (oldClipPath && oldClipPath !== newClipPath && oldClipPath.style.clipPathTargets) {
|
|
39
46
|
var index = oldClipPath.style.clipPathTargets.indexOf(object);
|
|
40
47
|
oldClipPath.style.clipPathTargets.splice(index, 1);
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
import type { DisplayObject } from '../../display-objects';
|
|
2
2
|
import type { CSSProperty } from '../CSSProperty';
|
|
3
3
|
import type { CSSUnitValue } from '../cssom';
|
|
4
|
-
import { mergeDimensions } from '../parser';
|
|
5
4
|
import { CSSPropertyLengthOrPercentage } from './CSSPropertyLengthOrPercentage';
|
|
6
5
|
/**
|
|
7
6
|
* local position
|
|
8
7
|
*/
|
|
9
8
|
export declare class CSSPropertyLocalPosition extends CSSPropertyLengthOrPercentage implements Partial<CSSProperty<CSSUnitValue, CSSUnitValue>> {
|
|
10
|
-
/**
|
|
11
|
-
* <length> & <percentage>
|
|
12
|
-
*/
|
|
13
|
-
parser: (css: string) => CSSUnitValue;
|
|
14
|
-
/**
|
|
15
|
-
* mix between CSS.px(x)
|
|
16
|
-
*/
|
|
17
|
-
mixer: typeof mergeDimensions;
|
|
18
9
|
/**
|
|
19
10
|
* update local position
|
|
20
11
|
*/
|
|
@@ -9,10 +9,12 @@ var _tslib = require("tslib");
|
|
|
9
9
|
|
|
10
10
|
var _manaSyringe = require("mana-syringe");
|
|
11
11
|
|
|
12
|
-
var _parser = require("../parser");
|
|
13
|
-
|
|
14
12
|
var _CSSPropertyLengthOrPercentage = require("./CSSPropertyLengthOrPercentage");
|
|
15
13
|
|
|
14
|
+
var _utils = require("../../utils");
|
|
15
|
+
|
|
16
|
+
var _types = require("../../types");
|
|
17
|
+
|
|
16
18
|
/**
|
|
17
19
|
* local position
|
|
18
20
|
*/
|
|
@@ -22,19 +24,7 @@ function (_super) {
|
|
|
22
24
|
(0, _tslib.__extends)(CSSPropertyLocalPosition, _super);
|
|
23
25
|
|
|
24
26
|
function CSSPropertyLocalPosition() {
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* <length> & <percentage>
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
_this.parser = _parser.parseLengthOrPercentage;
|
|
32
|
-
/**
|
|
33
|
-
* mix between CSS.px(x)
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
_this.mixer = _parser.mergeDimensions;
|
|
37
|
-
return _this;
|
|
27
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
38
28
|
}
|
|
39
29
|
/**
|
|
40
30
|
* update local position
|
|
@@ -42,11 +32,66 @@ function (_super) {
|
|
|
42
32
|
|
|
43
33
|
|
|
44
34
|
CSSPropertyLocalPosition.prototype.postProcessor = function (object) {
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
object.
|
|
35
|
+
var x;
|
|
36
|
+
var y;
|
|
37
|
+
var z;
|
|
38
|
+
|
|
39
|
+
switch (object.nodeName) {
|
|
40
|
+
case _types.Shape.CIRCLE:
|
|
41
|
+
case _types.Shape.ELLIPSE:
|
|
42
|
+
var _a = object.parsedStyle,
|
|
43
|
+
cx = _a.cx,
|
|
44
|
+
cy = _a.cy;
|
|
45
|
+
|
|
46
|
+
if (!(0, _utils.isNil)(cx)) {
|
|
47
|
+
x = cx.value;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!(0, _utils.isNil)(cy)) {
|
|
51
|
+
y = cy.value;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
break;
|
|
55
|
+
|
|
56
|
+
case _types.Shape.RECT:
|
|
57
|
+
case _types.Shape.GROUP:
|
|
58
|
+
case _types.Shape.IMAGE:
|
|
59
|
+
case _types.Shape.HTML:
|
|
60
|
+
case _types.Shape.TEXT:
|
|
61
|
+
case _types.Shape.MESH:
|
|
62
|
+
if (!(0, _utils.isNil)(object.parsedStyle.x)) {
|
|
63
|
+
x = object.parsedStyle.x.value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!(0, _utils.isNil)(object.parsedStyle.y)) {
|
|
67
|
+
y = object.parsedStyle.y.value;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
break;
|
|
71
|
+
|
|
72
|
+
case _types.Shape.LINE:
|
|
73
|
+
var _b = object.parsedStyle,
|
|
74
|
+
x1 = _b.x1,
|
|
75
|
+
x2 = _b.x2,
|
|
76
|
+
y1 = _b.y1,
|
|
77
|
+
y2 = _b.y2;
|
|
78
|
+
var minX = Math.min(x1.value, x2.value);
|
|
79
|
+
var minY = Math.min(y1.value, y2.value);
|
|
80
|
+
x = minX;
|
|
81
|
+
y = minY;
|
|
82
|
+
z = 0;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
object.parsedStyle.defX = x || 0;
|
|
87
|
+
object.parsedStyle.defY = y || 0;
|
|
88
|
+
|
|
89
|
+
var _c = (0, _tslib.__read)(object.getLocalPosition(), 3),
|
|
90
|
+
ox = _c[0],
|
|
91
|
+
oy = _c[1],
|
|
92
|
+
oz = _c[2];
|
|
93
|
+
|
|
94
|
+
object.setLocalPosition((0, _utils.isNil)(x) ? ox : x, (0, _utils.isNil)(y) ? oy : y, (0, _utils.isNil)(z) ? oz : z);
|
|
50
95
|
};
|
|
51
96
|
|
|
52
97
|
CSSPropertyLocalPosition = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)()], CSSPropertyLocalPosition);
|
|
@@ -8,12 +8,12 @@ export declare class CSSPropertyPath implements Partial<CSSProperty<ParsedPathSt
|
|
|
8
8
|
*/
|
|
9
9
|
parser: typeof parsePath;
|
|
10
10
|
calculator(name: string, oldParsed: ParsedPathStyleProps['path'], parsed: ParsedPathStyleProps['path']): {
|
|
11
|
-
absolutePath: import("
|
|
11
|
+
absolutePath: import("../..").PathCommand[];
|
|
12
12
|
hasArc: boolean;
|
|
13
13
|
segments: import("../../display-objects").PathSegment[];
|
|
14
14
|
polygons: [number, number][][];
|
|
15
15
|
polylines: [number, number][][];
|
|
16
|
-
curve: import("
|
|
16
|
+
curve: import("../..").PathCommand[];
|
|
17
17
|
totalLength: number;
|
|
18
18
|
curveSegments: number[][];
|
|
19
19
|
zCommandIndexes: number[];
|
|
@@ -27,7 +27,8 @@ function () {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
CSSPropertyPath.prototype.calculator = function (name, oldParsed, parsed) {
|
|
30
|
-
|
|
30
|
+
// unset
|
|
31
|
+
if (parsed instanceof _cssom.CSSKeywordValue && parsed.value === 'unset') {
|
|
31
32
|
return {
|
|
32
33
|
absolutePath: [],
|
|
33
34
|
hasArc: false,
|
|
@@ -51,10 +52,11 @@ function () {
|
|
|
51
52
|
|
|
52
53
|
CSSPropertyPath.prototype.postProcessor = function (object) {
|
|
53
54
|
var _a = object.parsedStyle,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
_b = _a.defX,
|
|
56
|
+
defX = _b === void 0 ? 0 : _b,
|
|
57
|
+
_c = _a.defY,
|
|
58
|
+
defY = _c === void 0 ? 0 : _c;
|
|
59
|
+
object.setLocalPosition(defX, defY);
|
|
58
60
|
};
|
|
59
61
|
|
|
60
62
|
CSSPropertyPath = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)()], CSSPropertyPath);
|
|
@@ -24,10 +24,9 @@ function () {
|
|
|
24
24
|
|
|
25
25
|
CSSPropertyPoints.prototype.postProcessor = function (object) {
|
|
26
26
|
var _a = object.parsedStyle,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
object.setLocalPosition(x && x.value || 0, y && y.value || 0, z && z.value || 0);
|
|
27
|
+
defX = _a.defX,
|
|
28
|
+
defY = _a.defY;
|
|
29
|
+
object.setLocalPosition(defX, defY);
|
|
31
30
|
};
|
|
32
31
|
|
|
33
32
|
CSSPropertyPoints = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)()], CSSPropertyPoints);
|
|
@@ -34,5 +34,5 @@ import { parseTransform, mergeTransforms } from '../parser';
|
|
|
34
34
|
export declare class CSSPropertyTransform implements Partial<CSSProperty<any[], any[]>> {
|
|
35
35
|
parser: typeof parseTransform;
|
|
36
36
|
mixer: typeof mergeTransforms;
|
|
37
|
-
|
|
37
|
+
postProcessor(object: DisplayObject): void;
|
|
38
38
|
}
|