0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2025-01-11 01:20:16 -05:00
penpot-exporter-figma-plugin/plugin-src/transformers/partials/transformVectorPaths.ts

29 lines
735 B
TypeScript
Raw Normal View History

import { translateVectorPaths } from '@plugin/translators';
2024-05-06 01:06:14 -05:00
import { PathAttributes } from '@ui/lib/types/shapes/pathShape';
const getVectorPaths = (node: VectorNode | StarNode | LineNode | PolygonNode): VectorPaths => {
switch (node.type) {
case 'STAR':
case 'POLYGON':
return node.fillGeometry;
case 'VECTOR':
return node.vectorPaths;
case 'LINE':
return node.strokeGeometry;
}
};
export const transformVectorPaths = (
node: VectorNode | StarNode | LineNode | PolygonNode,
baseX: number,
baseY: number
): PathAttributes => {
const vectorPaths = getVectorPaths(node);
return {
type: 'path',
content: translateVectorPaths(vectorPaths, baseX + node.x, baseY + node.y)
};
};