Skip to content

Instantly share code, notes, and snippets.

@cppio
Last active November 2, 2025 15:56
Show Gist options
  • Select an option

  • Save cppio/9cee96641b49796c310024da70140e2d to your computer and use it in GitHub Desktop.

Select an option

Save cppio/9cee96641b49796c310024da70140e2d to your computer and use it in GitHub Desktop.
Extract previews from vectormagic.com as SVG files
(result => {
let paths = [];
result.pieces.forEach(piece => {
let index = 0;
piece.shapes.forEach(shape => {
let commands = [];
shape.lenghts.forEach(length => {
commands.push(`M ${piece.floats[index++]} ${piece.floats[index++]}`);
for (let i = 0; i < (length - 2) / 6; i++) {
commands.push(`C ${piece.floats[index++]} ${piece.floats[index++]} ${piece.floats[index++]} ${piece.floats[index++]} ${piece.floats[index++]} ${piece.floats[index++]}`);
}
commands.push("Z");
});
paths.push(` <path d="${commands.join(" ")}" fill="${shape.color}"/>`);
});
});
return `<svg width="${result.imageWidth}" height="${result.imageHeight}" xmlns="http://www.w3.org/2000/svg">
${paths.join("\n")}
</svg>
`;
})(queryHolders(queryHolders(document.getElementById('App-ImageView-RightCanvas'))[0])[0].root.vector.result);
@nalmeida
Copy link

How to use it?

@Bit-Blazer
Copy link

Does this still work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment