Expand description
Spot - A simple 2D graphics library for drawing images.
§Example
use spot::{Context, Spot, Image, ImageDrawOptions, switch_scene};
struct MyApp {
image: Image,
}
impl Spot for MyApp {
fn initialize(_context: Context) -> Self {
let rgba = vec![255u8; 256 * 256 * 4];
let image = Image::new_from_rgba8(256, 256, &rgba).unwrap();
Self { image }
}
fn draw(&mut self, context: &mut Context) {
let mut opts = ImageDrawOptions::default();
opts.position = [spot::Pt(100.0), spot::Pt(100.0)];
opts.scale = [0.78125, 0.78125];
self.image.draw(context, opts);
}
fn update(&mut self, _context: &mut Context, _dt: std::time::Duration) {}
fn remove(&self) {}
}
fn main() {
spot::run::<MyApp>(spot::WindowConfig::default());
}
// Scene switching example:
// switch_scene::<NewScene>(); // Switches to NewSceneStructs§
- Bounds
- Rectangle bounds for defining sub-regions of images.
- Context
- Drawing context for managing render commands.
- Draw
Option - Image
- Handle to an image resource.
- Image
Draw Options - Options for drawing images.
- Input
Manager - Pt
- Text
- Text handle for drawing text to the screen.
- Text
Options - Window
Config
Enums§
Traits§
- Spot
- Main application trait that must be implemented by your application.
Functions§
- cursor_
position - get_
input - ime_
preedit - key_
down - key_
pressed - key_
released - load_
font_ from_ bytes - load_
font_ from_ file - run
- Runs the application with the specified Spot type.
- switch_
scene - Switches to a new scene of the specified type.
- text_
input