2024-04-12 09:52:36 -05:00
|
|
|
import { PenpotNode } from '@ui/lib/types/penpotNode';
|
|
|
|
|
2024-04-12 06:55:42 -05:00
|
|
|
import {
|
|
|
|
transformEllipseNode,
|
|
|
|
transformFrameNode,
|
|
|
|
transformGroupNode,
|
2024-04-17 03:53:38 -05:00
|
|
|
transformPathNode,
|
2024-04-12 06:55:42 -05:00
|
|
|
transformRectangleNode,
|
2024-05-13 06:21:46 -05:00
|
|
|
transformTextNode,
|
|
|
|
transformVectorNode
|
2024-04-12 06:55:42 -05:00
|
|
|
} from '.';
|
|
|
|
|
|
|
|
export const transformSceneNode = async (
|
|
|
|
node: SceneNode,
|
|
|
|
baseX: number = 0,
|
|
|
|
baseY: number = 0
|
2024-04-19 02:48:19 -05:00
|
|
|
): Promise<PenpotNode | undefined> => {
|
2024-04-12 06:55:42 -05:00
|
|
|
switch (node.type) {
|
|
|
|
case 'RECTANGLE':
|
2024-05-09 09:59:27 -05:00
|
|
|
return await transformRectangleNode(node, baseX, baseY);
|
2024-04-12 06:55:42 -05:00
|
|
|
case 'ELLIPSE':
|
2024-05-09 09:59:27 -05:00
|
|
|
return await transformEllipseNode(node, baseX, baseY);
|
2024-04-17 04:38:13 -05:00
|
|
|
case 'SECTION':
|
2024-04-12 06:55:42 -05:00
|
|
|
case 'FRAME':
|
|
|
|
return await transformFrameNode(node, baseX, baseY);
|
|
|
|
case 'GROUP':
|
|
|
|
return await transformGroupNode(node, baseX, baseY);
|
|
|
|
case 'TEXT':
|
2024-05-09 09:59:27 -05:00
|
|
|
return await transformTextNode(node, baseX, baseY);
|
2024-05-13 06:21:46 -05:00
|
|
|
case 'VECTOR':
|
|
|
|
return await transformVectorNode(node, baseX, baseY);
|
2024-04-16 09:08:39 -05:00
|
|
|
case 'STAR':
|
|
|
|
case 'POLYGON':
|
2024-04-17 03:53:38 -05:00
|
|
|
case 'LINE':
|
2024-05-09 09:59:27 -05:00
|
|
|
return await transformPathNode(node, baseX, baseY);
|
2024-04-12 06:55:42 -05:00
|
|
|
}
|
|
|
|
|
2024-04-19 02:48:19 -05:00
|
|
|
console.error(`Unsupported node type: ${node.type}`);
|
2024-04-12 06:55:42 -05:00
|
|
|
};
|