Crate geologic

Source
Expand description

Mathematical and geometrical abstractions with a focus on ergonomics.

§Disclaimer

This library is a work in progress still, there may be breaking changes between versions.

If you want a missing feature or want to report a bug, please create an issue on GitHub.

§Examples

// Import the prelude for convenience
use geologic::*;

let position = point!(0i32, 40);
let size = size!(5; 2);

// Derive a Bounds2D from a position and size.
let bounds = position.with_size(size);

// Translate the bounds with an offset
let moved_bounds = bounds + offset!(3, 5);

// Resize the bounds up with a size
let enlarged_bounds = moved_bounds + size!(10, 10);
assert_eq!(enlarged_bounds, bounds!(3, 45, 15, 15));

// We can also use tuples and types interchangeably for operations like these
let moved_bounds = bounds.with_position((0, 0));
assert_eq!(moved_bounds, bounds!(0, 0, 5, 5))

Re-exports§

pub use crate::macros::*;

Modules§

macros
Helper macros for instantiating different kinds of algebraic types.

Macros§

bounds
Creates a new bounding box.
offset
Creates a new offset vector.
point
Creates a new point vector.
size
Creates a new size.

Structs§

Bounds2D
A two-dimensional bounding box.
Grid2D
A 2D array, representing a grid with X and Y space.
Offset
Marker struct for a vector used as a translation or velocity.
Point
Marker struct for a vector used as a point.
Size2D
A vector describing a two-dimensional size.
Vector2D
A generic vector with an X and Y component.

Traits§

Interpretation2D
IntoBounds2D
ToOffset2D
Trait alias for ToVector2D where Kind is Offset.
ToPoint2D
Trait alias for ToVector2D where Kind is Point.
ToSize2D
A trait to aid in the ergonomics of creating a Size2D and usage of interfaces expecting Size2D.
ToVector2D
A helper trait to aid with the ergonomics of using a Vector2D.
Vector
A trait defining common helper methods to aid in the usage of a vector, or types with underlying vectors.

Type Aliases§

Offset2D
A two-dimensional vector representing an offset.
Point2D
A two-dimensional vector representing a point.