https://github.com/deep110/ada
Primitive shapes rendering library in rust
https://github.com/deep110/ada
Last synced: about 1 year ago
JSON representation
Primitive shapes rendering library in rust
- Host: GitHub
- URL: https://github.com/deep110/ada
- Owner: deep110
- License: apache-2.0
- Created: 2021-01-18T18:46:49.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-22T21:43:28.000Z (about 5 years ago)
- Last Synced: 2025-03-25T09:18:47.003Z (about 1 year ago)
- Language: Rust
- Size: 53.7 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ada
[](https://travis-ci.com/deep110/ada)
[](https://crates.io/crates/ada)
[](https://docs.rs/ada)
A 2D Shapes pixel rendering library in rust. Supported shapes are:
* Line2D
* Rectangle2D
* Ellipse2D
* Polygon2D
* Bezier2D [Both quadratic and cubic]
No use of unsafe blocks. `#![forbid(unsafe_code)]` is also declared at crate level.
## Usage
Add this to `Cargo.toml` file:
```toml
[dependencies]
ada = "0.3.0"
```
Example code:
```rust
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:
```shell
cargo run --example draw_hollow
```
## Contributing
Please feel free to open any issues or pull requests.
## License
This is under Apache 2.0 License.