Expand description
A 2D Shapes pixel rendering library in rust. Supported shapes are:
- Line2D
- Rectangle2D
- Ellipse2D
- Polygon2D
- Bezier2D [Both quadratic and cubic]
§Example
ⓘ
use ada::{shape, Canvas};
const WIDTH: usize = 512;
const HEIGHT: usize = 512;
pub fn main {
// 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
// draw circle
shape::draw_ellipse2d(350, 200, 100, 100, canvas, &ada::color::BLUE, &mut buffer[..]);
}
Re-exports§
pub use color::Color;
Modules§
- color
- The
color
module is a utility module for defining RGBA colors - errors
- The
errors
module defines the common error types. - shape
- The
shape
module implements the rendering of shapes
Macros§
Structs§
- Canvas
- Container for drawing the shapes
Type Aliases§
- Result
- A type for result generated by Ada