pub struct Image { /* private fields */ }
Expand description
Images are a rectangle of pixels that can be manipulated and drawn on screen/saved to disk
Implementations§
Source§impl Image
impl Image
Sourcepub fn new(
pixels: Vec<Color>,
width: usize,
height: usize,
) -> Result<Image, GraphicsError>
pub fn new( pixels: Vec<Color>, width: usize, height: usize, ) -> Result<Image, GraphicsError>
Create an image of width x height size using provided pixels
Sourcepub fn new_blank(width: usize, height: usize) -> Image
pub fn new_blank(width: usize, height: usize) -> Image
Create a white image of width x height size
pub fn from_indexed(indexed_image: &IndexedImage) -> Image
Source§impl Image
impl Image
pub fn width(&self) -> usize
pub fn height(&self) -> usize
Sourcepub fn is_transparent(&self) -> bool
pub fn is_transparent(&self) -> bool
Returns true if any pixels are transparent
pub fn pixels(&self) -> &[Color]
pub fn get_pixel(&self, x: usize, y: usize) -> Color
pub fn set_pixel(&mut self, x: usize, y: usize, value: Color)
pub fn blend_pixel(&mut self, x: usize, y: usize, value: Color)
Sourcepub fn flip_horizontal(&mut self)
pub fn flip_horizontal(&mut self)
Flip image horizontally
Sourcepub fn flip_vertical(&mut self)
pub fn flip_vertical(&mut self)
Flip image vertically
Sourcepub fn rotate_ccw(&mut self) -> Image
pub fn rotate_ccw(&mut self) -> Image
Rotate 90° counterclockwise
pub fn to_renderable<P>(self, xy: P, draw_offset: DrawOffset) -> RenderableImage
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Image
impl<'de> Deserialize<'de> for Image
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Image, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Image, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Renderable<Image> for RenderableImage
impl Renderable<Image> for RenderableImage
Source§impl Serialize for Image
impl Serialize for Image
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Eq for Image
impl StructuralPartialEq for Image
Auto Trait Implementations§
impl Freeze for Image
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.