Hylograph.ForceEngine.Types
- Package
- purescript-hylograph-simulation
- Repository
- afcondon/purescript-hylograph-simulation
Pure Force Engine Types
These types model the data structures needed for force-directed layouts. The force calculations are pure functions over these structures.
Key insight: D3's force functions just mutate vx/vy on nodes. We can call them directly without the simulation wrapper.
#SimNode Source
type SimNode :: Row Type -> Typetype SimNode extra = { index :: Int, vx :: Number, vy :: Number, x :: Number, y :: Number | extra }
A simulation node with position and velocity. This is the minimal structure that D3 force functions expect.
The extra row allows extending with application-specific data.
Note: vx, vy, index are added by the FFI initialization function.
#SimLink Source
type SimLink :: Row Type -> Row Type -> Typetype SimLink nodeRow linkData = { index :: Int, source :: { x :: Number, y :: Number | nodeRow }, target :: { x :: Number, y :: Number | nodeRow } | linkData }
A link between nodes. Before simulation: source/target are indices or IDs After swizzling: source/target are node references
#SimulationState Source
type SimulationState :: Row Type -> Row Type -> Typetype SimulationState nodeRow linkData = { alpha :: Number, alphaDecay :: Number, alphaMin :: Number, alphaTarget :: Number, links :: Array (RawLink linkData), nodes :: Array (SimNode nodeRow), running :: Boolean, velocityDecay :: Number }
The complete state of a force simulation. We manage this ourselves instead of letting D3 do it.
#ManyBodyConfig Source
type ManyBodyConfig = { distanceMax :: Number, distanceMin :: Number, strength :: Number, theta :: Number }Configuration for a many-body (charge) force
#CollideConfig Source
type CollideConfig = { iterations :: Int, radius :: Number, strength :: Number }Configuration for a collision force
#LinkConfig Source
type LinkConfig = { distance :: Number, iterations :: Int, strength :: Number }Configuration for a link force
#CenterConfig Source
type CenterConfig = { strength :: Number, x :: Number, y :: Number }Configuration for centering force
#ForceXConfig Source
type ForceXConfig = { strength :: Number, x :: Number }Configuration for X positioning force
#ForceYConfig Source
type ForceYConfig = { strength :: Number, y :: Number }Configuration for Y positioning force
#RadialConfig Source
type RadialConfig = { radius :: Number, strength :: Number, x :: Number, y :: Number }Configuration for radial force
#CollideDynamicConfig Source
type CollideDynamicConfig node = { iterations :: Int, radiusAccessor :: node -> Number, strength :: Number }Configuration for collision force with dynamic radius Radius is computed per-node via accessor function
#ForceXDynamicConfig Source
type ForceXDynamicConfig node = { strength :: Number, xAccessor :: node -> Number }Configuration for X positioning force with dynamic target Target X is computed per-node via accessor function
#ForceYDynamicConfig Source
type ForceYDynamicConfig node = { strength :: Number, yAccessor :: node -> Number }Configuration for Y positioning force with dynamic target
#LinkDynamicConfig Source
type LinkDynamicConfig link = { distance :: Number, iterations :: Int, strengthAccessor :: link -> Number }Configuration for link force with dynamic strength per-link Strength is computed per-link via accessor function
- Modules
- Hylograph.
Config. Apply - Hylograph.
Config. Force - Hylograph.
Config. Scene - Hylograph.
ForceEngine - Hylograph.
ForceEngine. Core - Hylograph.
ForceEngine. Demo - Hylograph.
ForceEngine. Events - Hylograph.
ForceEngine. Links - Hylograph.
ForceEngine. Registry - Hylograph.
ForceEngine. Render - Hylograph.
ForceEngine. Setup - Hylograph.
ForceEngine. Setup. WASM - Hylograph.
ForceEngine. Simulation - Hylograph.
ForceEngine. Types - Hylograph.
ForceEngine. WASM - Hylograph.
ForceEngine. WASMEngine - Hylograph.
Scene. Engine - Hylograph.
Scene. Handle - Hylograph.
Scene. Rules - Hylograph.
Scene. Types - Hylograph.
Simulation - Hylograph.
Simulation. Emitter - Hylograph.
Simulation. HATS - Hylograph.
Simulation. Scene - Hylograph.
Transition. Consumers - Hylograph.
Transition. Example