Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/li3zhen1/Grape
Browse files Browse the repository at this point in the history
  • Loading branch information
li3zhen1 committed Jan 8, 2024
2 parents b766c7b + 58f01d7 commit 714091d
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ Grape ships 2 modules:

<br/>

### `Grape`
### The `Grape` module

Please refer to [documentation](https://li3zhen1.github.io/Grape/Grape/documentation/grape) to get started.

```swift
import Grape
Expand Down Expand Up @@ -130,23 +132,21 @@ Below is another [example](https://github.com/li3zhen1/Grape/blob/main/Examples/
https://github.com/li3zhen1/Grape/assets/45376537/73213e7f-73ee-44f3-9b3e-7e58355045d2





> [!IMPORTANT]
> `ForceDirectedGraph` is only a minimal working example. Please refer to the next section to create a more complex view.
<br/>



### `ForceSimulation`
### The `ForceSimulation` module
<details>
<summary>Refer to the <a href="https://li3zhen1.github.io/Grape/ForceSimulation/documentation/forcesimulation/">documentation</a> or expand this section to find more about this module.
</summary>

`ForceSimulation` module mainly contains 3 concepts, `Kinetics`, `ForceProtocol` and `Simulation`.

<p align="center">
<img src="https://raw.githubusercontent.com/li3zhen1/Grape/main/Assets/SimulationDiagram.svg" alt="A diagram showing the relationships of `Kinetics`, `ForceProtocol` and `Simulation`. A `Simulation` contains a `Kinetics` and a `ForceProtocol`.">
</p>


- `Kinetics` describes all kinetic states of your system, i.e. position, velocity, link connections, and the variable `alpha` that describes how "active" your system is.
- Forces are any types that conforms to `ForceProtocol`. This module provides most of the forces you will use in force directed graphs. And you can also create your own forces. They should be responsible for 2 tasks:
- `bindKinetics(_ kinetics: Kinetics<Vector>)`: binding to a `Kinetics`. In most cases the force should keep a reference of the `Kinetics` so they know what to mutate when `apply` is called.
Expand All @@ -163,7 +163,8 @@ import simd
import ForceSimulation

// assuming you’re simulating 4 nodes
let nodeCount = 4
let nodeCount = 4


// Connect them
let links = [(0, 1), (1, 2), (2, 3), (3, 0)]
Expand Down Expand Up @@ -200,6 +201,10 @@ for mySimulation in 0..<120 {

See [Example](https://github.com/li3zhen1/Grape/tree/main/Examples/ForceDirectedGraphExample) for more details.

</details>



<br/>

<br/>
Expand All @@ -217,7 +222,7 @@ See [Example](https://github.com/li3zhen1/Grape/tree/main/Examples/ForceDirected
| &emsp;CollideForce ||| |
| &emsp;PositionForce ||| |
| &emsp;RadialForce ||| |
| **SwiftUI View** | 🚧 | | |
| **SwiftUI View** | | | |


<br/>
Expand Down

0 comments on commit 714091d

Please sign in to comment.