mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-22 13:43:03 -05:00
dddc457281
* wip * wip * fix something? * wip * wip * wip * fixes * fixes * stroke image * wip * fixes * fixes * remove old code * fix translate fills * remove penpot public uri * remove old code * fix return undefineds * updated packages * finish refactor --------- Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>
38 lines
898 B
TypeScript
38 lines
898 B
TypeScript
import {
|
|
Command,
|
|
PathContent,
|
|
Segment,
|
|
VECTOR_CLOSE_PATH,
|
|
VECTOR_CURVE_TO,
|
|
VECTOR_LINE_TO,
|
|
VECTOR_MOVE_TO
|
|
} from '@ui/lib/types/shapes/pathShape';
|
|
|
|
export const translatePathContent = (content: PathContent): PathContent =>
|
|
content
|
|
.map(({ command: stringCommand, ...rest }) => {
|
|
const command = translatePathCommand(stringCommand);
|
|
|
|
if (!command) return;
|
|
|
|
return {
|
|
command,
|
|
...rest
|
|
} as Segment;
|
|
})
|
|
.filter((command): command is Segment => !!command);
|
|
|
|
const translatePathCommand = (command: Command): Command | undefined => {
|
|
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;
|
|
}
|
|
|
|
console.error(`Unsupported svg command type: ${String(command)}`);
|
|
};
|