pub struct Palette { /* private fields */ }
Expand description
Color table for use with indexed Raster
s.
Implementations§
source§impl Palette
impl Palette
sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a new color Palette
.
capacity
Maximum number of entries.
sourcepub fn set_threshold_fn(&mut self, threshold_fn: fn(_: usize) -> SRgb8)
pub fn set_threshold_fn(&mut self, threshold_fn: fn(_: usize) -> SRgb8)
Set the threshold function for matching entries.
threshold_fn
Called when checking whether a color matches an existing entry. The parameter is the palette table size. Returns the maximumChannel
-wise difference to match.
sourcepub fn set_entry(&mut self, clr: SRgb8) -> Option<usize>
pub fn set_entry(&mut self, clr: SRgb8) -> Option<usize>
Set a Palette
entry.
The table is searched for the best matching color within the threshold. If none found, a new entry is added.
clr
Color to lookup or add.
Returns
Index of best matching or added entry if successful. Otherwise, when
no matches are found and the table is full, None
is returned.
sourcepub fn replace_entry(&mut self, i: usize, clr: SRgb8) -> Option<SRgb8>
pub fn replace_entry(&mut self, i: usize, clr: SRgb8) -> Option<SRgb8>
Replace a Palette
entry.
i
Index of entry.clr
Color to replace entry with.
Returns
Previous entry, or None
if index is larger than table size.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Palette
impl Send for Palette
impl Sync for Palette
impl Unpin for Palette
impl UnwindSafe for Palette
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more