bitart: Use choose also for random color
This commit is contained in:
@@ -28,15 +28,15 @@ fn random_color<R: Rng>(rng: &mut R) -> Color {
|
|||||||
let b = rng.random::<u8>();
|
let b = rng.random::<u8>();
|
||||||
let c = 0;
|
let c = 0;
|
||||||
|
|
||||||
let (r, g, b) = match rng.random_range(0..6) {
|
let permutations = [
|
||||||
0 => (a, b, c),
|
(a, b, c),
|
||||||
1 => (a, c, b),
|
(a, c, b),
|
||||||
2 => (b, a, c),
|
(b, a, c),
|
||||||
3 => (b, c, a),
|
(b, c, a),
|
||||||
4 => (c, a, b),
|
(c, a, b),
|
||||||
5 => (c, b, a),
|
(c, b, a),
|
||||||
_ => unreachable!(),
|
];
|
||||||
};
|
let &(r, g, b) = permutations.choose(rng).unwrap();
|
||||||
|
|
||||||
Color::new(r, g, b)
|
Color::new(r, g, b)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user