Expand description
Bounded horizontal meter geometry in logical UI units, without rendering, clocks, input, smoothing, allocation or gameplay availability decisions.
Values are validated, never clamped. Empty explicitly means no capacity;
it differs from a known zero with a positive capacity and from Unknown.
A known zero denominator is rejected; callers must choose Empty or
Unknown. Geometry rounds to f32 logical units, not simulation precision.
use ferravex_play::ui::{Rect, meters::*};
let track = Rect { min: [-10., 2.5], size: [120., 8.] };
let meter = MeterGeometry::new(track,
MeterValue::Known { current: 3., capacity: 6. })?;
assert_eq!(meter.fill().unwrap().size, [60., 8.]);
let mut markers = [track; MAX_METER_MARKERS];
assert_eq!(meter.markers_into(&[0., 0.25, 1.], 2., &mut markers)?, 3);
assert_eq!(markers[0].min[0], -10.);
assert_eq!(markers[2].min[0] + markers[2].size[0], 110.);Structs§
- Meter
Geometry - Immutable continuous geometry. Zero extents are valid (and paint nothing); positive extents must have representable edges. Negative origins are valid.
- Segment
Geometry - Immutable strip descriptor; results use caller-owned storage.
- Segment
Rect - Geometry and accepted-count state for one cell; Unknown has filled=false, and must be distinguished by the enclosing SegmentGeometry::value.
Enums§
- Meter
Error - Validation/capacity errors are reported before changing caller buffers.
- Meter
Value - Supplied telemetry.
Unknownhas no implied fraction;Emptyfills zero. - Segment
Value - Count telemetry, with no fractional/invented segments. Empty has zero cells; Unknown may reserve zero through 64 cells, without marking any as accepted.
Constants§
- MAX_
METER_ MARKERS - Maximum explicit thresholds per continuous meter.
- MAX_
METER_ SEGMENTS - Maximum segments per strip; callers must choose a smaller representation explicitly when their telemetry exceeds this bound.