From d173617ee23b179ed7e9926d124eaa41b855e071 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 18 Feb 2025 09:56:13 -0500 Subject: Update deps --- src/forest.rs | 2 +- src/frontier/min.rs | 4 ++-- src/main.rs | 12 +++--------- 3 files changed, 6 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/forest.rs b/src/forest.rs index 4feffcb..be31cb0 100644 --- a/src/forest.rs +++ b/src/forest.rs @@ -238,7 +238,7 @@ mod tests { use acap::exhaustive::ExhaustiveSearch; use acap::knn::{NearestNeighbors, Neighbor}; - use rand::prelude::*; + use rand::random; type Point = Euclidean<[f32; 3]>; diff --git a/src/frontier/min.rs b/src/frontier/min.rs index 2a332e6..77c475f 100644 --- a/src/frontier/min.rs +++ b/src/frontier/min.rs @@ -76,9 +76,9 @@ where fn free_neighbor(&mut self, x: u32, y: u32) -> Option<(u32, u32)> { // Pick a pseudo-random neighbor - let offset: usize = self.rng.gen(); - let neighbors = neighbors(x, y); + let offset = self.rng.random_range(..neighbors.len()); + for i in 0..8 { let (x, y) = neighbors[(i + offset) % 8]; if x < self.width && y < self.height { diff --git a/src/main.rs b/src/main.rs index c139ee8..d24ac84 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,7 @@ use crate::frontier::Frontier; use clap::{ArgAction, CommandFactory, Parser, ValueEnum}; use clap::error::ErrorKind; -use image::{self, ColorType, ImageEncoder, ImageError, Rgba, RgbaImage}; +use image::{self, ExtendedColorType, ImageEncoder, ImageError, Rgba, RgbaImage}; use image::codecs::png::{CompressionType, FilterType, PngEncoder}; use rand::{self, SeedableRng}; @@ -193,12 +193,6 @@ impl From for AppError { } } -impl From for AppError { - fn from(err: rand::Error) -> Self { - Self::RuntimeError(Box::new(err)) - } -} - /// Result type for this app. type AppResult = Result; @@ -391,7 +385,7 @@ impl App { self.paint_on(colors, ImageFrontier::::new(&img)) } FrontierArg::Min => { - let rng = Pcg64::from_rng(&mut self.rng)?; + let rng = Pcg64::from_rng(&mut self.rng); self.paint_on(colors, MinFrontier::::new(rng, width, height, x0, y0)) } FrontierArg::Mean => { @@ -410,7 +404,7 @@ impl App { let writer = BufWriter::new(stdout.lock()); let encoder = PngEncoder::new_with_quality(writer, CompressionType::Fast, FilterType::NoFilter); - encoder.write_image(image, image.width(), image.height(), ColorType::Rgba8)?; + encoder.write_image(image, image.width(), image.height(), ExtendedColorType::Rgba8)?; Ok(()) } -- cgit v1.2.3