abstract-image 8.1.3 → 8.2.1
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/CHANGELOG.md +6 -0
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-dashed-line.d.ts +3 -0
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-dashed-line.d.ts.map +1 -0
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-dashed-line.js +38 -0
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-dashed-line.js.map +1 -0
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-ellipse.js +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-ellipse.js.map +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-group.js +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-group.js.map +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-line.js +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-line.js.map +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-polygon.js +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-polygon.js.map +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-polyline.js +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-polyline.js.map +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-rectangle.js +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-rectangle.js.map +1 -1
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-dashed-line.d.ts +3 -0
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-dashed-line.d.ts.map +1 -0
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-dashed-line.js +38 -0
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-dashed-line.js.map +1 -0
- package/lib/exporters/react-svg-export-image.js +25 -10
- package/lib/exporters/react-svg-export-image.js.map +1 -1
- package/lib/exporters/svg-export-image.js +45 -51
- package/lib/exporters/svg-export-image.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/model/component.d.ts +12 -5
- package/lib/model/component.d.ts.map +1 -1
- package/lib/model/component.js +12 -5
- package/lib/model/component.js.map +1 -1
- package/lib/model/dash-style.d.ts +7 -0
- package/lib/model/dash-style.d.ts.map +1 -0
- package/lib/model/dash-style.js +12 -0
- package/lib/model/dash-style.js.map +1 -0
- package/lib/model/index.d.ts +1 -0
- package/lib/model/index.d.ts.map +1 -1
- package/lib/model/index.js +1 -0
- package/lib/model/index.js.map +1 -1
- package/package.json +2 -2
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-dashed-line.tsx +28 -0
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-ellipse.tsx +1 -1
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-group.tsx +1 -1
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-line.tsx +1 -1
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-polygon.tsx +1 -1
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-polyline.tsx +1 -1
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-rectangle.tsx +1 -1
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-dashed-line.ts +28 -0
- package/src/exporters/react-svg-export-image.tsx +41 -6
- package/src/exporters/svg-export-image.ts +51 -5
- package/src/index.ts +1 -0
- package/src/model/component.ts +24 -5
- package/src/model/dash-style.ts +13 -0
- package/src/model/index.ts +1 -0
package/lib/model/component.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as Point from "./point";
|
|
2
2
|
import * as Color from "./color";
|
|
3
|
+
import * as DashStyle from "./dash-style";
|
|
3
4
|
import * as AbstractImage from "./abstract-image";
|
|
4
5
|
export type Component = BinaryImage | Ellipse | Line | PolyLine | Polygon | Rectangle | Text | SubImage | Group;
|
|
5
6
|
export interface Group {
|
|
@@ -36,46 +37,52 @@ export interface Ellipse {
|
|
|
36
37
|
readonly bottomRight: Point.Point;
|
|
37
38
|
readonly strokeColor: Color.Color;
|
|
38
39
|
readonly strokeThickness: number;
|
|
40
|
+
readonly strokeDashStyle: DashStyle.DashStyle;
|
|
39
41
|
readonly fillColor: Color.Color;
|
|
40
42
|
readonly id: string | undefined;
|
|
41
43
|
}
|
|
42
|
-
export declare function createEllipse(topLeft: Point.Point, bottomRight: Point.Point, strokeColor: Color.Color, strokeThickness: number, fillColor: Color.Color, id?: string): Ellipse;
|
|
44
|
+
export declare function createEllipse(topLeft: Point.Point, bottomRight: Point.Point, strokeColor: Color.Color, strokeThickness: number, fillColor: Color.Color, id?: string, strokeDashStyle?: DashStyle.DashStyle): Ellipse;
|
|
43
45
|
export interface Line {
|
|
44
46
|
readonly type: "line";
|
|
45
47
|
readonly start: Point.Point;
|
|
46
48
|
readonly end: Point.Point;
|
|
47
49
|
readonly strokeColor: Color.Color;
|
|
48
50
|
readonly strokeThickness: number;
|
|
51
|
+
readonly strokeDashStyle: DashStyle.DashStyle;
|
|
49
52
|
readonly id: string | undefined;
|
|
50
53
|
}
|
|
51
|
-
export declare function createLine(start: Point.Point, end: Point.Point, strokeColor: Color.Color, strokeThickness: number, id?: string): Line;
|
|
54
|
+
export declare function createLine(start: Point.Point, end: Point.Point, strokeColor: Color.Color, strokeThickness: number, id?: string, strokeDashStyle?: DashStyle.DashStyle): Line;
|
|
52
55
|
export interface PolyLine {
|
|
53
56
|
readonly type: "polyline";
|
|
54
57
|
readonly points: Array<Point.Point>;
|
|
55
58
|
readonly strokeColor: Color.Color;
|
|
56
59
|
readonly strokeThickness: number;
|
|
60
|
+
readonly strokeDashStyle: DashStyle.DashStyle;
|
|
57
61
|
readonly id: string | undefined;
|
|
58
62
|
}
|
|
59
|
-
export declare function createPolyLine(points: Array<Point.Point>, strokeColor: Color.Color, strokeThickness: number, id?: string): PolyLine;
|
|
63
|
+
export declare function createPolyLine(points: Array<Point.Point>, strokeColor: Color.Color, strokeThickness: number, id?: string, strokeDashStyle?: DashStyle.DashStyle): PolyLine;
|
|
60
64
|
export interface Polygon {
|
|
61
65
|
readonly type: "polygon";
|
|
62
66
|
readonly points: Array<Point.Point>;
|
|
63
67
|
readonly strokeColor: Color.Color;
|
|
64
68
|
readonly strokeThickness: number;
|
|
69
|
+
readonly strokeDashStyle: DashStyle.DashStyle;
|
|
65
70
|
readonly fillColor: Color.Color;
|
|
66
71
|
readonly id: string | undefined;
|
|
67
72
|
}
|
|
68
|
-
export declare function createPolygon(points: Array<Point.Point>, strokeColor: Color.Color, strokeThickness: number, fillColor: Color.Color, id?: string): Polygon;
|
|
73
|
+
export declare function createPolygon(points: Array<Point.Point>, strokeColor: Color.Color, strokeThickness: number, fillColor: Color.Color, id?: string, strokeDashStyle?: DashStyle.DashStyle): Polygon;
|
|
69
74
|
export interface Rectangle {
|
|
70
75
|
readonly type: "rectangle";
|
|
71
76
|
readonly topLeft: Point.Point;
|
|
72
77
|
readonly bottomRight: Point.Point;
|
|
73
78
|
readonly strokeColor: Color.Color;
|
|
74
79
|
readonly strokeThickness: number;
|
|
80
|
+
readonly strokeDashStyle: DashStyle.DashStyle;
|
|
75
81
|
readonly fillColor: Color.Color;
|
|
76
82
|
readonly id: string | undefined;
|
|
83
|
+
readonly radius?: Point.Point;
|
|
77
84
|
}
|
|
78
|
-
export declare function createRectangle(topLeft: Point.Point, bottomRight: Point.Point, strokeColor: Color.Color, strokeThickness: number, fillColor: Color.Color, id?: string): Rectangle;
|
|
85
|
+
export declare function createRectangle(topLeft: Point.Point, bottomRight: Point.Point, strokeColor: Color.Color, strokeThickness: number, fillColor: Color.Color, id?: string, strokeDashStyle?: DashStyle.DashStyle, radius?: Point.Point): Rectangle;
|
|
79
86
|
export declare function corners(rectangle: Rectangle): Array<Point.Point>;
|
|
80
87
|
export type AbstractFontWeight = "light" | "normal" | "mediumBold" | "bold" | "extraBold";
|
|
81
88
|
export type TextAlignment = "left" | "center" | "right";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/model/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC;AAElD,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,OAAO,GAAG,IAAI,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEhH,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;CACrC;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,KAAK,CAM3E;AAED;;GAEG;AAEH,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,KAAK,CAAC;AAEzC,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED,MAAM,MAAM,SAAS,GAAG,UAA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AAE,eAAe,EAC1C,uBAAuB,EAAE,eAAe,EACxC,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,KAAK,CAAC,KAAK,EACxB,MAAM,EAAE,OAAO,EACf,EAAE,CAAC,EAAE,MAAM,GACV,IAAI,CAkBN;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC3B;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,GAAG,QAAQ,CAE/E;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,aAAa,GAAG,SAAS,CAEpH"}
|
package/lib/model/component.js
CHANGED
|
@@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.embedAbstractImage = exports.createSubImage = exports.createText = exports.corners = exports.createRectangle = exports.createPolygon = exports.createPolyLine = exports.createLine = exports.createEllipse = exports.createBinaryImage = exports.createGroup = void 0;
|
|
27
27
|
const Point = __importStar(require("./point"));
|
|
28
|
+
const DashStyle = __importStar(require("./dash-style"));
|
|
28
29
|
function createGroup(name, children) {
|
|
29
30
|
return {
|
|
30
31
|
type: "group",
|
|
@@ -44,59 +45,65 @@ function createBinaryImage(topLeft, bottomRight, format, data, id) {
|
|
|
44
45
|
};
|
|
45
46
|
}
|
|
46
47
|
exports.createBinaryImage = createBinaryImage;
|
|
47
|
-
function createEllipse(topLeft, bottomRight, strokeColor, strokeThickness, fillColor, id) {
|
|
48
|
+
function createEllipse(topLeft, bottomRight, strokeColor, strokeThickness, fillColor, id, strokeDashStyle = DashStyle.solidLine) {
|
|
48
49
|
return {
|
|
49
50
|
type: "ellipse",
|
|
50
51
|
topLeft: topLeft,
|
|
51
52
|
bottomRight: bottomRight,
|
|
52
53
|
strokeColor: strokeColor,
|
|
53
54
|
strokeThickness: strokeThickness,
|
|
55
|
+
strokeDashStyle: strokeDashStyle,
|
|
54
56
|
fillColor: fillColor,
|
|
55
57
|
id: id,
|
|
56
58
|
};
|
|
57
59
|
}
|
|
58
60
|
exports.createEllipse = createEllipse;
|
|
59
|
-
function createLine(start, end, strokeColor, strokeThickness, id) {
|
|
61
|
+
function createLine(start, end, strokeColor, strokeThickness, id, strokeDashStyle = DashStyle.solidLine) {
|
|
60
62
|
return {
|
|
61
63
|
type: "line",
|
|
62
64
|
start: start,
|
|
63
65
|
end: end,
|
|
64
66
|
strokeColor: strokeColor,
|
|
65
67
|
strokeThickness: strokeThickness,
|
|
68
|
+
strokeDashStyle: strokeDashStyle,
|
|
66
69
|
id: id,
|
|
67
70
|
};
|
|
68
71
|
}
|
|
69
72
|
exports.createLine = createLine;
|
|
70
|
-
function createPolyLine(points, strokeColor, strokeThickness, id) {
|
|
73
|
+
function createPolyLine(points, strokeColor, strokeThickness, id, strokeDashStyle = DashStyle.solidLine) {
|
|
71
74
|
return {
|
|
72
75
|
type: "polyline",
|
|
73
76
|
points: points,
|
|
74
77
|
strokeColor: strokeColor,
|
|
75
78
|
strokeThickness: strokeThickness,
|
|
79
|
+
strokeDashStyle: strokeDashStyle,
|
|
76
80
|
id: id,
|
|
77
81
|
};
|
|
78
82
|
}
|
|
79
83
|
exports.createPolyLine = createPolyLine;
|
|
80
|
-
function createPolygon(points, strokeColor, strokeThickness, fillColor, id) {
|
|
84
|
+
function createPolygon(points, strokeColor, strokeThickness, fillColor, id, strokeDashStyle = DashStyle.solidLine) {
|
|
81
85
|
return {
|
|
82
86
|
type: "polygon",
|
|
83
87
|
points: points,
|
|
84
88
|
strokeColor: strokeColor,
|
|
85
89
|
strokeThickness: strokeThickness,
|
|
90
|
+
strokeDashStyle: strokeDashStyle,
|
|
86
91
|
fillColor: fillColor,
|
|
87
92
|
id: id,
|
|
88
93
|
};
|
|
89
94
|
}
|
|
90
95
|
exports.createPolygon = createPolygon;
|
|
91
|
-
function createRectangle(topLeft, bottomRight, strokeColor, strokeThickness, fillColor, id) {
|
|
96
|
+
function createRectangle(topLeft, bottomRight, strokeColor, strokeThickness, fillColor, id, strokeDashStyle = DashStyle.solidLine, radius) {
|
|
92
97
|
return {
|
|
93
98
|
type: "rectangle",
|
|
94
99
|
topLeft: topLeft,
|
|
95
100
|
bottomRight: bottomRight,
|
|
96
101
|
strokeColor: strokeColor,
|
|
97
102
|
strokeThickness: strokeThickness,
|
|
103
|
+
strokeDashStyle: strokeDashStyle,
|
|
98
104
|
fillColor: fillColor,
|
|
99
105
|
id: id,
|
|
106
|
+
radius,
|
|
100
107
|
};
|
|
101
108
|
}
|
|
102
109
|
exports.createRectangle = createRectangle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/model/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/model/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AAEjC,wDAA0C;AAW1C,SAAgB,WAAW,CAAC,IAAY,EAAE,QAA0B;IAClE,OAAO;QACL,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,QAAQ;KACnB,CAAC;AACJ,CAAC;AAND,kCAMC;AA6BD,SAAgB,iBAAiB,CAC/B,OAAoB,EACpB,WAAwB,EACxB,MAAoB,EACpB,IAAe,EACf,EAAW;IAEX,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,WAAW;QACxB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI;QACV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,yBAAyB;QACzB,uBAAuB;QACvB,eAAe;QACf,WAAW;QACX,MAAM;QACN,EAAE;KACH,CAAC;AACJ,CAAC;AAjCD,gCAiCC;AAQD,SAAgB,cAAc,CAAC,OAAoB,EAAE,KAAgB;IACnE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC9C,CAAC;AAFD,wCAEC;AAED,SAAgB,kBAAkB,CAAC,OAAoB,EAAE,IAAY,EAAE,KAAkC;IACvG,OAAO,cAAc,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AACtE,CAAC;AAFD,gDAEC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface DashStyle {
|
|
2
|
+
readonly dashes: ReadonlyArray<number>;
|
|
3
|
+
readonly offset: number;
|
|
4
|
+
}
|
|
5
|
+
export declare function createDashStyle(dashes: ReadonlyArray<number>, offset?: number): DashStyle;
|
|
6
|
+
export declare const solidLine: DashStyle;
|
|
7
|
+
//# sourceMappingURL=dash-style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dash-style.d.ts","sourceRoot":"","sources":["../../src/model/dash-style.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,GAAE,MAAU,GAAG,SAAS,CAK5F;AAED,eAAO,MAAM,SAAS,WAAsB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.solidLine = exports.createDashStyle = void 0;
|
|
4
|
+
function createDashStyle(dashes, offset = 0) {
|
|
5
|
+
return {
|
|
6
|
+
dashes: dashes,
|
|
7
|
+
offset: offset,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
exports.createDashStyle = createDashStyle;
|
|
11
|
+
exports.solidLine = createDashStyle([]);
|
|
12
|
+
//# sourceMappingURL=dash-style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dash-style.js","sourceRoot":"","sources":["../../src/model/dash-style.ts"],"names":[],"mappings":";;;AAKA,SAAgB,eAAe,CAAC,MAA6B,EAAE,SAAiB,CAAC;IAC/E,OAAO;QACL,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,MAAM;KACf,CAAC;AACJ,CAAC;AALD,0CAKC;AAEY,QAAA,SAAS,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC"}
|
package/lib/model/index.d.ts
CHANGED
package/lib/model/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC"}
|
package/lib/model/index.js
CHANGED
|
@@ -19,4 +19,5 @@ __exportStar(require("./color"), exports);
|
|
|
19
19
|
__exportStar(require("./component"), exports);
|
|
20
20
|
__exportStar(require("./point"), exports);
|
|
21
21
|
__exportStar(require("./size"), exports);
|
|
22
|
+
__exportStar(require("./dash-style"), exports);
|
|
22
23
|
//# sourceMappingURL=index.js.map
|
package/lib/model/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,0CAAwB;AACxB,8CAA4B;AAC5B,0CAAwB;AACxB,yCAAuB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,0CAAwB;AACxB,8CAA4B;AAC5B,0CAAwB;AACxB,yCAAuB;AACvB,+CAA6B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "abstract-image",
|
|
3
|
-
"version": "8.1
|
|
3
|
+
"version": "8.2.1",
|
|
4
4
|
"description": "Dynamically create images using code or JSX and render to any format",
|
|
5
5
|
"repository": "https://github.com/dividab/abstract-visuals/tree/master/packages/abstract-image",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"@types/react": "^18.3.3",
|
|
25
25
|
"@types/react-dom": "^18.3.0"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "7a35c6d3b98bb18e168f34e501234b330cbc20c5"
|
|
28
28
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ExportTestDef } from "../export-test-def";
|
|
2
|
+
import * as AbstractImage from "../../../../../src/index";
|
|
3
|
+
|
|
4
|
+
const components = [
|
|
5
|
+
AbstractImage.createLine(
|
|
6
|
+
AbstractImage.createPoint(10, 100),
|
|
7
|
+
AbstractImage.createPoint(40, 70),
|
|
8
|
+
AbstractImage.black,
|
|
9
|
+
2,
|
|
10
|
+
undefined,
|
|
11
|
+
AbstractImage.createDashStyle([10, 5], 3)
|
|
12
|
+
),
|
|
13
|
+
];
|
|
14
|
+
const image = AbstractImage.createAbstractImage(
|
|
15
|
+
AbstractImage.createPoint(0, 0),
|
|
16
|
+
AbstractImage.createSize(400, 400),
|
|
17
|
+
AbstractImage.white,
|
|
18
|
+
components
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const svg = AbstractImage.createReactSvg(image);
|
|
22
|
+
|
|
23
|
+
export const test: ExportTestDef = {
|
|
24
|
+
name: "react svg dashed line",
|
|
25
|
+
abstractImage: svg,
|
|
26
|
+
expectedSerializedJsx:
|
|
27
|
+
'{"type":"svg","key":null,"ref":null,"props":{"id":"ai_root","width":"400px","height":"400px","viewBox":"0 0 400 400","children":[{"key":"0","ref":null,"props":{"component":{"type":"line","start":{"x":10,"y":100},"end":{"x":40,"y":70},"strokeColor":{"a":255,"r":0,"g":0,"b":0},"strokeThickness":2,"strokeDashStyle":{"dashes":[10,5],"offset":3}}},"_owner":null,"_store":{}}]},"_owner":null,"_store":{}}',
|
|
28
|
+
};
|
|
@@ -24,5 +24,5 @@ export const test: ExportTestDef = {
|
|
|
24
24
|
name: "react svg ellipse",
|
|
25
25
|
abstractImage: svg,
|
|
26
26
|
expectedSerializedJsx:
|
|
27
|
-
'{"type":"svg","key":null,"ref":null,"props":{"id":"ai_root","width":"400px","height":"400px","viewBox":"0 0 400 400","children":[{"key":"0","ref":null,"props":{"component":{"type":"ellipse","topLeft":{"x":50,"y":50},"bottomRight":{"x":100,"y":100},"strokeColor":{"a":255,"r":0,"g":128,"b":0},"strokeThickness":2,"fillColor":{"a":255,"r":255,"g":255,"b":0}}},"_owner":null,"_store":{}}]},"_owner":null,"_store":{}}',
|
|
27
|
+
'{"type":"svg","key":null,"ref":null,"props":{"id":"ai_root","width":"400px","height":"400px","viewBox":"0 0 400 400","children":[{"key":"0","ref":null,"props":{"component":{"type":"ellipse","topLeft":{"x":50,"y":50},"bottomRight":{"x":100,"y":100},"strokeColor":{"a":255,"r":0,"g":128,"b":0},"strokeThickness":2,"strokeDashStyle":{"dashes":[],"offset":0},"fillColor":{"a":255,"r":255,"g":255,"b":0}}},"_owner":null,"_store":{}}]},"_owner":null,"_store":{}}',
|
|
28
28
|
};
|
|
@@ -40,5 +40,5 @@ export const test: ExportTestDef = {
|
|
|
40
40
|
name: "react svg group",
|
|
41
41
|
abstractImage: svg,
|
|
42
42
|
expectedSerializedJsx:
|
|
43
|
-
'{"type":"svg","key":null,"ref":null,"props":{"id":"ai_root","width":"400px","height":"400px","viewBox":"0 0 400 400","children":[{"key":"0","ref":null,"props":{"component":{"type":"group","name":"group","children":[{"type":"text","position":{"x":200,"y":200},"text":"Test","fontFamily":"Helvetica","fontSize":12,"textColor":{"a":255,"r":0,"g":0,"b":0},"fontWeight":"normal","clockwiseRotationDegrees":0,"textAlignment":"center","horizontalGrowthDirection":"uniform","verticalGrowthDirection":"uniform","strokeThickness":0,"strokeColor":{"a":255,"r":0,"g":0,"b":0},"italic":false},{"type":"rectangle","topLeft":{"x":10,"y":50},"bottomRight":{"x":50,"y":60},"strokeColor":{"a":255,"r":0,"g":0,"b":255},"strokeThickness":2,"fillColor":{"a":255,"r":255,"g":0,"b":0}}]}},"_owner":null,"_store":{}}]},"_owner":null,"_store":{}}',
|
|
43
|
+
'{"type":"svg","key":null,"ref":null,"props":{"id":"ai_root","width":"400px","height":"400px","viewBox":"0 0 400 400","children":[{"key":"0","ref":null,"props":{"component":{"type":"group","name":"group","children":[{"type":"text","position":{"x":200,"y":200},"text":"Test","fontFamily":"Helvetica","fontSize":12,"textColor":{"a":255,"r":0,"g":0,"b":0},"fontWeight":"normal","clockwiseRotationDegrees":0,"textAlignment":"center","horizontalGrowthDirection":"uniform","verticalGrowthDirection":"uniform","strokeThickness":0,"strokeColor":{"a":255,"r":0,"g":0,"b":0},"italic":false},{"type":"rectangle","topLeft":{"x":10,"y":50},"bottomRight":{"x":50,"y":60},"strokeColor":{"a":255,"r":0,"g":0,"b":255},"strokeThickness":2,"strokeDashStyle":{"dashes":[],"offset":0},"fillColor":{"a":255,"r":255,"g":0,"b":0}}]}},"_owner":null,"_store":{}}]},"_owner":null,"_store":{}}',
|
|
44
44
|
};
|
|
@@ -22,5 +22,5 @@ export const test: ExportTestDef = {
|
|
|
22
22
|
name: "react svg line",
|
|
23
23
|
abstractImage: svg,
|
|
24
24
|
expectedSerializedJsx:
|
|
25
|
-
'{"type":"svg","key":null,"ref":null,"props":{"id":"ai_root","width":"400px","height":"400px","viewBox":"0 0 400 400","children":[{"key":"0","ref":null,"props":{"component":{"type":"line","start":{"x":10,"y":100},"end":{"x":40,"y":70},"strokeColor":{"a":255,"r":0,"g":0,"b":0},"strokeThickness":2}},"_owner":null,"_store":{}}]},"_owner":null,"_store":{}}',
|
|
25
|
+
'{"type":"svg","key":null,"ref":null,"props":{"id":"ai_root","width":"400px","height":"400px","viewBox":"0 0 400 400","children":[{"key":"0","ref":null,"props":{"component":{"type":"line","start":{"x":10,"y":100},"end":{"x":40,"y":70},"strokeColor":{"a":255,"r":0,"g":0,"b":0},"strokeThickness":2,"strokeDashStyle":{"dashes":[],"offset":0}}},"_owner":null,"_store":{}}]},"_owner":null,"_store":{}}',
|
|
26
26
|
};
|
|
@@ -28,5 +28,5 @@ export const test: ExportTestDef = {
|
|
|
28
28
|
name: "react svg polygon",
|
|
29
29
|
abstractImage: svg,
|
|
30
30
|
expectedSerializedJsx:
|
|
31
|
-
'{"type":"svg","key":null,"ref":null,"props":{"id":"ai_root","width":"400px","height":"400px","viewBox":"0 0 400 400","children":[{"key":"0","ref":null,"props":{"component":{"type":"polygon","points":[{"x":110,"y":10},{"x":100,"y":20},{"x":110,"y":30},{"x":100,"y":40},{"x":110,"y":50}],"strokeColor":{"a":255,"r":0,"g":0,"b":255},"strokeThickness":2,"fillColor":{"a":255,"r":255,"g":0,"b":0}}},"_owner":null,"_store":{}}]},"_owner":null,"_store":{}}',
|
|
31
|
+
'{"type":"svg","key":null,"ref":null,"props":{"id":"ai_root","width":"400px","height":"400px","viewBox":"0 0 400 400","children":[{"key":"0","ref":null,"props":{"component":{"type":"polygon","points":[{"x":110,"y":10},{"x":100,"y":20},{"x":110,"y":30},{"x":100,"y":40},{"x":110,"y":50}],"strokeColor":{"a":255,"r":0,"g":0,"b":255},"strokeThickness":2,"strokeDashStyle":{"dashes":[],"offset":0},"fillColor":{"a":255,"r":255,"g":0,"b":0}}},"_owner":null,"_store":{}}]},"_owner":null,"_store":{}}',
|
|
32
32
|
};
|
|
@@ -29,5 +29,5 @@ export const test: ExportTestDef = {
|
|
|
29
29
|
name: "react svg polyline",
|
|
30
30
|
abstractImage: svg,
|
|
31
31
|
expectedSerializedJsx:
|
|
32
|
-
'{"type":"svg","key":null,"ref":null,"props":{"id":"ai_root","width":"400px","height":"400px","viewBox":"0 0 400 400","children":[{"key":"0","ref":null,"props":{"component":{"type":"polyline","points":[{"x":10,"y":40},{"x":20,"y":30},{"x":30,"y":40},{"x":40,"y":30},{"x":50,"y":40},{"x":60,"y":30},{"x":70,"y":40}],"strokeColor":{"a":255,"r":0,"g":0,"b":0},"strokeThickness":2}},"_owner":null,"_store":{}}]},"_owner":null,"_store":{}}',
|
|
32
|
+
'{"type":"svg","key":null,"ref":null,"props":{"id":"ai_root","width":"400px","height":"400px","viewBox":"0 0 400 400","children":[{"key":"0","ref":null,"props":{"component":{"type":"polyline","points":[{"x":10,"y":40},{"x":20,"y":30},{"x":30,"y":40},{"x":40,"y":30},{"x":50,"y":40},{"x":60,"y":30},{"x":70,"y":40}],"strokeColor":{"a":255,"r":0,"g":0,"b":0},"strokeThickness":2,"strokeDashStyle":{"dashes":[],"offset":0}}},"_owner":null,"_store":{}}]},"_owner":null,"_store":{}}',
|
|
33
33
|
};
|
|
@@ -23,5 +23,5 @@ export const test: ExportTestDef = {
|
|
|
23
23
|
name: "react svg rectangle",
|
|
24
24
|
abstractImage: svg,
|
|
25
25
|
expectedSerializedJsx:
|
|
26
|
-
'{"type":"svg","key":null,"ref":null,"props":{"id":"ai_root","width":"400px","height":"400px","viewBox":"0 0 400 400","children":[{"key":"0","ref":null,"props":{"component":{"type":"rectangle","topLeft":{"x":10,"y":50},"bottomRight":{"x":50,"y":60},"strokeColor":{"a":255,"r":0,"g":0,"b":255},"strokeThickness":2,"fillColor":{"a":255,"r":255,"g":0,"b":0}}},"_owner":null,"_store":{}}]},"_owner":null,"_store":{}}',
|
|
26
|
+
'{"type":"svg","key":null,"ref":null,"props":{"id":"ai_root","width":"400px","height":"400px","viewBox":"0 0 400 400","children":[{"key":"0","ref":null,"props":{"component":{"type":"rectangle","topLeft":{"x":10,"y":50},"bottomRight":{"x":50,"y":60},"strokeColor":{"a":255,"r":0,"g":0,"b":255},"strokeThickness":2,"strokeDashStyle":{"dashes":[],"offset":0},"fillColor":{"a":255,"r":255,"g":0,"b":0}}},"_owner":null,"_store":{}}]},"_owner":null,"_store":{}}',
|
|
27
27
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ExportTestDef } from "../export-test-def";
|
|
2
|
+
import * as AbstractImage from "../../../../../src/index";
|
|
3
|
+
|
|
4
|
+
const components = [
|
|
5
|
+
AbstractImage.createLine(
|
|
6
|
+
AbstractImage.createPoint(10, 100),
|
|
7
|
+
AbstractImage.createPoint(40, 70),
|
|
8
|
+
AbstractImage.black,
|
|
9
|
+
2,
|
|
10
|
+
undefined,
|
|
11
|
+
AbstractImage.createDashStyle([10, 5], 3)
|
|
12
|
+
),
|
|
13
|
+
];
|
|
14
|
+
const image = AbstractImage.createAbstractImage(
|
|
15
|
+
AbstractImage.createPoint(0, 0),
|
|
16
|
+
AbstractImage.createSize(400, 400),
|
|
17
|
+
AbstractImage.white,
|
|
18
|
+
components
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const svg = AbstractImage.createSVG(image);
|
|
22
|
+
|
|
23
|
+
export const test: ExportTestDef = {
|
|
24
|
+
name: "svg dashed line",
|
|
25
|
+
abstractImage: svg,
|
|
26
|
+
expectedImage:
|
|
27
|
+
'<svg xmlns="http://www.w3.org/2000/svg" width="400px" height="400px" viewBox="0 0 400 400"><line x1="10" y1="100" x2="40" y2="70" stroke="rgb(0, 0, 0)" stroke-opacity="1" stroke-width="2" stroke-dasharray="10 5" stroke-dashoffset="3"></line></svg>',
|
|
28
|
+
};
|
|
@@ -91,7 +91,11 @@ function Component({ component }: { readonly component: AbstractImage.Component
|
|
|
91
91
|
/>
|
|
92
92
|
);
|
|
93
93
|
|
|
94
|
-
case "line":
|
|
94
|
+
case "line": {
|
|
95
|
+
const strokeDasharray =
|
|
96
|
+
component.strokeDashStyle.dashes.length > 0 ? component.strokeDashStyle.dashes.join(" ") : undefined;
|
|
97
|
+
const strokeDashoffset =
|
|
98
|
+
component.strokeDashStyle.dashes.length > 0 ? component.strokeDashStyle.offset : undefined;
|
|
95
99
|
return (
|
|
96
100
|
<line
|
|
97
101
|
id={makeIdAttr(component.id)}
|
|
@@ -102,9 +106,11 @@ function Component({ component }: { readonly component: AbstractImage.Component
|
|
|
102
106
|
stroke={colorToRgb(component.strokeColor)}
|
|
103
107
|
strokeWidth={component.strokeThickness}
|
|
104
108
|
strokeOpacity={colorToOpacity(component.strokeColor)}
|
|
109
|
+
strokeDasharray={strokeDasharray}
|
|
110
|
+
strokeDashoffset={strokeDashoffset}
|
|
105
111
|
/>
|
|
106
112
|
);
|
|
107
|
-
|
|
113
|
+
}
|
|
108
114
|
case "text": {
|
|
109
115
|
if (!component.text) {
|
|
110
116
|
return <></>;
|
|
@@ -153,11 +159,15 @@ function Component({ component }: { readonly component: AbstractImage.Component
|
|
|
153
159
|
</>
|
|
154
160
|
);
|
|
155
161
|
}
|
|
156
|
-
case "ellipse":
|
|
162
|
+
case "ellipse": {
|
|
157
163
|
const rx = Math.abs(component.bottomRight.x - component.topLeft.x) * 0.5;
|
|
158
164
|
const ry = Math.abs(component.bottomRight.y - component.topLeft.y) * 0.5;
|
|
159
165
|
const cx = (component.bottomRight.x + component.topLeft.x) * 0.5;
|
|
160
166
|
const cy = (component.bottomRight.y + component.topLeft.y) * 0.5;
|
|
167
|
+
const strokeDasharray =
|
|
168
|
+
component.strokeDashStyle.dashes.length > 0 ? component.strokeDashStyle.dashes.join(" ") : undefined;
|
|
169
|
+
const strokeDashoffset =
|
|
170
|
+
component.strokeDashStyle.dashes.length > 0 ? component.strokeDashStyle.offset : undefined;
|
|
161
171
|
return (
|
|
162
172
|
<ellipse
|
|
163
173
|
id={makeIdAttr(component.id)}
|
|
@@ -168,12 +178,19 @@ function Component({ component }: { readonly component: AbstractImage.Component
|
|
|
168
178
|
stroke={colorToRgb(component.strokeColor)}
|
|
169
179
|
strokeWidth={component.strokeThickness}
|
|
170
180
|
strokeOpacity={colorToOpacity(component.strokeColor)}
|
|
181
|
+
strokeDasharray={strokeDasharray}
|
|
182
|
+
strokeDashoffset={strokeDashoffset}
|
|
171
183
|
fillOpacity={colorToOpacity(component.fillColor)}
|
|
172
184
|
fill={colorToRgb(component.fillColor)}
|
|
173
185
|
/>
|
|
174
186
|
);
|
|
175
|
-
|
|
187
|
+
}
|
|
188
|
+
case "polyline": {
|
|
176
189
|
let linePoints = component.points.map((p) => p.x.toString() + "," + p.y.toString()).join(" ");
|
|
190
|
+
const strokeDasharray =
|
|
191
|
+
component.strokeDashStyle.dashes.length > 0 ? component.strokeDashStyle.dashes.join(" ") : undefined;
|
|
192
|
+
const strokeDashoffset =
|
|
193
|
+
component.strokeDashStyle.dashes.length > 0 ? component.strokeDashStyle.offset : undefined;
|
|
177
194
|
return (
|
|
178
195
|
<polyline
|
|
179
196
|
id={makeIdAttr(component.id)}
|
|
@@ -181,11 +198,18 @@ function Component({ component }: { readonly component: AbstractImage.Component
|
|
|
181
198
|
stroke={colorToRgb(component.strokeColor)}
|
|
182
199
|
strokeWidth={component.strokeThickness}
|
|
183
200
|
strokeOpacity={colorToOpacity(component.strokeColor)}
|
|
201
|
+
strokeDasharray={strokeDasharray}
|
|
202
|
+
strokeDashoffset={strokeDashoffset}
|
|
184
203
|
fill="none"
|
|
185
204
|
/>
|
|
186
205
|
);
|
|
187
|
-
|
|
206
|
+
}
|
|
207
|
+
case "polygon": {
|
|
188
208
|
let points = component.points.map((p) => p.x.toString() + "," + p.y.toString()).join(" ");
|
|
209
|
+
const strokeDasharray =
|
|
210
|
+
component.strokeDashStyle.dashes.length > 0 ? component.strokeDashStyle.dashes.join(" ") : undefined;
|
|
211
|
+
const strokeDashoffset =
|
|
212
|
+
component.strokeDashStyle.dashes.length > 0 ? component.strokeDashStyle.offset : undefined;
|
|
189
213
|
return (
|
|
190
214
|
<polygon
|
|
191
215
|
id={makeIdAttr(component.id)}
|
|
@@ -193,11 +217,18 @@ function Component({ component }: { readonly component: AbstractImage.Component
|
|
|
193
217
|
stroke={colorToRgb(component.strokeColor)}
|
|
194
218
|
strokeWidth={component.strokeThickness}
|
|
195
219
|
strokeOpacity={colorToOpacity(component.strokeColor)}
|
|
220
|
+
strokeDasharray={strokeDasharray}
|
|
221
|
+
strokeDashoffset={strokeDashoffset}
|
|
196
222
|
fillOpacity={colorToOpacity(component.fillColor)}
|
|
197
223
|
fill={colorToRgb(component.fillColor)}
|
|
198
224
|
/>
|
|
199
225
|
);
|
|
200
|
-
|
|
226
|
+
}
|
|
227
|
+
case "rectangle": {
|
|
228
|
+
const strokeDasharray =
|
|
229
|
+
component.strokeDashStyle.dashes.length > 0 ? component.strokeDashStyle.dashes.join(" ") : undefined;
|
|
230
|
+
const strokeDashoffset =
|
|
231
|
+
component.strokeDashStyle.dashes.length > 0 ? component.strokeDashStyle.offset : undefined;
|
|
201
232
|
return (
|
|
202
233
|
<rect
|
|
203
234
|
id={makeIdAttr(component.id)}
|
|
@@ -208,10 +239,14 @@ function Component({ component }: { readonly component: AbstractImage.Component
|
|
|
208
239
|
stroke={colorToRgb(component.strokeColor)}
|
|
209
240
|
strokeWidth={component.strokeThickness}
|
|
210
241
|
strokeOpacity={colorToOpacity(component.strokeColor)}
|
|
242
|
+
strokeDasharray={strokeDasharray}
|
|
243
|
+
strokeDashoffset={strokeDashoffset}
|
|
211
244
|
fillOpacity={colorToOpacity(component.fillColor)}
|
|
245
|
+
{...(component.radius ? { rx: component.radius.x.toString(), ry: component.radius.y.toString() } : {})}
|
|
212
246
|
fill={colorToRgb(component.fillColor)}
|
|
213
247
|
/>
|
|
214
248
|
);
|
|
249
|
+
}
|
|
215
250
|
default:
|
|
216
251
|
return <></>;
|
|
217
252
|
}
|
|
@@ -41,7 +41,14 @@ function abstractComponentToSVG(component: AbstractImage.Component): string {
|
|
|
41
41
|
);
|
|
42
42
|
case "subimage":
|
|
43
43
|
return "";
|
|
44
|
-
case "line":
|
|
44
|
+
case "line": {
|
|
45
|
+
const dashStyle: Attributes =
|
|
46
|
+
component.strokeDashStyle.dashes.length > 0
|
|
47
|
+
? {
|
|
48
|
+
strokeDasharray: component.strokeDashStyle.dashes.join(" "),
|
|
49
|
+
strokeDashoffset: component.strokeDashStyle.offset.toString(),
|
|
50
|
+
}
|
|
51
|
+
: {};
|
|
45
52
|
return createElement(
|
|
46
53
|
"line",
|
|
47
54
|
{
|
|
@@ -52,10 +59,19 @@ function abstractComponentToSVG(component: AbstractImage.Component): string {
|
|
|
52
59
|
stroke: colorToRgb(component.strokeColor),
|
|
53
60
|
strokeOpacity: colorToOpacity(component.strokeColor),
|
|
54
61
|
strokeWidth: component.strokeThickness.toString(),
|
|
62
|
+
...dashStyle,
|
|
55
63
|
},
|
|
56
64
|
[]
|
|
57
65
|
);
|
|
58
|
-
|
|
66
|
+
}
|
|
67
|
+
case "polyline": {
|
|
68
|
+
const dashStyle: Attributes =
|
|
69
|
+
component.strokeDashStyle.dashes.length > 0
|
|
70
|
+
? {
|
|
71
|
+
strokeDasharray: component.strokeDashStyle.dashes.join(" "),
|
|
72
|
+
strokeDashoffset: component.strokeDashStyle.offset.toString(),
|
|
73
|
+
}
|
|
74
|
+
: {};
|
|
59
75
|
return createElement(
|
|
60
76
|
"polyline",
|
|
61
77
|
{
|
|
@@ -64,9 +80,11 @@ function abstractComponentToSVG(component: AbstractImage.Component): string {
|
|
|
64
80
|
stroke: colorToRgb(component.strokeColor),
|
|
65
81
|
strokeOpacity: colorToOpacity(component.strokeColor),
|
|
66
82
|
strokeWidth: component.strokeThickness.toString(),
|
|
83
|
+
...dashStyle,
|
|
67
84
|
},
|
|
68
85
|
[]
|
|
69
86
|
);
|
|
87
|
+
}
|
|
70
88
|
case "text":
|
|
71
89
|
if (!component.text) {
|
|
72
90
|
return "";
|
|
@@ -128,7 +146,14 @@ function abstractComponentToSVG(component: AbstractImage.Component): string {
|
|
|
128
146
|
}
|
|
129
147
|
cs.push(createElement("text", { style: objectToAttributeValue(style), transform: transform }, tSpans));
|
|
130
148
|
return cs.join();
|
|
131
|
-
case "ellipse":
|
|
149
|
+
case "ellipse": {
|
|
150
|
+
const dashStyle: Attributes =
|
|
151
|
+
component.strokeDashStyle.dashes.length > 0
|
|
152
|
+
? {
|
|
153
|
+
strokeDasharray: component.strokeDashStyle.dashes.join(" "),
|
|
154
|
+
strokeDashoffset: component.strokeDashStyle.offset.toString(),
|
|
155
|
+
}
|
|
156
|
+
: {};
|
|
132
157
|
const rx = Math.abs(component.bottomRight.x - component.topLeft.x) * 0.5;
|
|
133
158
|
const ry = Math.abs(component.bottomRight.y - component.topLeft.y) * 0.5;
|
|
134
159
|
const cx = (component.bottomRight.x + component.topLeft.x) * 0.5;
|
|
@@ -145,10 +170,19 @@ function abstractComponentToSVG(component: AbstractImage.Component): string {
|
|
|
145
170
|
strokeWidth: component.strokeThickness.toString(),
|
|
146
171
|
fill: colorToRgb(component.fillColor),
|
|
147
172
|
fillOpacity: colorToOpacity(component.fillColor),
|
|
173
|
+
...dashStyle,
|
|
148
174
|
},
|
|
149
175
|
[]
|
|
150
176
|
);
|
|
151
|
-
|
|
177
|
+
}
|
|
178
|
+
case "polygon": {
|
|
179
|
+
const dashStyle: Attributes =
|
|
180
|
+
component.strokeDashStyle.dashes.length > 0
|
|
181
|
+
? {
|
|
182
|
+
strokeDasharray: component.strokeDashStyle.dashes.join(" "),
|
|
183
|
+
strokeDashoffset: component.strokeDashStyle.offset.toString(),
|
|
184
|
+
}
|
|
185
|
+
: {};
|
|
152
186
|
return createElement(
|
|
153
187
|
"polygon",
|
|
154
188
|
{
|
|
@@ -158,10 +192,19 @@ function abstractComponentToSVG(component: AbstractImage.Component): string {
|
|
|
158
192
|
strokeWidth: component.strokeThickness.toString(),
|
|
159
193
|
fill: colorToRgb(component.fillColor),
|
|
160
194
|
fillOpacity: colorToOpacity(component.fillColor),
|
|
195
|
+
...dashStyle,
|
|
161
196
|
},
|
|
162
197
|
[]
|
|
163
198
|
);
|
|
164
|
-
|
|
199
|
+
}
|
|
200
|
+
case "rectangle": {
|
|
201
|
+
const dashStyle: Attributes =
|
|
202
|
+
component.strokeDashStyle.dashes.length > 0
|
|
203
|
+
? {
|
|
204
|
+
strokeDasharray: component.strokeDashStyle.dashes.join(" "),
|
|
205
|
+
strokeDashoffset: component.strokeDashStyle.offset.toString(),
|
|
206
|
+
}
|
|
207
|
+
: {};
|
|
165
208
|
return createElement(
|
|
166
209
|
"rect",
|
|
167
210
|
{
|
|
@@ -174,9 +217,12 @@ function abstractComponentToSVG(component: AbstractImage.Component): string {
|
|
|
174
217
|
strokeWidth: component.strokeThickness.toString(),
|
|
175
218
|
fill: colorToRgb(component.fillColor),
|
|
176
219
|
fillOpacity: colorToOpacity(component.fillColor),
|
|
220
|
+
...(component.radius ? { rx: component.radius.x.toString(), ry: component.radius.y.toString() } : {}),
|
|
221
|
+
...dashStyle,
|
|
177
222
|
},
|
|
178
223
|
[]
|
|
179
224
|
);
|
|
225
|
+
}
|
|
180
226
|
default:
|
|
181
227
|
return "";
|
|
182
228
|
}
|
package/src/index.ts
CHANGED