#2d #graphics


A math library specialized for 2d screen graphics

4 releases

0.1.2 Sep 2, 2021
0.1.1 Aug 29, 2021
0.1.0 Aug 22, 2021
0.0.0-reserve.0 Aug 10, 2021

#1200 in Math

Download history 44/week @ 2023-07-20 21/week @ 2023-07-27 16/week @ 2023-08-03 22/week @ 2023-08-10 24/week @ 2023-08-17 18/week @ 2023-08-24 18/week @ 2023-08-31 29/week @ 2023-09-07 17/week @ 2023-09-14 15/week @ 2023-09-21 23/week @ 2023-09-28 20/week @ 2023-10-05 14/week @ 2023-10-12 28/week @ 2023-10-19 29/week @ 2023-10-26 22/week @ 2023-11-02

98 downloads per month
Used in 5 crates (2 directly)




crate version Live Build Status HTML Coverage Report for main branch Documentation for main branch

A minimalist crate for 2d math focused on what is needed to build user interfaces. Written for Gooey and Kludgine.

figures utilizes the Rust type system to prevent performing math on numbers with different units. The core types in figures all accept arbitrary unit types, allowing you to safely manage numbers in a wide variety of use cases while allowing the Rust compiler to help you prevent easy mistakes.

While the core types support any arbitrary units, figures defines three built in units:

  • Pixels: Represents physical pixels on a display.
  • Points: Represents a DPI-scaled resolution, as configured in the operating system.
  • Scaled: Represents an arbitrarily scaled resolution, enabling applications to add a "user interface scale" option to their applications easily.

To ease converting between these three units, the Displayable trait is implemented by all measurement types in this library.


This library is born of a difference of opinions from the excellent library euclid. Ultimately, I disagree on some fundamental design decisions. One of the most prevalent is that in euclid you are prevented from adding a Point and a Size together. In figures, you are able to interoperate with more types freely.

The second major change from euclid is embracing the Length/[Figure] type throughout the types. APIs will often favor returning a Figure instead of the raw type.

This library is hyper-focused on being a minimalistic math library for Gooey and Kludgine. euclid has more functionality. While we may accept PRs for some additional functionality, if you're looking for a more complete library, euclid should be your choice.


This is being developed by and for Khonsu Labs for Cosmic Verge. I hope it will be useful to others as well.

This code is dual-licensed under the MIT License and Apache License 2.0. Fonts in this repository are not included by default, and are solely licensed under the Apache License 2.0.