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