diff options
author | bobzel <zzzman@gmail.com> | 2024-11-03 18:12:54 -0500 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2024-11-03 18:12:54 -0500 |
commit | 4ab636e338a11e8153d43adddb0e0d3e6bad57ec (patch) | |
tree | bb7be9c45e53a854299d42fd696db310b08d12c3 | |
parent | 4b9b61dc9b0a7f1fd50fce7646f9312ea826364c (diff) |
fixed parsing of chat's svg's to strokes
-rw-r--r-- | src/client/util/bezierFit.ts | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/client/util/bezierFit.ts b/src/client/util/bezierFit.ts index 4aef28e6b..d52460023 100644 --- a/src/client/util/bezierFit.ts +++ b/src/client/util/bezierFit.ts @@ -691,8 +691,9 @@ export function SVGToBezier(name: SVGType, attributes: any): Point[] { } case 'path': { const coordList: Point[] = []; - const startPt = attributes.d.match(/M(-?\d+\.?\d*),(-?\d+\.?\d*)/); - coordList.push({ X: parseInt(startPt[1]), Y: parseInt(startPt[2]) }); + const [startX, startY] = attributes.d.match(/M(-?\d+\.?\d*),(-?\d+\.?\d*)/).slice(1); + const startPt = { X: parseInt(startX), Y: parseInt(startY) }; + coordList.push(startPt); const matches: RegExpMatchArray[] = Array.from( attributes.d.matchAll(/Q(-?\d+\.?\d*),(-?\d+\.?\d*) (-?\d+\.?\d*),(-?\d+\.?\d*)|C(-?\d+\.?\d*),(-?\d+\.?\d*) (-?\d+\.?\d*),(-?\d+\.?\d*) (-?\d+\.?\d*),(-?\d+\.?\d*)|L(-?\d+\.?\d*),(-?\d+\.?\d*)/g) ); @@ -721,8 +722,8 @@ export function SVGToBezier(name: SVGType, attributes: any): Point[] { const hasZ = attributes.d.match(/Z/); if (hasZ) { coordList.push(lastPt); - coordList.push({ X: parseInt(startPt[1]), Y: parseInt(startPt[2]) }); - coordList.push({ X: parseInt(startPt[1]), Y: parseInt(startPt[2]) }); + coordList.push(startPt); + coordList.push(startPt); } else { coordList.pop(); } |