Expand description
Spot - A simple 2D graphics library for drawing images.
§Example
use spottedcat::{Context, Spot, Image, DrawOption, switch_scene};
struct MyApp {
image: Image,
}
impl Spot for MyApp {
fn initialize(_context: &mut Context) -> Self {
let rgba = vec![255u8; 256 * 256 * 4];
let image = Image::new_from_rgba8(256u32.into(), 256u32.into(), &rgba).unwrap();
Self { image }
}
fn draw(&mut self, context: &mut Context) {
let opts = DrawOption::default()
.with_position([spottedcat::Pt::from(100.0), spottedcat::Pt::from(100.0)])
.with_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() {
spottedcat::run::<MyApp>(spottedcat::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 - Unified options for drawing images and text.
- Image
- Handle to an image resource.
- Input
Manager - Pt
- Shader
Opts - Text
- Text handle for drawing text to the screen.
- Touch
Info - Window
Config
Enums§
Traits§
- Spot
- Main application trait that must be implemented by your application.
Functions§
- cursor_
position - get_
input - get_
registered_ font - ime_
preedit - key_
down - key_
pressed - key_
released - load_
font_ from_ bytes - load_
font_ from_ file - mouse_
button_ down - mouse_
button_ pressed - mouse_
button_ pressed_ position - mouse_
button_ released - register_
font - register_
image_ shader - run
- Runs the application with the specified Spot type.
- set_
text_ input_ enabled - switch_
scene - Switches to a new scene of the specified type.
- switch_
scene_ with - Switches to a new scene and provides a payload for the next scene to read.
- text_
input - text_
input_ enabled - touch_
down - touches
- window_
size