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/ui-src/translators/translatePathContent.ts
Jordi Sala Morales 73ccf83657
Vectors - Pen & pencil (#35)
* path shapes

* add polygon node

* wip vector

* implement translation of commands and paths

* vectors and polygon

* strokes

* star

* deformed shapes

* simplify star

* simplify star

* fix transformers

---------

Co-authored-by: Alex Sánchez <sion333@gmail.com>
2024-04-16 16:08:39 +02:00

32 lines
716 B
TypeScript

import {
Command,
PathContent,
Segment,
VECTOR_CLOSE_PATH,
VECTOR_CURVE_TO,
VECTOR_LINE_TO,
VECTOR_MOVE_TO
} from '@ui/lib/types/path/PathContent';
export const translatePathContent = (content: PathContent): PathContent =>
content.map(({ command, ...rest }) => {
return {
command: translatePathCommand(command),
...rest
} as Segment;
});
const translatePathCommand = (command: Command): Command => {
switch (command) {
case 'line-to':
return VECTOR_LINE_TO;
case 'close-path':
return VECTOR_CLOSE_PATH;
case 'move-to':
return VECTOR_MOVE_TO;
case 'curve-to':
return VECTOR_CURVE_TO;
}
throw new Error('Unknown path command');
};