0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2025-01-03 05:10:13 -05:00

Fixed line nodes (#96)

* fixed line nodes

* fixed line nodes

* changeset

* changeset

* Update .changeset/new-spiders-travel.md

Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>

---------

Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>
This commit is contained in:
Alex Sánchez 2024-05-10 11:08:00 +02:00 committed by GitHub
parent f5a8b9ca6f
commit 9355f282d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 37 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
"penpot-exporter": patch
---
Fixed correct size for line nodes

View file

@ -0,0 +1,5 @@
---
"penpot-exporter": patch
---
Fixed line node export when using opacity 0 on the line

View file

@ -1,4 +1,4 @@
import { translateVectorPaths } from '@plugin/translators';
import { createLineGeometry, translateVectorPaths } from '@plugin/translators';
import { PathAttributes } from '@ui/lib/types/shapes/pathShape';
@ -10,7 +10,7 @@ const getVectorPaths = (node: VectorNode | StarNode | LineNode | PolygonNode): V
case 'VECTOR':
return node.vectorPaths;
case 'LINE':
return node.strokeGeometry;
return createLineGeometry(node);
}
};

View file

@ -16,6 +16,31 @@ export const translateVectorPaths = (
return segments;
};
export const createLineGeometry = (node: LineNode): VectorPaths => {
const commands: (MoveToCommand | LineToCommand)[] = [];
commands.push({
command: 'moveto',
code: 'M',
x: 0,
y: 0
});
commands.push({
command: 'lineto',
code: 'L',
x: node.width,
y: node.height
});
return [
{
windingRule: 'NONZERO',
data: commands.map(({ code, x, y }) => `${code} ${x} ${y}`).join(' ') + ' Z'
}
];
};
const translateVectorPath = (path: VectorPath, baseX: number, baseY: number): Segment[] => {
const normalizedPaths = parseSVG(path.data);