Crates.io | ada |
lib.rs | ada |
version | 0.3.0 |
source | src |
created_at | 2021-04-12 14:50:55.442528 |
updated_at | 2021-05-22 21:42:48.059749 |
description | 2D Primitive Shapes Rendering Library |
homepage | https://github.com/deep110/ada |
repository | https://github.com/deep110/ada |
max_upload_size | |
id | 382409 |
size | 70,474 |
A 2D Shapes pixel rendering library in rust. Supported shapes are:
No use of unsafe blocks. #![forbid(unsafe_code)]
is also declared at crate level.
Add this to Cargo.toml
file:
[dependencies]
ada = "0.2.0"
Example code:
use ada::{shape, Canvas};
const WIDTH: usize = 512;
const HEIGHT: usize = 512;
// create a pixel buffer for RGBA values
let mut buffer = vec![0u8; 4 * WIDTH * HEIGHT];
// create canvas
let mut canvas = Canvas::new(WIDTH, HEIGHT).unwrap();
// draw line
shape::draw_line2d(50, 50, 200, 300, canvas, &ada::color::WHITE, &mut buffer[..]);
// draw rectangle
shape::draw_rect2d(50, 100, 100, 150, canvas, &ada::color::RED, &mut buffer[..]); // hollow
shape::draw_rect2d_filled(50, 100, 90, 120, canvas, &ada::color::GREEN, &mut buffer[..]); // filled
You can find more examples for all shapes in examples
folder. To run an example:
cargo run --example draw_hollow
Please feel free to open any issues or pull requests.
This is under Apache 2.0 License.