Expand description
A terse, no-std crate for 2D integer geometry.
§Coordinate system
All types in this crate use a y-down coordinate system, where the origin (0, 0) is at the
top-left and y increases downward:
+---------→ x
|
|
↓
yThis is the natural convention for screens, terminals, images, and most 2D game grids, and
matches the row-major ordering used by Pos’s Ord implementation and by the layout
module’s default traversal order.
§Related crates
This crate deliberately stays allocation-free and does not provide an owning grid type. For a
Vec-backed grid built on top of layout’s traversal and indexing abstractions, see the
sibling crate grixy.
§Examples
use ixy::{Pos, Rect};
let pos = Pos::new(10, 20);
let rect = Rect::from_ltwh(0, 0, 100, 200);
assert_eq!(pos.x, 10);
assert_eq!(pos.y, 20);
assert_eq!(rect.left(), 0);
assert_eq!(rect.top(), 0);
assert_eq!(rect.width(), 100);
assert_eq!(rect.height(), 200);
assert_eq!(rect.right(), 100);
assert_eq!(rect.bottom(), 200);
assert!(rect.contains_pos(pos));
assert!(!rect.contains_pos(Pos::new(150, 250)));Modules§
- int
- Sealed traits implemented by all of Rust’s primitive integer types.
- layout
- Maps 2-dimensional positions and provides traversal orders.
- ops
- Operations on 2D geometric types.
Macros§
- pos
- A macro that creates a position with the given
xandycoordinates. - rect
- A macro that creates a rectangle with the given coordinates.
Structs§
- Into
Iter - Iterator over the positions in a
Rect<T>, in row-major order. - Pos
- A 2-dimensional point with integer precision.
- Rect
- A 2-dimensional rectangle with integer precision.
- Size
- Represents a size in 2D space, with
widthandheight.
Enums§
- Rect
Error - Error type for rectangle operations.
- TryFrom
PosError - An error type for when a
Pos<T>cannot be converted to another type.