pub struct ColorBucket { /* private fields */ }
Expand description
Struct holding an Vec<Color>
.
Implements helpful functions for the median cut algorithm.
Implementations§
Source§impl ColorBucket
impl ColorBucket
Sourcepub fn from_pixels(pixels: Vec<Color>) -> Option<Self>
pub fn from_pixels(pixels: Vec<Color>) -> Option<Self>
Creates a ColorBucket
based on the colors passed. Returns None
if passed an empty vector.
§Arguments
colors
- Color vector from which the mean color is created.
§Examples
use iris_lib::color::Color;
use iris_lib::color_bucket::ColorBucket;
let data = vec![Color { r: 15, g: 131, b: 0, a: 255 }, Color { r: 221, g: 11, b: 22, a: 130 }, Color { r: 81, g: 11, b: 16, a: 0 }];
let result = ColorBucket::from_pixels(data.clone()).expect("Passed empty color vector to test.");
Sourcepub fn make_palette(&mut self, iter_count: u8) -> Vec<Color>
pub fn make_palette(&mut self, iter_count: u8) -> Vec<Color>
Creates a color palette from own pixels.
§Arguments
iter_count
- number of iterations to be performed on the bucket.
§Example
use iris_lib::color_bucket::ColorBucket;
use iris_lib::color::Color;
let data = vec![Color { r: 15, g: 131, b: 0, a: 255 }, Color { r: 221, g: 11, b: 22, a: 130 }, Color { r: 81, g: 11, b: 16, a: 0 }];
let mut bucket = ColorBucket::from_pixels(data.clone()).expect("Passed empty color vector to test.");
let result = bucket.make_palette(3);
Trait Implementations§
Source§impl Debug for ColorBucket
impl Debug for ColorBucket
Source§impl PartialEq for ColorBucket
impl PartialEq for ColorBucket
impl StructuralPartialEq for ColorBucket
Auto Trait Implementations§
impl Freeze for ColorBucket
impl RefUnwindSafe for ColorBucket
impl Send for ColorBucket
impl Sync for ColorBucket
impl Unpin for ColorBucket
impl UnwindSafe for ColorBucket
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