diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2020-06-24 15:20:02 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2020-06-24 15:44:14 -0400 |
commit | 39c0348c9f98b4dd29bd112a0a2a42faa67c92d4 (patch) | |
tree | 6c8ed80bd8cbbb0af79c9ac57bdb39634fa178fd /src/frontier/min.rs | |
parent | adaafdd7043507cbceae65e78c38954e47103b5c (diff) | |
download | kd-forest-master.tar.xz |
Diffstat (limited to 'src/frontier/min.rs')
-rw-r--r-- | src/frontier/min.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/frontier/min.rs b/src/frontier/min.rs index 269f3b7..95b3321 100644 --- a/src/frontier/min.rs +++ b/src/frontier/min.rs @@ -1,19 +1,18 @@ //! Minimum selection frontier. -use super::{neighbors, Frontier, Pixel}; +use super::{neighbors, Frontier, RcPixel, Target}; use crate::color::{ColorSpace, Rgb8}; -use crate::metric::soft::SoftKdForest; -use crate::metric::NearestNeighbors; +use crate::soft::SoftKdForest; -use rand::Rng; +use acap::NearestNeighbors; -use std::rc::Rc; +use rand::Rng; /// A pixel on a min frontier. #[derive(Debug)] struct MinPixel<C> { - pixel: Option<Rc<Pixel<C>>>, + pixel: Option<RcPixel<C>>, filled: bool, } @@ -31,7 +30,7 @@ impl<C: ColorSpace> MinPixel<C> { pub struct MinFrontier<C, R> { rng: R, pixels: Vec<MinPixel<C>>, - forest: SoftKdForest<Rc<Pixel<C>>>, + forest: SoftKdForest<RcPixel<C>>, width: u32, height: u32, x0: u32, @@ -94,7 +93,7 @@ impl<C: ColorSpace, R: Rng> MinFrontier<C, R> { return None; } - let rc = Rc::new(Pixel::new(x, y, color)); + let rc = RcPixel::new(x, y, color); pixel.pixel = Some(rc.clone()); pixel.filled = true; @@ -144,7 +143,7 @@ impl<C: ColorSpace, R: Rng> Frontier for MinFrontier<C, R> { let color = C::from(rgb8); let (x, y) = self .forest - .nearest(&color) + .nearest(&Target(color)) .map(|n| n.item.pos) .map(|(x, y)| self.free_neighbor(x, y).unwrap()) .unwrap_or((self.x0, self.y0)); |