summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2025-02-18 09:56:13 -0500
committerTavian Barnes <tavianator@tavianator.com>2025-02-18 09:56:13 -0500
commitd173617ee23b179ed7e9926d124eaa41b855e071 (patch)
tree474663e68a3e4b33230556679fddba6240ef698c /src
parentc404a0a02915e4f6d329d7667ed30b8519b8a964 (diff)
downloadkd-forest-d173617ee23b179ed7e9926d124eaa41b855e071.tar.xz
Update deps
Diffstat (limited to 'src')
-rw-r--r--src/forest.rs2
-rw-r--r--src/frontier/min.rs4
-rw-r--r--src/main.rs12
3 files changed, 6 insertions, 12 deletions
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<io::Error> for AppError {
}
}
-impl From<rand::Error> for AppError {
- fn from(err: rand::Error) -> Self {
- Self::RuntimeError(Box::new(err))
- }
-}
-
/// Result type for this app.
type AppResult<T> = Result<T, AppError>;
@@ -391,7 +385,7 @@ impl App {
self.paint_on(colors, ImageFrontier::<C>::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::<C, _>::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(())
}