Skip to main content

Crate spottedcat

Crate spottedcat 

Source
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 NewScene

Re-exports§

pub use model::Model;

Modules§

graphics
Graphics module - split into focused submodules for readability.
model
utils

Structs§

Bounds
Rectangle bounds for defining sub-regions of images.
Context
Drawing context for managing render commands.
DrawOption
Unified options for drawing images and text.
DrawOption3D
Unified options for drawing 3D models.
Image
Handle to an image resource.
InputManager
Pt
ShaderOpts
SoundOptions
Text
Text handle for drawing text to the screen.
TouchInfo
WindowConfig

Enums§

Key
MouseButton
PlatformEvent
Events received from the native platform (e.g. Android JNI or iOS ObjC).
TouchPhase

Traits§

Spot

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