abstract-image 3.2.5 → 3.3.2

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