pub struct Image { /* private fields */ }
Expand description

Images are rectangles of pixels that can be manipulated and drawn on screen

Implementations§

source§

impl Image

source

pub fn new( pixels: Vec<Color>, width: usize, height: usize ) -> Result<Self, GraphicsError>

Create a image of width x height size using provided pixels

source

pub fn new_blank(width: usize, height: usize) -> Self

Create a white image of width x height size

source§

impl Image

source

pub fn width(&self) -> usize

source

pub fn height(&self) -> usize

source

pub fn get_pixel(&self, x: usize, y: usize) -> Color

source

pub fn set_pixel(&mut self, x: usize, y: usize, value: Color)

source

pub fn flip_horizontal(&mut self)

Flip image horizontally

source

pub fn flip_vertical(&mut self)

Flip image vertically

source

pub fn blend(&self, other: &Image) -> Result<Image, GraphicsError>

Blend two images making a new one

source

pub fn scale(&self, algo: Scaling) -> Image

Return a new image after scaling

source

pub fn to_renderable<P: Into<Coord>>( self, xy: P, draw_offset: DrawOffset ) -> RenderableImage

Trait Implementations§

source§

impl Clone for Image

source§

fn clone(&self) -> Image

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Image

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Image

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Renderable<Image> for RenderableImage

source§

fn render(&self, graphics: &mut Graphics<'_>)

source§

impl Serialize for Image

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Tint for Image

source§

fn tint_add( &mut self, r_diff: isize, g_diff: isize, b_diff: isize, a_diff: isize )

Add to the RGBA channels by the amounts specified Read more
source§

fn tint_mul(&mut self, r_diff: f32, g_diff: f32, b_diff: f32, a_diff: f32)

Multiple the RGBA channels by the amounts specified Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Image

§

impl Send for Image

§

impl Sync for Image

§

impl Unpin for Image

§

impl UnwindSafe for Image

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,