Skip to main content

Module units

Module units 

Source
Expand description

Grid unit system — flexible measurements for grid graphics.

R’s grid package uses a rich unit system where lengths can be expressed in physical units (cm, inches, points), relative units (npc, snpc), data coordinates (native), or text-metric units (lines, char, strwidth). Units can be combined with arithmetic (+, -, *) to create compound measurements that are resolved at drawing time.

Structs§

Unit
A grid unit — one or more (value, type) pairs representing a measurement.
UnitContext
Context needed to resolve relative and data-dependent units to centimeters.

Enums§

Axis
Which axis a unit is being resolved along. Matters for relative units like Npc (which uses width for x, height for y) and Native.
UnitType
The type of measurement for a grid unit value.

Functions§

resolve_one 🔒
Resolve a single (value, unit_type) pair to centimeters.