bracket_geometry/
lib.rs

1#![warn(clippy::all, clippy::pedantic, clippy::cargo)]
2#![warn(missing_docs)]
3
4//! This crate is part of the `bracket-lib` family.
5//!
6//! It provides point (2D and 3D), rectangle, line and circle plotting functionality.
7//! It uses UltraViolet behind the scenes for very fast calculations. If you enable the
8//! `serde` feature flag, it implements serialization/deserialization of the primitive types.
9//!
10//! For example:
11//! ```rust
12//! use bracket_geometry::prelude::*;
13//! let my_point = Point::new(5,6);
14//! println!("{:?}", my_point);
15//! ```
16//!
17//! ```rust
18//! use bracket_geometry::prelude::*;
19//!
20//! let my_point3 = Point3::new(5,6,7);
21//! println!("{:?}", my_point3);
22//! ```
23//!
24//! ```rust
25//! use bracket_geometry::prelude::*;
26//! let my_rect = Rect::with_size(1, 1, 10, 10);
27//! let center = my_rect.center();
28//! println!("{:?}", center);
29//! ```
30//!
31//! Line examples:
32//!
33//! ```rust
34//! use bracket_geometry::prelude::*;
35//! let bresenham_line = line2d(LineAlg::Bresenham, Point::new(1,1), Point::new(5,5));
36//! println!("{:?}", bresenham_line);
37//! ```
38//!
39//! ```rust
40//! use bracket_geometry::prelude::*;
41//! for point in Bresenham::new(Point::new(1,1), Point::new(5,5)) {
42//!     println!("{:?}", point);
43//! }
44//! ```
45//!
46//! Circle example:
47//!
48//! ```rust
49//! use bracket_geometry::prelude::*;
50//! for point in BresenhamCircle::new(Point::new(10,10), 5) {
51//!     println!("{:?}", point);
52//! }
53//! ```
54//!
55//! Distance examples:
56//!
57//! ```rust
58//! use bracket_geometry::prelude::*;
59//! println!("{:?}", DistanceAlg::Pythagoras.distance2d(Point::new(0,0), Point::new(5,5)));
60//! println!("{:?}", DistanceAlg::PythagorasSquared.distance2d(Point::new(0,0), Point::new(5,5)));
61//! println!("{:?}", DistanceAlg::Manhattan.distance2d(Point::new(0,0), Point::new(5,5)));
62//! println!("{:?}", DistanceAlg::Chebyshev.distance2d(Point::new(0,0), Point::new(5,5)));
63//! ```
64
65mod angle;
66mod angles;
67mod circle_bresenham;
68mod distance;
69mod line_bresenham;
70mod line_vector;
71mod lines;
72mod point;
73mod point3;
74mod rect;
75mod rectf;
76
77/// Export the library into a prelude for convenience. See the main library declaration.
78pub mod prelude {
79    pub use crate::angle::*;
80    pub use crate::angles::*;
81    pub use crate::circle_bresenham::*;
82    pub use crate::distance::*;
83    pub use crate::line_bresenham::*;
84    pub use crate::line_vector::*;
85    pub use crate::lines::*;
86    pub use crate::point::*;
87    pub use crate::point3::*;
88    pub use crate::rect::*;
89    pub use crate::rectf::*;
90}