diff --git a/src/components/plates/destination_plate.rs b/src/components/plates/destination_plate.rs index 9ac0dd8..68dcb1b 100644 --- a/src/components/plates/destination_plate.rs +++ b/src/components/plates/destination_plate.rs @@ -111,7 +111,7 @@ pub fn DestinationPlate(props: &DestinationPlateProps) -> Html { selected={super::source_plate::in_rect(*m_start_handle.clone(), *m_end_handle.clone(), (i,j))} mouse={mouse_callback.clone()} in_transfer={destination_wells.contains(&(i,j))} - color={color_map.get(&(i,j)).copied().map(|y| (y,color_counter))} + color={color_map.get(&(i,j)).copied()} /> } }).collect::(); @@ -151,7 +151,7 @@ pub struct DestPlateCellProps { pub selected: bool, pub mouse: Callback<(u8, u8, MouseEventType)>, pub in_transfer: Option, - color: Option<(u8, u8)>, + color: Option, } #[function_component] @@ -165,7 +165,7 @@ fn DestPlateCell(props: &DestPlateCellProps) -> Html { _ => None, }; let color = match props.color { - Some(num) => PALETTE.get_u8(num.0, num.1), + Some(num) => PALETTE.get_u8(num), None => [255.0, 255.0, 255.0], }; let mouse = Callback::clone(&props.mouse); diff --git a/src/components/plates/source_plate.rs b/src/components/plates/source_plate.rs index 83f0afd..eb626af 100644 --- a/src/components/plates/source_plate.rs +++ b/src/components/plates/source_plate.rs @@ -113,7 +113,7 @@ pub fn SourcePlate(props: &SourcePlateProps) -> Html { selected={in_rect(*m_start_handle.clone(), *m_end_handle.clone(), (i,j))} mouse={mouse_callback.clone()} in_transfer={source_wells.contains(&(i,j))} - color={color_map.get(&(i,j)).copied().map(|y| (y,color_counter))} + color={color_map.get(&(i,j)).copied()} /> } }) @@ -149,7 +149,7 @@ pub struct SourcePlateCellProps { selected: bool, mouse: Callback<(u8, u8, MouseEventType)>, in_transfer: Option, - color: Option<(u8, u8)>, + color: Option, } #[derive(Debug)] pub enum MouseEventType { @@ -168,7 +168,7 @@ fn SourcePlateCell(props: &SourcePlateCellProps) -> Html { _ => None, }; let color = match props.color { - Some(num) => PALETTE.get_u8(num.0, num.1), + Some(num) => PALETTE.get_u8(num), None => [255.0, 255.0, 255.0], }; let mouse = Callback::clone(&props.mouse); diff --git a/src/components/plates/util.rs b/src/components/plates/util.rs index 5dd970d..df1f498 100644 --- a/src/components/plates/util.rs +++ b/src/components/plates/util.rs @@ -26,13 +26,9 @@ impl ColorPalette { ] } - pub fn get_u8(&self, t: u8, n: u8) -> [f64; 3] { + pub fn get_u8(&self, t: u8) -> [f64; 3] { assert!(t > 0, "t must be greater than zero!"); - assert!(n > 0, "There cannot be zero points!"); - if n == 1 { - return self.get(0.5f64); - } - self.get((t - 1) as f64 / (n - 1) as f64) + self.get((2f64.powi(-1*t.ilog2() as i32)) as f64 * (t as f64 + 0.5f64)-1.0f64) } }