Struct fdg_sim::force::Force

source ·
pub struct Force<N, E, Ty = Undirected> {
    pub dict: LinkedHashMap<String, Value>,
    pub dict_default: LinkedHashMap<String, Value>,
    pub name: &'static str,
    pub continuous: bool,
    pub info: Option<&'static str>,
    pub update: fn(dict: &LinkedHashMap<String, Value>, graph: &mut ForceGraph<N, E, Ty>, dt: f32),
}
Expand description

A struct that defines how your force behaves.

Fields§

§dict: LinkedHashMap<String, Value>

Current dictionary

§dict_default: LinkedHashMap<String, Value>

Default dictionary

§name: &'static str

Name of the force

§continuous: bool

Whether or not the force should be run on each frame.

§info: Option<&'static str>

A short description of the force.

§update: fn(dict: &LinkedHashMap<String, Value>, graph: &mut ForceGraph<N, E, Ty>, dt: f32)

Force callback function.

Implementations§

Retrieve the name of the force.

Retrieve the force’s information.

Update the graph’s node’s positions for a given interval.

Examples found in repository?
src/simulation.rs (line 128)
127
128
129
130
131
132
133
134
    pub fn update(&mut self, dt: f32) {
        self.parameters.force().update(&mut self.graph, dt);
    }

    /// Update the graph's node's positions for a given interval with a custom [`Force`].
    pub fn update_custom(&mut self, force: &Force<N, E, Ty>, dt: f32) {
        force.update(&mut self.graph, dt)
    }

Retrieve a mutable reference to the force’s internal dictionary.

Retrieve a reference to the force’s internal dictionary.

Reset the force’s internal dictionary.

Retrieve if the force is continuous. Continuous forces run their update on every frame, non-continuous forces run their update every time the user clicks a “Run” button.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.