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!
Top-level Running / Creation Methods
====================================
Intialize a new running window. name
is used as a caption.
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() { ... }
Return true when there is an event waiting in the queue for processing.
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.
Return true if the button is currently pressed. NOTE: This function is probably not
performant.
Return true if the specified button is down. NOTE: Unknown mouse buttons are NOT handled
and will always return false
.
Return the current position of the mouse, relative to the top-left corner of the Window.
Use this Font for future calls to print()
.
This does not cause the program to exit immediately. It just means that next_frame
will return false on the next call.
Drawing Methods
===============
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)
Display the image with its top-left corner at (x, y)
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.
Clear the screen to black. Does not affect the current rendering color.
Clear the screen to the color you specify.
Resource Loading Methods
========================
Load the image at the path you specify.
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.
Load a Font from the hard drive. See the documentation on Font
for details.
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.
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static