Skip to content

Commit

Permalink
Merge pull request #34 from swhitty/fix-winding
Browse files Browse the repository at this point in the history
Fixing winding when out of order
  • Loading branch information
swhitty committed Nov 15, 2023
2 parents c8342a0 + f969376 commit d7f58f9
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions SwiftDraw/LayerTree.Path+Reversed.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,17 @@ private extension LayerTree.Path {
var nodes = [SubPathNode]()

for p in subpaths {
let node = SubPathNode(p)
var node = SubPathNode(p)
if let idx = nodes.firstIndex(where: { $0.containsNode(node) }) {
nodes[idx].append(node)
} else {
nodes.append(node)
if let idx = nodes.firstIndex(where: { node.containsNode($0) }) {
// existing node is inside new node
node.append(nodes[idx])
nodes[idx] = node
} else {
nodes.append(node)
}
}
}
return nodes
Expand Down Expand Up @@ -105,7 +111,14 @@ private struct SubPathNode {
if let idx = children.firstIndex(where: { $0.containsNode(node) }) {
children[idx].append(node)
} else {
children.append(node)
if let idx = children.firstIndex(where: { node.containsNode($0) }) {
// existing node is inside new node
var node = node
node.append(children[idx])
children[idx] = node
} else {
children.append(node)
}
}
}

Expand Down

0 comments on commit d7f58f9

Please sign in to comment.