abstract-image 3.3.2 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -38
- package/LICENSE +21 -21
- package/README.md +73 -73
- package/lib/_tests_/exporters/svg-export-image.test.d.ts.map +1 -0
- package/lib/_tests_/exporters/svg-export-image.test.js.map +1 -0
- 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.js +123 -123
- 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.js +135 -135
- package/lib/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text.js +63 -63
- package/lib/exporters/__tests__/eps-export-image/export.test.js +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.js +26 -26
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-group.js +31 -31
- 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.js +59 -59
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text-iso-latin1-encoding.d.ts +3 -0
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text-iso-latin1-encoding.d.ts.map +1 -0
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text-iso-latin1-encoding.js +71 -0
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text-iso-latin1-encoding.js.map +1 -0
- package/lib/exporters/__tests__/eps-export-image/test-defs/eps-text.js +26 -26
- package/lib/exporters/eps-export-image.d.ts +2 -0
- package/lib/exporters/eps-export-image.d.ts.map +1 -1
- package/lib/exporters/eps-export-image.js +113 -32
- package/lib/exporters/eps-export-image.js.map +1 -1
- package/package.json +4 -2
- package/src/__stories__/react-svg-export/example-1.stories.tsx +54 -54
- 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 -166
- 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 -214
- package/src/exporters/__tests__/dxf2d-export-image/test-defs/dxf2d-text.ts +97 -97
- 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 -60
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-group.ts +74 -74
- 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 -138
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-text-iso-latin1-encoding.ts +71 -0
- package/src/exporters/__tests__/eps-export-image/test-defs/eps-text.ts +60 -60
- package/src/exporters/__tests__/exception/png-unsupported.test.tsx +25 -25
- package/src/exporters/__tests__/exception/react-svg-direction-exception.test.tsx +65 -65
- package/src/exporters/__tests__/exception/svg-direction-exception.test.tsx +65 -65
- 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 +26 -26
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary-url.tsx +26 -26
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-binary.tsx +25 -25
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-callback.tsx +60 -60
- 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 -35
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-group.tsx +44 -44
- 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 -36
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-bold.tsx +50 -50
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-growth-directions.tsx +80 -80
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-italic.tsx +65 -65
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text-sub.tsx +35 -35
- package/src/exporters/__tests__/react-svg-export-image/test-defs/react-svg-text.tsx +35 -35
- 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 +25 -25
- 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 -34
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-group.ts +44 -44
- 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 -50
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-text-growth-directions.ts +80 -80
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-text-italic.ts +65 -65
- package/src/exporters/__tests__/svg-export-image/test-defs/svg-text.ts +35 -35
- package/src/exporters/dxf2d-export-image.ts +218 -218
- package/src/exporters/eps-export-image.ts +233 -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 +315 -315
- package/src/exporters/svg-export-image.ts +309 -309
- 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 +279 -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.map +0 -1
- package/lib/exporters/__tests__/svg-export-image.test.js.map +0 -1
- /package/lib/{exporters/__tests__ → _tests_/exporters}/svg-export-image.test.d.ts +0 -0
- /package/lib/{exporters/__tests__ → _tests_/exporters}/svg-export-image.test.js +0 -0
|
@@ -21,7 +21,24 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.epsExportImage = void 0;
|
|
23
23
|
const R = __importStar(require("ramda"));
|
|
24
|
-
function epsExportImage(root) {
|
|
24
|
+
function epsExportImage(root, characterEncoding) {
|
|
25
|
+
if (characterEncoding === "iso-latin-1-encoding") {
|
|
26
|
+
const eps = [
|
|
27
|
+
...createEpsHeaderLines(root),
|
|
28
|
+
...createIsoLatin1FontLines(root),
|
|
29
|
+
...R.unnest(root.components.map((c) => epsExportComponent(c, root.size.height, "iso-latin-1-encoding"))),
|
|
30
|
+
].join("\n");
|
|
31
|
+
return encodeLatin1Encoding(eps);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return [
|
|
35
|
+
...createEpsHeaderLines(root),
|
|
36
|
+
...R.unnest(root.components.map((c) => epsExportComponent(c, root.size.height, "standard-encoding"))),
|
|
37
|
+
].join("\n");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.epsExportImage = epsExportImage;
|
|
41
|
+
function createEpsHeaderLines(root) {
|
|
25
42
|
return [
|
|
26
43
|
"%!PS-Adobe-3.0 EPSF-3.0",
|
|
27
44
|
`%%BoundingBox: 0 0 ${root.size.width} ${root.size.height}`,
|
|
@@ -39,11 +56,9 @@ function epsExportImage(root) {
|
|
|
39
56
|
"savematrix setmatrix",
|
|
40
57
|
"end",
|
|
41
58
|
"} def",
|
|
42
|
-
|
|
43
|
-
].join("\n");
|
|
59
|
+
];
|
|
44
60
|
}
|
|
45
|
-
|
|
46
|
-
function epsExportComponent(c, height) {
|
|
61
|
+
function epsExportComponent(c, height, characterEncoding) {
|
|
47
62
|
switch (c.type) {
|
|
48
63
|
case "ellipse": {
|
|
49
64
|
const cx = (c.topLeft.x + c.bottomRight.x) * 0.5;
|
|
@@ -51,72 +66,66 @@ function epsExportComponent(c, height) {
|
|
|
51
66
|
const rx = 0.5 * (c.bottomRight.x - c.topLeft.x);
|
|
52
67
|
const ry = 0.5 * (c.bottomRight.y - c.topLeft.y);
|
|
53
68
|
return [
|
|
54
|
-
...getColored(c.fillColor, [
|
|
55
|
-
`${cx} ${cy} ${rx} ${ry} 0 360 ellipse`,
|
|
56
|
-
"closepath",
|
|
57
|
-
"fill"
|
|
58
|
-
]),
|
|
69
|
+
...getColored(c.fillColor, [`${cx} ${cy} ${rx} ${ry} 0 360 ellipse`, "closepath", "fill"]),
|
|
59
70
|
...getColored(c.strokeColor, [
|
|
60
71
|
`${cx} ${cy} ${rx} ${ry} 0 360 ellipse`,
|
|
61
72
|
"closepath",
|
|
62
73
|
`${c.strokeThickness} setlinewidth`,
|
|
63
|
-
"stroke"
|
|
64
|
-
])
|
|
74
|
+
"stroke",
|
|
75
|
+
]),
|
|
65
76
|
];
|
|
66
77
|
}
|
|
67
78
|
case "group": {
|
|
68
|
-
return R.unnest(c.children.map(cc => epsExportComponent(cc, height)));
|
|
79
|
+
return R.unnest(c.children.map((cc) => epsExportComponent(cc, height, characterEncoding)));
|
|
69
80
|
}
|
|
70
81
|
case "line": {
|
|
71
82
|
return getColored(c.strokeColor, [
|
|
72
83
|
`${c.start.x} ${height - c.start.y} moveto`,
|
|
73
84
|
`${c.end.x} ${height - c.end.y} lineto`,
|
|
74
85
|
`${c.strokeThickness} setlinewidth`,
|
|
75
|
-
"stroke"
|
|
86
|
+
"stroke",
|
|
76
87
|
]);
|
|
77
88
|
}
|
|
78
89
|
case "polygon": {
|
|
79
90
|
return [
|
|
80
91
|
...getColored(c.fillColor, [
|
|
81
92
|
`${c.points[0].x} ${height - c.points[0].y} moveto`,
|
|
82
|
-
...c.points.map(p => `${p.x} ${height - p.y} lineto`),
|
|
93
|
+
...c.points.map((p) => `${p.x} ${height - p.y} lineto`),
|
|
83
94
|
"closepath",
|
|
84
95
|
`${c.strokeThickness} setlinewidth`,
|
|
85
|
-
"fill"
|
|
96
|
+
"fill",
|
|
86
97
|
]),
|
|
87
98
|
...getColored(c.strokeColor, [
|
|
88
99
|
`${c.points[0].x} ${height - c.points[0].y} moveto`,
|
|
89
|
-
...c.points.map(p => `${p.x} ${height - p.y} lineto`),
|
|
100
|
+
...c.points.map((p) => `${p.x} ${height - p.y} lineto`),
|
|
90
101
|
"closepath",
|
|
91
|
-
"stroke"
|
|
92
|
-
])
|
|
102
|
+
"stroke",
|
|
103
|
+
]),
|
|
93
104
|
];
|
|
94
105
|
}
|
|
95
106
|
case "polyline": {
|
|
96
107
|
return getColored(c.strokeColor, [
|
|
97
108
|
`${c.points[0].x} ${height - c.points[0].y} moveto`,
|
|
98
|
-
...c.points.map(p => `${p.x} ${height - p.y} lineto`),
|
|
109
|
+
...c.points.map((p) => `${p.x} ${height - p.y} lineto`),
|
|
99
110
|
`${c.strokeThickness} setlinewidth`,
|
|
100
|
-
"stroke"
|
|
111
|
+
"stroke",
|
|
101
112
|
]);
|
|
102
113
|
}
|
|
103
114
|
case "rectangle": {
|
|
104
115
|
const w = c.bottomRight.x - c.topLeft.x;
|
|
105
116
|
const h = c.bottomRight.y - c.topLeft.y;
|
|
106
117
|
return [
|
|
107
|
-
...getColored(c.fillColor, [
|
|
108
|
-
`${c.topLeft.x} ${height - c.bottomRight.y} ${w} ${h} rectfill`
|
|
109
|
-
]),
|
|
118
|
+
...getColored(c.fillColor, [`${c.topLeft.x} ${height - c.bottomRight.y} ${w} ${h} rectfill`]),
|
|
110
119
|
...getColored(c.strokeColor, [
|
|
111
120
|
`${c.strokeThickness} setlinewidth`,
|
|
112
|
-
`${c.topLeft.x} ${height - c.bottomRight.y} ${w} ${h} rectstroke
|
|
113
|
-
])
|
|
121
|
+
`${c.topLeft.x} ${height - c.bottomRight.y} ${w} ${h} rectstroke`,
|
|
122
|
+
]),
|
|
114
123
|
];
|
|
115
124
|
}
|
|
116
125
|
case "text": {
|
|
117
126
|
return getColored(c.textColor, [
|
|
118
127
|
`gsave`,
|
|
119
|
-
`/${c.fontFamily} findfont`,
|
|
128
|
+
`/${createFontName(characterEncoding, c.fontFamily)} findfont`,
|
|
120
129
|
`${c.fontSize} scalefont setfont`,
|
|
121
130
|
`${c.position.x} ${height - c.position.y} moveto`,
|
|
122
131
|
getTextXOffset(c),
|
|
@@ -124,7 +133,7 @@ function epsExportComponent(c, height) {
|
|
|
124
133
|
`rmoveto`,
|
|
125
134
|
`${-c.clockwiseRotationDegrees} rotate`,
|
|
126
135
|
`(${c.text}) show`,
|
|
127
|
-
`grestore
|
|
136
|
+
`grestore`,
|
|
128
137
|
]);
|
|
129
138
|
}
|
|
130
139
|
default:
|
|
@@ -157,9 +166,81 @@ function getColored(color, instructions) {
|
|
|
157
166
|
if (color.a === 0) {
|
|
158
167
|
return [];
|
|
159
168
|
}
|
|
160
|
-
return [
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
169
|
+
return [`${color.r / 255} ${color.g / 255} ${color.b / 255} setrgbcolor`, ...instructions];
|
|
170
|
+
}
|
|
171
|
+
function createFontName(characterEncoding, fontFamily) {
|
|
172
|
+
if (characterEncoding === "iso-latin-1-encoding") {
|
|
173
|
+
return `${fontFamily}-ISOLatin1`;
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
return fontFamily;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function encodeLatin1Encoding(text) {
|
|
180
|
+
// ISOLatin1Encoding is close to iso-8859-1 encoding (https://en.wikipedia.org/wiki/PostScript_Latin_1_Encoding)
|
|
181
|
+
// Code points 0-256 returned by codePointAt() maps to iso-8859-1
|
|
182
|
+
const unknownCharacter = "?".codePointAt(0) || 32;
|
|
183
|
+
const output = [];
|
|
184
|
+
// Array.from() to handle characters consisting of multiple code points
|
|
185
|
+
for (const c of Array.from(text)) {
|
|
186
|
+
if (c.length > 1) {
|
|
187
|
+
output.push(unknownCharacter);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
const cp = c.codePointAt(0) || 32;
|
|
191
|
+
if (cp > 255) {
|
|
192
|
+
output.push(unknownCharacter);
|
|
193
|
+
}
|
|
194
|
+
output.push(cp);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return new Uint8Array(output);
|
|
198
|
+
}
|
|
199
|
+
function createIsoLatin1FontLines(root) {
|
|
200
|
+
const fontFamilies = getUsedFontFamilies(root.components);
|
|
201
|
+
const lines = [];
|
|
202
|
+
for (const fontFamily of fontFamilies) {
|
|
203
|
+
// 1. Makes a copy of the font dictionary, including all entries except the one whose
|
|
204
|
+
// key is FID. (This exclusion is necessary only in LanguageLevel 1; in Language-
|
|
205
|
+
// Level 2, the interpreter ignores any existing FID entry in a font being defined.)
|
|
206
|
+
//
|
|
207
|
+
// 2. Installs the desired change: replaces the font’s Encoding array with the value of
|
|
208
|
+
// ISOLatin1Encoding, which is a built-in, 256-element array of character names
|
|
209
|
+
// defined in systemdict.
|
|
210
|
+
//
|
|
211
|
+
// 3. Registers this modified font under a new name (Helvetica-ISOLatin1).
|
|
212
|
+
//
|
|
213
|
+
// https://www.adobe.com/jp/print/postscript/pdfs/PLRM.pdf
|
|
214
|
+
lines.push(...[
|
|
215
|
+
`/${fontFamily} findfont`,
|
|
216
|
+
"dup length dict begin",
|
|
217
|
+
" { 1 index /FID ne",
|
|
218
|
+
" {def}",
|
|
219
|
+
" {pop pop}",
|
|
220
|
+
" ifelse",
|
|
221
|
+
" } forall",
|
|
222
|
+
" /Encoding ISOLatin1Encoding def",
|
|
223
|
+
" currentdict",
|
|
224
|
+
"end",
|
|
225
|
+
`/${createFontName("iso-latin-1-encoding", fontFamily)} exch definefont pop`,
|
|
226
|
+
]);
|
|
227
|
+
}
|
|
228
|
+
return lines;
|
|
229
|
+
}
|
|
230
|
+
function getUsedFontFamilies(components) {
|
|
231
|
+
const families = [];
|
|
232
|
+
for (const c of components) {
|
|
233
|
+
switch (c.type) {
|
|
234
|
+
case "text":
|
|
235
|
+
families.push(c.fontFamily);
|
|
236
|
+
break;
|
|
237
|
+
case "group":
|
|
238
|
+
families.push(...getUsedFontFamilies(c.children));
|
|
239
|
+
break;
|
|
240
|
+
default:
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return R.uniq(families);
|
|
164
245
|
}
|
|
165
246
|
//# sourceMappingURL=eps-export-image.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eps-export-image.js","sourceRoot":"","sources":["../../src/exporters/eps-export-image.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,yCAA2B;
|
|
1
|
+
{"version":3,"file":"eps-export-image.js","sourceRoot":"","sources":["../../src/exporters/eps-export-image.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,yCAA2B;AAO3B,SAAgB,cAAc,CAAC,IAAsB,EAAE,iBAAqC;IAC1F,IAAI,iBAAiB,KAAK,sBAAsB,EAAE;QAChD,MAAM,GAAG,GAAG;YACV,GAAG,oBAAoB,CAAC,IAAI,CAAC;YAC7B,GAAG,wBAAwB,CAAC,IAAI,CAAC;YACjC,GAAG,CAAC,CAAC,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C1B,QAAQ,CAAC,CAAC,IAAI,EAAE;YACd,KAAK,MAAM;gBACT,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;gBAC5B,MAAM;YACR,KAAK,OAAO;gBACV,QAAQ,CAAC,IAAI,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAClD,MAAM;YACR;gBACE,MAAM;SACT;KACF;IACD,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "abstract-image",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "Dynamically create images using code or JSX and render to any format",
|
|
5
5
|
"repository": "https://github.com/dividab/abstract-visuals/tree/master/packages/abstract-image",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -16,13 +16,15 @@
|
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"base64-js": "^1.2.0",
|
|
19
|
+
"ramda": "^0.22.1",
|
|
19
20
|
"react": "^16.12.0",
|
|
20
21
|
"react-dom": "^16.12.0"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
24
|
"@types/base64-js": "^1.2.5",
|
|
25
|
+
"@types/ramda": "^0.25.29",
|
|
24
26
|
"@types/react": "^16.9.0",
|
|
25
27
|
"@types/react-dom": "^16.9.0"
|
|
26
28
|
},
|
|
27
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "cc48e3f14a9ec319766ae3322bcdd98748718cab"
|
|
28
30
|
}
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Meta } from "@storybook/react";
|
|
3
|
-
import * as AbstractImage from "../..";
|
|
4
|
-
|
|
5
|
-
export function ReactSvgExportExample1(): React.ReactElement<{}> {
|
|
6
|
-
const components = [
|
|
7
|
-
AbstractImage.createLine(
|
|
8
|
-
AbstractImage.createPoint(0, 200),
|
|
9
|
-
AbstractImage.createPoint(400, 200),
|
|
10
|
-
AbstractImage.black,
|
|
11
|
-
1
|
|
12
|
-
),
|
|
13
|
-
AbstractImage.createLine(
|
|
14
|
-
AbstractImage.createPoint(200, 0),
|
|
15
|
-
AbstractImage.createPoint(200, 400),
|
|
16
|
-
AbstractImage.black,
|
|
17
|
-
1
|
|
18
|
-
),
|
|
19
|
-
AbstractImage.createText(
|
|
20
|
-
AbstractImage.createPoint(200, 200),
|
|
21
|
-
"Testing texting",
|
|
22
|
-
"Arial",
|
|
23
|
-
20,
|
|
24
|
-
AbstractImage.black,
|
|
25
|
-
"normal",
|
|
26
|
-
0,
|
|
27
|
-
"center",
|
|
28
|
-
"uniform",
|
|
29
|
-
"down",
|
|
30
|
-
0,
|
|
31
|
-
AbstractImage.black,
|
|
32
|
-
false
|
|
33
|
-
),
|
|
34
|
-
];
|
|
35
|
-
const image = AbstractImage.createAbstractImage(
|
|
36
|
-
AbstractImage.createPoint(0, 0),
|
|
37
|
-
AbstractImage.createSize(400, 400),
|
|
38
|
-
AbstractImage.white,
|
|
39
|
-
components
|
|
40
|
-
);
|
|
41
|
-
const svg = AbstractImage.createReactSvg(image);
|
|
42
|
-
return (
|
|
43
|
-
<div>
|
|
44
|
-
<h1>React Svg</h1>
|
|
45
|
-
<pre>{svg}</pre>
|
|
46
|
-
</div>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// eslint-disable-next-line import/no-default-export
|
|
51
|
-
export default {
|
|
52
|
-
component: ReactSvgExportExample1,
|
|
53
|
-
title: "ReactSvgExportExample1",
|
|
54
|
-
} as Meta;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Meta } from "@storybook/react";
|
|
3
|
+
import * as AbstractImage from "../..";
|
|
4
|
+
|
|
5
|
+
export function ReactSvgExportExample1(): React.ReactElement<{}> {
|
|
6
|
+
const components = [
|
|
7
|
+
AbstractImage.createLine(
|
|
8
|
+
AbstractImage.createPoint(0, 200),
|
|
9
|
+
AbstractImage.createPoint(400, 200),
|
|
10
|
+
AbstractImage.black,
|
|
11
|
+
1
|
|
12
|
+
),
|
|
13
|
+
AbstractImage.createLine(
|
|
14
|
+
AbstractImage.createPoint(200, 0),
|
|
15
|
+
AbstractImage.createPoint(200, 400),
|
|
16
|
+
AbstractImage.black,
|
|
17
|
+
1
|
|
18
|
+
),
|
|
19
|
+
AbstractImage.createText(
|
|
20
|
+
AbstractImage.createPoint(200, 200),
|
|
21
|
+
"Testing texting",
|
|
22
|
+
"Arial",
|
|
23
|
+
20,
|
|
24
|
+
AbstractImage.black,
|
|
25
|
+
"normal",
|
|
26
|
+
0,
|
|
27
|
+
"center",
|
|
28
|
+
"uniform",
|
|
29
|
+
"down",
|
|
30
|
+
0,
|
|
31
|
+
AbstractImage.black,
|
|
32
|
+
false
|
|
33
|
+
),
|
|
34
|
+
];
|
|
35
|
+
const image = AbstractImage.createAbstractImage(
|
|
36
|
+
AbstractImage.createPoint(0, 0),
|
|
37
|
+
AbstractImage.createSize(400, 400),
|
|
38
|
+
AbstractImage.white,
|
|
39
|
+
components
|
|
40
|
+
);
|
|
41
|
+
const svg = AbstractImage.createReactSvg(image);
|
|
42
|
+
return (
|
|
43
|
+
<div>
|
|
44
|
+
<h1>React Svg</h1>
|
|
45
|
+
<pre>{svg}</pre>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// eslint-disable-next-line import/no-default-export
|
|
51
|
+
export default {
|
|
52
|
+
component: ReactSvgExportExample1,
|
|
53
|
+
title: "ReactSvgExportExample1",
|
|
54
|
+
} as Meta;
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Meta } from "@storybook/react";
|
|
3
|
-
import * as AbstractImage from "../..";
|
|
4
|
-
|
|
5
|
-
export function SvgExportExample1(): React.ReactElement<{}> {
|
|
6
|
-
const components = [
|
|
7
|
-
AbstractImage.createLine(
|
|
8
|
-
AbstractImage.createPoint(25, 25),
|
|
9
|
-
AbstractImage.createPoint(80, 60),
|
|
10
|
-
AbstractImage.black,
|
|
11
|
-
2
|
|
12
|
-
),
|
|
13
|
-
AbstractImage.createRectangle(
|
|
14
|
-
AbstractImage.createPoint(10, 50),
|
|
15
|
-
AbstractImage.createPoint(40, 80),
|
|
16
|
-
AbstractImage.blue,
|
|
17
|
-
2,
|
|
18
|
-
AbstractImage.red
|
|
19
|
-
),
|
|
20
|
-
];
|
|
21
|
-
const image = AbstractImage.createAbstractImage(
|
|
22
|
-
AbstractImage.createPoint(0, 0),
|
|
23
|
-
AbstractImage.createSize(400, 400),
|
|
24
|
-
AbstractImage.white,
|
|
25
|
-
components
|
|
26
|
-
);
|
|
27
|
-
const svg = AbstractImage.createSVG(image);
|
|
28
|
-
const base64 = btoa(svg);
|
|
29
|
-
return (
|
|
30
|
-
<div>
|
|
31
|
-
<h1>Svg</h1>
|
|
32
|
-
<pre>{svg}</pre>
|
|
33
|
-
<img src={`data:image/svg+xml;base64,${base64}`} />
|
|
34
|
-
</div>
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// eslint-disable-next-line import/no-default-export
|
|
39
|
-
export default {
|
|
40
|
-
component: SvgExportExample1,
|
|
41
|
-
title: "SvgExportExample1",
|
|
42
|
-
} as Meta;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Meta } from "@storybook/react";
|
|
3
|
+
import * as AbstractImage from "../..";
|
|
4
|
+
|
|
5
|
+
export function SvgExportExample1(): React.ReactElement<{}> {
|
|
6
|
+
const components = [
|
|
7
|
+
AbstractImage.createLine(
|
|
8
|
+
AbstractImage.createPoint(25, 25),
|
|
9
|
+
AbstractImage.createPoint(80, 60),
|
|
10
|
+
AbstractImage.black,
|
|
11
|
+
2
|
|
12
|
+
),
|
|
13
|
+
AbstractImage.createRectangle(
|
|
14
|
+
AbstractImage.createPoint(10, 50),
|
|
15
|
+
AbstractImage.createPoint(40, 80),
|
|
16
|
+
AbstractImage.blue,
|
|
17
|
+
2,
|
|
18
|
+
AbstractImage.red
|
|
19
|
+
),
|
|
20
|
+
];
|
|
21
|
+
const image = AbstractImage.createAbstractImage(
|
|
22
|
+
AbstractImage.createPoint(0, 0),
|
|
23
|
+
AbstractImage.createSize(400, 400),
|
|
24
|
+
AbstractImage.white,
|
|
25
|
+
components
|
|
26
|
+
);
|
|
27
|
+
const svg = AbstractImage.createSVG(image);
|
|
28
|
+
const base64 = btoa(svg);
|
|
29
|
+
return (
|
|
30
|
+
<div>
|
|
31
|
+
<h1>Svg</h1>
|
|
32
|
+
<pre>{svg}</pre>
|
|
33
|
+
<img src={`data:image/svg+xml;base64,${base64}`} />
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// eslint-disable-next-line import/no-default-export
|
|
39
|
+
export default {
|
|
40
|
+
component: SvgExportExample1,
|
|
41
|
+
title: "SvgExportExample1",
|
|
42
|
+
} as Meta;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines a data-type that represents a single test for the Docx render function
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export type ExportTestDef = {
|
|
6
|
-
readonly name: string;
|
|
7
|
-
readonly only?: boolean;
|
|
8
|
-
readonly skip?: boolean;
|
|
9
|
-
readonly abstractImage: string;
|
|
10
|
-
readonly expectedImage: string;
|
|
11
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Defines a data-type that represents a single test for the Docx render function
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export type ExportTestDef = {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly only?: boolean;
|
|
8
|
+
readonly skip?: boolean;
|
|
9
|
+
readonly abstractImage: string;
|
|
10
|
+
readonly expectedImage: string;
|
|
11
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { loadTests, onlySkip } from "@abstract-visuals/test-utils";
|
|
3
|
-
import { ExportTestDef } from "./export-test-def";
|
|
4
|
-
|
|
5
|
-
export const tests = loadTests<ExportTestDef>(path.join(__dirname, "test-defs/"));
|
|
6
|
-
|
|
7
|
-
describe("dxf2d-export-image", () => {
|
|
8
|
-
onlySkip(tests).forEach((item) => {
|
|
9
|
-
test(item.name, async () => {
|
|
10
|
-
expect(item.abstractImage).toEqual(item.expectedImage);
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
});
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { loadTests, onlySkip } from "@abstract-visuals/test-utils";
|
|
3
|
+
import { ExportTestDef } from "./export-test-def";
|
|
4
|
+
|
|
5
|
+
export const tests = loadTests<ExportTestDef>(path.join(__dirname, "test-defs/"));
|
|
6
|
+
|
|
7
|
+
describe("dxf2d-export-image", () => {
|
|
8
|
+
onlySkip(tests).forEach((item) => {
|
|
9
|
+
test(item.name, async () => {
|
|
10
|
+
expect(item.abstractImage).toEqual(item.expectedImage);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
});
|