Adjust shades

This commit is contained in:
Simon Gellis 2025-02-25 10:18:36 -05:00
parent f2d3f5ec07
commit fb6f09fce5
1 changed files with 4 additions and 4 deletions

View File

@ -3,12 +3,12 @@ use egui::{Color32, Image, ImageSource, Response, Sense, TextureOptions, Ui, Wid
pub const GENERIC_PALETTE: [u8; 4] = [0, 32, 64, 128]; pub const GENERIC_PALETTE: [u8; 4] = [0, 32, 64, 128];
pub fn shade(brt: u8, color: Color32) -> Color32 { pub fn shade(brt: u8, color: Color32) -> Color32 {
let corrected = if brt & 0x80 != 0 { let corrected = if brt > 132 {
255 255.0
} else { } else {
(brt << 1) | (brt >> 6) (brt as f32 * 255.0 / 133.0).round()
}; };
color.gamma_multiply(corrected as f32 / 255.0) color.gamma_multiply(corrected / 255.0)
} }
pub fn generic_palette(color: Color32) -> [Color32; 4] { pub fn generic_palette(color: Color32) -> [Color32; 4] {