pronto-graphics

Crates.iopronto-graphics
lib.rspronto-graphics
version0.4.0
sourcesrc
created_at2022-04-15 19:42:09.465743
updated_at2022-04-17 10:58:34.009545
descriptionQuick and simple graphics for Rust
homepagehttps://github.com/Garbaz/pronto-graphics/
repositoryhttps://github.com/Garbaz/pronto-graphics/
max_upload_size
id568670
size471,362
(Garbaz)

documentation

README

Pronto Graphics

|| Docs.rs || Lib.rs || Crates.io ||

A library for anyone who just wants to get some graphics on the screen, without having to faff about with the technical details of proper graphics libraries. Just create a window, and start drawing to it. Minimal setup, minimal bother, minimal interference with your own code's structure.

Loosely inspired by Processing.

Examples

You want some circles on the screen?

let mut pg = Window::new(800, 600, "Circles!");
loop {
    pg.circle((100., 100.), 15.);

    pg.fill_color(Color::BLUE);
    pg.circle((300., 450.), 24.);
    
    pg.update();
}

Or a texture?

let mut pg = Window::new_fullscreen();
let my_texture = pg.load_texture("my_texture.png").unwrap();
loop {
    pg.texture((100., 250.), my_texture, 100., 150.);
    
    pg.update();
}

How about some text?

let mut pg = Window::new(720, 480, "Text!");
loop {
    pg.font_color((0xEE, 0x44, 0x88));
    pg.font_size(30);
    pg.text((100., 100.), "Greetings!");
    
    pg.update();
}

Want to press some keys and click some stuff?

let mut pg = Window::new_fullscreen();
loop {
    if pg.key_just_pressed(Key::SPACE) {
        println!("Action!");
    }

    if pg.mouse_pressed(Button::LEFT) {
        pg.circle(pg.mouse_position(), 16.);
    }

    pg.update();
}

Install

Since Pronto Graphics uses SFML for rendering, specifically the SFML bindings for Rust for rendering, it's prerequisites are the same as the SFML Rust bindings, namely for the SFML library to be installed. This might change in future versions.

# Cargo.toml

[dependencies]
pronto-graphics = "0.4.0"

Features

  • Circle, Rectangles, Squares
  • Lines
  • Textures
  • Text
  • Keyboard
  • Mouse
  • Doc comments
  • Custom fonts

Planned

  • Transforms (Rotation, Origin, text alignment)
  • Triangles
  • Arbitrary shapes
  • Audio
  • Caching/Batching of draw calls
  • Draw customization (outline thickness/etc.)

Contributions

I'm no experiences open saucer either, so don't hesitate with pull requests :)

Just make sure to explain what you're adding or changing and to adequately add doc comments to anything that will be exposed to the end-user.

Notes

  • Investigate whether it might be better for performance to create a new SFML object for each draw call, instead of reusing them.
  • Add separate examples for different features, the hello-world.rs is getting quite big.
Commit count: 31

cargo fmt