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