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: PistonWindow
§points: Option<Vec<Point>>
§point_count: usize
§min_distance: f64
§window_size: [f64; 2]
Implementations§
Source§impl Canvas
impl Canvas
Sourcepub fn new(point_count: usize, min_distance: f64) -> Self
pub fn new(point_count: usize, min_distance: f64) -> Self
Returns a new canvas
§Arguments
point_count
- the number of points in the setmin_distance
- if a pair of points are closer than themin_distance
, then one of the points will be removed and replaced with a fresh random point
Sourcepub fn show(&mut self)
pub fn show(&mut self)
Begins the decluster loop by listening for render and update window events.
Sourcepub(crate) fn render(&mut self, e: &Event, args: RenderArgs)
pub(crate) fn render(&mut self, e: &Event, args: RenderArgs)
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.
Auto Trait Implementations§
impl !Freeze for Canvas
impl !RefUnwindSafe for Canvas
impl !Send for Canvas
impl !Sync for Canvas
impl Unpin for Canvas
impl !UnwindSafe for Canvas
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more