summaryrefslogtreecommitdiffstats
path: root/src/frontier
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontier')
-rw-r--r--src/frontier/image.rs10
-rw-r--r--src/frontier/mean.rs15
-rw-r--r--src/frontier/min.rs15
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
}