abstract-image 3.1.3 → 3.2.3

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