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

The underlying subpixel type.

Required Methods

Returns the number of channels of this pixel type.

Returns the components as a slice.

Returns the components as a mutable slice

Construct a pixel from the 4 channels a, b, c and d. If the pixel does not contain 4 channels the extra are ignored.

Returns a string that can help to interprete the meaning each channel See gimp babl.

Returns a view into a slice.

Panics

If the slice it not long enough this method will panic.

Returns mutable view into a mutable slice.

Panics

If the slice it not long enough this method will panic.

Apply the function f to each channel except the alpha channel. Apply the function g to the alpha channel. Works in-place.

Provided Methods

Apply the function f to each channel of this pixel.

Apply the function f to each channel of this pixel.

Apply the function f to each channel except the alpha channel. Apply the function g to the alpha channel.

Apply the function f to each channel of this pixel and other pairwise.

Apply the function f to each channel of this pixel and other pairwise. Works in-place.

Implementors