[−][src]Crate meander
This crate provides a way to show slow change in several variables at once. This change is done in such a way that should explore the value space fairly well while also appearing natural and random.
One place this might be useful is in code that demonstrates how changing certain parameters changes a model.
use meander::rand; use meander::typenum::U3; use meander::Meander; struct Color { r: u8, g: u8, b: u8, } fn random_colors() -> impl Iterator<Item=Color> { rand::random::<Meander<U3>>() .into_time_steps(0.01).map(|a| { match a.as_slice() { // The variables yielded by `Meander` are floats between 0 and 1, // so we multiply by 256 and cast to `u8` to get the range we want. &[r, g, b] => Color { r: (r*256.0) as u8, g: (g*256.0) as u8, b: (b*256.0) as u8, }, _ => unreachable!() } }) }
Re-exports
pub use rand; |
pub use generic_array; |
pub use generic_array::typenum; |
Structs
Meander | Represents a curve that meanders through |
Meander1D | Represents a curve that meanders through 1-dimensional space. Consists of 3 sinusoids whose values are averaged. |
UnitSinusoid | Represents a sinusoid that varies between 0 and 1. |