[−][src]Struct graphics::image::Image
An image
Example
extern crate piston; extern crate graphics; extern crate glutin_window; extern crate opengl_graphics; use piston::window::WindowSettings; use piston::event::*; use glutin_window::GlutinWindow as Window; use opengl_graphics::{GlGraphics, OpenGL, Texture}; use graphics::{Image, clear, default_draw_state}; use graphics::rectangle::square; use std::path::Path; fn main() { let opengl = OpenGL::_3_2; let mut gl = GlGraphics::new(opengl); let window = Window::new( opengl, WindowSettings::new( "Example", [600, 400] ).exit_on_esc(true)); //Create the image object and attach a square Rectangle object inside. let image = Image::new().rect(square(0.0, 0.0, 200.0)); //A texture to use with the image let texture = Texture::from_path(Path::new("Example.png")).unwrap(); //Main loop for e in window.events() { if let Some(r) = e.render_args() { gl.draw(r.viewport(), |c, gl| { //Clear the screen clear([0.0, 0.0, 0.0, 1.0], gl); //Draw the image with the texture image.draw(&texture, default_draw_state(), c.transform, gl); }); } } }
Fields
color: Option<Color>
The color
rectangle: Option<Rectangle>
The rectangle to draw image inside
source_rectangle: Option<SourceRectangle>
The image source rectangle
Methods
impl Image[src]
impl Imagepub fn new() -> Image[src]
pub fn new() -> ImageCreates a new image
pub fn new_color(color: Color) -> Image[src]
pub fn new_color(color: Color) -> ImageCreates a new colored image
pub fn color(self, value: Color) -> Self[src]
pub fn color(self, value: Color) -> SelfSets color.
pub fn maybe_color(self, value: Option<Color>) -> Self[src]
pub fn maybe_color(self, value: Option<Color>) -> SelfSets optional color.
pub fn rect<R: Into<Rectangle>>(self, value: R) -> Self[src]
pub fn rect<R: Into<Rectangle>>(self, value: R) -> SelfSets rectangle.
pub fn maybe_rect<R: Into<Rectangle>>(self, value: Option<R>) -> Self[src]
pub fn maybe_rect<R: Into<Rectangle>>(self, value: Option<R>) -> SelfSets optional rectangle.
pub fn src_rect(self, value: SourceRectangle) -> Self[src]
pub fn src_rect(self, value: SourceRectangle) -> SelfSets source rectangle.
pub fn maybe_src_rect(self, value: Option<SourceRectangle>) -> Self[src]
pub fn maybe_src_rect(self, value: Option<SourceRectangle>) -> SelfSets optional source rectangle.
pub fn draw<G>(
&self,
texture: &<G as Graphics>::Texture,
draw_state: &DrawState,
transform: Matrix2d,
g: &mut G
) where
G: Graphics, [src]
pub fn draw<G>(
&self,
texture: &<G as Graphics>::Texture,
draw_state: &DrawState,
transform: Matrix2d,
g: &mut G
) where
G: Graphics, Draws image using default method.
pub fn draw_tri<G>(
&self,
texture: &<G as Graphics>::Texture,
draw_state: &DrawState,
transform: Matrix2d,
g: &mut G
) where
G: Graphics, [src]
pub fn draw_tri<G>(
&self,
texture: &<G as Graphics>::Texture,
draw_state: &DrawState,
transform: Matrix2d,
g: &mut G
) where
G: Graphics, Draws image using triangulation.
Trait Implementations
impl Clone for Image[src]
impl Clone for Imagefn clone(&self) -> Image[src]
fn clone(&self) -> ImageReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Copy for Image[src]
impl Copy for ImageAuto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, type Owned = T
fn to_owned(&self) -> T[src]
fn to_owned(&self) -> TCreates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)[src]
fn clone_into(&self, target: &mut T)🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> From for T[src]
impl<T> From for Timpl<T, U> TryFrom for T where
T: From<U>, [src]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>try_from)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, fn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut TMutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>try_from)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeId🔬 This is a nightly-only experimental API. (get_type_id)
this method will likely be replaced by an associated static
Gets the TypeId of self. Read more