rectutils

Common rectangle algorithms for Rust: clipping, quadtree, and rect packing

Library
Cargo
v0.7.0
2stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
23/100Needs Attention
Development Activity32
Maintenance8
Community4
Maturity48
Momentum0

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
72/100Good
Architecture74
Code Quality72
Innovation58
Learning Curve82

rectutils is a small Rust crate that collects common algorithms for working with rectangles, including clipping, transformation, quadtree spatial partitioning, and rectangle bin packing. It defines a generic Rect<T> type parameterized over any numeric type, along with helper structures for building bounding rectangles from points.

Built on nalgebra and num-traits, the crate forbids unsafe code and is used within the Fyrox game engine ecosystem for tasks such as UI layout, texture atlas packing, and spatial queries. It is distributed under the permissive MIT license.

What You Get

  • A generic Rect<T> type over any numeric scalar
  • Clipping and matrix transformation helpers for rectangles
  • A quadtree module for spatial partitioning and queries
  • A rectangle bin-packing module for atlas and layout building

Common Use Cases

  • Packing sprites or glyphs into a texture atlas
  • Spatially partitioning 2D scenes with a quadtree
  • Computing bounding rectangles from a series of points
  • Clipping and transforming UI or game rectangles

Under The Hood

Architecture - The crate centers on a generic Rect<T> struct (position and size as nalgebra Vector2<T>) with a Number trait blanket-implemented for numeric types. Functionality is split into a pack module for rectangle bin packing and a quadtree module for spatial partitioning, plus an optional-bounds RectOpt helper for accumulating bounding rects.

Tech Stack - Pure Rust built on nalgebra for vectors and matrices and num-traits for generic numerics; it forbids unsafe code and is published as the rectutils crate on crates.io.

Code Quality - A compact, focused codebase that enforces #![warn(missing_docs)] and #![forbid(unsafe_code)], split cleanly across lib.rs, pack.rs, and quadtree.rs; it is a young crate with a small contributor base.

API Design - The API is straightforward and generic: a single Rect<T> type with intuitive methods and two self-contained algorithm modules, making it easy to drop into graphics or game code without ceremony.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search