[][src]Struct canrust::utils::Image

pub struct Image { /* fields omitted */ }

Struct containing an image which can be projected onto the Canvas.

Implementations

impl Image[src]

pub fn from_file(path: &str, position: (f32, f32)) -> Result<Self, String>[src]

Load a new image from file.

pub fn from_image(img: &Image) -> Option<Self>[src]

Clones an existing image from reference

impl Image[src]

pub fn save(&self, path: &str) -> Result<(), String>[src]

Saves Image to file

pub fn get_size(&self) -> Option<(u32, u32)>[src]

Returns size of the Image

pub fn get_pixel(&self, x: u32, y: u32) -> Option<Color>[src]

Returns color of a pixel at give coordinates

pub fn put_pixel(&mut self, x: u32, y: u32, color: Color) -> Result<(), String>[src]

Gives a pixel at given coordinates a color. Returns and Error if the coordinates are too large.

pub fn pixels_memory(&self) -> Option<&[u8]>[src]

Returns Images memory buffer

pub fn set_position(&mut self, pos: (f32, f32)) -> Result<(), String>[src]

Sets objects position on the Canvas

pub fn get_position(&self) -> Option<(f32, f32)>[src]

Returns objects position on the Canvas

pub fn set_rotation(&mut self, angle: f32) -> Result<(), String>[src]

Sets the angle at which the image will be displayed on Canvas

Trait Implementations

impl CShape for Image[src]

impl Clone for Image[src]

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

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

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

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

impl<T> From<T> for T[src]

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

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

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.