Expand description
Spot - A simple 2D graphics library for drawing images.
§Example
use spottedcat::{Context, DrawOption, Image, Spot, switch_scene};
struct MyApp {
image: Image,
}
impl Spot for MyApp {
fn initialize(_ctx: &mut Context) -> Self {
let rgba = vec![255u8; 256 * 256 * 4];
let image = Image::new_from_rgba8(_ctx, 256u32.into(), 256u32.into(), &rgba).unwrap();
Self { image }
}
fn draw(&mut self, ctx: &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(ctx, opts);
}
fn update(&mut self, _ctx: &mut Context, _dt: std::time::Duration) {}
fn remove(&mut self, _ctx: &mut Context) {}
}
fn main() {
spottedcat::run::<MyApp>(spottedcat::WindowConfig::default());
}
// Scene switching example:
// switch_scene::<NewScene>(); // Switches to NewSceneRe-exports§
pub use model::Model;
Modules§
Structs§
- 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.
- Draw
Option3D - Unified options for drawing 3D models.
- Image
- Handle to an image resource.
- Input
Manager - Pt
- Shader
Opts - Sound
Options - Text
- Text handle for drawing text to the screen.
- Touch
Info - Window
Config
Enums§
- Key
- Mouse
Button - Platform
Event - Events received from the native platform (e.g. Android JNI or iOS ObjC).
- Touch
Phase
Traits§
Functions§
- compress_
assets - cursor_
position - fade_
in_ sound - fade_
out_ sound - get_
input - get_
registered_ font - ime_
preedit - is_
background_ transparent - is_
sound_ playing - key_
down - key_
pressed - key_
released - load_
asset - mouse_
button_ down - mouse_
button_ pressed - mouse_
button_ pressed_ position - mouse_
button_ released - pause_
sound - play_
sine - play_
sound - play_
sound_ simple - poll_
platform_ events - push_
platform_ event - quit
- register_
font - register_
image_ shader - register_
model_ shader - register_
sound - resume_
sound - run
- set_
background_ transparent - set_
sound_ volume - set_
text_ input_ enabled - stop_
sound - switch_
scene - switch_
scene_ with - text_
input - text_
input_ enabled - touch_
down - touches
- unregister_
font - unregister_
sound - window_
size