Skip to content

Commit

Permalink
Merge pull request #2 from JohJakob/develop
Browse files Browse the repository at this point in the history
Version 1.0.1
  • Loading branch information
JohJakob authored Jul 26, 2022
2 parents fb60cd5 + 8366d8c commit e88b8fe
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,34 @@ 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.");
continue;
}

// 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 = "";
Expand Down Expand Up @@ -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.");
Expand Down

0 comments on commit e88b8fe

Please sign in to comment.