Skip to content

Commit 817daed

Browse files
bors[bot]okaneco
andauthored
Merge #189
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 <[email protected]>
2 parents b4f0dcd + acf85d1 commit 817daed

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

palette/src/lab.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ where
701701
// `a` and `b` both range from (-128.0, 127.0)
702702
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Lab<Wp, T> {
703703
Lab {
704-
l: rng.gen(),
704+
l: rng.gen() * from_f64(100.0),
705705
a: rng.gen() * from_f64(255.0) - from_f64(128.0),
706706
b: rng.gen() * from_f64(255.0) - from_f64(128.0),
707707
white_point: PhantomData,

palette/src/lch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ where
589589
{
590590
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Lch<Wp, T> {
591591
Lch {
592-
l: rng.gen(),
592+
l: rng.gen() * from_f64(100.0),
593593
chroma: crate::Float::sqrt(rng.gen()) * from_f64(128.0),
594594
hue: rng.gen::<LabHue<T>>(),
595595
white_point: PhantomData,

0 commit comments

Comments
 (0)