2024-05-21 07:36:30 -05:00
|
|
|
import { transformVectorPaths } from '@plugin/transformers/partials';
|
2024-05-13 06:21:46 -05:00
|
|
|
|
|
|
|
import { GroupShape } from '@ui/lib/types/shapes/groupShape';
|
|
|
|
import { PathShape } from '@ui/lib/types/shapes/pathShape';
|
|
|
|
|
2024-05-21 07:36:30 -05:00
|
|
|
import { transformGroupNodeLike } from '.';
|
2024-05-13 06:21:46 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Vector nodes can have multiple vector paths, each with its own fills.
|
|
|
|
*
|
2024-05-14 03:12:18 -05:00
|
|
|
* If there are no regions on the vector network, we treat it like a normal `PathShape`.
|
|
|
|
* If there are regions, we treat the vector node as a `GroupShape` with multiple `PathShape` children.
|
2024-05-13 06:21:46 -05:00
|
|
|
*/
|
|
|
|
export const transformVectorNode = async (
|
|
|
|
node: VectorNode,
|
|
|
|
baseX: number,
|
|
|
|
baseY: number
|
|
|
|
): Promise<GroupShape | PathShape> => {
|
2024-05-21 07:36:30 -05:00
|
|
|
const children = await transformVectorPaths(node, baseX, baseY);
|
|
|
|
|
|
|
|
if (children.length === 1) {
|
|
|
|
return {
|
|
|
|
...children[0],
|
|
|
|
name: node.name
|
|
|
|
};
|
2024-05-14 03:12:18 -05:00
|
|
|
}
|
2024-05-13 06:21:46 -05:00
|
|
|
|
|
|
|
return {
|
|
|
|
...transformGroupNodeLike(node, baseX, baseY),
|
2024-05-21 07:36:30 -05:00
|
|
|
children
|
2024-05-13 06:21:46 -05:00
|
|
|
};
|
|
|
|
};
|