@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
|
@@ -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
|
@@ -121,8 +121,8 @@ function propertyInterpolation(property, left, right, target) {
|
|
|
121
121
|
|
|
122
122
|
if (propertyHandler) {
|
|
123
123
|
if (propertyHandler.parser) {
|
|
124
|
-
parsedLeft = propertyHandler.parser(left);
|
|
125
|
-
parsedRight = propertyHandler.parser(right);
|
|
124
|
+
parsedLeft = propertyHandler.parser(left, target);
|
|
125
|
+
parsedRight = propertyHandler.parser(right, target);
|
|
126
126
|
} // if (propertyHandler.calculator) {
|
|
127
127
|
// parsedLeft = propertyHandler.calculator(parsedLeft);
|
|
128
128
|
// // parsedLeft = handler.calculator
|
|
@@ -184,12 +184,6 @@ var FORMAT_ATTR_MAP = {
|
|
|
184
184
|
d: {
|
|
185
185
|
alias: 'path'
|
|
186
186
|
},
|
|
187
|
-
cx: {
|
|
188
|
-
alias: 'x'
|
|
189
|
-
},
|
|
190
|
-
cy: {
|
|
191
|
-
alias: 'y'
|
|
192
|
-
},
|
|
193
187
|
strokeDasharray: {
|
|
194
188
|
alias: 'lineDash'
|
|
195
189
|
},
|
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,10 +275,16 @@ 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) {
|
|
@@ -274,9 +303,11 @@ function rectToCommands(width, height, x, y, radius) {
|
|
|
274
303
|
*/
|
|
275
304
|
|
|
276
305
|
|
|
277
|
-
export function convertToPath(object) {
|
|
278
|
-
|
|
279
|
-
|
|
306
|
+
export function convertToPath(object, applyLocalTransform) {
|
|
307
|
+
if (applyLocalTransform === void 0) {
|
|
308
|
+
applyLocalTransform = true;
|
|
309
|
+
}
|
|
310
|
+
|
|
280
311
|
var commands = [];
|
|
281
312
|
|
|
282
313
|
switch (object.nodeName) {
|
|
@@ -293,9 +324,9 @@ export function convertToPath(object) {
|
|
|
293
324
|
{
|
|
294
325
|
var _b = object.parsedStyle,
|
|
295
326
|
r = _b.r,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
commands = ellipseToCommands(r.value, r.value,
|
|
327
|
+
cx = _b.cx,
|
|
328
|
+
cy = _b.cy;
|
|
329
|
+
commands = ellipseToCommands(r.value, r.value, cx.value, cy.value);
|
|
299
330
|
break;
|
|
300
331
|
}
|
|
301
332
|
|
|
@@ -304,16 +335,16 @@ export function convertToPath(object) {
|
|
|
304
335
|
var _c = object.parsedStyle,
|
|
305
336
|
rx = _c.rx,
|
|
306
337
|
ry = _c.ry,
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
commands = ellipseToCommands(rx.value, ry.value,
|
|
338
|
+
cx = _c.cx,
|
|
339
|
+
cy = _c.cy;
|
|
340
|
+
commands = ellipseToCommands(rx.value, ry.value, cx.value, cy.value);
|
|
310
341
|
break;
|
|
311
342
|
}
|
|
312
343
|
|
|
313
344
|
case Shape.POLYLINE:
|
|
314
345
|
case Shape.POLYGON:
|
|
315
346
|
var points = object.parsedStyle.points;
|
|
316
|
-
commands = polygonToCommands(points.points);
|
|
347
|
+
commands = polygonToCommands(points.points, object.nodeName === Shape.POLYGON);
|
|
317
348
|
break;
|
|
318
349
|
|
|
319
350
|
case Shape.RECT:
|
|
@@ -327,11 +358,17 @@ export function convertToPath(object) {
|
|
|
327
358
|
break;
|
|
328
359
|
|
|
329
360
|
case Shape.PATH:
|
|
330
|
-
|
|
361
|
+
var _e = object.parsedStyle.path,
|
|
362
|
+
curve = _e.curve,
|
|
363
|
+
zCommandIndexes = _e.zCommandIndexes;
|
|
364
|
+
commands = __spreadArray([], __read(curve), false);
|
|
365
|
+
zCommandIndexes.forEach(function (zIndex, index) {
|
|
366
|
+
commands.splice(zIndex + index, 1, ['Z']);
|
|
367
|
+
});
|
|
331
368
|
break;
|
|
332
369
|
}
|
|
333
370
|
|
|
334
371
|
if (commands.length) {
|
|
335
|
-
return commandsToPathString(commands,
|
|
372
|
+
return commandsToPathString(commands, object, applyLocalTransform);
|
|
336
373
|
}
|
|
337
374
|
}
|
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/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
|
*/
|