mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-23 06:04:01 -05:00
9355f282d0
* fixed line nodes * fixed line nodes * changeset * changeset * Update .changeset/new-spiders-travel.md Co-authored-by: Jordi Sala Morales <jordism91@gmail.com> --------- Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>
28 lines
760 B
TypeScript
28 lines
760 B
TypeScript
import { createLineGeometry, translateVectorPaths } from '@plugin/translators';
|
|
|
|
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 createLineGeometry(node);
|
|
}
|
|
};
|
|
|
|
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)
|
|
};
|
|
};
|