fix some rounding errors and color picker breaking everything from last change

This commit is contained in:
bgkillas 2024-10-30 10:31:06 -04:00
parent ad5e02fc75
commit 51ed3e28ea

View file

@ -51,7 +51,7 @@ pub fn replace_color(image: &mut RgbaImage, main: Rgba<u8>, alt: Rgba<u8>, arm:
}
fn to_u8(c: [f64; 4]) -> [u8; 4] {
[c[0] as u8, c[1] as u8, c[2] as u8, c[3] as u8]
[c[0].round() as u8, c[1].round() as u8, c[2].round() as u8, c[3].round() as u8]
}
pub fn make_player_image(image: &mut RgbaImage, colors: PlayerColor) {
@ -191,9 +191,10 @@ pub fn player_skin_display_color_picker(
}
pub fn color_picker(ui: &mut Ui, color: &mut [f64; 4]) {
let mut rgb = Color32::from_rgb(color[0] as u8, color[1] as u8, color[2] as u8);
color_picker_color32(ui, &mut rgb, Alpha::Opaque);
let mut rgb = Color32::from_rgb(color[0].round() as u8, color[1].round() as u8, color[2].round() as u8);
if color_picker_color32(ui, &mut rgb, Alpha::Opaque) {
*color = [rgb.r() as f64, rgb.g() as f64, rgb.b() as f64, 255.0]
}
}
pub fn player_select_current_color_slot(ui: &mut Ui, app: &mut App) {