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.
- package/CHANGELOG.md +27 -21
- package/LICENSE +21 -21
- package/README.md +73 -71
- package/lib/__stories__/react-svg-export/example-1.stories.d.ts.map +1 -1
- package/lib/__stories__/react-svg-export/example-1.stories.js +1 -1
- package/lib/__stories__/react-svg-export/example-1.stories.js.map +1 -1
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-ellipse.js +379 -379
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-group.d.ts.map +1 -1
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-group.js +124 -124
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-group.js.map +1 -1
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-line.js +55 -55
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-polygon.js +89 -89
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-polyline.js +79 -79
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-rectangle.js +99 -99
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text-growth-directions.d.ts.map +1 -1
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text-growth-directions.js +139 -139
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text-growth-directions.js.map +1 -1
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text.d.ts.map +1 -1
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text.js +64 -64
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text.js.map +1 -1
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-ellipse.js +24 -24
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-empty-text.d.ts.map +1 -1
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-empty-text.js +27 -27
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-empty-text.js.map +1 -1
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-group.d.ts.map +1 -1
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-group.js +32 -32
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-group.js.map +1 -1
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-line.js +20 -20
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-polygon.js +34 -34
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-polyline.js +26 -26
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-rectangle.js +20 -20
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text-growth-directions.d.ts.map +1 -1
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text-growth-directions.js +63 -63
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text-growth-directions.js.map +1 -1
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text.d.ts.map +1 -1
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text.js +27 -27
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text.js.map +1 -1
- package/lib/exporters/__tests__/exception/react-svg-direction-exception.test.js +2 -2
- package/lib/exporters/__tests__/exception/react-svg-direction-exception.test.js.map +1 -1
- package/lib/exporters/__tests__/exception/svg-direction-exception.test.js +2 -2
- package/lib/exporters/__tests__/exception/svg-direction-exception.test.js.map +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary.js +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary.js.map +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-callback.d.ts.map +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-callback.js +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-callback.js.map +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-empty-text.d.ts.map +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-empty-text.js +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-empty-text.js.map +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-group.d.ts.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-subimage.d.ts.map +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-subimage.js +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-subimage.js.map +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-bold.d.ts +3 -0
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-bold.d.ts.map +1 -0
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-bold.js +35 -0
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-bold.js.map +1 -0
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-growth-directions.d.ts.map +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-growth-directions.js +4 -4
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-growth-directions.js.map +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-italic.d.ts +3 -0
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-italic.d.ts.map +1 -0
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-italic.js +36 -0
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-italic.js.map +1 -0
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-sub.d.ts.map +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-sub.js +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-sub.js.map +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text.d.ts.map +1 -1
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text.js +2 -2
- package/lib/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text.js.map +1 -1
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-binary.js +2 -1
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-binary.js.map +1 -1
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-empty-text.d.ts.map +1 -1
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-empty-text.js +1 -1
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-empty-text.js.map +1 -1
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-group.d.ts.map +1 -1
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-group.js +1 -1
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-group.js.map +1 -1
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-text-bold.d.ts +3 -0
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-text-bold.d.ts.map +1 -0
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-text-bold.js +35 -0
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-text-bold.js.map +1 -0
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-text-growth-directions.d.ts.map +1 -1
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-text-growth-directions.js +4 -4
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-text-growth-directions.js.map +1 -1
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-text-italic.d.ts +3 -0
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-text-italic.d.ts.map +1 -0
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-text-italic.js +36 -0
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-text-italic.js.map +1 -0
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-text.d.ts.map +1 -1
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-text.js +2 -2
- package/lib/exporters/__tests__/svg-export-image/test-defs/svg-text.js.map +1 -1
- package/lib/exporters/react-svg-export-image.js +4 -5
- package/lib/exporters/react-svg-export-image.js.map +1 -1
- package/lib/exporters/svg-export-image.d.ts.map +1 -1
- package/lib/exporters/svg-export-image.js +30 -35
- package/lib/exporters/svg-export-image.js.map +1 -1
- package/lib/model/component.d.ts +3 -2
- package/lib/model/component.d.ts.map +1 -1
- package/lib/model/component.js +12 -11
- package/lib/model/component.js.map +1 -1
- package/package.json +2 -2
- package/src/__stories__/react-svg-export/example-1.stories.tsx +54 -53
- package/src/__stories__/svg-export/example-1.stories.tsx +42 -42
- package/src/exporters/__tests__/dxf2d-export-image/export-test-def.ts +11 -11
- package/src/exporters/__tests__/dxf2d-export-image/export.test.tsx +13 -13
- package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-ellipse.ts +405 -405
- package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-group.ts +166 -165
- package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-line.ts +80 -80
- package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-polygon.ts +114 -114
- package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-polyline.ts +103 -103
- package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-rectangle.ts +125 -125
- package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text-growth-directions.ts +214 -210
- package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text.ts +97 -96
- package/src/exporters/__tests__/eps-export-image/export-test-def.ts +11 -11
- package/src/exporters/__tests__/eps-export-image/export.test.tsx +13 -13
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-ellipse.ts +50 -50
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-empty-text.ts +60 -59
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-group.ts +74 -73
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-line.ts +45 -45
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-polygon.ts +65 -65
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-polyline.ts +58 -58
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-rectangle.ts +46 -46
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-text-growth-directions.ts +138 -134
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-text.ts +60 -59
- package/src/exporters/__tests__/exception/png-unsupported.test.tsx +25 -25
- package/src/exporters/__tests__/exception/react-svg-direction-exception.test.tsx +65 -63
- package/src/exporters/__tests__/exception/svg-direction-exception.test.tsx +65 -63
- package/src/exporters/__tests__/png-export-image/export-test-def.ts +11 -11
- package/src/exporters/__tests__/png-export-image/export.test.tsx +13 -13
- package/src/exporters/__tests__/png-export-image/test-defs/png-createPNG.tsx +26 -26
- package/src/exporters/__tests__/react-svg-export-image/export-test-def.tsx +13 -13
- package/src/exporters/__tests__/react-svg-export-image/export.test.tsx +13 -13
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary-png.tsx +27 -27
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary.tsx +26 -26
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-callback.tsx +60 -59
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-ellipse.tsx +28 -28
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-empty-text.tsx +35 -34
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-group.tsx +44 -43
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-line.tsx +26 -26
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-polygon.tsx +32 -32
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-polyline.tsx +33 -33
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-rectangle.tsx +27 -27
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-subimage.tsx +36 -35
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-bold.tsx +50 -0
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-growth-directions.tsx +80 -76
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-italic.tsx +65 -0
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-sub.tsx +35 -34
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text.tsx +35 -34
- package/src/exporters/__tests__/svg-export-image/export-test-def.ts +11 -11
- package/src/exporters/__tests__/svg-export-image/export.test.tsx +13 -13
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-binary.tsx +26 -26
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-ellipse.ts +27 -27
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-empty-text.ts +34 -33
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-group.ts +44 -43
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-line.ts +26 -26
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-polygon.ts +32 -32
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-polyline.ts +33 -33
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-rectangle.ts +27 -27
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-text-bold.ts +50 -0
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-text-growth-directions.ts +80 -76
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-text-italic.ts +65 -0
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-text.ts +35 -34
- package/src/exporters/dxf2d-export-image.ts +218 -218
- package/src/exporters/eps-export-image.ts +154 -154
- package/src/exporters/index.ts +3 -3
- package/src/exporters/png-export-image.ts +12 -12
- package/src/exporters/react-svg-export-image.tsx +301 -298
- package/src/exporters/svg-export-image.ts +296 -334
- package/src/index.ts +11 -11
- package/src/model/__tests__/color/export-test-def.ts +13 -13
- package/src/model/__tests__/color/export.test.tsx +14 -14
- package/src/model/__tests__/color/test-defs/color-from-string.ts +46 -46
- package/src/model/__tests__/color/test-defs/color-to-string.ts +35 -35
- package/src/model/__tests__/color/test-defs/color-undefined-2.ts +8 -8
- package/src/model/__tests__/color/test-defs/color-undefined.ts +8 -8
- package/src/model/abstract-image.ts +25 -25
- package/src/model/color.ts +52 -52
- package/src/model/component.ts +266 -279
- package/src/model/index.ts +5 -5
- package/src/model/point.ts +11 -11
- package/src/model/size.ts +11 -11
- package/lib/exporters/__tests__/svg-export-image.test.d.ts +0 -2
- package/lib/exporters/__tests__/svg-export-image.test.d.ts.map +0 -1
- package/lib/exporters/__tests__/svg-export-image.test.js +0 -35
- package/lib/exporters/__tests__/svg-export-image.test.js.map +0 -1
package/src/model/component.ts
CHANGED
|
@@ -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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
export
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
readonly
|
|
211
|
-
readonly
|
|
212
|
-
readonly
|
|
213
|
-
readonly
|
|
214
|
-
readonly
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
export
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
+
}
|
package/src/model/index.ts
CHANGED
|
@@ -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";
|
package/src/model/point.ts
CHANGED
|
@@ -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,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"}
|