abstract-image 3.3.2 → 3.4.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.
Files changed (118) hide show
  1. package/CHANGELOG.md +54 -38
  2. package/LICENSE +21 -21
  3. package/README.md +73 -73
  4. package/lib/_tests_/exporters/svg-export-image.test.d.ts.map +1 -0
  5. package/lib/_tests_/exporters/svg-export-image.test.js.map +1 -0
  6. package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-ellipse.js +379 -379
  7. package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-group.js +123 -123
  8. package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-line.js +55 -55
  9. package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-polygon.js +89 -89
  10. package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-polyline.js +79 -79
  11. package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-rectangle.js +99 -99
  12. package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text-growth-directions.js +135 -135
  13. package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text.js +63 -63
  14. package/lib/exporters/__tests__/eps-export-image/export.test.js +1 -1
  15. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-ellipse.js +24 -24
  16. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-empty-text.js +26 -26
  17. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-group.js +31 -31
  18. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-line.js +20 -20
  19. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-polygon.js +34 -34
  20. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-polyline.js +26 -26
  21. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-rectangle.js +20 -20
  22. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text-growth-directions.js +59 -59
  23. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text-iso-latin1-encoding.d.ts +3 -0
  24. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text-iso-latin1-encoding.d.ts.map +1 -0
  25. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text-iso-latin1-encoding.js +71 -0
  26. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text-iso-latin1-encoding.js.map +1 -0
  27. package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text.js +26 -26
  28. package/lib/exporters/eps-export-image.d.ts +2 -0
  29. package/lib/exporters/eps-export-image.d.ts.map +1 -1
  30. package/lib/exporters/eps-export-image.js +113 -32
  31. package/lib/exporters/eps-export-image.js.map +1 -1
  32. package/package.json +4 -2
  33. package/src/__stories__/react-svg-export/example-1.stories.tsx +54 -54
  34. package/src/__stories__/svg-export/example-1.stories.tsx +42 -42
  35. package/src/exporters/__tests__/dxf2d-export-image/export-test-def.ts +11 -11
  36. package/src/exporters/__tests__/dxf2d-export-image/export.test.tsx +13 -13
  37. package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-ellipse.ts +405 -405
  38. package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-group.ts +166 -166
  39. package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-line.ts +80 -80
  40. package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-polygon.ts +114 -114
  41. package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-polyline.ts +103 -103
  42. package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-rectangle.ts +125 -125
  43. package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text-growth-directions.ts +214 -214
  44. package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text.ts +97 -97
  45. package/src/exporters/__tests__/eps-export-image/export-test-def.ts +11 -11
  46. package/src/exporters/__tests__/eps-export-image/export.test.tsx +13 -13
  47. package/src/exporters/__tests__/eps-export-image/test-defs/eps-ellipse.ts +50 -50
  48. package/src/exporters/__tests__/eps-export-image/test-defs/eps-empty-text.ts +60 -60
  49. package/src/exporters/__tests__/eps-export-image/test-defs/eps-group.ts +74 -74
  50. package/src/exporters/__tests__/eps-export-image/test-defs/eps-line.ts +45 -45
  51. package/src/exporters/__tests__/eps-export-image/test-defs/eps-polygon.ts +65 -65
  52. package/src/exporters/__tests__/eps-export-image/test-defs/eps-polyline.ts +58 -58
  53. package/src/exporters/__tests__/eps-export-image/test-defs/eps-rectangle.ts +46 -46
  54. package/src/exporters/__tests__/eps-export-image/test-defs/eps-text-growth-directions.ts +138 -138
  55. package/src/exporters/__tests__/eps-export-image/test-defs/eps-text-iso-latin1-encoding.ts +71 -0
  56. package/src/exporters/__tests__/eps-export-image/test-defs/eps-text.ts +60 -60
  57. package/src/exporters/__tests__/exception/png-unsupported.test.tsx +25 -25
  58. package/src/exporters/__tests__/exception/react-svg-direction-exception.test.tsx +65 -65
  59. package/src/exporters/__tests__/exception/svg-direction-exception.test.tsx +65 -65
  60. package/src/exporters/__tests__/png-export-image/export-test-def.ts +11 -11
  61. package/src/exporters/__tests__/png-export-image/export.test.tsx +13 -13
  62. package/src/exporters/__tests__/png-export-image/test-defs/png-createPNG.tsx +26 -26
  63. package/src/exporters/__tests__/react-svg-export-image/export-test-def.tsx +13 -13
  64. package/src/exporters/__tests__/react-svg-export-image/export.test.tsx +13 -13
  65. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary-png.tsx +26 -26
  66. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary-url.tsx +26 -26
  67. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary.tsx +25 -25
  68. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-callback.tsx +60 -60
  69. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-ellipse.tsx +28 -28
  70. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-empty-text.tsx +35 -35
  71. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-group.tsx +44 -44
  72. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-line.tsx +26 -26
  73. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-polygon.tsx +32 -32
  74. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-polyline.tsx +33 -33
  75. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-rectangle.tsx +27 -27
  76. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-subimage.tsx +36 -36
  77. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-bold.tsx +50 -50
  78. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-growth-directions.tsx +80 -80
  79. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-italic.tsx +65 -65
  80. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-sub.tsx +35 -35
  81. package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text.tsx +35 -35
  82. package/src/exporters/__tests__/svg-export-image/export-test-def.ts +11 -11
  83. package/src/exporters/__tests__/svg-export-image/export.test.tsx +13 -13
  84. package/src/exporters/__tests__/svg-export-image/test-defs/svg-binary.tsx +25 -25
  85. package/src/exporters/__tests__/svg-export-image/test-defs/svg-ellipse.ts +27 -27
  86. package/src/exporters/__tests__/svg-export-image/test-defs/svg-empty-text.ts +34 -34
  87. package/src/exporters/__tests__/svg-export-image/test-defs/svg-group.ts +44 -44
  88. package/src/exporters/__tests__/svg-export-image/test-defs/svg-line.ts +26 -26
  89. package/src/exporters/__tests__/svg-export-image/test-defs/svg-polygon.ts +32 -32
  90. package/src/exporters/__tests__/svg-export-image/test-defs/svg-polyline.ts +33 -33
  91. package/src/exporters/__tests__/svg-export-image/test-defs/svg-rectangle.ts +27 -27
  92. package/src/exporters/__tests__/svg-export-image/test-defs/svg-text-bold.ts +50 -50
  93. package/src/exporters/__tests__/svg-export-image/test-defs/svg-text-growth-directions.ts +80 -80
  94. package/src/exporters/__tests__/svg-export-image/test-defs/svg-text-italic.ts +65 -65
  95. package/src/exporters/__tests__/svg-export-image/test-defs/svg-text.ts +35 -35
  96. package/src/exporters/dxf2d-export-image.ts +218 -218
  97. package/src/exporters/eps-export-image.ts +233 -154
  98. package/src/exporters/index.ts +3 -3
  99. package/src/exporters/png-export-image.ts +12 -12
  100. package/src/exporters/react-svg-export-image.tsx +315 -315
  101. package/src/exporters/svg-export-image.ts +309 -309
  102. package/src/index.ts +11 -11
  103. package/src/model/__tests__/color/export-test-def.ts +13 -13
  104. package/src/model/__tests__/color/export.test.tsx +14 -14
  105. package/src/model/__tests__/color/test-defs/color-from-string.ts +46 -46
  106. package/src/model/__tests__/color/test-defs/color-to-string.ts +35 -35
  107. package/src/model/__tests__/color/test-defs/color-undefined-2.ts +8 -8
  108. package/src/model/__tests__/color/test-defs/color-undefined.ts +8 -8
  109. package/src/model/abstract-image.ts +25 -25
  110. package/src/model/color.ts +52 -52
  111. package/src/model/component.ts +279 -279
  112. package/src/model/index.ts +5 -5
  113. package/src/model/point.ts +11 -11
  114. package/src/model/size.ts +11 -11
  115. package/lib/exporters/__tests__/svg-export-image.test.d.ts.map +0 -1
  116. package/lib/exporters/__tests__/svg-export-image.test.js.map +0 -1
  117. /package/lib/{exporters/__tests__ → _tests_/exporters}/svg-export-image.test.d.ts +0 -0
  118. /package/lib/{exporters/__tests__ → _tests_/exporters}/svg-export-image.test.js +0 -0
@@ -1,279 +1,279 @@
1
- import * as Point from "./point";
2
- import * as Color from "./color";
3
- import * as AbstractImage from "./abstract-image";
4
-
5
- export type Component = BinaryImage | Ellipse | Line | PolyLine | Polygon | Rectangle | Text | SubImage | Group;
6
-
7
- export interface Group {
8
- readonly type: "group";
9
- readonly name: string;
10
- readonly children: Array<Component>;
11
- }
12
-
13
- export function createGroup(name: string, children: Array<Component>): Group {
14
- return {
15
- type: "group",
16
- name: name,
17
- children: children,
18
- };
19
- }
20
-
21
- /**
22
- * Embed a foreign binary image in any suported format.
23
- */
24
-
25
- export type BinaryFormat = "svg" | "png";
26
-
27
- export interface BinaryImage {
28
- readonly type: "binaryimage";
29
- readonly topLeft: Point.Point;
30
- readonly bottomRight: Point.Point;
31
- readonly format: BinaryFormat;
32
- readonly data: ImageData;
33
- readonly id: string | undefined;
34
- }
35
-
36
- export type ImageData = ImageBytes | ImageUrl;
37
-
38
- export interface ImageBytes {
39
- readonly type: "bytes";
40
- readonly bytes: Uint8Array;
41
- }
42
-
43
- export interface ImageUrl {
44
- readonly type: "url";
45
- readonly url: string;
46
- }
47
-
48
- export function createBinaryImage(
49
- topLeft: Point.Point,
50
- bottomRight: Point.Point,
51
- format: BinaryFormat,
52
- data: ImageData,
53
- id?: string
54
- ): BinaryImage {
55
- return {
56
- type: "binaryimage",
57
- topLeft: topLeft,
58
- bottomRight: bottomRight,
59
- format: format,
60
- data: data,
61
- id: id,
62
- };
63
- }
64
-
65
- export interface Ellipse {
66
- readonly type: "ellipse";
67
- readonly topLeft: Point.Point;
68
- readonly bottomRight: Point.Point;
69
- readonly strokeColor: Color.Color;
70
- readonly strokeThickness: number;
71
- readonly fillColor: Color.Color;
72
- readonly id: string | undefined;
73
- }
74
-
75
- export function createEllipse(
76
- topLeft: Point.Point,
77
- bottomRight: Point.Point,
78
- strokeColor: Color.Color,
79
- strokeThickness: number,
80
- fillColor: Color.Color,
81
- id?: string
82
- ): Ellipse {
83
- return {
84
- type: "ellipse",
85
- topLeft: topLeft,
86
- bottomRight: bottomRight,
87
- strokeColor: strokeColor,
88
- strokeThickness: strokeThickness,
89
- fillColor: fillColor,
90
- id: id,
91
- };
92
- }
93
-
94
- export interface Line {
95
- readonly type: "line";
96
- readonly start: Point.Point;
97
- readonly end: Point.Point;
98
- readonly strokeColor: Color.Color;
99
- readonly strokeThickness: number;
100
- readonly id: string | undefined;
101
- }
102
-
103
- export function createLine(
104
- start: Point.Point,
105
- end: Point.Point,
106
- strokeColor: Color.Color,
107
- strokeThickness: number,
108
- id?: string
109
- ): Line {
110
- return {
111
- type: "line",
112
- start: start,
113
- end: end,
114
- strokeColor: strokeColor,
115
- strokeThickness: strokeThickness,
116
- id: id,
117
- };
118
- }
119
-
120
- export interface PolyLine {
121
- readonly type: "polyline";
122
- readonly points: Array<Point.Point>;
123
- readonly strokeColor: Color.Color;
124
- readonly strokeThickness: number;
125
- readonly id: string | undefined;
126
- }
127
-
128
- export function createPolyLine(
129
- points: Array<Point.Point>,
130
- strokeColor: Color.Color,
131
- strokeThickness: number,
132
- id?: string
133
- ): PolyLine {
134
- return {
135
- type: "polyline",
136
- points: points,
137
- strokeColor: strokeColor,
138
- strokeThickness: strokeThickness,
139
- id: id,
140
- };
141
- }
142
-
143
- export interface Polygon {
144
- readonly type: "polygon";
145
- readonly points: Array<Point.Point>;
146
- readonly strokeColor: Color.Color;
147
- readonly strokeThickness: number;
148
- readonly fillColor: Color.Color;
149
- readonly id: string | undefined;
150
- }
151
-
152
- export function createPolygon(
153
- points: Array<Point.Point>,
154
- strokeColor: Color.Color,
155
- strokeThickness: number,
156
- fillColor: Color.Color,
157
- id?: string
158
- ): Polygon {
159
- return {
160
- type: "polygon",
161
- points: points,
162
- strokeColor: strokeColor,
163
- strokeThickness: strokeThickness,
164
- fillColor: fillColor,
165
- id: id,
166
- };
167
- }
168
-
169
- export interface Rectangle {
170
- readonly type: "rectangle";
171
- readonly topLeft: Point.Point;
172
- readonly bottomRight: Point.Point;
173
- readonly strokeColor: Color.Color;
174
- readonly strokeThickness: number;
175
- readonly fillColor: Color.Color;
176
- readonly id: string | undefined;
177
- }
178
-
179
- export function createRectangle(
180
- topLeft: Point.Point,
181
- bottomRight: Point.Point,
182
- strokeColor: Color.Color,
183
- strokeThickness: number,
184
- fillColor: Color.Color,
185
- id?: string
186
- ): Rectangle {
187
- return {
188
- type: "rectangle",
189
- topLeft: topLeft,
190
- bottomRight: bottomRight,
191
- strokeColor: strokeColor,
192
- strokeThickness: strokeThickness,
193
- fillColor: fillColor,
194
- id: id,
195
- };
196
- }
197
-
198
- export function corners(rectangle: Rectangle): Array<Point.Point> {
199
- return [
200
- rectangle.topLeft,
201
- Point.createPoint(rectangle.bottomRight.x, rectangle.topLeft.y),
202
- rectangle.bottomRight,
203
- Point.createPoint(rectangle.topLeft.x, rectangle.bottomRight.y),
204
- ];
205
- }
206
-
207
- export type AbstractFontWeight = "normal" | "mediumBold" | "bold";
208
-
209
- export type TextAlignment = "left" | "center" | "right";
210
-
211
- export type GrowthDirection = "up" | "down" | "uniform" | "left" | "right";
212
-
213
- export interface Text {
214
- readonly type: "text";
215
- readonly position: Point.Point;
216
- readonly text: string;
217
- readonly fontFamily: string;
218
- readonly fontSize: number;
219
- readonly textColor: Color.Color;
220
- readonly fontWeight: AbstractFontWeight;
221
- readonly clockwiseRotationDegrees: number;
222
- readonly textAlignment: TextAlignment;
223
- readonly horizontalGrowthDirection: GrowthDirection;
224
- readonly verticalGrowthDirection: GrowthDirection;
225
- readonly strokeThickness: number;
226
- readonly strokeColor: Color.Color;
227
- readonly italic: boolean;
228
- }
229
-
230
- export function createText(
231
- position: Point.Point,
232
- text: string,
233
- fontFamily: string,
234
- fontSize: number,
235
- textColor: Color.Color,
236
- fontWeight: AbstractFontWeight,
237
- clockwiseRotationDegrees: number,
238
- textAlignment: TextAlignment,
239
- horizontalGrowthDirection: GrowthDirection,
240
- verticalGrowthDirection: GrowthDirection,
241
- strokeThickness: number,
242
- strokeColor: Color.Color,
243
- italic: boolean
244
- ): Text {
245
- return {
246
- type: "text",
247
- position: position,
248
- text: text,
249
- fontFamily: fontFamily,
250
- fontSize: fontSize,
251
- textColor: textColor,
252
- fontWeight: fontWeight,
253
- clockwiseRotationDegrees: clockwiseRotationDegrees,
254
- textAlignment: textAlignment,
255
- horizontalGrowthDirection: horizontalGrowthDirection,
256
- verticalGrowthDirection: verticalGrowthDirection,
257
- strokeThickness: strokeThickness,
258
- strokeColor: strokeColor,
259
- italic: italic,
260
- };
261
- }
262
-
263
- export interface SubImage {
264
- readonly type: "subimage";
265
- readonly topLeft: Point.Point;
266
- readonly image: Component;
267
- }
268
-
269
- export function createSubImage(topLeft: Point.Point, image: Component): SubImage {
270
- return {
271
- type: "subimage",
272
- topLeft: topLeft,
273
- image: image,
274
- };
275
- }
276
-
277
- export function embedAbstractImage(topLeft: Point.Point, name: string, image: AbstractImage.AbstractImage): Component {
278
- return createSubImage(topLeft, createGroup(name, image.components));
279
- }
1
+ import * as Point from "./point";
2
+ import * as Color from "./color";
3
+ import * as AbstractImage from "./abstract-image";
4
+
5
+ export type Component = BinaryImage | Ellipse | Line | PolyLine | Polygon | Rectangle | Text | SubImage | Group;
6
+
7
+ export interface Group {
8
+ readonly type: "group";
9
+ readonly name: string;
10
+ readonly children: Array<Component>;
11
+ }
12
+
13
+ export function createGroup(name: string, children: Array<Component>): Group {
14
+ return {
15
+ type: "group",
16
+ name: name,
17
+ children: children,
18
+ };
19
+ }
20
+
21
+ /**
22
+ * Embed a foreign binary image in any suported format.
23
+ */
24
+
25
+ export type BinaryFormat = "svg" | "png";
26
+
27
+ export interface BinaryImage {
28
+ readonly type: "binaryimage";
29
+ readonly topLeft: Point.Point;
30
+ readonly bottomRight: Point.Point;
31
+ readonly format: BinaryFormat;
32
+ readonly data: ImageData;
33
+ readonly id: string | undefined;
34
+ }
35
+
36
+ export type ImageData = ImageBytes | ImageUrl;
37
+
38
+ export interface ImageBytes {
39
+ readonly type: "bytes";
40
+ readonly bytes: Uint8Array;
41
+ }
42
+
43
+ export interface ImageUrl {
44
+ readonly type: "url";
45
+ readonly url: string;
46
+ }
47
+
48
+ export function createBinaryImage(
49
+ topLeft: Point.Point,
50
+ bottomRight: Point.Point,
51
+ format: BinaryFormat,
52
+ data: ImageData,
53
+ id?: string
54
+ ): BinaryImage {
55
+ return {
56
+ type: "binaryimage",
57
+ topLeft: topLeft,
58
+ bottomRight: bottomRight,
59
+ format: format,
60
+ data: data,
61
+ id: id,
62
+ };
63
+ }
64
+
65
+ export interface Ellipse {
66
+ readonly type: "ellipse";
67
+ readonly topLeft: Point.Point;
68
+ readonly bottomRight: Point.Point;
69
+ readonly strokeColor: Color.Color;
70
+ readonly strokeThickness: number;
71
+ readonly fillColor: Color.Color;
72
+ readonly id: string | undefined;
73
+ }
74
+
75
+ export function createEllipse(
76
+ topLeft: Point.Point,
77
+ bottomRight: Point.Point,
78
+ strokeColor: Color.Color,
79
+ strokeThickness: number,
80
+ fillColor: Color.Color,
81
+ id?: string
82
+ ): Ellipse {
83
+ return {
84
+ type: "ellipse",
85
+ topLeft: topLeft,
86
+ bottomRight: bottomRight,
87
+ strokeColor: strokeColor,
88
+ strokeThickness: strokeThickness,
89
+ fillColor: fillColor,
90
+ id: id,
91
+ };
92
+ }
93
+
94
+ export interface Line {
95
+ readonly type: "line";
96
+ readonly start: Point.Point;
97
+ readonly end: Point.Point;
98
+ readonly strokeColor: Color.Color;
99
+ readonly strokeThickness: number;
100
+ readonly id: string | undefined;
101
+ }
102
+
103
+ export function createLine(
104
+ start: Point.Point,
105
+ end: Point.Point,
106
+ strokeColor: Color.Color,
107
+ strokeThickness: number,
108
+ id?: string
109
+ ): Line {
110
+ return {
111
+ type: "line",
112
+ start: start,
113
+ end: end,
114
+ strokeColor: strokeColor,
115
+ strokeThickness: strokeThickness,
116
+ id: id,
117
+ };
118
+ }
119
+
120
+ export interface PolyLine {
121
+ readonly type: "polyline";
122
+ readonly points: Array<Point.Point>;
123
+ readonly strokeColor: Color.Color;
124
+ readonly strokeThickness: number;
125
+ readonly id: string | undefined;
126
+ }
127
+
128
+ export function createPolyLine(
129
+ points: Array<Point.Point>,
130
+ strokeColor: Color.Color,
131
+ strokeThickness: number,
132
+ id?: string
133
+ ): PolyLine {
134
+ return {
135
+ type: "polyline",
136
+ points: points,
137
+ strokeColor: strokeColor,
138
+ strokeThickness: strokeThickness,
139
+ id: id,
140
+ };
141
+ }
142
+
143
+ export interface Polygon {
144
+ readonly type: "polygon";
145
+ readonly points: Array<Point.Point>;
146
+ readonly strokeColor: Color.Color;
147
+ readonly strokeThickness: number;
148
+ readonly fillColor: Color.Color;
149
+ readonly id: string | undefined;
150
+ }
151
+
152
+ export function createPolygon(
153
+ points: Array<Point.Point>,
154
+ strokeColor: Color.Color,
155
+ strokeThickness: number,
156
+ fillColor: Color.Color,
157
+ id?: string
158
+ ): Polygon {
159
+ return {
160
+ type: "polygon",
161
+ points: points,
162
+ strokeColor: strokeColor,
163
+ strokeThickness: strokeThickness,
164
+ fillColor: fillColor,
165
+ id: id,
166
+ };
167
+ }
168
+
169
+ export interface Rectangle {
170
+ readonly type: "rectangle";
171
+ readonly topLeft: Point.Point;
172
+ readonly bottomRight: Point.Point;
173
+ readonly strokeColor: Color.Color;
174
+ readonly strokeThickness: number;
175
+ readonly fillColor: Color.Color;
176
+ readonly id: string | undefined;
177
+ }
178
+
179
+ export function createRectangle(
180
+ topLeft: Point.Point,
181
+ bottomRight: Point.Point,
182
+ strokeColor: Color.Color,
183
+ strokeThickness: number,
184
+ fillColor: Color.Color,
185
+ id?: string
186
+ ): Rectangle {
187
+ return {
188
+ type: "rectangle",
189
+ topLeft: topLeft,
190
+ bottomRight: bottomRight,
191
+ strokeColor: strokeColor,
192
+ strokeThickness: strokeThickness,
193
+ fillColor: fillColor,
194
+ id: id,
195
+ };
196
+ }
197
+
198
+ export function corners(rectangle: Rectangle): Array<Point.Point> {
199
+ return [
200
+ rectangle.topLeft,
201
+ Point.createPoint(rectangle.bottomRight.x, rectangle.topLeft.y),
202
+ rectangle.bottomRight,
203
+ Point.createPoint(rectangle.topLeft.x, rectangle.bottomRight.y),
204
+ ];
205
+ }
206
+
207
+ export type AbstractFontWeight = "normal" | "mediumBold" | "bold";
208
+
209
+ export type TextAlignment = "left" | "center" | "right";
210
+
211
+ export type GrowthDirection = "up" | "down" | "uniform" | "left" | "right";
212
+
213
+ export interface Text {
214
+ readonly type: "text";
215
+ readonly position: Point.Point;
216
+ readonly text: string;
217
+ readonly fontFamily: string;
218
+ readonly fontSize: number;
219
+ readonly textColor: Color.Color;
220
+ readonly fontWeight: AbstractFontWeight;
221
+ readonly clockwiseRotationDegrees: number;
222
+ readonly textAlignment: TextAlignment;
223
+ readonly horizontalGrowthDirection: GrowthDirection;
224
+ readonly verticalGrowthDirection: GrowthDirection;
225
+ readonly strokeThickness: number;
226
+ readonly strokeColor: Color.Color;
227
+ readonly italic: boolean;
228
+ }
229
+
230
+ export function createText(
231
+ position: Point.Point,
232
+ text: string,
233
+ fontFamily: string,
234
+ fontSize: number,
235
+ textColor: Color.Color,
236
+ fontWeight: AbstractFontWeight,
237
+ clockwiseRotationDegrees: number,
238
+ textAlignment: TextAlignment,
239
+ horizontalGrowthDirection: GrowthDirection,
240
+ verticalGrowthDirection: GrowthDirection,
241
+ strokeThickness: number,
242
+ strokeColor: Color.Color,
243
+ italic: boolean
244
+ ): Text {
245
+ return {
246
+ type: "text",
247
+ position: position,
248
+ text: text,
249
+ fontFamily: fontFamily,
250
+ fontSize: fontSize,
251
+ textColor: textColor,
252
+ fontWeight: fontWeight,
253
+ clockwiseRotationDegrees: clockwiseRotationDegrees,
254
+ textAlignment: textAlignment,
255
+ horizontalGrowthDirection: horizontalGrowthDirection,
256
+ verticalGrowthDirection: verticalGrowthDirection,
257
+ strokeThickness: strokeThickness,
258
+ strokeColor: strokeColor,
259
+ italic: italic,
260
+ };
261
+ }
262
+
263
+ export interface SubImage {
264
+ readonly type: "subimage";
265
+ readonly topLeft: Point.Point;
266
+ readonly image: Component;
267
+ }
268
+
269
+ export function createSubImage(topLeft: Point.Point, image: Component): SubImage {
270
+ return {
271
+ type: "subimage",
272
+ topLeft: topLeft,
273
+ image: image,
274
+ };
275
+ }
276
+
277
+ export function embedAbstractImage(topLeft: Point.Point, name: string, image: AbstractImage.AbstractImage): Component {
278
+ return createSubImage(topLeft, createGroup(name, image.components));
279
+ }
@@ -1,5 +1,5 @@
1
- export * from "./abstract-image";
2
- export * from "./color";
3
- export * from "./component";
4
- export * from "./point";
5
- export * from "./size";
1
+ export * from "./abstract-image";
2
+ export * from "./color";
3
+ export * from "./component";
4
+ export * from "./point";
5
+ export * from "./size";
@@ -1,11 +1,11 @@
1
- export interface Point {
2
- readonly x: number;
3
- readonly y: number;
4
- }
5
-
6
- export function createPoint(x: number, y: number): Point {
7
- return {
8
- x: x,
9
- y: y
10
- };
11
- }
1
+ export interface Point {
2
+ readonly x: number;
3
+ readonly y: number;
4
+ }
5
+
6
+ export function createPoint(x: number, y: number): Point {
7
+ return {
8
+ x: x,
9
+ y: y
10
+ };
11
+ }
package/src/model/size.ts CHANGED
@@ -1,11 +1,11 @@
1
- export interface Size {
2
- readonly width: number;
3
- readonly height: number;
4
- }
5
-
6
- export function createSize(width: number, height: number): Size {
7
- return {
8
- width: width,
9
- height: height
10
- };
11
- }
1
+ export interface Size {
2
+ readonly width: number;
3
+ readonly height: number;
4
+ }
5
+
6
+ export function createSize(width: number, height: number): Size {
7
+ return {
8
+ width: width,
9
+ height: height
10
+ };
11
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"svg-export-image.test.d.ts","sourceRoot":"","sources":["../../../src/exporters/__tests__/svg-export-image.test.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"svg-export-image.test.js","sourceRoot":"","sources":["../../../src/exporters/__tests__/svg-export-image.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,kEAAoD;AAEpD,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,UAAU,GAAG;YACjB,aAAa,CAAC,UAAU,CACtB,aAAa,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,CAAC,EACjC,aAAa,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,CAAC,EACjC,aAAa,CAAC,KAAK,EACnB,CAAC,CACF;YACD,aAAa,CAAC,eAAe,CAC3B,aAAa,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,CAAC,EACjC,aAAa,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,CAAC,EACjC,aAAa,CAAC,IAAI,EAClB,CAAC,EACD,aAAa,CAAC,GAAG,CAClB;SACF,CAAC;QACF,MAAM,KAAK,GAAG,aAAa,CAAC,mBAAmB,CAC7C,aAAa,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAC/B,aAAa,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,EAClC,aAAa,CAAC,KAAK,EACnB,UAAU,CACX,CAAC;QACF,MAAM,GAAG,GAAG,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC3C,oBAAoB;QACpB,MAAM,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}