ltk/widget/tab_strip/
icons.rsuse std::cell::RefCell;
use std::collections::HashMap;
use crate::types::Color;
use crate::wallpaper::ImageData;
const RASTER_PX: u32 = 48;
thread_local!
{
static CACHE: RefCell<HashMap<( String, [ u8; 4 ] ), Option<ImageData>>> = RefCell::new( HashMap::new() );
}
pub( crate ) fn tinted( name: &str, tint: Color ) -> Option<ImageData>
{
let key = ( name.to_string(), [ channel( tint.r ), channel( tint.g ), channel( tint.b ), channel( tint.a ) ] );
CACHE.with( |cache|
{
cache.borrow_mut()
.entry( key )
.or_insert_with( || crate::chassis::theme_icon_tinted( name, RASTER_PX, tint ) )
.clone()
} )
}
fn channel( v: f32 ) -> u8
{
( v.clamp( 0.0, 1.0 ) * 255.0 ) as u8
}