pub struct Canvas {
    pub(crate) window: PistonWindow,
    pub(crate) points: Option<Vec<Point>>,
    pub(crate) point_count: usize,
    pub(crate) min_distance: f64,
    pub(crate) window_size: [f64; 2],
}
Expand description

The drawing surface and piston window used to display the set of points.

Fields

window: PistonWindowpoints: Option<Vec<Point>>point_count: usizemin_distance: f64window_size: [f64; 2]

Implementations

Returns a new canvas

Arguments
  • point_count - the number of points in the set
  • min_distance - if a pair of points are closer than the min_distance, then one of the points will be removed and replaced with a fresh random point

Begins the decluster loop by listening for render and update window events.

Lazy initialises the the set of points to random locations. This needs to be delayed until the first render so the full-size window dimensions can be can be used to constrain the random locations. This window size only become available when the window is first rendered.

Declusters the current set of points then refills the set with new randomised points. This amounts to a random search for a viable set, that is a set of points where each individual point is seprated by at least the minimum distance.

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 alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. 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.