Skip to content

Commit

Permalink
Reorder UniformLabHue and UniformRgbHue
Browse files Browse the repository at this point in the history
  • Loading branch information
okaneco committed Apr 1, 2020
1 parent a9413cf commit 4ba7494
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions palette/src/hues.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,27 +289,27 @@ fn normalize_angle_positive<T: Float + FromF64>(deg: T) -> T {
}

#[cfg(feature = "random")]
pub struct UniformRgbHue<T>
pub struct UniformLabHue<T>
where
T: Float + FromF64 + SampleUniform,
{
hue: Uniform<T>,
}

#[cfg(feature = "random")]
impl<T> SampleUniform for RgbHue<T>
impl<T> SampleUniform for LabHue<T>
where
T: Float + FromF64 + SampleUniform,
{
type Sampler = UniformRgbHue<T>;
type Sampler = UniformLabHue<T>;
}

#[cfg(feature = "random")]
impl<T> UniformSampler for UniformRgbHue<T>
impl<T> UniformSampler for UniformLabHue<T>
where
T: Float + FromF64 + SampleUniform,
{
type X = RgbHue<T>;
type X = LabHue<T>;

fn new<B1, B2>(low_b: B1, high_b: B2) -> Self
where
Expand All @@ -319,10 +319,10 @@ where
let low = *low_b.borrow();
let high = *high_b.borrow();

UniformRgbHue {
UniformLabHue {
hue: Uniform::new(
RgbHue::to_positive_degrees(low),
RgbHue::to_positive_degrees(high),
LabHue::to_positive_degrees(low),
LabHue::to_positive_degrees(high),
),
}
}
Expand All @@ -335,41 +335,41 @@ where
let low = *low_b.borrow();
let high = *high_b.borrow();

UniformRgbHue {
UniformLabHue {
hue: Uniform::new_inclusive(
RgbHue::to_positive_degrees(low),
RgbHue::to_positive_degrees(high),
LabHue::to_positive_degrees(low),
LabHue::to_positive_degrees(high),
),
}
}

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> RgbHue<T> {
RgbHue::from(self.hue.sample(rng) * from_f64(360.0))
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> LabHue<T> {
LabHue::from(self.hue.sample(rng) * from_f64(360.0))
}
}

#[cfg(feature = "random")]
pub struct UniformLabHue<T>
pub struct UniformRgbHue<T>
where
T: Float + FromF64 + SampleUniform,
{
hue: Uniform<T>,
}

#[cfg(feature = "random")]
impl<T> SampleUniform for LabHue<T>
impl<T> SampleUniform for RgbHue<T>
where
T: Float + FromF64 + SampleUniform,
{
type Sampler = UniformLabHue<T>;
type Sampler = UniformRgbHue<T>;
}

#[cfg(feature = "random")]
impl<T> UniformSampler for UniformLabHue<T>
impl<T> UniformSampler for UniformRgbHue<T>
where
T: Float + FromF64 + SampleUniform,
{
type X = LabHue<T>;
type X = RgbHue<T>;

fn new<B1, B2>(low_b: B1, high_b: B2) -> Self
where
Expand All @@ -379,10 +379,10 @@ where
let low = *low_b.borrow();
let high = *high_b.borrow();

UniformLabHue {
UniformRgbHue {
hue: Uniform::new(
LabHue::to_positive_degrees(low),
LabHue::to_positive_degrees(high),
RgbHue::to_positive_degrees(low),
RgbHue::to_positive_degrees(high),
),
}
}
Expand All @@ -395,16 +395,16 @@ where
let low = *low_b.borrow();
let high = *high_b.borrow();

UniformLabHue {
UniformRgbHue {
hue: Uniform::new_inclusive(
LabHue::to_positive_degrees(low),
LabHue::to_positive_degrees(high),
RgbHue::to_positive_degrees(low),
RgbHue::to_positive_degrees(high),
),
}
}

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> LabHue<T> {
LabHue::from(self.hue.sample(rng) * from_f64(360.0))
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> RgbHue<T> {
RgbHue::from(self.hue.sample(rng) * from_f64(360.0))
}
}

Expand Down

0 comments on commit 4ba7494

Please sign in to comment.