Skip to content

Commit

Permalink
Merge #189
Browse files Browse the repository at this point in the history
189: Correct scaling on random distribution of Lab/Lch r=Ogeon a=okaneco

Add the proper scaling factor for random color distribution in Lab/Lch.

Lab/Lch brightness was being treated as 0-1 instead of 0-100.

Co-authored-by: okaneco <47607823+okaneco@users.noreply.github.com>
  • Loading branch information
bors[bot] and okaneco committed May 16, 2020
2 parents b4f0dcd + acf85d1 commit 817daed
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion palette/src/lab.rs
Expand Up @@ -701,7 +701,7 @@ where
// `a` and `b` both range from (-128.0, 127.0)
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Lab<Wp, T> {
Lab {
l: rng.gen(),
l: rng.gen() * from_f64(100.0),
a: rng.gen() * from_f64(255.0) - from_f64(128.0),
b: rng.gen() * from_f64(255.0) - from_f64(128.0),
white_point: PhantomData,
Expand Down
2 changes: 1 addition & 1 deletion palette/src/lch.rs
Expand Up @@ -589,7 +589,7 @@ where
{
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Lch<Wp, T> {
Lch {
l: rng.gen(),
l: rng.gen() * from_f64(100.0),
chroma: crate::Float::sqrt(rng.gen()) * from_f64(128.0),
hue: rng.gen::<LabHue<T>>(),
white_point: PhantomData,
Expand Down

0 comments on commit 817daed

Please sign in to comment.