[][src]Struct simple::Window

pub struct Window { /* fields omitted */ }

A Window can display graphics and handle events.

A Window has a draw color at all times, and that color is applied to every operation. If you set the color to (255, 0, 0), all drawn graphics and images will have a red tint.

Creating multiple Windows is untested and will probably crash!

Methods

impl Window
[src]

Top-level Running / Creation Methods ====================================

pub fn new(name: &str, width: u16, height: u16) -> Self
[src]

Intialize a new running window. name is used as a caption.

pub fn next_frame(&mut self) -> bool
[src]

Redrawing and update the display, while maintaining a consistent framerate and updating the event queue. You should draw your objects immediately before you call this function.

NOTE: This function returns false if the program should terminate. This allows for nice constructs like while app.next_frame() { ... }

pub fn has_event(&self) -> bool
[src]

Return true when there is an event waiting in the queue for processing.

pub fn next_event(&mut self) -> Event
[src]

Get the next event from the queue. NOTE: If the event queue on the Window is empty, this function will panic. Call has_event() to find out if there is an event ready for processing.

Note that events are handled in a first-in-first-out order. If a user presses three keys 1, 2, 3 during a frame, then the next three calls to next_event will return 1, 2, 3 in the same order.

pub fn is_key_down(&self, key: Key) -> bool
[src]

Return true if the button is currently pressed. NOTE: This function is probably not performant.

pub fn is_mouse_button_down(&self, button: MouseButton) -> bool
[src]

Return true if the specified button is down. NOTE: Unknown mouse buttons are NOT handled and will always return false.

pub fn mouse_position(&self) -> (i32, i32)
[src]

Return the current position of the mouse, relative to the top-left corner of the Window.

pub fn set_font(&mut self, font: Font)
[src]

Use this Font for future calls to print().

pub fn quit(&mut self)
[src]

This does not cause the program to exit immediately. It just means that next_frame will return false on the next call.

impl Window
[src]

Drawing Methods ===============

pub fn set_color(&mut self, red: u8, green: u8, blue: u8, alpha: u8)
[src]

Windows have a color set on them at all times. This color is applied to every draw operation. To "unset" the color, call set_color with (255,255,255,255)

pub fn draw_rect(&mut self, rect: Rect)
[src]

pub fn fill_rect(&mut self, rect: Rect)
[src]

pub fn draw_point(&mut self, point: Point)
[src]

pub fn draw_polygon(&mut self, polygon: Polygon)
[src]

pub fn draw_image(&mut self, image: &mut Image, x: i32, y: i32)
[src]

Display the image with its top-left corner at (x, y)

pub fn print(&mut self, text: &str, x: i32, y: i32) -> Rect
[src]

Write the text to the screen at (x, y) using the currently set font on the Window. Return a Rectangle describing the area of the screen that was modified.

pub fn clear(&mut self)
[src]

Clear the screen to black. Does not affect the current rendering color.

pub fn clear_to_color(&mut self, r: u8, g: u8, b: u8)
[src]

Clear the screen to the color you specify.

impl Window
[src]

Resource Loading Methods ========================

pub fn load_image_from_file(&self, filename: &Path) -> Result<Image, String>
[src]

Load the image at the path you specify.

pub fn load_image(&self, data: &[u8]) -> Result<Image, String>
[src]

Load an image from a slice of bytes. This function is particularly powerful when used in conjunction with the include_bytes macro that embeds data in the compiled executable. In this way, you can pack all of your game data into your executable.

pub fn load_font_from_file(
    &self,
    filename: &Path,
    string: String
) -> Result<Font, String>
[src]

Load a Font from the hard drive. See the documentation on Font for details.

pub fn load_font(&self, data: &[u8], string: String) -> Result<Font, String>
[src]

Load a Font from a slice of bytes. See the documentation on Font for details. This function is particularly powerful when used in conjunction with the include_bytes macro that embeds data in the compiled executable.

Auto Trait Implementations

impl !Send for Window

impl !Sync for Window

Blanket Implementations

impl<T> From for T
[src]

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

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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