pub struct Palette {
pub palette: Vec<[u8; 4]>,
}
Expand description
A palette, composed of group of 16 color when the first is transparent. Colors are RGBA.
Fields§
§palette: Vec<[u8; 4]>
Implementations§
Source§impl Palette
impl Palette
Sourcepub fn new_from_bytes<F: Read + Seek>(file: &mut F) -> Result<Palette, WanError>
pub fn new_from_bytes<F: Read + Seek>(file: &mut F) -> Result<Palette, WanError>
load the Palette. Assume the cursor it located at the palette header
Sourcepub fn get(&self, id: u8, palette_id: u16) -> Option<[u8; 4]>
pub fn get(&self, id: u8, palette_id: u16) -> Option<[u8; 4]>
Return the rgba color for the given color id and palette id.
Return Option::None
if the color doesn’t exist.
Note that the alpha range from 0 to 128 normally, thought this is not an hard guarantee.
pub fn color_id( &self, target_color: [u8; 4], palette_id: u16, ) -> Result<usize, WanError>
pub fn write<F: Write + Seek>(&self, file: &mut F) -> Result<u64, WanError>
Trait Implementations§
impl Eq for Palette
impl StructuralPartialEq for Palette
Auto Trait Implementations§
impl Freeze for Palette
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