Trait img::PixelArithmetic [] [src]

pub trait PixelArithmetic: Pixel {
    type ScalarT: Scalar;
    fn add_px_px(self, rhs: Self) -> Self;
    fn sub_px_px(self, rhs: Self) -> Self;
    fn mul_px_px(self, rhs: Self) -> Self;
    fn div_px_px(self, rhs: Self) -> Self;
    fn add_px_sc(self, rhs: Self::ScalarT) -> Self;
    fn sub_px_sc(self, rhs: Self::ScalarT) -> Self;
    fn mul_px_sc(self, rhs: Self::ScalarT) -> Self;
    fn div_px_sc(self, rhs: Self::ScalarT) -> Self;
    fn add_sc_px(self, lhs: Self::ScalarT) -> Self;
    fn sub_sc_px(self, lhs: Self::ScalarT) -> Self;
    fn mul_sc_px(self, lhs: Self::ScalarT) -> Self;
    fn div_sc_px(self, lhs: Self::ScalarT) -> Self;
}

Trait for Pixel types which can be used for arithmetic operations.

For alot of image operations it is convenient to use arithmetic operations on Pixel types. Because this can not be supported for all implementations it is a separated trait.

It is important to note, that you usually want to use this trait directly only for type bounds. This makes it possbile to define functions which require Pixel implementations to be used in arithmetic operations.

Examples

use img::{PixelVal, PixelArithmetic};
fn foo<PixelT>(a: PixelVal<PixelT>, b: PixelVal<PixelT>) -> PixelVal<PixelT>
    where PixelT: PixelArithmetic {
    a + b
}

Associated Types

Required Methods

Add two pixels.

Subtract two pixels.

Multiply two pixels.

Divide two pixels.

Add a pixel and a scalar

Subtract a pixel and a scalar

Multiply a pixel and a scalar

Divide a pixel and a scalar

Add a scalar and a pixel

Subtract a scalar and a pixel

Multiply a scalar and a pixel

Divide a scalar and a pixel

Implementors