From dc5db88c73afacd8e8725b71f537718fded7ac07 Mon Sep 17 00:00:00 2001 From: Alex Lockwood Date: Wed, 29 Nov 2017 21:36:42 -0800 Subject: [PATCH] fixes #1 --- src/plugins/bakeGroupTransforms.ts | 4 ++-- src/plugins/convertPathData.ts | 5 +---- src/plugins/mergePaths.ts | 2 +- test/plugins/_plugins.spec.ts | 10 ++++++---- test/plugins/bakeGroupTransforms.01.xml | 2 +- test/plugins/convertPathData.01.xml | 4 ++++ test/plugins/convertPathData.05.xml | 4 ++++ test/plugins/convertPathData.14.xml | 4 ++++ test/plugins/convertPathData.15.xml | 2 +- test/plugins/convertPathData.17.xml | 2 +- test/plugins/convertPathData.19.xml | 13 +++++++++++++ test/plugins/convertPathData.20.xml | 13 +++++++++++++ test/plugins/mergePaths.04.xml | 4 ++++ 13 files changed, 55 insertions(+), 14 deletions(-) create mode 100644 test/plugins/convertPathData.19.xml create mode 100644 test/plugins/convertPathData.20.xml diff --git a/src/plugins/bakeGroupTransforms.ts b/src/plugins/bakeGroupTransforms.ts index 0947f71..097ec2e 100644 --- a/src/plugins/bakeGroupTransforms.ts +++ b/src/plugins/bakeGroupTransforms.ts @@ -109,8 +109,8 @@ function fn(item: JsApi, params: Params) { data = applyTransforms(item, i, data, params); data.forEach(d => roundData(d.data)); js2path(i, data, { - collapseRepeated: false, - negativeExtraSpace: false, + collapseRepeated: true, + negativeExtraSpace: true, leadingZero: false, }); } diff --git a/src/plugins/convertPathData.ts b/src/plugins/convertPathData.ts index bfeaf08..72a06a1 100644 --- a/src/plugins/convertPathData.ts +++ b/src/plugins/convertPathData.ts @@ -34,7 +34,7 @@ export const defaultParams = { removeUseless: true, collapseRepeated: true, utilizeAbsolute: true, - leadingZero: true, + leadingZero: false, negativeExtraSpace: true, }; @@ -67,9 +67,6 @@ function fn(item: JsApi, params: Params) { } convertToRelative(data); - // if (params.applyTransforms) { - // data = applyTransforms(item, data, params); - // } data = filters(data, params); if (params.utilizeAbsolute) { data = convertToMixed(data, params); diff --git a/src/plugins/mergePaths.ts b/src/plugins/mergePaths.ts index 2a11d77..9bc9e6f 100644 --- a/src/plugins/mergePaths.ts +++ b/src/plugins/mergePaths.ts @@ -65,7 +65,7 @@ export const mergePaths: Plugin = { description: 'merges multiple paths into one, if possible', params: { collapseRepeated: true, - leadingZero: true, + leadingZero: false, negativeExtraSpace: true, }, fn, diff --git a/test/plugins/_plugins.spec.ts b/test/plugins/_plugins.spec.ts index 9c45f1b..0dd1fe7 100644 --- a/test/plugins/_plugins.spec.ts +++ b/test/plugins/_plugins.spec.ts @@ -30,17 +30,19 @@ describe('plugin tests', () => { let avdo: Avdo; const plugin = plugins[name]; + const origParams = plugin.params; if (params) { - plugin.params = { ...plugin.params, ...JSON.parse(params) }; + plugin.params = { ...origParams, ...JSON.parse(params) }; } avdo = new Avdo({ plugins: [[plugin]], pretty: true, }); - - return avdo.optimize(orig).then(result => { - normalize(result).should.be.equal(should); + const result = avdo.optimize(orig).then(res => { + normalize(res).should.be.equal(should); }); + plugin.params = origParams; + return result; }); }); } diff --git a/test/plugins/bakeGroupTransforms.01.xml b/test/plugins/bakeGroupTransforms.01.xml index e84c067..4465a50 100644 --- a/test/plugins/bakeGroupTransforms.01.xml +++ b/test/plugins/bakeGroupTransforms.01.xml @@ -8,6 +8,6 @@ - + diff --git a/test/plugins/convertPathData.01.xml b/test/plugins/convertPathData.01.xml index c28c8cc..3bd1669 100644 --- a/test/plugins/convertPathData.01.xml +++ b/test/plugins/convertPathData.01.xml @@ -35,3 +35,7 @@ + +@@@ + +{ "leadingZero": true } diff --git a/test/plugins/convertPathData.05.xml b/test/plugins/convertPathData.05.xml index 041e13c..88988e0 100644 --- a/test/plugins/convertPathData.05.xml +++ b/test/plugins/convertPathData.05.xml @@ -13,3 +13,7 @@ + +@@@ + +{ "leadingZero": true } diff --git a/test/plugins/convertPathData.14.xml b/test/plugins/convertPathData.14.xml index bcda7c3..031a33d 100644 --- a/test/plugins/convertPathData.14.xml +++ b/test/plugins/convertPathData.14.xml @@ -21,3 +21,7 @@ + +@@@ + +{ "leadingZero": true } diff --git a/test/plugins/convertPathData.15.xml b/test/plugins/convertPathData.15.xml index a02ad09..3f9877f 100644 --- a/test/plugins/convertPathData.15.xml +++ b/test/plugins/convertPathData.15.xml @@ -12,4 +12,4 @@ @@@ -{ "floatPrecision": 2 } +{ "floatPrecision": 2, "leadingZero": true } diff --git a/test/plugins/convertPathData.17.xml b/test/plugins/convertPathData.17.xml index 4370c13..4f75b38 100644 --- a/test/plugins/convertPathData.17.xml +++ b/test/plugins/convertPathData.17.xml @@ -10,4 +10,4 @@ @@@ -{ "floatPrecision": 8 } +{ "floatPrecision": 8, "leadingZero": true } diff --git a/test/plugins/convertPathData.19.xml b/test/plugins/convertPathData.19.xml new file mode 100644 index 0000000..e279524 --- /dev/null +++ b/test/plugins/convertPathData.19.xml @@ -0,0 +1,13 @@ + + + + +@@@ + + + + + +@@@ + +{ "leadingZero": true } diff --git a/test/plugins/convertPathData.20.xml b/test/plugins/convertPathData.20.xml new file mode 100644 index 0000000..2087dce --- /dev/null +++ b/test/plugins/convertPathData.20.xml @@ -0,0 +1,13 @@ + + + + +@@@ + + + + + +@@@ + +{ "leadingZero": false } diff --git a/test/plugins/mergePaths.04.xml b/test/plugins/mergePaths.04.xml index 0a70e56..c0558fd 100644 --- a/test/plugins/mergePaths.04.xml +++ b/test/plugins/mergePaths.04.xml @@ -16,3 +16,7 @@ + +@@@ + +{ "leadingZero": true }