mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-22 13:43:03 -05:00
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { parseSVG } from 'svg-path-parser';
|
|
|
|
import {
|
|
transformBlend,
|
|
transformConstraints,
|
|
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): PathShape => {
|
|
return {
|
|
type: 'path',
|
|
name: node.name,
|
|
content: translatePathNode(node),
|
|
...transformFigmaIds(node),
|
|
...transformFills(node),
|
|
...transformStrokes(node),
|
|
...transformEffects(node),
|
|
...transformSceneNode(node),
|
|
...transformBlend(node),
|
|
...transformProportion(node),
|
|
...transformRotation(node),
|
|
...transformLayoutAttributes(node),
|
|
...transformConstraints(node),
|
|
...transformOverrides(node)
|
|
};
|
|
};
|
|
|
|
const translatePathNode = (node: StarNode | PolygonNode): Segment[] =>
|
|
translateCommands(node, parseSVG(node.fillGeometry[0].data));
|