[][src]Struct dither::color::RGB

pub struct RGB<N>(pub N, pub N, pub N);

RGB represents a triplet of pixels (r, g, b). RGB<u8>, RGB<i8>, RGB<i16>, and RGB<u16> are all one-word COPY types.

Methods

impl<P> RGB<P>[src]

pub fn convert_with<Q>(self, convert: impl FnMut(P) -> Q) -> RGB<Q>[src]

map a function across all channels of the RGB.

assert_eq!(RGB(2_u8, 5, 8).convert_with(|channel| channel+10), RGB(12_u8, 15, 18));

pub fn map_across(
    quantize: impl FnMut(P) -> (P, P)
) -> impl FnMut(RGB<P>) -> (RGB<P>, RGB<P>)
[src]

this higher-order function takes a function from function from P to (P, P) and creates the equivalent function that maps it across RGB

.

impl RGB<f64>[src]

impl RGB<u8>[src]

pub const unsafe fn from_hex(hex: u32) -> Self[src]

convert a hexidecimal code to the appropriate RGB value, silently discarding the highest 8 bits, if they exist. Proper use should ensure that the input is less than or equal to 0xFFFFFF

assert_eq!(unsafe{RGB::from_hex(0xff_aa_bb)}, RGB(0xff, 0xaa, 0xbb));

pub fn from_chroma_corrected_black_and_white(p: f64) -> Self[src]

pub fn to_hex(self) -> u32[src]

convert to the equivalent 24-bit hexidecimal integer.

assert_eq!(RGB(0xff, 0, 0).to_hex(), 0xff_00_00)

Trait Implementations

impl Copy for RGB<u8>[src]

impl Copy for RGB<i8>[src]

impl Copy for RGB<i16>[src]

impl Copy for RGB<u16>[src]

impl<N: PartialEq> PartialEq<RGB<N>> for RGB<N>[src]

impl<N: Default> Default for RGB<N>[src]

impl From<RGB<u8>> for RGB<f64>[src]

impl<N: Copy, M: From<N>> From<[N; 3]> for RGB<M>[src]

impl<N, M: From<N>> From<(N, N, N)> for RGB<M>[src]

impl<N: Clone> Clone for RGB<N>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<N: Eq> Eq for RGB<N>[src]

impl<N: Debug> Debug for RGB<N>[src]

impl<N: Sub<Output = N>> Sub<RGB<N>> for RGB<N>[src]

type Output = Self

The resulting type after applying the - operator.

impl<N: Hash> Hash for RGB<N>[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl<N: Add<Output = N>> Add<RGB<N>> for RGB<N>[src]

type Output = Self

The resulting type after applying the + operator.

impl<S: Mul<Output = S> + Copy> Mul<S> for RGB<S>[src]

type Output = Self

The resulting type after applying the * operator.

impl<S: Div<Output = S> + Copy> Div<S> for RGB<S>[src]

type Output = Self

The resulting type after applying the / operator.

impl<S: Rem<Output = S> + Copy> Rem<S> for RGB<S>[src]

type Output = Self

The resulting type after applying the % operator.

impl<N: Neg<Output = N>> Neg for RGB<N>[src]

type Output = Self

The resulting type after applying the - operator.

impl<T: From<u8>> FromStr for RGB<T>[src]

type Err = Error

The associated error which can be returned from parsing.

impl LowerHex for RGB<u8>[src]

impl UpperHex for RGB<u8>[src]

Auto Trait Implementations

impl<N> Send for RGB<N> where
    N: Send

impl<N> Sync for RGB<N> where
    N: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> SetParameter for T

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 

Sets value as a parameter of self.