pub struct Palette { /* private fields */ }
Expand description
Color table for use with indexed Raster
s.
Implementations
sourceimpl 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.
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more