[−][src]Crate crow
A pixel perfect 2D graphics library
Examples
use crow::{ glutin::{Event, EventsLoop, WindowBuilder, WindowEvent}, Context, DrawConfig, Texture, }; fn main() -> Result<(), crow::Error> { let mut ctx = Context::new(WindowBuilder::new(), EventsLoop::new())?; let texture = Texture::load(&mut ctx, "path/to/texture.png").expect("Unable to load texture"); let mut surface = ctx.window_surface(); let mut fin = false; loop { ctx.events_loop().poll_events(|event| match event { Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => fin = true, _ => (), }); ctx.clear_color(&mut surface, (0.4, 0.4, 0.8, 1.0))?; ctx.draw(&mut surface, &texture, (100, 150), &DrawConfig::default())?; ctx.finalize_frame()?; if fin { break; } } Ok(()) }
Re-exports
pub use glutin; |
pub use image; |
Modules
color | A collection of useful color matrices. |
target | A collect of useful draw modifiers. |
Structs
Context | A struct storing the global state which is used for all operations which require access to the GPU. |
DrawConfig | How exactly should a texture be drawn? |
ErrDontCare | An error in cases where dealing with errors is hard. This will be slowly replaced by useful error types later on. |
Texture | A two dimensional texture stored in video memory. |
WindowSurface | A handle which can be used to draw to the window. |
Enums
BlendMode | Used in |
Error | The super type of every error in this crate. If this is used as a return type, the question mark operator can always be used. |
LoadTextureError | An error returned by |
Traits
DrawTarget | A trait implemented by types upon which can be drawn. |