1pub mod border;
39pub mod canvas;
40pub mod color;
41pub mod error;
42pub mod font;
43pub mod image;
44pub mod paint;
45pub mod pixmap;
46pub mod point;
47pub mod rect;
48pub mod surface;
49
50pub use border::{Border, BorderRadius, BorderSide};
52pub use canvas::Canvas;
53pub use color::Color;
54pub use error::{DrawError, FontError, ImageError, Result};
55pub use font::{Font, FontStyle, FontWeight, TextStyle};
56pub use image::{Image, ImageFormat};
57pub use paint::{DashStyle, FilterMode, Paint, PaintStyle, StrokeCap, StrokeJoin};
58pub use pixmap::Pixmap;
59pub use point::{IPoint, Point, PointF};
60pub use rect::{IRect, Rect, RectF};
61pub use surface::Surface;
62
63pub const VERSION: &str = env!("CARGO_PKG_VERSION");
65
66pub const NAME: &str = env!("CARGO_PKG_NAME");
68
69#[cfg(test)]
70mod tests {
71 use super::*;
72
73 #[test]
74 fn test_create_canvas() {
75 let canvas = Canvas::new(100, 100);
76 assert!(canvas.is_ok());
77 let canvas = canvas.unwrap();
78 assert_eq!(canvas.width(), 100);
79 assert_eq!(canvas.height(), 100);
80 }
81
82 #[test]
83 fn test_color_creation() {
84 let color = Color::rgb(255, 0, 0);
85 assert_eq!(color.r, 255);
86 assert_eq!(color.g, 0);
87 assert_eq!(color.b, 0);
88 assert_eq!(color.a, 255);
89 }
90
91 #[test]
92 fn test_color_from_hex() {
93 let color = Color::from_hex("#FF0000").unwrap();
94 assert_eq!(color.r, 255);
95 assert_eq!(color.g, 0);
96 assert_eq!(color.b, 0);
97
98 let color = Color::from_hex("#00FF00FF").unwrap();
99 assert_eq!(color.r, 0);
100 assert_eq!(color.g, 255);
101 assert_eq!(color.b, 0);
102 assert_eq!(color.a, 255);
103 }
104
105 #[test]
106 fn test_point_creation() {
107 let point = Point::new(10, 20);
108 assert_eq!(point.x, 10);
109 assert_eq!(point.y, 20);
110 }
111
112 #[test]
113 fn test_rect_creation() {
114 let rect = Rect::new(10, 20, 100, 50);
115 assert_eq!(rect.x, 10);
116 assert_eq!(rect.y, 20);
117 assert_eq!(rect.width, 100);
118 assert_eq!(rect.height, 50);
119 }
120
121 #[test]
122 fn test_paint_creation() {
123 let paint = Paint::fill(Color::RED);
124 assert_eq!(paint.color(), Color::RED);
125 assert_eq!(paint.style(), PaintStyle::Fill);
126 }
127
128 #[test]
129 fn test_surface_creation() {
130 let surface = Surface::new(100, 100);
131 assert!(surface.is_ok());
132 let surface = surface.unwrap();
133 assert_eq!(surface.width(), 100);
134 assert_eq!(surface.height(), 100);
135 }
136}