Expand description

Mathematical and geometrical abstractions with a focus on ergonomics.


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.


// 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))


pub use crate::macros::*;


Helper macros for instantiating different kinds of algebraic types.


Creates a new bounding box.

Creates a new offset vector.

Creates a new point vector.

Creates a new size.


A two-dimensional bounding box.

A 2D array, representing a grid with X and Y space.

Marker struct for a vector used as a translation or velocity.

Marker struct for a vector used as a point.

A vector describing a two-dimensional size.

A generic vector with an X and Y component.


Trait alias for ToVector2D where Kind is Offset.

Trait alias for ToVector2D where Kind is Point.

A trait to aid in the ergonomics of creating a Size2D and usage of interfaces expecting Size2D.

A helper trait to aid with the ergonomics of using a Vector2D.

A trait defining common helper methods to aid in the usage of a vector, or types with underlying vectors.

Type Definitions

A two-dimensional vector representing an offset.

A two-dimensional vector representing a point.