Skip to content

Commit

Permalink
fixes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjlockwood committed Nov 30, 2017
1 parent fef9e21 commit dc5db88
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/plugins/bakeGroupTransforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}
Expand Down
5 changes: 1 addition & 4 deletions src/plugins/convertPathData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const defaultParams = {
removeUseless: true,
collapseRepeated: true,
utilizeAbsolute: true,
leadingZero: true,
leadingZero: false,
negativeExtraSpace: true,
};

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/mergePaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const mergePaths: Plugin<Params> = {
description: 'merges multiple paths into one, if possible',
params: {
collapseRepeated: true,
leadingZero: true,
leadingZero: false,
negativeExtraSpace: true,
},
fn,
Expand Down
10 changes: 6 additions & 4 deletions test/plugins/_plugins.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion test/plugins/bakeGroupTransforms.01.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

<vector xmlns:android="http://schemas.android.com/apk/res/android">
<group>
<path android:pathData="M1000 1000l-500 -500l-500 -500"/>
<path android:pathData="M1000 1000l-500-500-500-500"/>
</group>
</vector>
4 changes: 4 additions & 0 deletions test/plugins/convertPathData.01.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@
<path android:pathData="M-10-50"/>
<path android:pathData="..."/>
</vector>

@@@

{ "leadingZero": true }
4 changes: 4 additions & 0 deletions test/plugins/convertPathData.05.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
<path android:pathData="M0 0l.113 1 .114 2L.34 6"/>
<path android:pathData="M0 0l.003 3 .002 2 .003 3 .002 2"/>
</vector>

@@@

{ "leadingZero": true }
4 changes: 4 additions & 0 deletions test/plugins/convertPathData.14.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@
<path android:pathData="M15 23.54a8.493 8.493 0 0 1-5.25-1.807"/>
<path android:pathData="M-9.5 82.311a4.81 4.81 0 1 1 .002-9.622A4.81 4.81 0 0 1-9.5 82.31z"/>
</vector>

@@@

{ "leadingZero": true }
2 changes: 1 addition & 1 deletion test/plugins/convertPathData.15.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@

@@@

{ "floatPrecision": 2 }
{ "floatPrecision": 2, "leadingZero": true }
2 changes: 1 addition & 1 deletion test/plugins/convertPathData.17.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

@@@

{ "floatPrecision": 8 }
{ "floatPrecision": 8, "leadingZero": true }
13 changes: 13 additions & 0 deletions test/plugins/convertPathData.19.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/>
</vector>

@@@

<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:pathData="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/>
</vector>

@@@

{ "leadingZero": true }
13 changes: 13 additions & 0 deletions test/plugins/convertPathData.20.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/>
</vector>

@@@

<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:pathData="M6 19c0 1.1 0.9 2 2 2h8c1.1 0 2-0.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/>
</vector>

@@@

{ "leadingZero": false }
4 changes: 4 additions & 0 deletions test/plugins/mergePaths.04.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@
<path android:pathData="M705.16 292.54c-5.615-35.752-25.082-67.015-25.082-67.015 7.35 15.128 20.257 53.835 23.64 77.45l2.33-2.24-.888-8.195z"/>
</group>
</vector>

@@@

{ "leadingZero": true }

0 comments on commit dc5db88

Please sign in to comment.