Skip to content

Commit 14b29f2

Browse files
authored
cache to prevent lag and test different outlines
1 parent f7aecc6 commit 14b29f2

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/helper/selectable-shapes.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,17 @@ const selectablePaths = Object.fromEntries(
337337
);
338338

339339
const generateShapeSVG = (shapeObj) => {
340+
if (shapeObj._cachedSVG) return shapeObj._cachedSVG;
341+
340342
const strokeColor = "#575e75";
341343
const path = new paper.Path(shapeObj.path);
342344
const bounds = path.getBounds();
343345
const viewbox = `${bounds.x} ${bounds.y} ${bounds.width} ${bounds.height}`;
344346
path.remove();
345347

346-
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${viewbox}">`
347-
+ `<path d="${shapeObj.path}" stroke-width="${bounds.width / bounds.height}" stroke="${strokeColor}" fill="none"/></svg>`;
348+
shapeObj._cachedSVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${viewbox}">`
349+
+ `<path d="${shapeObj.path}" stroke-width="${window.test ?? 1}" stroke="${strokeColor}" fill="none"/></svg>`;
350+
return shapeObj._cachedSVG;
348351
};
349352

350353
export {

0 commit comments

Comments
 (0)