Function pix_engine::math::random_rng

source ·
pub fn random_rng<T, R>(val: R) -> T
where T: SampleUniform + PartialOrd, R: Into<Range<T>>,
Expand description

Returns a random number within a range.

Examples

use pix_engine::math::random_rng;

let x = random_rng(0.0..1.0); // x will range from (0.0..1.0]
assert!(x >= 0.0 && x < 1.0);

let x = random_rng(20..50); // x will range from (20..50]
assert!(x >= 20 && x < 50);