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:
parent
f5a8b9ca6f
commit
9355f282d0
4 changed files with 37 additions and 2 deletions
5
.changeset/many-lamps-stare.md
Normal file
5
.changeset/many-lamps-stare.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"penpot-exporter": patch
|
||||
---
|
||||
|
||||
Fixed correct size for line nodes
|
5
.changeset/new-spiders-travel.md
Normal file
5
.changeset/new-spiders-travel.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"penpot-exporter": patch
|
||||
---
|
||||
|
||||
Fixed line node export when using opacity 0 on the line
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue