Skip to content

Commit

Permalink
Update code for rand 0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Icelk committed Jan 28, 2025
1 parent 0fcc0f0 commit a798577
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,10 @@ pub mod primitives {
}
}
/// enables using `rng.gen` to get a Vec3, with x,y,z between 0 and 1
impl rand::distributions::Distribution<Vec3> for rand::distributions::Standard {
impl rand::distr::Distribution<Vec3> for rand::distr::StandardUniform {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Vec3 {
Vec3::new(rng.gen(), rng.gen(), rng.gen())
let values: [f64; 3] = rng.random();
Vec3::new(values[0], values[1], values[2])
}
}

Expand Down Expand Up @@ -652,7 +653,7 @@ impl Runtime {
zbuf: ImageBuffer::new(0, 0),
max: 0,

rng: rand::rngs::SmallRng::from_entropy(),
rng: rand::rngs::SmallRng::from_os_rng(),
}
}
/// Creates a new runtime from the dimensions of [`Config`].
Expand Down Expand Up @@ -744,7 +745,7 @@ impl Runtime {
/// `rotation` is around [`View::center_camera`], in radians.
#[allow(clippy::many_single_char_names)]
pub fn render(config: &Config<impl Attractor, impl ColorTransform>, runtime: &mut Runtime) {
let mut initial_point = runtime.rng.gen::<Vec3>() * 0.1;
let mut initial_point = runtime.rng.random::<Vec3>() * 0.1;
// skip first 1000 to get good values in the attractor
for _ in 0..1000 {
initial_point = config.attractor.next_point(initial_point);
Expand Down

0 comments on commit a798577

Please sign in to comment.