Hylograph.Config.Force
- Package
- purescript-hylograph-simulation
- Repository
- afcondon/purescript-hylograph-simulation
Force Configuration Module
This module defines immutable force configurations that are separate from the mutable d3-force JavaScript handles. This separation allows for:
- Predictable scene transitions
- Easy parameter resets
- Better type safety
- Improved debuggability
Key types:
- ForceConfig: Complete force specification (type, name, params, filter)
- ForceParams: Type-specific parameters (ManyBody, Collide, etc.)
- AttrValue: Parameter values (static or function-based)
#AttrValue Source
data AttrValue aAn attribute value can be:
- Static: a constant value for all nodes
- Dynamic: computed per node
- DynamicIndexed: computed per node with index
Constructors
StaticValue aDynamicValue (Datum_ -> a)DynamicIndexedValue (Datum_ -> Index_ -> a)
Instances
#ForceFilter Source
data ForceFilterForce filter - applies force only to nodes matching predicate e.g., "tree parents only", "packages only", "modules only"
Constructors
ForceFilter { description :: String, predicate :: Datum_ -> Boolean }
Instances
#ForceParams Source
data ForceParamsType-specific force parameters Each force type has its own set of valid parameters
Constructors
ManyBodyParams { distanceMax :: AttrValue Number, distanceMin :: AttrValue Number, strength :: AttrValue Number, theta :: AttrValue Number }CenterParams { strength :: AttrValue Number, x :: AttrValue Number, y :: AttrValue Number }CollideParams { iterations :: AttrValue Number, radius :: AttrValue Number, strength :: AttrValue Number }ForceXParams { strength :: AttrValue Number, x :: AttrValue Number }ForceYParams { strength :: AttrValue Number, y :: AttrValue Number }RadialParams { radius :: AttrValue Number, strength :: AttrValue Number, x :: AttrValue Number, y :: AttrValue Number }LinkParams { distance :: AttrValue Number, iterations :: AttrValue Number, strength :: AttrValue Number }
Instances
#ForceConfig Source
newtype ForceConfigComplete force configuration This is pure data with no JavaScript references
Constructors
ForceConfig { filter :: Maybe ForceFilter, forceType :: ForceType, name :: Label, params :: ForceParams }
Instances
#manyBodyForce Source
manyBodyForce :: Label -> ForceConfigCreate a many-body force with default parameters Default: repulsive force (negative strength)
#centerForce Source
centerForce :: Label -> ForceConfigCreate a centering force with default parameters
#collideForce Source
collideForce :: Label -> AttrValue Number -> ForceConfigCreate a collision force with default parameters Note: typically you want to provide a custom radius function
#forceX Source
forceX :: Label -> AttrValue Number -> ForceConfigCreate an X-positioning force with default parameters
#forceY Source
forceY :: Label -> AttrValue Number -> ForceConfigCreate a Y-positioning force with default parameters
#radialForce Source
radialForce :: Label -> Number -> ForceConfigCreate a radial force with default parameters
#linkForce Source
linkForce :: Label -> ForceConfigCreate a link force with default parameters
#updateParams Source
updateParams :: ForceConfig -> ForceParams -> ForceConfigUpdate a force's parameters Provides a type-safe way to modify parameters
#withFilter Source
withFilter :: ForceConfig -> ForceFilter -> ForceConfigAdd or update a filter on a force
#withoutFilter Source
withoutFilter :: ForceConfig -> ForceConfigRemove filter from a force
#withStrength Source
withStrength :: Number -> ForceConfig -> ForceConfigUpdate strength parameter (works for forces that have strength)
#withRadius Source
withRadius :: AttrValue Number -> ForceConfig -> ForceConfigUpdate radius parameter (works for Collide and Radial forces)
#withDistance Source
withDistance :: Number -> ForceConfig -> ForceConfigUpdate distance parameter (Link force only)
- 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