Hylograph.Forces
- Package
- purescript-hylograph-forces
- Repository
- afcondon/purescript-hylograph-forces
d3-force's forces in PureScript, with no JavaScript for the algorithms, and what the Rust kernel has that d3 does not.
Each force has its own module with an initialize and an apply; this
module gathers them into one Force type and gives d3's loop: cool,
apply each force, move the nodes, and then (the Rust kernel's addition)
apply any hard constraint and put pinned nodes back.
The d3 forces are held to d3-force 3.0.0 bit for bit, and the others to
the Rust kernel built at 64 bits, by test/differential.mjs.
tick, applyForces and the order of a tick are ported from d3-force
3.0.0, simulation.js (ISC, Copyright 2010-2021 Mike Bostock); see
LICENSE.
#linkById Source
linkById :: forall id row linkRow. Ord id => Show id => (Node row -> id) -> Config (Identified id linkRow) -> Source -> Array (Node row) -> Array (Identified id linkRow) -> Either String (Force row)The link force for links that name their nodes by id; d3's error where a link names an id no node has.
#directionalById Source
directionalById :: forall id row linkRow. Ord id => Show id => (Node row -> id) -> Config row (Identified id linkRow) -> Array (Node row) -> Array (Identified id linkRow) -> Either String (Force row)#applyForce Source
applyForce :: forall row. Number -> Force row -> Effect UnitApply one force at the given alpha: d3's force(alpha).
#constrain Source
constrain :: forall row. Array (Force (Pinnable row)) -> Array (Node (Pinnable row)) -> Effect UnitThe part of the forces that runs after the nodes have moved: every hard containment clamps its nodes into their regions and every hard directional constraint projects its links, in the order the forces are listed, and then, if any force was hard, pinned coordinates are put back, so that a pin beats them all. Nothing at all where no force is hard.
#defaultSettings Source
defaultSettings :: Settingsd3's defaults.
#tick Source
tick :: forall row. Settings -> Array (Force (Pinnable row)) -> Array (Node (Pinnable row)) -> Number -> Effect NumberOne tick of d3's simulation: cool alpha, apply the forces at the cooled
alpha, move the nodes; and then the Rust kernel's last step, constrain.
Returns the cooled alpha, to pass to the next tick.
- Modules
- Hylograph.
Forces - Hylograph.
Forces. Center - Hylograph.
Forces. Cohesion - Hylograph.
Forces. Collide - Hylograph.
Forces. Contain - Hylograph.
Forces. Directional - Hylograph.
Forces. Group - Hylograph.
Forces. Link - Hylograph.
Forces. Linkage - Hylograph.
Forces. ManyBody - Hylograph.
Forces. Measure - Hylograph.
Forces. Node - Hylograph.
Forces. Position - Hylograph.
Forces. Quadtree - Hylograph.
Forces. Radial - Hylograph.
Forces. Random - Hylograph.
Forces. RectCollide - Hylograph.
Forces. Snapshot - Hylograph.
Forces. Tick - Hylograph.
Forces. Towards