Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cenadros committed Apr 26, 2024
1 parent 2a2b90e commit 190a25f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions plugin-src/transformers/partials/transformVectorPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const hasFillGeometry = (node: VectorNode | StarNode | LineNode | PolygonNode):
return 'fillGeometry' in node && node.fillGeometry.length > 0;
};

const hasStrokeGeometry = (node: VectorNode | StarNode | LineNode | PolygonNode): boolean => {
return 'strokeGeometry' in node && node.strokeGeometry.length > 0;
};

const hasStrokeCaps = (node: GeometryMixin & VectorLikeMixin): boolean => {
if (node.strokeCap !== figma.mixed) {
return node.strokeCap !== 'NONE';
Expand All @@ -22,19 +26,20 @@ const hasStrokeCaps = (node: GeometryMixin & VectorLikeMixin): boolean => {
};

const getVectorPaths = (node: VectorNode | StarNode | LineNode | PolygonNode): VectorPaths => {
console.log(node);
switch (node.type) {
case 'STAR':
case 'POLYGON':
return node.fillGeometry;
case 'VECTOR':
// closed figures always work with fillGeometry
if (hasFillGeometry(node)) {
return node.fillGeometry;
// mixed vector & simple open figures
if (hasStrokeGeometry(node) && !hasStrokeCaps(node) && node.strokeGeometry.length > 0) {
return node.strokeGeometry;
}

// open figures without stroke caps work with strokeGeometry
if (!hasStrokeCaps(node) && node.strokeGeometry.length > 0) {
return node.strokeGeometry;
// simple closed figures
if (hasFillGeometry(node)) {
return node.fillGeometry;
}

return node.vectorPaths;
Expand Down

0 comments on commit 190a25f

Please sign in to comment.