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
fn add_px_px(self, rhs: Self) -> Self
Add two pixels.
fn sub_px_px(self, rhs: Self) -> Self
Subtract two pixels.
fn mul_px_px(self, rhs: Self) -> Self
Multiply two pixels.
fn div_px_px(self, rhs: Self) -> Self
Divide two pixels.
fn add_px_sc(self, rhs: Self::ScalarT) -> Self
Add a pixel and a scalar
fn sub_px_sc(self, rhs: Self::ScalarT) -> Self
Subtract a pixel and a scalar
fn mul_px_sc(self, rhs: Self::ScalarT) -> Self
Multiply a pixel and a scalar
fn div_px_sc(self, rhs: Self::ScalarT) -> Self
Divide a pixel and a scalar
fn add_sc_px(self, lhs: Self::ScalarT) -> Self
Add a scalar and a pixel
fn sub_sc_px(self, lhs: Self::ScalarT) -> Self
Subtract a scalar and a pixel
fn mul_sc_px(self, lhs: Self::ScalarT) -> Self
Multiply a scalar and a pixel
fn div_sc_px(self, lhs: Self::ScalarT) -> Self
Divide a scalar and a pixel