0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2025-01-05 06:10:52 -05:00
penpot-exporter-figma-plugin/plugin-src/translators/vectors/translateCommands.ts
Jordi Sala Morales 202e7f4fda
Apply rotations to any figure (#168)
* Apply rotations to any figure

* add changelog

* apply rotations to curves too
2024-06-17 12:14:16 +02:00

18 lines
620 B
TypeScript

import { Command } from 'svg-path-parser';
import { hasRotation } from '@plugin/utils';
import { translateNonRotatedCommands } from '.';
import { translateRotatedCommands } from './translateRotatedCommands';
export const translateCommands = (node: LayoutMixin, commands: Command[], baseRotation: number) => {
if (hasRotation(node.rotation + baseRotation) && node.absoluteBoundingBox) {
return translateRotatedCommands(commands, node.absoluteTransform, node.absoluteBoundingBox);
}
return translateNonRotatedCommands(
commands,
node.absoluteTransform[0][2],
node.absoluteTransform[1][2]
);
};