0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-23 14:14:05 -05:00
penpot-exporter-figma-plugin/plugin-src/transformers/transformPathNode.ts
Alex Sánchez 02fa3363f5
Constraints translation (#142)
* constraints translation

* fix lint

* fixes

* fix vector constraints

* fix lint
2024-06-06 12:17:17 +02:00

39 lines
1.1 KiB
TypeScript

import {
transformBlend,
transformConstraints,
transformDimensionAndPosition,
transformEffects,
transformFigmaIds,
transformFills,
transformProportion,
transformSceneNode,
transformStrokes,
transformVectorPathsAsContent
} from '@plugin/transformers/partials';
import { PathShape } from '@ui/lib/types/shapes/pathShape';
const hasFillGeometry = (node: StarNode | LineNode | PolygonNode): boolean => {
return 'fillGeometry' in node && node.fillGeometry.length > 0;
};
export const transformPathNode = (
node: StarNode | LineNode | PolygonNode,
baseX: number,
baseY: number
): PathShape => {
return {
type: 'path',
name: node.name,
...transformFigmaIds(node),
...(hasFillGeometry(node) ? transformFills(node) : []),
...transformStrokes(node),
...transformEffects(node),
...transformVectorPathsAsContent(node, baseX, baseY),
...transformDimensionAndPosition(node, baseX, baseY),
...transformSceneNode(node),
...transformBlend(node),
...transformProportion(node),
...transformConstraints(node)
};
};