ada/
lib.rs

1//! A 2D Shapes pixel rendering library in rust. Supported shapes are:
2//! * Line2D
3//! * Rectangle2D
4//! * Ellipse2D
5//! * Polygon2D
6//! * Bezier2D [Both quadratic and cubic]
7//! 
8//! # Example
9//! 
10//! ```ignore
11//! use ada::{shape, Canvas};
12//! 
13//! const WIDTH: usize = 512;
14//! const HEIGHT: usize = 512;
15//! 
16//! pub fn main {
17//!     // create a pixel buffer for RGBA values
18//!     let mut buffer = vec![0u8; 4 * WIDTH * HEIGHT];
19//!     
20//!     // create canvas
21//!     let mut canvas = Canvas::new(WIDTH, HEIGHT).unwrap();
22//!     
23//!     // draw line
24//!     shape::draw_line2d(50, 50, 200, 300, canvas, &ada::color::WHITE, &mut buffer[..]);
25//!     
26//!     // draw rectangle
27//!     shape::draw_rect2d(50, 100, 100, 150, canvas, &ada::color::RED, &mut buffer[..]); // hollow
28//!     shape::draw_rect2d_filled(50, 100, 90, 120, canvas, &ada::color::GREEN, &mut buffer[..]); // filled
29//!     
30//!     // draw circle
31//!     shape::draw_ellipse2d(350, 200, 100, 100, canvas, &ada::color::BLUE, &mut buffer[..]);
32//! }
33//! ```
34
35// forbid unsafe code
36#![forbid(unsafe_code)]
37
38#![feature(test)]
39extern crate test;
40
41mod canvas;
42pub mod color;
43pub mod errors;
44pub mod shape;
45
46pub use canvas::Canvas;
47pub use color::Color;
48
49/// A type for result generated by Ada
50pub type Result<T> = core::result::Result<T, errors::Error>;