Trait image_buffer::Color
[−]
[src]
pub trait Color: Copy + Clone + AsRef<Self::Storage> + AsMut<Self::Storage> + 'static { type Subpixel: Primitive; type Storage: AsRef<[Self::Subpixel]> + AsMut<[Self::Subpixel]> + 'static; fn channel_count() -> usize; fn channels(&self) -> &Self::Storage; fn channels_mut(&mut self) -> &mut Self::Storage; fn from_channels(_: Self::Storage) -> Self; fn color_model() -> &'static str; fn from_slice<'a>(slice: &'a [Self::Subpixel]) -> &'a Self; fn from_slice_mut<'a>(slice: &'a mut [Self::Subpixel]) -> &'a mut Self; fn apply_with_alpha<F, G>(&mut self, f: F, g: G)
where
F: Fn(Self::Subpixel) -> Self::Subpixel,
G: Fn(Self::Subpixel) -> Self::Subpixel; fn map<F>(&self, f: F) -> Self
where
F: Fn(Self::Subpixel) -> Self::Subpixel, { ... } fn apply<F>(&mut self, f: F)
where
F: Fn(Self::Subpixel) -> Self::Subpixel, { ... } fn map_with_alpha<F, G>(&self, f: F, g: G) -> Self
where
F: Fn(Self::Subpixel) -> Self::Subpixel,
G: Fn(Self::Subpixel) -> Self::Subpixel, { ... } fn map2<F>(&self, other: &Self, f: F) -> Self
where
F: Fn(Self::Subpixel, Self::Subpixel) -> Self::Subpixel, { ... } fn apply2<F>(&mut self, other: &Self, f: F)
where
F: Fn(Self::Subpixel, Self::Subpixel) -> Self::Subpixel, { ... } }
A generalized pixel.
A pixel object is usually not used standalone but as a view into an image buffer.
Associated Types
type Subpixel: Primitive
The underlying subpixel type.
type Storage: AsRef<[Self::Subpixel]> + AsMut<[Self::Subpixel]> + 'static
Required Methods
fn channel_count() -> usize
Returns the number of channels of this pixel type.
fn channels(&self) -> &Self::Storage
Returns the components as a slice.
fn channels_mut(&mut self) -> &mut Self::Storage
Returns the components as a mutable slice
fn from_channels(_: Self::Storage) -> Self
Construct a pixel from the 4 channels a, b, c and d. If the pixel does not contain 4 channels the extra are ignored.
fn color_model() -> &'static str
Returns a string that can help to interprete the meaning each channel See gimp babl.
fn from_slice<'a>(slice: &'a [Self::Subpixel]) -> &'a Self
fn from_slice_mut<'a>(slice: &'a mut [Self::Subpixel]) -> &'a mut Self
Returns mutable view into a mutable slice.
Panics
If the slice it not long enough this method will panic.
fn apply_with_alpha<F, G>(&mut self, f: F, g: G) where
F: Fn(Self::Subpixel) -> Self::Subpixel,
G: Fn(Self::Subpixel) -> Self::Subpixel,
F: Fn(Self::Subpixel) -> Self::Subpixel,
G: Fn(Self::Subpixel) -> Self::Subpixel,
Apply the function f
to each channel except the alpha channel.
Apply the function g
to the alpha channel. Works in-place.
Provided Methods
fn map<F>(&self, f: F) -> Self where
F: Fn(Self::Subpixel) -> Self::Subpixel,
F: Fn(Self::Subpixel) -> Self::Subpixel,
Apply the function f
to each channel of this pixel.
fn apply<F>(&mut self, f: F) where
F: Fn(Self::Subpixel) -> Self::Subpixel,
F: Fn(Self::Subpixel) -> Self::Subpixel,
Apply the function f
to each channel of this pixel.
fn map_with_alpha<F, G>(&self, f: F, g: G) -> Self where
F: Fn(Self::Subpixel) -> Self::Subpixel,
G: Fn(Self::Subpixel) -> Self::Subpixel,
F: Fn(Self::Subpixel) -> Self::Subpixel,
G: Fn(Self::Subpixel) -> Self::Subpixel,
Apply the function f
to each channel except the alpha channel.
Apply the function g
to the alpha channel.
fn map2<F>(&self, other: &Self, f: F) -> Self where
F: Fn(Self::Subpixel, Self::Subpixel) -> Self::Subpixel,
F: Fn(Self::Subpixel, Self::Subpixel) -> Self::Subpixel,
Apply the function f
to each channel of this pixel and
other
pairwise.
fn apply2<F>(&mut self, other: &Self, f: F) where
F: Fn(Self::Subpixel, Self::Subpixel) -> Self::Subpixel,
F: Fn(Self::Subpixel, Self::Subpixel) -> Self::Subpixel,
Apply the function f
to each channel of this pixel and
other
pairwise. Works in-place.