From 9e578b515a6b23e6ab4bd41f7b28e2655d3bd110 Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Fri, 13 Aug 2021 18:34:12 +0300 Subject: [PATCH] Reset current cursor on Z Ref https://github.com/svg/svgo/issues/1510 --- plugins/_applyTransforms.js | 5 +++++ test/plugins/convertPathData.25.svg | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 test/plugins/convertPathData.25.svg diff --git a/plugins/_applyTransforms.js b/plugins/_applyTransforms.js index 307160da..b08cde02 100644 --- a/plugins/_applyTransforms.js +++ b/plugins/_applyTransforms.js @@ -323,6 +323,11 @@ const applyMatrixToPathData = (pathData, matrix) => { args[6] = y; } + if (command === 'z' || command === 'Z') { + cursor[0] = start[0]; + cursor[1] = start[1]; + } + pathItem.instruction = command; pathItem.data = args; } diff --git a/test/plugins/convertPathData.25.svg b/test/plugins/convertPathData.25.svg new file mode 100644 index 00000000..4b5e262f --- /dev/null +++ b/test/plugins/convertPathData.25.svg @@ -0,0 +1,27 @@ +Current cursor is reset by closepath command with the first moveto coords of segment + +=== + + + + + +@@@ + + + +