Space colors evenly, consistently, etc

Colors should now:
	- Not change if new transfers are added
	- Be evenly spaced throughout the palette
	- Be persistent across refreshes
This commit is contained in:
Emilia Allison 2023-12-29 18:02:00 -05:00
parent 6e08f47955
commit 535b14a586
Signed by: emilia
GPG Key ID: 7A3F8997BFE894E0
2 changed files with 18 additions and 2 deletions

View File

@ -41,6 +41,14 @@ pub fn DestinationPlate(props: &DestinationPlateProps) -> Html {
}
let destination_wells = ct_state.transfer.transfer_region.get_destination_wells();
let ordered_ids: Vec<uuid::Uuid> = {
let mut ids: Vec<uuid::Uuid> = main_state.transfers.clone().iter()
.map(|x| x.id)
.collect();
ids.sort_unstable();
ids
};
let mouse_callback = {
let m_start_handle = m_start_handle.clone();
let m_end_handle = m_end_handle.clone();
@ -118,7 +126,7 @@ pub fn DestinationPlate(props: &DestinationPlateProps) -> Html {
in_transfer={destination_wells.contains(&(i,j))}
color={transfer_map.get(&(i,j))
.and_then(|t| t.last())
.map(|t| PALETTE.get_uuid(t.get_uuid()))
.map(|t| PALETTE.get_ordered(t.get_uuid(), &ordered_ids))
}
cell_height={props.cell_height}
title={transfer_map.get(&(i,j)).map(|transfers| format!("Used by: {}", transfers.iter().map(|t| t.name.clone())

View File

@ -61,6 +61,14 @@ pub fn SourcePlate(props: &SourcePlateProps) -> Html {
let source_wells = ct_state.transfer.transfer_region.get_source_wells();
let ordered_ids: Vec<uuid::Uuid> = {
let mut ids: Vec<uuid::Uuid> = main_state.transfers.clone().iter()
.map(|x| x.id)
.collect();
ids.sort_unstable();
ids
};
let mouse_callback = {
let m_start_handle = m_start_handle.clone();
let m_end_handle = m_end_handle.clone();
@ -122,7 +130,7 @@ pub fn SourcePlate(props: &SourcePlateProps) -> Html {
in_transfer={source_wells.contains(&(i,j))}
color={transfer_map.get(&(i,j))
.and_then(|t| t.last())
.map(|t| PALETTE.get_uuid(t.get_uuid()))
.map(|t| PALETTE.get_ordered(t.get_uuid(), &ordered_ids))
}
cell_height={props.cell_height}
title={transfer_map.get(&(i,j)).map(|transfers| format!("Used by: {}", transfers.iter().map(|t| t.name.clone())