Skip to content

Commit d775fe6

Browse files
committed
Rename nodeRadiusSquaredLookup to nodeHitSizeAreaLookup
1 parent 875eaaf commit d775fe6

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/MyRing.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct MyRing: View {
2424
.stroke(.clear)
2525
NodeMark(id: 3 * i + 1)
2626
.symbol(.pentagon)
27-
.symbolSize(radius:5.0)
27+
.symbolSize(radius:10)
2828
.foregroundStyle(.blue)
2929
.stroke(.clear)
3030
NodeMark(id: 3 * i + 2)

Sources/Grape/Contents/NodeMark.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public struct NodeMark<NodeID: Hashable>: GraphContent, Identifiable, Equatable
2323
)
2424
)
2525
context.states.currentID = .node(id)
26-
context.nodeRadiusSquaredLookup[id] = simd_length_squared(
26+
context.nodeHitSizeAreaLookup[id] = simd_length_squared(
2727
context.states.currentSymbolSizeOrDefault.simd)
2828
}
2929
}

Sources/Grape/Views/ForceDirectedGraphModel.findNode.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extension ForceDirectedGraphModel {
1313
for i in simulationContext.storage.kinetics.range.reversed() {
1414
let iNodeID = simulationContext.nodeIndices[i]
1515
guard
16-
let iRadius2 = graphRenderingContext.nodeRadiusSquaredLookup[
16+
let iRadius2 = graphRenderingContext.nodeHitSizeAreaLookup[
1717
simulationContext.nodeIndices[i]
1818
]
1919
else { continue }

Sources/Grape/Views/ForceDirectedGraphModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,9 @@ extension ForceDirectedGraphModel {
361361
if let pathBuilder = op.path {
362362
{
363363
let sourceNodeRadius =
364-
sqrt(graphRenderingContext.nodeRadiusSquaredLookup[op.mark.id.source] ?? 0) / 2
364+
sqrt(graphRenderingContext.nodeHitSizeAreaLookup[op.mark.id.source] ?? 0) / 2
365365
let targetNodeRadius =
366-
sqrt(graphRenderingContext.nodeRadiusSquaredLookup[op.mark.id.target] ?? 0) / 2
366+
sqrt(graphRenderingContext.nodeHitSizeAreaLookup[op.mark.id.target] ?? 0) / 2
367367
let angle = atan2(targetPos.y - sourcePos.y, targetPos.x - sourcePos.x)
368368
let sourceOffset = SIMD2<Double>(
369369
cos(angle) * sourceNodeRadius, sin(angle) * sourceNodeRadius

Sources/Grape/Views/GraphRenderingContext.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ public struct _GraphRenderingContext<NodeID: Hashable> {
2424
@usableFromInline
2525
internal var nodeOperations: [RenderOperation<NodeID>.Node] = []
2626

27+
/// A lookup table for the hit area of each node (width * height).
2728
@usableFromInline
28-
internal var nodeRadiusSquaredLookup: [NodeID: Double] = [:]
29+
internal var nodeHitSizeAreaLookup: [NodeID: Double] = [:]
2930

3031
@usableFromInline
3132
internal var linkOperations: [RenderOperation<NodeID>.Link] = []

0 commit comments

Comments
 (0)