2024-04-16 09:08:39 -05:00
|
|
|
import {
|
|
|
|
transformBlend,
|
|
|
|
transformDimensionAndPosition,
|
2024-04-22 07:35:59 -05:00
|
|
|
transformEffects,
|
2024-04-17 08:27:53 -05:00
|
|
|
transformFills,
|
2024-04-19 05:18:12 -05:00
|
|
|
transformProportion,
|
2024-04-17 03:53:38 -05:00
|
|
|
transformSceneNode,
|
|
|
|
transformStrokes,
|
2024-05-13 06:21:46 -05:00
|
|
|
transformVectorPathsAsContent
|
2024-04-16 09:08:39 -05:00
|
|
|
} from '@plugin/transformers/partials';
|
|
|
|
|
2024-05-06 01:06:14 -05:00
|
|
|
import { PathShape } from '@ui/lib/types/shapes/pathShape';
|
2024-04-16 09:08:39 -05:00
|
|
|
|
2024-05-21 07:36:30 -05:00
|
|
|
const hasFillGeometry = (node: StarNode | LineNode | PolygonNode): boolean => {
|
2024-04-17 08:27:53 -05:00
|
|
|
return 'fillGeometry' in node && node.fillGeometry.length > 0;
|
|
|
|
};
|
|
|
|
|
2024-05-09 09:59:27 -05:00
|
|
|
export const transformPathNode = async (
|
2024-05-21 07:36:30 -05:00
|
|
|
node: StarNode | LineNode | PolygonNode,
|
2024-04-17 03:53:38 -05:00
|
|
|
baseX: number,
|
|
|
|
baseY: number
|
2024-05-09 09:59:27 -05:00
|
|
|
): Promise<PathShape> => {
|
2024-04-16 09:08:39 -05:00
|
|
|
return {
|
2024-05-13 06:21:46 -05:00
|
|
|
type: 'path',
|
2024-04-16 09:08:39 -05:00
|
|
|
name: node.name,
|
2024-05-09 09:59:27 -05:00
|
|
|
...(hasFillGeometry(node) ? await transformFills(node) : []),
|
|
|
|
...(await transformStrokes(node)),
|
2024-04-22 07:35:59 -05:00
|
|
|
...transformEffects(node),
|
2024-05-13 06:21:46 -05:00
|
|
|
...transformVectorPathsAsContent(node, baseX, baseY),
|
2024-04-16 09:08:39 -05:00
|
|
|
...transformDimensionAndPosition(node, baseX, baseY),
|
|
|
|
...transformSceneNode(node),
|
2024-04-19 05:18:12 -05:00
|
|
|
...transformBlend(node),
|
|
|
|
...transformProportion(node)
|
2024-04-16 09:08:39 -05:00
|
|
|
};
|
|
|
|
};
|