# [−][src]Crate bracket_geometry

This crate is part of the `bracket-lib` family.

It provides point (2D and 3D), rectangle, line and circle plotting functionality. It uses UltraViolet behind the scenes for very fast calculations. If you enable the `serde` feature flag, it implements serialization/deserialization of the primitive types.

For example:

```use bracket_geometry::prelude::*;
let my_point = Point::new(5,6);
println!("{:?}", my_point);```
```use bracket_geometry::prelude::*;

let my_point3 = Point3::new(5,6,7);
println!("{:?}", my_point3);```
```use bracket_geometry::prelude::*;
let my_rect = Rect::with_size(1, 1, 10, 10);
let center = my_rect.center();
println!("{:?}", center);```

Line examples:

```use bracket_geometry::prelude::*;
let bresenham_line = line2d(LineAlg::Bresenham, Point::new(1,1), Point::new(5,5));
println!("{:?}", bresenham_line);```
```use bracket_geometry::prelude::*;
for point in Bresenham::new(Point::new(1,1), Point::new(5,5)) {
println!("{:?}", point);
}```

Circle example:

```use bracket_geometry::prelude::*;
for point in BresenhamCircle::new(Point::new(10,10), 5) {
println!("{:?}", point);
}```

Distance examples:

```use bracket_geometry::prelude::*;
println!("{:?}", DistanceAlg::Pythagoras.distance2d(Point::new(0,0), Point::new(5,5)));
println!("{:?}", DistanceAlg::PythagorasSquared.distance2d(Point::new(0,0), Point::new(5,5)));
println!("{:?}", DistanceAlg::Manhattan.distance2d(Point::new(0,0), Point::new(5,5)));
println!("{:?}", DistanceAlg::Chebyshev.distance2d(Point::new(0,0), Point::new(5,5)));```

## Modules

 prelude