Skip to content

Commit

Permalink
Merge branch 'TypedView'
Browse files Browse the repository at this point in the history
  • Loading branch information
li3zhen1 committed Jan 7, 2024
2 parents 3b6ebe6 + 495b3eb commit ed2b7d9
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ func buildSimulation() -> Simulation3D<My3DForce> {
forceField: My3DForce()
)

<<<<<<< HEAD
for _ in 0..<720 {
=======
for i in 0..<720 {
>>>>>>> main
sim.tick()
}
return sim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
B70B52AF2AF822FF00A1E6CD /* Grape in Frameworks */ = {isa = PBXBuildFile; productRef = B70B52AE2AF822FF00A1E6CD /* Grape */; };
B71759592AFBFC4B000DF006 /* Miserables.swift in Sources */ = {isa = PBXBuildFile; fileRef = B71759582AFBFC4B000DF006 /* Miserables.swift */; };
B717595B2AFBFDBD000DF006 /* Lattice.swift in Sources */ = {isa = PBXBuildFile; fileRef = B717595A2AFBFDBD000DF006 /* Lattice.swift */; };
<<<<<<< HEAD
B762092F2B49FCD000476B93 /* MermaidVisualization.swift in Sources */ = {isa = PBXBuildFile; fileRef = B762092E2B49FCD000476B93 /* MermaidVisualization.swift */; };
=======
B719E4112AE5FBFC009D6C24 /* ForceDirectedLatticeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B719E4102AE5FBFC009D6C24 /* ForceDirectedLatticeView.swift */; };
>>>>>>> main
B780DD7A2AF84ECB001C605F /* MyRing.swift in Sources */ = {isa = PBXBuildFile; fileRef = B780DD792AF84ECB001C605F /* MyRing.swift */; };
B7AFA55B2ADF4997009C7154 /* ForceDirectedGraphExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7AFA55A2ADF4997009C7154 /* ForceDirectedGraphExampleApp.swift */; };
B7AFA55D2ADF4997009C7154 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7AFA55C2ADF4997009C7154 /* ContentView.swift */; };
Expand All @@ -28,11 +24,7 @@
/* Begin PBXFileReference section */
B71759582AFBFC4B000DF006 /* Miserables.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Miserables.swift; sourceTree = "<group>"; };
B717595A2AFBFDBD000DF006 /* Lattice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Lattice.swift; sourceTree = "<group>"; };
<<<<<<< HEAD
B762092E2B49FCD000476B93 /* MermaidVisualization.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MermaidVisualization.swift; sourceTree = "<group>"; };
=======
B719E4102AE5FBFC009D6C24 /* ForceDirectedLatticeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForceDirectedLatticeView.swift; sourceTree = "<group>"; };
>>>>>>> main
B780DD792AF84ECB001C605F /* MyRing.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MyRing.swift; sourceTree = "<group>"; };
B7AFA5572ADF4997009C7154 /* ForceDirectedGraphExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ForceDirectedGraphExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
B7AFA55A2ADF4997009C7154 /* ForceDirectedGraphExampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForceDirectedGraphExampleApp.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -77,10 +69,6 @@
isa = PBXGroup;
children = (
B780DD792AF84ECB001C605F /* MyRing.swift */,
<<<<<<< HEAD
=======
B719E4102AE5FBFC009D6C24 /* ForceDirectedLatticeView.swift */,
>>>>>>> main
B7AFA55A2ADF4997009C7154 /* ForceDirectedGraphExampleApp.swift */,
B7AFA55C2ADF4997009C7154 /* ContentView.swift */,
B7AFA55E2ADF4999009C7154 /* Assets.xcassets */,
Expand All @@ -89,10 +77,7 @@
B7AFA56E2ADF49D6009C7154 /* Data.swift */,
B71759582AFBFC4B000DF006 /* Miserables.swift */,
B717595A2AFBFDBD000DF006 /* Lattice.swift */,
<<<<<<< HEAD
B762092E2B49FCD000476B93 /* MermaidVisualization.swift */,
=======
>>>>>>> main
);
path = ForceDirectedGraphExample;
sourceTree = "<group>";
Expand Down Expand Up @@ -188,10 +173,7 @@
B7AFA55D2ADF4997009C7154 /* ContentView.swift in Sources */,
B719E4112AE5FBFC009D6C24 /* ForceDirectedLatticeView.swift in Sources */,
B7AFA56F2ADF49D6009C7154 /* Data.swift in Sources */,
<<<<<<< HEAD
B762092F2B49FCD000476B93 /* MermaidVisualization.swift in Sources */,
=======
>>>>>>> main
B71759592AFBFC4B000DF006 /* Miserables.swift in Sources */,
B7AFA55B2ADF4997009C7154 /* ForceDirectedGraphExampleApp.swift in Sources */,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,9 @@ enum ExampleKind {
case ring
case classicMiserable
case lattice
<<<<<<< HEAD
case mermaid

static let list: [ExampleKind] = [.ring, .classicMiserable, .lattice, .mermaid]
=======

static let list: [ExampleKind] = [.ring, .classicMiserable, .lattice]
>>>>>>> main
}

extension ExampleKind {
Expand All @@ -90,11 +85,8 @@ extension ExampleKind {
return "Miserables"
case .lattice:
return "Lattice"
<<<<<<< HEAD
case .mermaid:
return "Mermaid visualization"
=======
>>>>>>> main
}
}
}
Expand All @@ -116,11 +108,8 @@ struct ContentView: View {
MiserableGraph()
case .lattice:
Lattice()
<<<<<<< HEAD
case .mermaid:
MermaidVisualization()
=======
>>>>>>> main
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,44 +33,25 @@ struct Lattice: View {
@inlinable
var body: some View {
ForceDirectedGraph($isRunning) {
<<<<<<< HEAD

Repeated(0..<(width*width)) { i in
let _i = Double(i / width) / Double(width)
let _j = Double(i % width) / Double(width)
=======
ForEach(Array(0..<(width*width)), id:\.self) { i in

let _i = Double(i / width) / Double(width)
let _j = Double(i % width) / Double(width)

>>>>>>> main
NodeMark(id: i, radius: 3.0)
.foregroundStyle(Color(red: 1, green: _i, blue: _j))
.stroke()
}
<<<<<<< HEAD

Repeated(edge) {
LinkMark(from: $0.0, to: $0.1)
}

=======
for l in edge {

LinkMark(from: l.0, to: l.1)
}
>>>>>>> main
} force: {
LinkForce(
originalLength: .constant(0.8),
stiffness: .weightedByDegree(k: { _, _ in 1})
)
ManyBodyForce(strength: -0.8)
<<<<<<< HEAD
=======

>>>>>>> main
}
.toolbar {
Button {
Expand All @@ -80,9 +61,6 @@ struct Lattice: View {
Text(isRunning ? "Pause" : "Start")
}
}
<<<<<<< HEAD

=======
>>>>>>> main
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
//
<<<<<<< HEAD
// Miserables.swift
=======
// ForceDirectedGraphSwiftUIExample.swift
>>>>>>> main
// ForceDirectedGraphExample
//
// Created by li3zhen1 on 11/5/23.
Expand All @@ -12,7 +8,6 @@
import Foundation
import Grape
import SwiftUI
<<<<<<< HEAD
import Charts


Expand Down Expand Up @@ -54,70 +49,13 @@ struct MiserableGraph: View {
LinkMark(from: l.source, to: l.target)
}
//
=======
import ForceSimulation
import Charts


//struct MyForceField: ForceField {
//
// typealias Vector = SIMD2<Double>
//
// public var force = CompositedForce {
// LinkForce(
// originalLength: .constant(20.0),
// stiffness: .weightedByDegree(k: { _, _ in 3.0})
// )
// CenterForce()
// ManyBodyForce(strength: -15)
// }
//}



struct MiserableGraph: View {

@State var isRunning = false
let graphData = getData(miserables)

var body: some View {
ForceDirectedGraph($isRunning) {

for l in graphData.links {
let fromID = graphData.nodes.firstIndex { mn in
mn.id == l.source
}!
let toID = graphData.nodes.firstIndex { mn in
mn.id == l.target
}!
LinkMark(from: fromID, to: toID)
}
ForEach(graphData.nodes.indices, id: \.self) { i in
NodeMark(id: i)
.symbol(.asterisk)
.symbolSize(radius: 12.0)
.foregroundStyle(
colors[graphData.nodes[i].group % colors.count]
.shadow(.inner(color:colors[graphData.nodes[i].group % colors.count].opacity(0.3), radius: 3, x:0, y: 1.5))
.shadow(.drop(color:colors[graphData.nodes[i].group % colors.count].opacity(0.12), radius: 12, x:0, y: 8))
)
.stroke()
.label(offset: CGVector(dx: 0.0, dy: 12.0)) {
// if i.isMultiple(of: 5) {
Text(graphData.nodes[i].id)
.font(.title3)
// }
}
}
>>>>>>> main
} force: {
ManyBodyForce(strength: -20)
LinkForce(
originalLength: .constant(35.0),
stiffness: .weightedByDegree(k: { _, _ in 1.0})
)
CenterForce()
<<<<<<< HEAD
}
.onNodeTapped { node in
inspectorPresented = true
Expand All @@ -134,16 +72,6 @@ struct MiserableGraph: View {
if opacity < 1 {
opacity = 1
}
=======
// CollideForce()
}
.onNodeTapped {
print($0)
}
.toolbar {
Button {
isRunning = !isRunning
>>>>>>> main
} label: {
Image(systemName: isRunning ? "pause.fill" : "play.fill")
Text(isRunning ? "Pause" : "Start")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ struct MyRing: View {


ForceDirectedGraph($isRunning) {
<<<<<<< HEAD
Repeated(0..<20) { i in
=======
ForEach(Array(0..<20), id: \.self) { i in
>>>>>>> main
NodeMark(id: 3 * i + 0)
.symbol(.circle)
.symbolSize(radius:4.0)
Expand All @@ -53,7 +49,6 @@ struct MyRing: View {
.symbolSize(radius:6.0)
.foregroundStyle(.yellow)

<<<<<<< HEAD


LinkMark(from: 3 * i + 0, to: 3 * i + 1)
Expand All @@ -63,14 +58,6 @@ struct MyRing: View {
LinkMark(from: 3 * i + 1, to: 3 * ((i + 1) % 20) + 1)
LinkMark(from: 3 * i + 2, to: 3 * ((i + 1) % 20) + 2)

=======
LinkMark(from: 3 * i + 0, to: 3 * i + 1)
LinkMark(from: 3 * i + 1, to: 3 * i + 2)

for j in 0..<3 {
LinkMark(from: 3 * i + j, to: 3 * ((i + 1) % 20) + j)
}
>>>>>>> main
}
} force: {
ManyBodyForce(strength: -15)
Expand Down

0 comments on commit ed2b7d9

Please sign in to comment.