diff --git a/src/code.ts b/src/code.ts index f895462..5aa1312 100644 --- a/src/code.ts +++ b/src/code.ts @@ -10,7 +10,12 @@ const makeFilled = (selection) => { // Only process visible nodes if (node.visible) { - if (node.type === "ELLIPSE" || node.type === "POLYGON" || node.type === "STAR" || node.type === "RECTANGLE" || node.type === "VECTOR") { + if (node.type === "BOOLEAN_OPERATION") { + // Process children of boolean operation nodes + makeFilled(node.children); + } + + if (node.type === "ELLIPSE" || node.type === "POLYGON" || node.type === "STAR" || node.type === "RECTANGLE" || node.type === "VECTOR" || node.type === "BOOLEAN_OPERATION") { // Skip node if it is just a line if (node.type === "VECTOR" && node.vectorNetwork.segments.length < 2) { figma.notify("Lines cannot be filled."); @@ -18,22 +23,21 @@ const makeFilled = (selection) => { } // Skip node if it has no stroke - if (node.strokeWeight === 0) { + if (node.strokes.length === 0) { continue; } - if ("strokes" in node) { - // Save first stroke of node - strokes = clone(node.strokes[0]); - } + // Save first stroke of node + strokes = clone(node.strokes[0]); // Clone node to be filled const fillNode = node.clone(); - // Reparent cloned node and set its position + // Reparent cloned node and set its position and rotation node.parent.appendChild(fillNode); fillNode.x = node.x; fillNode.y = node.y; + fillNode.rotation = node.rotation; // Remove strokes from cloned node fillNode.strokeStyleId = ""; @@ -69,8 +73,8 @@ const makeFilled = (selection) => { } madeFilled = true; - } else if (node.type === "BOOLEAN_OPERATION" || node.type === "COMPONENT" || node.type === "FRAME" || node.type === "GROUP" || node.type === "INSTANCE") { - // Process the children of boolean operation nodes, components, frames, groups, and instances + } else if (node.type === "COMPONENT" || node.type === "FRAME" || node.type === "GROUP" || node.type === "INSTANCE") { + // Process the children of components, frames, groups, and instances makeFilled(node.children); } else { figma.notify("This layer type is not supported.");