Fix: indexing error w.r.t. logarithm argument

This commit is contained in:
Emilia Allison 2023-12-29 18:03:00 -05:00
parent 535b14a586
commit 5e1137c460
Signed by: emilia
GPG Key ID: 7A3F8997BFE894E0
1 changed files with 6 additions and 6 deletions

View File

@ -35,15 +35,15 @@ impl ColorPalette {
self.get((2f64.powi(-(t.ilog2() as i32))) * (t as f64 + 0.5f64) - 1.0f64)
}
pub fn get_uuid(&self, t: uuid::Uuid) -> [f64; 3] {
// self.get(t.as_u128() as f64 / (u128::MAX) as f64)
let mut r = SmallRng::seed_from_u64(t.as_u128() as u64);
self.get(r.gen_range(0.0..1.0f64))
}
// pub fn get_uuid(&self, t: uuid::Uuid) -> [f64; 3] {
// // self.get(t.as_u128() as f64 / (u128::MAX) as f64)
// let mut r = SmallRng::seed_from_u64(t.as_u128() as u64);
// self.get(r.gen_range(0.0..1.0f64))
// }
pub fn get_ordered(&self, t: uuid::Uuid, ordered_uuids: &Vec<uuid::Uuid>)
-> [f64; 3] {
let index = ordered_uuids.iter().position(|&x| x == t).expect("uuid must be in list of uuids");
let index = ordered_uuids.iter().position(|&x| x == t).expect("uuid must be in list of uuids") + 1;
return self.get(Self::space_evenly(index))
}