mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2025-01-05 06:10:52 -05:00
c9f8a0dcd2
* lines & arrows draft * simplify vectors * try to refactor * remove comments * add more clarity to code * fix translate strokes * minor style fix * fix for vectors without geometry * reduce code --------- Co-authored-by: Alex Sánchez <alejandro@runroom.com> Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>
28 lines
738 B
TypeScript
28 lines
738 B
TypeScript
import { translateVectorPaths } from '@plugin/translators';
|
|
|
|
import { PathAttributes } from '@ui/lib/types/path/pathAttributes';
|
|
|
|
const getVectorPaths = (node: VectorNode | StarNode | LineNode | PolygonNode): VectorPaths => {
|
|
switch (node.type) {
|
|
case 'STAR':
|
|
case 'POLYGON':
|
|
return node.fillGeometry;
|
|
case 'VECTOR':
|
|
return node.vectorPaths;
|
|
case 'LINE':
|
|
return node.strokeGeometry;
|
|
}
|
|
};
|
|
|
|
export const transformVectorPaths = (
|
|
node: VectorNode | StarNode | LineNode | PolygonNode,
|
|
baseX: number,
|
|
baseY: number
|
|
): PathAttributes => {
|
|
const vectorPaths = getVectorPaths(node);
|
|
|
|
return {
|
|
type: 'path',
|
|
content: translateVectorPaths(vectorPaths, baseX + node.x, baseY + node.y)
|
|
};
|
|
};
|