@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
package/es/Canvas.js
CHANGED
|
@@ -94,6 +94,8 @@ function (_super) {
|
|
|
94
94
|
/**
|
|
95
95
|
* limits query
|
|
96
96
|
*/
|
|
97
|
+
// the following feature-detect from hammer.js
|
|
98
|
+
// @see https://github.com/hammerjs/hammer.js/blob/master/src/inputjs/input-consts.js#L5
|
|
97
99
|
|
|
98
100
|
_this.supportTouchEvent = supportTouchEvent !== null && supportTouchEvent !== void 0 ? supportTouchEvent : 'ontouchstart' in globalThis;
|
|
99
101
|
_this.supportPointerEvent = supportPointerEvent !== null && supportPointerEvent !== void 0 ? supportPointerEvent : !!globalThis.PointerEvent;
|
package/es/css/CSSProperty.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { DisplayObject } from '../display-objects';
|
|
1
2
|
import type { IElement } from '../dom';
|
|
2
3
|
import type { StyleValueRegistry } from './interfaces';
|
|
3
4
|
export declare type Interpolatable = number | boolean | number[] | boolean[];
|
|
4
5
|
declare type CSSPropertyMixer<Parsed = any, T extends Interpolatable = any> = (left: Parsed, right: Parsed, displayObject: IElement | null) => [T, T, (i: T) => string | any] | undefined;
|
|
5
|
-
declare type CSSPropertyParser<Parsed> = (value: string | any) => Parsed;
|
|
6
|
+
declare type CSSPropertyParser<Parsed> = (value: string | any, object: DisplayObject) => Parsed;
|
|
6
7
|
declare type CSSPropertyCalculator<Parsed, Used> = (name: string, oldParsed: Parsed, parsed: Parsed, object: IElement, registry: StyleValueRegistry) => Used;
|
|
7
8
|
/**
|
|
8
9
|
* 1. parser: raw CSS string -> Computed Value
|
|
@@ -14,6 +14,7 @@ export declare const PropertySyntax: {
|
|
|
14
14
|
LENGTH: string;
|
|
15
15
|
PERCENTAGE: string;
|
|
16
16
|
LENGTH_PERCENTAGE: string;
|
|
17
|
+
LIST_OF_POINTS: string;
|
|
17
18
|
};
|
|
18
19
|
export interface PropertyMetadata {
|
|
19
20
|
name: string;
|
|
@@ -99,7 +100,7 @@ export declare class DefaultStyleValueRegistry implements StyleValueRegistry {
|
|
|
99
100
|
/**
|
|
100
101
|
* string -> parsed value
|
|
101
102
|
*/
|
|
102
|
-
parseProperty(name: string, value: any): CSSStyleValue;
|
|
103
|
+
parseProperty(name: string, value: any, object: DisplayObject): CSSStyleValue;
|
|
103
104
|
/**
|
|
104
105
|
* computed value -> used value
|
|
105
106
|
*/
|
|
@@ -8,7 +8,7 @@ import { Shape } from '../types';
|
|
|
8
8
|
import { CSSKeywordValue, CSSStyleValue, CSSUnitValue } from './cssom';
|
|
9
9
|
import { convertPercentUnit } from './parser';
|
|
10
10
|
import { CSSPropertyLocalPosition, CSSPropertyOpacity, CSSPropertyColor, CSSPropertyFilter, CSSPropertyLengthOrPercentage, CSSPropertyLineDash, CSSPropertyShadowBlur, CSSPropertyOffsetPath, CSSPropertyOffsetDistance, CSSPropertyAnchor, CSSPropertyZIndex, CSSPropertyTransform, CSSPropertyTransformOrigin, CSSPropertyPath, CSSPropertyClipPath, CSSPropertyPoints, CSSPropertyText, CSSPropertyTextTransform } from './properties';
|
|
11
|
-
import { formatAttribute } from '../utils';
|
|
11
|
+
import { formatAttribute, isNil } from '../utils';
|
|
12
12
|
import { AABB } from '../shapes';
|
|
13
13
|
import { StyleValueRegistry } from './interfaces';
|
|
14
14
|
export var PropertySyntax = {
|
|
@@ -17,7 +17,8 @@ export var PropertySyntax = {
|
|
|
17
17
|
NUMBER: '<number>',
|
|
18
18
|
LENGTH: '<length>',
|
|
19
19
|
PERCENTAGE: '<percentage>',
|
|
20
|
-
LENGTH_PERCENTAGE: '<length> | <percentage>'
|
|
20
|
+
LENGTH_PERCENTAGE: '<length> | <percentage>',
|
|
21
|
+
LIST_OF_POINTS: '<list-of-points>'
|
|
21
22
|
};
|
|
22
23
|
/**
|
|
23
24
|
* Blink used them in code generation(css_properties.json5)
|
|
@@ -30,29 +31,6 @@ export var BUILT_IN_PROPERTIES = [{
|
|
|
30
31
|
*/
|
|
31
32
|
name: 'display',
|
|
32
33
|
keywords: ['none']
|
|
33
|
-
}, {
|
|
34
|
-
// x in local space
|
|
35
|
-
name: 'x',
|
|
36
|
-
interpolable: true,
|
|
37
|
-
alias: ['cx'],
|
|
38
|
-
defaultValue: '0',
|
|
39
|
-
syntax: PropertySyntax.LENGTH_PERCENTAGE,
|
|
40
|
-
handler: CSSPropertyLocalPosition
|
|
41
|
-
}, {
|
|
42
|
-
// y in local space
|
|
43
|
-
name: 'y',
|
|
44
|
-
interpolable: true,
|
|
45
|
-
alias: ['cy'],
|
|
46
|
-
defaultValue: '0',
|
|
47
|
-
syntax: PropertySyntax.LENGTH_PERCENTAGE,
|
|
48
|
-
handler: CSSPropertyLocalPosition
|
|
49
|
-
}, {
|
|
50
|
-
// z in local space
|
|
51
|
-
name: 'z',
|
|
52
|
-
interpolable: true,
|
|
53
|
-
defaultValue: '0',
|
|
54
|
-
syntax: PropertySyntax.LENGTH_PERCENTAGE,
|
|
55
|
-
handler: CSSPropertyLocalPosition
|
|
56
34
|
}, {
|
|
57
35
|
/**
|
|
58
36
|
* range [0.0, 1.0]
|
|
@@ -225,6 +203,7 @@ export var BUILT_IN_PROPERTIES = [{
|
|
|
225
203
|
handler: CSSPropertyClipPath
|
|
226
204
|
}, {
|
|
227
205
|
name: 'transform',
|
|
206
|
+
parsePriority: 100,
|
|
228
207
|
interpolable: true,
|
|
229
208
|
keywords: ['none'],
|
|
230
209
|
defaultValue: 'none',
|
|
@@ -241,8 +220,20 @@ export var BUILT_IN_PROPERTIES = [{
|
|
|
241
220
|
parsePriority: 99,
|
|
242
221
|
layoutDependent: true,
|
|
243
222
|
handler: CSSPropertyAnchor
|
|
244
|
-
}, //
|
|
223
|
+
}, // <circle> & <ellipse>
|
|
245
224
|
{
|
|
225
|
+
name: 'cx',
|
|
226
|
+
interpolable: true,
|
|
227
|
+
defaultValue: '0',
|
|
228
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE,
|
|
229
|
+
handler: CSSPropertyLocalPosition
|
|
230
|
+
}, {
|
|
231
|
+
name: 'cy',
|
|
232
|
+
interpolable: true,
|
|
233
|
+
defaultValue: '0',
|
|
234
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE,
|
|
235
|
+
handler: CSSPropertyLocalPosition
|
|
236
|
+
}, {
|
|
246
237
|
name: 'r',
|
|
247
238
|
interpolable: true,
|
|
248
239
|
layoutDependent: true,
|
|
@@ -260,8 +251,29 @@ export var BUILT_IN_PROPERTIES = [{
|
|
|
260
251
|
layoutDependent: true,
|
|
261
252
|
defaultValue: 'auto',
|
|
262
253
|
handler: CSSPropertyLengthOrPercentage
|
|
263
|
-
}, // Rect Image
|
|
254
|
+
}, // Rect Image Group
|
|
264
255
|
{
|
|
256
|
+
// x in local space
|
|
257
|
+
name: 'x',
|
|
258
|
+
interpolable: true,
|
|
259
|
+
defaultValue: '0',
|
|
260
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE,
|
|
261
|
+
handler: CSSPropertyLocalPosition
|
|
262
|
+
}, {
|
|
263
|
+
// y in local space
|
|
264
|
+
name: 'y',
|
|
265
|
+
interpolable: true,
|
|
266
|
+
defaultValue: '0',
|
|
267
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE,
|
|
268
|
+
handler: CSSPropertyLocalPosition
|
|
269
|
+
}, {
|
|
270
|
+
// z in local space
|
|
271
|
+
name: 'z',
|
|
272
|
+
interpolable: true,
|
|
273
|
+
defaultValue: '0',
|
|
274
|
+
syntax: PropertySyntax.LENGTH_PERCENTAGE,
|
|
275
|
+
handler: CSSPropertyLocalPosition
|
|
276
|
+
}, {
|
|
265
277
|
name: 'width',
|
|
266
278
|
interpolable: true,
|
|
267
279
|
layoutDependent: true,
|
|
@@ -326,11 +338,13 @@ export var BUILT_IN_PROPERTIES = [{
|
|
|
326
338
|
interpolable: true,
|
|
327
339
|
layoutDependent: true,
|
|
328
340
|
defaultValue: '',
|
|
341
|
+
alias: ['d'],
|
|
329
342
|
handler: CSSPropertyPath
|
|
330
|
-
}, // Polyline
|
|
343
|
+
}, // Polyline & Polygon
|
|
331
344
|
{
|
|
332
345
|
name: 'points',
|
|
333
346
|
layoutDependent: true,
|
|
347
|
+
syntax: PropertySyntax.LIST_OF_POINTS,
|
|
334
348
|
handler: CSSPropertyPoints
|
|
335
349
|
}, // Text
|
|
336
350
|
{
|
|
@@ -526,7 +540,7 @@ function () {
|
|
|
526
540
|
|
|
527
541
|
if (!skipParse) {
|
|
528
542
|
sortedNames.forEach(function (name) {
|
|
529
|
-
object.computedStyle[name] = _this.parseProperty(name, object.attributes[name]);
|
|
543
|
+
object.computedStyle[name] = _this.parseProperty(name, object.attributes[name], object);
|
|
530
544
|
});
|
|
531
545
|
}
|
|
532
546
|
|
|
@@ -570,11 +584,11 @@ function () {
|
|
|
570
584
|
*/
|
|
571
585
|
|
|
572
586
|
|
|
573
|
-
DefaultStyleValueRegistry.prototype.parseProperty = function (name, value) {
|
|
587
|
+
DefaultStyleValueRegistry.prototype.parseProperty = function (name, value, object) {
|
|
574
588
|
var metadata = this.getMetadata(name);
|
|
575
589
|
var computed = value;
|
|
576
590
|
|
|
577
|
-
if (value === '') {
|
|
591
|
+
if (value === '' || isNil(value)) {
|
|
578
592
|
value = 'unset';
|
|
579
593
|
}
|
|
580
594
|
|
|
@@ -593,7 +607,7 @@ function () {
|
|
|
593
607
|
|
|
594
608
|
if (propertyHandler && propertyHandler.parser) {
|
|
595
609
|
// try to parse it to CSSStyleValue, eg. '10px' -> CSS.px(10)
|
|
596
|
-
computed = propertyHandler.parser(value);
|
|
610
|
+
computed = propertyHandler.parser(value, object);
|
|
597
611
|
}
|
|
598
612
|
}
|
|
599
613
|
}
|
|
@@ -632,8 +646,8 @@ function () {
|
|
|
632
646
|
|
|
633
647
|
if (value === 'initial') {
|
|
634
648
|
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/initial
|
|
635
|
-
if (defaultValue) {
|
|
636
|
-
computed = this.parseProperty(name, defaultValue);
|
|
649
|
+
if (!isNil(defaultValue)) {
|
|
650
|
+
computed = this.parseProperty(name, defaultValue, object);
|
|
637
651
|
}
|
|
638
652
|
} else if (value === 'inherit') {
|
|
639
653
|
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit
|
|
@@ -770,41 +784,23 @@ function () {
|
|
|
770
784
|
height = _b.height,
|
|
771
785
|
_c = _b.depth,
|
|
772
786
|
depth = _c === void 0 ? 0 : _c,
|
|
773
|
-
_d = _b.
|
|
774
|
-
|
|
775
|
-
_e = _b.
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
// z = 0,
|
|
780
|
-
offsetX = _f === void 0 ? 0 : _f,
|
|
781
|
-
_g = _b.offsetY,
|
|
782
|
-
offsetY = _g === void 0 ? 0 : _g,
|
|
783
|
-
_h = _b.offsetZ,
|
|
784
|
-
offsetZ = _h === void 0 ? 0 : _h;
|
|
785
|
-
|
|
786
|
-
if (object.nodeName === Shape.LINE || object.nodeName === Shape.POLYLINE || object.nodeName === Shape.POLYGON || object.nodeName === Shape.PATH) {
|
|
787
|
-
parsedStyle.offsetX = x - (parsedStyle.defX || 0);
|
|
788
|
-
parsedStyle.offsetY = y - (parsedStyle.defY || 0);
|
|
789
|
-
parsedStyle.defX = x;
|
|
790
|
-
parsedStyle.defY = y; // modify x/y/z
|
|
791
|
-
|
|
792
|
-
object.attributes.x += parsedStyle.offsetX;
|
|
793
|
-
object.attributes.y += parsedStyle.offsetY;
|
|
794
|
-
parsedStyle.x = parsedStyle.x.add(new CSSUnitValue(parsedStyle.offsetX, 'px'));
|
|
795
|
-
parsedStyle.y = parsedStyle.y.add(new CSSUnitValue(parsedStyle.offsetY, 'px'));
|
|
796
|
-
} // init with content box
|
|
787
|
+
_d = _b.offsetX,
|
|
788
|
+
offsetX = _d === void 0 ? 0 : _d,
|
|
789
|
+
_e = _b.offsetY,
|
|
790
|
+
offsetY = _e === void 0 ? 0 : _e,
|
|
791
|
+
_f = _b.offsetZ,
|
|
792
|
+
offsetZ = _f === void 0 ? 0 : _f; // init with content box
|
|
797
793
|
|
|
798
794
|
|
|
799
795
|
var halfExtents = vec3.fromValues(width / 2, height / 2, depth / 2); // anchor is center by default, don't account for lineWidth here
|
|
800
796
|
|
|
801
|
-
var
|
|
802
|
-
lineWidth =
|
|
803
|
-
increasedLineWidthForHitTesting =
|
|
804
|
-
shadowColor =
|
|
805
|
-
|
|
806
|
-
filter =
|
|
807
|
-
transformOrigin =
|
|
797
|
+
var _g = parsedStyle,
|
|
798
|
+
lineWidth = _g.lineWidth,
|
|
799
|
+
increasedLineWidthForHitTesting = _g.increasedLineWidthForHitTesting,
|
|
800
|
+
shadowColor = _g.shadowColor,
|
|
801
|
+
_h = _g.filter,
|
|
802
|
+
filter = _h === void 0 ? [] : _h,
|
|
803
|
+
transformOrigin = _g.transformOrigin;
|
|
808
804
|
var anchor = parsedStyle.anchor; // <Text> use textAlign & textBaseline instead of anchor
|
|
809
805
|
|
|
810
806
|
if (object.nodeName === Shape.TEXT) {
|
|
@@ -820,13 +816,13 @@ function () {
|
|
|
820
816
|
geometry_1.renderBounds.update(center, halfExtents); // account for shadow, only support constant value now
|
|
821
817
|
|
|
822
818
|
if (shadowColor) {
|
|
823
|
-
var
|
|
824
|
-
min =
|
|
825
|
-
max =
|
|
826
|
-
var
|
|
827
|
-
shadowBlur =
|
|
828
|
-
shadowOffsetX =
|
|
829
|
-
shadowOffsetY =
|
|
819
|
+
var _j = geometry_1.renderBounds,
|
|
820
|
+
min = _j.min,
|
|
821
|
+
max = _j.max;
|
|
822
|
+
var _k = parsedStyle,
|
|
823
|
+
shadowBlur = _k.shadowBlur,
|
|
824
|
+
shadowOffsetX = _k.shadowOffsetX,
|
|
825
|
+
shadowOffsetY = _k.shadowOffsetY;
|
|
830
826
|
var shadowBlurInPixels = shadowBlur && shadowBlur.value || 0;
|
|
831
827
|
var shadowOffsetXInPixels = shadowOffsetX && shadowOffsetX.value || 0;
|
|
832
828
|
var shadowOffsetYInPixels = shadowOffsetY && shadowOffsetY.value || 0;
|
package/es/css/parser/color.d.ts
CHANGED
|
@@ -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/es/css/parser/color.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __read, __spreadArray } from "tslib";
|
|
2
2
|
import * as d3 from 'd3-color';
|
|
3
3
|
import { CSSRGB, CSSGradientValue, GradientPatternType } from '../cssom';
|
|
4
|
-
import { clamp, isString } from '../../utils';
|
|
4
|
+
import { clamp, isNil, isString } from '../../utils';
|
|
5
5
|
var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
|
|
6
6
|
var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
|
|
7
7
|
var regexPR = /^p\s*\(\s*([axyn])\s*\)\s*(.*)/i;
|
|
@@ -11,7 +11,7 @@ var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/gi;
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
export function parseColor(colorStr) {
|
|
14
|
-
if (colorStr
|
|
14
|
+
if (isNil(colorStr)) {
|
|
15
15
|
colorStr = '';
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { AABB } from '../../shapes';
|
|
2
|
-
import { isString, rad2deg, turn2deg } from '../../utils';
|
|
2
|
+
import { isNil, isString, rad2deg, turn2deg } from '../../utils';
|
|
3
3
|
import { UnitType } from '../cssom';
|
|
4
4
|
import { CSSUnitValue } from '../cssom';
|
|
5
5
|
export function parseDimension(unitRegExp, string) {
|
|
6
|
+
if (isNil(string)) {
|
|
7
|
+
return new CSSUnitValue(0, 'px');
|
|
8
|
+
}
|
|
9
|
+
|
|
6
10
|
string = "".concat(string).trim().toLowerCase();
|
|
7
11
|
|
|
8
12
|
if (isFinite(Number(string))) {
|
package/es/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/es/css/parser/path.js
CHANGED
|
@@ -3,7 +3,7 @@ import { path2Absolute, path2Segments, path2Curve } from '@antv/util';
|
|
|
3
3
|
import { Cubic as CubicUtil } from '@antv/g-math';
|
|
4
4
|
import { clonePath, equalizeSegments, getDrawDirection, getRotatedCurve, reverseCurve } from '../../utils/path';
|
|
5
5
|
import { Rectangle } from '../../shapes/Rectangle';
|
|
6
|
-
export function parsePath(path) {
|
|
6
|
+
export function parsePath(path, object) {
|
|
7
7
|
var absolutePath = path2Absolute(path);
|
|
8
8
|
var hasArc = hasArcOrBezier(absolutePath);
|
|
9
9
|
var clonedAbsolutePath = absolutePath.slice();
|
|
@@ -24,6 +24,13 @@ export function parsePath(path) {
|
|
|
24
24
|
totalLength = _c.totalLength,
|
|
25
25
|
curveSegments = _c.curveSegments;
|
|
26
26
|
|
|
27
|
+
var rect = getPathBBox(curve);
|
|
28
|
+
|
|
29
|
+
if (object) {
|
|
30
|
+
object.parsedStyle.defX = rect.x;
|
|
31
|
+
object.parsedStyle.defY = rect.y;
|
|
32
|
+
}
|
|
33
|
+
|
|
27
34
|
return {
|
|
28
35
|
absolutePath: absolutePath,
|
|
29
36
|
hasArc: hasArc,
|
|
@@ -34,7 +41,7 @@ export function parsePath(path) {
|
|
|
34
41
|
totalLength: totalLength,
|
|
35
42
|
curveSegments: curveSegments,
|
|
36
43
|
zCommandIndexes: zCommandIndexes,
|
|
37
|
-
rect:
|
|
44
|
+
rect: rect
|
|
38
45
|
};
|
|
39
46
|
}
|
|
40
47
|
|
|
@@ -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/es/css/parser/points.js
CHANGED
|
@@ -1,8 +1,26 @@
|
|
|
1
|
+
import { __read, __spreadArray } from "tslib";
|
|
1
2
|
import { Line as LineUtil, Polyline as PolylineUtil } from '@antv/g-math';
|
|
2
3
|
import { isString } from '../../utils';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/points
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* points="100,10 250,150 200,110"
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export function parsePoints(pointsOrStr, object) {
|
|
12
|
+
var points;
|
|
13
|
+
|
|
14
|
+
if (isString(pointsOrStr)) {
|
|
15
|
+
points = pointsOrStr.split(' ').map(function (pointStr) {
|
|
16
|
+
var _a = __read(pointStr.split(','), 2),
|
|
17
|
+
x = _a[0],
|
|
18
|
+
y = _a[1];
|
|
19
|
+
|
|
20
|
+
return [Number(x), Number(y)];
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
points = pointsOrStr;
|
|
6
24
|
}
|
|
7
25
|
|
|
8
26
|
var segments = [];
|
|
@@ -20,6 +38,18 @@ export function parsePoints(points) {
|
|
|
20
38
|
segments.push(segmentT);
|
|
21
39
|
}
|
|
22
40
|
});
|
|
41
|
+
var minX = Math.min.apply(Math, __spreadArray([], __read(points.map(function (point) {
|
|
42
|
+
return point[0];
|
|
43
|
+
})), false));
|
|
44
|
+
var minY = Math.min.apply(Math, __spreadArray([], __read(points.map(function (point) {
|
|
45
|
+
return point[1];
|
|
46
|
+
})), false));
|
|
47
|
+
|
|
48
|
+
if (object) {
|
|
49
|
+
object.parsedStyle.defX = minX;
|
|
50
|
+
object.parsedStyle.defY = minY;
|
|
51
|
+
}
|
|
52
|
+
|
|
23
53
|
return {
|
|
24
54
|
points: points,
|
|
25
55
|
totalLength: totalLength,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { singleton } from 'mana-syringe';
|
|
3
3
|
import { dirtifyToRoot } from '../../services';
|
|
4
|
+
import { CSSKeywordValue } from '../cssom';
|
|
4
5
|
/**
|
|
5
6
|
* @see /zh/docs/api/basic/display-object#clippath
|
|
6
7
|
* @example
|
|
@@ -25,7 +26,12 @@ function () {
|
|
|
25
26
|
function CSSPropertyClipPath() {}
|
|
26
27
|
|
|
27
28
|
CSSPropertyClipPath.prototype.calculator = function (name, oldClipPath, newClipPath, object) {
|
|
28
|
-
//
|
|
29
|
+
// unset
|
|
30
|
+
if (newClipPath instanceof CSSKeywordValue) {
|
|
31
|
+
newClipPath = null;
|
|
32
|
+
} // clear ref to old clip path
|
|
33
|
+
|
|
34
|
+
|
|
29
35
|
if (oldClipPath && oldClipPath !== newClipPath && oldClipPath.style.clipPathTargets) {
|
|
30
36
|
var index = oldClipPath.style.clipPathTargets.indexOf(object);
|
|
31
37
|
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
|
*/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { __decorate, __extends } from "tslib";
|
|
1
|
+
import { __decorate, __extends, __read } from "tslib";
|
|
2
2
|
import { singleton } from 'mana-syringe';
|
|
3
|
-
import { mergeDimensions, parseLengthOrPercentage } from '../parser';
|
|
4
3
|
import { CSSPropertyLengthOrPercentage } from './CSSPropertyLengthOrPercentage';
|
|
4
|
+
import { isNil } from '../../utils';
|
|
5
|
+
import { Shape } from '../../types';
|
|
5
6
|
/**
|
|
6
7
|
* local position
|
|
7
8
|
*/
|
|
@@ -12,19 +13,7 @@ function (_super) {
|
|
|
12
13
|
__extends(CSSPropertyLocalPosition, _super);
|
|
13
14
|
|
|
14
15
|
function CSSPropertyLocalPosition() {
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* <length> & <percentage>
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
_this.parser = parseLengthOrPercentage;
|
|
22
|
-
/**
|
|
23
|
-
* mix between CSS.px(x)
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
_this.mixer = mergeDimensions;
|
|
27
|
-
return _this;
|
|
16
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
28
17
|
}
|
|
29
18
|
/**
|
|
30
19
|
* update local position
|
|
@@ -32,11 +21,66 @@ function (_super) {
|
|
|
32
21
|
|
|
33
22
|
|
|
34
23
|
CSSPropertyLocalPosition.prototype.postProcessor = function (object) {
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
object.
|
|
24
|
+
var x;
|
|
25
|
+
var y;
|
|
26
|
+
var z;
|
|
27
|
+
|
|
28
|
+
switch (object.nodeName) {
|
|
29
|
+
case Shape.CIRCLE:
|
|
30
|
+
case Shape.ELLIPSE:
|
|
31
|
+
var _a = object.parsedStyle,
|
|
32
|
+
cx = _a.cx,
|
|
33
|
+
cy = _a.cy;
|
|
34
|
+
|
|
35
|
+
if (!isNil(cx)) {
|
|
36
|
+
x = cx.value;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!isNil(cy)) {
|
|
40
|
+
y = cy.value;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
break;
|
|
44
|
+
|
|
45
|
+
case Shape.RECT:
|
|
46
|
+
case Shape.GROUP:
|
|
47
|
+
case Shape.IMAGE:
|
|
48
|
+
case Shape.HTML:
|
|
49
|
+
case Shape.TEXT:
|
|
50
|
+
case Shape.MESH:
|
|
51
|
+
if (!isNil(object.parsedStyle.x)) {
|
|
52
|
+
x = object.parsedStyle.x.value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!isNil(object.parsedStyle.y)) {
|
|
56
|
+
y = object.parsedStyle.y.value;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
break;
|
|
60
|
+
|
|
61
|
+
case Shape.LINE:
|
|
62
|
+
var _b = object.parsedStyle,
|
|
63
|
+
x1 = _b.x1,
|
|
64
|
+
x2 = _b.x2,
|
|
65
|
+
y1 = _b.y1,
|
|
66
|
+
y2 = _b.y2;
|
|
67
|
+
var minX = Math.min(x1.value, x2.value);
|
|
68
|
+
var minY = Math.min(y1.value, y2.value);
|
|
69
|
+
x = minX;
|
|
70
|
+
y = minY;
|
|
71
|
+
z = 0;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
object.parsedStyle.defX = x || 0;
|
|
76
|
+
object.parsedStyle.defY = y || 0;
|
|
77
|
+
|
|
78
|
+
var _c = __read(object.getLocalPosition(), 3),
|
|
79
|
+
ox = _c[0],
|
|
80
|
+
oy = _c[1],
|
|
81
|
+
oz = _c[2];
|
|
82
|
+
|
|
83
|
+
object.setLocalPosition(isNil(x) ? ox : x, isNil(y) ? oy : y, isNil(z) ? oz : z);
|
|
40
84
|
};
|
|
41
85
|
|
|
42
86
|
CSSPropertyLocalPosition = __decorate([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[];
|
|
@@ -16,7 +16,8 @@ function () {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
CSSPropertyPath.prototype.calculator = function (name, oldParsed, parsed) {
|
|
19
|
-
|
|
19
|
+
// unset
|
|
20
|
+
if (parsed instanceof CSSKeywordValue && parsed.value === 'unset') {
|
|
20
21
|
return {
|
|
21
22
|
absolutePath: [],
|
|
22
23
|
hasArc: false,
|
|
@@ -40,10 +41,11 @@ function () {
|
|
|
40
41
|
|
|
41
42
|
CSSPropertyPath.prototype.postProcessor = function (object) {
|
|
42
43
|
var _a = object.parsedStyle,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
_b = _a.defX,
|
|
45
|
+
defX = _b === void 0 ? 0 : _b,
|
|
46
|
+
_c = _a.defY,
|
|
47
|
+
defY = _c === void 0 ? 0 : _c;
|
|
48
|
+
object.setLocalPosition(defX, defY);
|
|
47
49
|
};
|
|
48
50
|
|
|
49
51
|
CSSPropertyPath = __decorate([singleton()], CSSPropertyPath);
|
|
@@ -15,10 +15,9 @@ function () {
|
|
|
15
15
|
|
|
16
16
|
CSSPropertyPoints.prototype.postProcessor = function (object) {
|
|
17
17
|
var _a = object.parsedStyle,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
object.setLocalPosition(x && x.value || 0, y && y.value || 0, z && z.value || 0);
|
|
18
|
+
defX = _a.defX,
|
|
19
|
+
defY = _a.defY;
|
|
20
|
+
object.setLocalPosition(defX, defY);
|
|
22
21
|
};
|
|
23
22
|
|
|
24
23
|
CSSPropertyPoints = __decorate([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
|
}
|