Module

Hylograph.Forces.Center

Package
purescript-hylograph-forces
Repository
afcondon/purescript-hylograph-forces

The centering force: shift every node so that their mean position sits at a given point. It moves positions, not velocities.

Ported from d3-force 3.0.0, center.js (ISC, Copyright 2010-2021 Mike Bostock); see LICENSE.

#Config Source

type Config = { strength :: Number, x :: Number, y :: Number }

d3's forceCenter settings.

#defaultConfig Source

defaultConfig :: Config

d3's defaults: the origin, at full strength.

#Center Source

newtype Center :: Row Type -> Typenewtype Center row

An initialized centering force.

#initialize Source

initialize :: forall row. Config -> Array (Node row) -> Center row

d3's force.initialize(nodes).

#apply Source

apply :: forall row. Center row -> Effect Unit

d3's force(). The sums are taken over all the nodes before any node moves, and taken when the force is applied: the nodes are mutable, so reading them is part of the effect.