Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Hardware-accelerated drawing of shapes, images, and text, with an easy to use API.
Speedy2D aims to be:
- The simplest Rust API for creating a window, rendering graphics/text, and handling input
- Compatible with any device supporting OpenGL 2.0+ or WebGL 2.0. Support for OpenGL ES 2.0+ is planned
- Very fast
Supports Windows, Mac, Linux, and WebGL. Support for Android and iOS is in development.
By default, Speedy2D contains support for setting up a window with an OpenGL
context, and receiving input events. If you'd like to handle this yourself, and
use Speedy2D only for rendering, you can disable the
- Documentation and getting started guide: https://docs.rs/speedy2d
- Crate: https://crates.io/crates/speedy2d
|Draw 2D shapes||✔️||✔️||✔️||✔️|
|Load fonts and draw text||✔️||✔️||✔️||✔️|
|Load and draw images||✔️||✔️||✔️||✔️|
|Window control||✔️||✔️||✔️||ℹ️ Partial|
|DPI/scale change events||✔️||✔️||✔️||✔️|
- Hello world, with text rendering
- All input callbacks
- User-generated events
- WebGL (see the WebGL section below for details)
The example projects can be run using
cargo run --example=hello_world (just
hello_world to the name of the example source file).
Quick Start (Windows/Mac/Linux)
Step 1: Add Speedy2D to your
 = "2.0.0"
Step 2: Create a window:
use Window; let window = new_centered.unwrap;
Step 3: Create a struct implementing the
WindowHandler trait. Override
whichever callbacks you're interested in, for example
use Color; use ; use Graphics2D;
Step 4: Finally, start the event loop by passing your new
For a more detailed getting started guide, including a full list of
callbacks, and how to render text, go to
The full code of the above example is below for your convenience:
use Color; use ; use ;
Alternative: Managing the GL context yourself
If you'd rather handle the window creation and OpenGL context management
yourself, simply disable Speedy2D's
windowing feature in your
file, and create a context as follows. You will need to specify a loader
function to allow Speedy2D to obtain the OpenGL function pointers.
use GLRenderer; let mut renderer = unsafe .unwrap;
Then, draw a frame using
To use Speedy2D with WebGL, your app must be compiled for WebAssembly.
Speedy2D can attach itself to a
canvas on the page using an ID you
As with Windows/Mac/Linux targets, it's possible to use Speedy2D either in a full rendering and event handling configuation, or for rendering only.
For rendering only, use the following API:
For full keyboard/mouse/etc event handling in addition to rendering, use:
After initialization, the usual
WindowHandler callbacks and
Graphics2D APIs should operate as on other platforms.
For an example, see the
examples/webgl directory. To build this, first install
cargo install wasm-bindgen-cli just
Then use the following command to run the build:
Speedy2D is licensed under the Apache license, version 2.0. See LICENSE for more details.
Pull requests for Speedy2D are always welcome. Please ensure the following checks pass locally before submitting.
Note: the automated tests currently only run on Linux.
cargo test cargo test --no-default-features --lib --examples --tests cargo clippy cargo +nightly fmt -- --check cargo doc cargo build --target wasm32-unknown-unknown cargo build --target wasm32-unknown-unknown --no-default-features
These commands can be run automatically using
Some tests require the ability to create a headless OpenGL context.