diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2020-07-06 23:04:10 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2020-08-24 11:10:13 -0400 |
commit | 6ba084db4ba375eacaa1677fd75de318c12170c7 (patch) | |
tree | 9122e889fcc47d8f6ebd71717a8cb35a98ebafdb /src/frontier | |
parent | 39c0348c9f98b4dd29bd112a0a2a42faa67c92d4 (diff) | |
download | kd-forest-6ba084db4ba375eacaa1677fd75de318c12170c7.tar.xz |
Bump acap to 0.2.0
This requires adapting to the new k-d trees, which are significantly
faster.
Diffstat (limited to 'src/frontier')
-rw-r--r-- | src/frontier/image.rs | 10 | ||||
-rw-r--r-- | src/frontier/mean.rs | 15 | ||||
-rw-r--r-- | src/frontier/min.rs | 15 |
3 files changed, 32 insertions, 8 deletions
diff --git a/src/frontier/image.rs b/src/frontier/image.rs index 18bf620..8b4c233 100644 --- a/src/frontier/image.rs +++ b/src/frontier/image.rs @@ -19,7 +19,10 @@ pub struct ImageFrontier<C> { deleted: usize, } -impl<C: ColorSpace> ImageFrontier<C> { +impl<C: ColorSpace> ImageFrontier<C> +where + C::Value: PartialOrd<C::Distance>, +{ /// Create an ImageFrontier from an image. pub fn new(img: &RgbImage) -> Self { let width = img.width(); @@ -39,7 +42,10 @@ impl<C: ColorSpace> ImageFrontier<C> { } } -impl<C: ColorSpace> Frontier for ImageFrontier<C> { +impl<C: ColorSpace> Frontier for ImageFrontier<C> +where + C::Value: PartialOrd<C::Distance>, +{ fn width(&self) -> u32 { self.width } diff --git a/src/frontier/mean.rs b/src/frontier/mean.rs index 3c441b8..e59e45c 100644 --- a/src/frontier/mean.rs +++ b/src/frontier/mean.rs @@ -17,7 +17,10 @@ enum MeanPixel<C> { Filled(C), } -impl<C: ColorSpace> MeanPixel<C> { +impl<C: ColorSpace> MeanPixel<C> +where + C::Value: PartialOrd<C::Distance>, +{ fn filled_color(&self) -> Option<C> { match self { Self::Filled(color) => Some(*color), @@ -37,7 +40,10 @@ pub struct MeanFrontier<C> { deleted: usize, } -impl<C: ColorSpace> MeanFrontier<C> { +impl<C: ColorSpace> MeanFrontier<C> +where + C::Value: PartialOrd<C::Distance>, +{ /// Create a MeanFrontier with the given dimensions and initial pixel location. pub fn new(width: u32, height: u32, x0: u32, y0: u32) -> Self { let size = (width as usize) * (height as usize); @@ -117,7 +123,10 @@ impl<C: ColorSpace> MeanFrontier<C> { } } -impl<C: ColorSpace> Frontier for MeanFrontier<C> { +impl<C: ColorSpace> Frontier for MeanFrontier<C> +where + C::Value: PartialOrd<C::Distance>, +{ fn width(&self) -> u32 { self.width } diff --git a/src/frontier/min.rs b/src/frontier/min.rs index 95b3321..5c298e7 100644 --- a/src/frontier/min.rs +++ b/src/frontier/min.rs @@ -16,7 +16,10 @@ struct MinPixel<C> { filled: bool, } -impl<C: ColorSpace> MinPixel<C> { +impl<C: ColorSpace> MinPixel<C> +where + C::Value: PartialOrd<C::Distance>, +{ fn new() -> Self { Self { pixel: None, @@ -39,7 +42,10 @@ pub struct MinFrontier<C, R> { deleted: usize, } -impl<C: ColorSpace, R: Rng> MinFrontier<C, R> { +impl<C: ColorSpace, R: Rng> MinFrontier<C, R> +where + C::Value: PartialOrd<C::Distance>, +{ /// Create a MinFrontier with the given dimensions and initial pixel location. pub fn new(rng: R, width: u32, height: u32, x0: u32, y0: u32) -> Self { let size = (width as usize) * (height as usize); @@ -122,7 +128,10 @@ impl<C: ColorSpace, R: Rng> MinFrontier<C, R> { } } -impl<C: ColorSpace, R: Rng> Frontier for MinFrontier<C, R> { +impl<C: ColorSpace, R: Rng> Frontier for MinFrontier<C, R> +where + C::Value: PartialOrd<C::Distance>, +{ fn width(&self) -> u32 { self.width } |