0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 13:43:03 -05:00
penpot-exporter-figma-plugin/plugin-src/transformers/transformPathNode.ts

44 lines
1.2 KiB
TypeScript
Raw Normal View History

import { parseSVG } from 'svg-path-parser';
import {
transformBlend,
transformConstraints,
2024-04-22 07:35:59 -05:00
transformEffects,
transformFigmaIds,
transformFills,
transformLayoutAttributes,
transformOverrides,
transformProportion,
transformRotation,
transformSceneNode,
transformStrokes
} from '@plugin/transformers/partials';
import { translateCommands } from '@plugin/translators/vectors';
import { PathShape, Segment } from '@ui/lib/types/shapes/pathShape';
export const transformPathNode = (
node: StarNode | PolygonNode,
baseRotation: number
): PathShape => {
return {
type: 'path',
name: node.name,
content: translatePathNode(node, baseRotation),
...transformFigmaIds(node),
...transformFills(node),
...transformStrokes(node),
2024-04-22 07:35:59 -05:00
...transformEffects(node),
...transformSceneNode(node),
...transformBlend(node),
...transformProportion(node),
...transformRotation(node, baseRotation),
...transformLayoutAttributes(node),
...transformConstraints(node),
...transformOverrides(node)
};
};
const translatePathNode = (node: StarNode | PolygonNode, baseRotation: number): Segment[] =>
translateCommands(node, parseSVG(node.fillGeometry[0].data), baseRotation);