0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 21:53:27 -05:00
penpot-exporter-figma-plugin/plugin-src/transformers/transformRectangleNode.ts
2024-04-16 10:20:57 +02:00

32 lines
867 B
TypeScript

import {
transformBlend,
transformDimensionAndPosition,
transformSceneNode
} from '@plugin/transformers/partials';
import { translateFills } from '@plugin/translators';
import { RectShape } from '@ui/lib/types/rect/rectShape';
export const transformRectangleNode = (
node: RectangleNode,
baseX: number,
baseY: number
): RectShape => {
return {
type: 'rect',
name: node.name,
fills: translateFills(node.fills, node.width, node.height),
transform: {
a: node.absoluteTransform[0][0],
b: node.absoluteTransform[1][0],
c: node.absoluteTransform[0][1],
d: node.absoluteTransform[1][1],
e: 0,
f: 0
},
rotation: -node.rotation < 0 ? -node.rotation + 360 : -node.rotation,
...transformDimensionAndPosition(node, baseX, baseY),
...transformSceneNode(node),
...transformBlend(node)
};
};