@dudko.dev/vectorize-cli 0.4.8 → 0.4.10
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/dist/cli.js +14 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -74,6 +74,18 @@ function num(v) {
|
|
|
74
74
|
throw new Error(`expected a number, got "${v}"`);
|
|
75
75
|
return n;
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* A colour the exporters can all carry. SVG would take a named colour; PDF,
|
|
79
|
+
* EPS and DXF turn hex into their own numeric forms and quietly drop anything
|
|
80
|
+
* else — `--stroke-color blue` produced a DXF with no colour in it and exit 0.
|
|
81
|
+
*/
|
|
82
|
+
function hexColour(v, flag) {
|
|
83
|
+
if (v === undefined)
|
|
84
|
+
return undefined;
|
|
85
|
+
if (!/^#[0-9a-fA-F]{6}$/.test(v))
|
|
86
|
+
throw new Error(`--${flag} must be a #rrggbb colour, got "${v}"`);
|
|
87
|
+
return v;
|
|
88
|
+
}
|
|
77
89
|
function oneOf(v, allowed, flag) {
|
|
78
90
|
if (v === undefined)
|
|
79
91
|
return undefined;
|
|
@@ -145,7 +157,7 @@ export async function main(argv) {
|
|
|
145
157
|
layering: oneOf(values.layering, ['stacked', 'cutout', 'shared'], 'layering'),
|
|
146
158
|
curveMode: oneOf(values.curve, ['pixel', 'polygon', 'spline'], 'curve'),
|
|
147
159
|
maxColors: num(values.colors),
|
|
148
|
-
palette: values.palette ? values.palette.split(',').map((c) => c.trim()).filter(Boolean) : undefined,
|
|
160
|
+
palette: values.palette ? values.palette.split(',').map((c) => c.trim()).filter(Boolean).map((c) => hexColour(c, 'palette')) : undefined,
|
|
149
161
|
smooth: num(values.smooth),
|
|
150
162
|
cleanEdges: num(values['clean-edges']),
|
|
151
163
|
gapFill: num(values['gap-fill']),
|
|
@@ -158,7 +170,7 @@ export async function main(argv) {
|
|
|
158
170
|
adaptiveThreshold: values.adaptive ? true : undefined,
|
|
159
171
|
strokeMode: values.centerline ? 'centerline' : undefined,
|
|
160
172
|
strokeWidth: num(values['stroke-width']),
|
|
161
|
-
strokeColor: values['stroke-color'],
|
|
173
|
+
strokeColor: hexColour(values['stroke-color'], 'stroke-color'),
|
|
162
174
|
denoise: num(values.denoise),
|
|
163
175
|
upscale: num(values.upscale),
|
|
164
176
|
filterSpeckle: num(values.speckle),
|