proper doc comments
This commit is contained in:
12
src/grid.rs
12
src/grid.rs
@@ -4,7 +4,7 @@ use rand::{distributions::Uniform, Rng};
|
||||
use rayon::{iter::ParallelIterator, prelude::*};
|
||||
use std::fmt::{Display, Formatter};
|
||||
|
||||
// A population configuration.
|
||||
/// A population configuration.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct PopulationConfig {
|
||||
pub sensor_distance: f32,
|
||||
@@ -23,7 +23,7 @@ impl Display for PopulationConfig {
|
||||
}
|
||||
|
||||
impl PopulationConfig {
|
||||
// Construct a random configuration.
|
||||
/// Construct a random configuration.
|
||||
pub fn new<R: Rng + ?Sized>(rng: &mut R) -> Self {
|
||||
PopulationConfig {
|
||||
sensor_distance: rng.gen_range(0.0..=64.0),
|
||||
@@ -53,7 +53,7 @@ pub struct Grid {
|
||||
}
|
||||
|
||||
impl Grid {
|
||||
// Create a new grid filled with random floats in the [0.0..1.0) range.
|
||||
/// Create a new grid filled with random floats in the [0.0..1.0) range.
|
||||
pub fn new<R: Rng + ?Sized>(
|
||||
width: usize,
|
||||
height: usize,
|
||||
@@ -74,18 +74,18 @@ impl Grid {
|
||||
}
|
||||
}
|
||||
|
||||
// Truncate x and y and return a corresponding index into the data slice.
|
||||
/// Truncate x and y and return a corresponding index into the data slice.
|
||||
const fn index(&self, x: f32, y: f32) -> usize {
|
||||
crate::util::index(self.width, self.height, x, y)
|
||||
}
|
||||
|
||||
// Add a value to the grid data at a given position.
|
||||
/// Add a value to the grid data at a given position.
|
||||
pub fn deposit(&mut self, x: f32, y: f32) {
|
||||
let idx = self.index(x, y);
|
||||
self.data[idx] += self.config.deposition_amount;
|
||||
}
|
||||
|
||||
// Diffuse grid data and apply a decay multiplier.
|
||||
/// Diffuse grid data and apply a decay multiplier.
|
||||
pub fn diffuse(&mut self, radius: usize) {
|
||||
self.blur.run(
|
||||
&mut self.data,
|
||||
|
||||
Reference in New Issue
Block a user