mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-23 06:04:01 -05:00
c464ff9bda
* added support for corner radius * added support for corner radius * minor fix * added changelog to prettierignore
32 lines
944 B
TypeScript
32 lines
944 B
TypeScript
import { translateVectorPaths } from '@plugin/translators';
|
|
|
|
import { PathAttributes } from '@ui/lib/types/path/pathAttributes';
|
|
|
|
const hasFillGeometry = (node: VectorNode | StarNode | LineNode | PolygonNode): boolean => {
|
|
return 'fillGeometry' in node && node.fillGeometry.length > 0;
|
|
};
|
|
|
|
const getVectorPaths = (node: VectorNode | StarNode | LineNode | PolygonNode): VectorPaths => {
|
|
switch (node.type) {
|
|
case 'STAR':
|
|
case 'POLYGON':
|
|
return node.fillGeometry;
|
|
case 'VECTOR':
|
|
return hasFillGeometry(node) ? node.fillGeometry : 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)
|
|
};
|
|
};
|