Module meters

Source
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§

MeterGeometry
Immutable continuous geometry. Zero extents are valid (and paint nothing); positive extents must have representable edges. Negative origins are valid.
SegmentGeometry
Immutable strip descriptor; results use caller-owned storage.
SegmentRect
Geometry and accepted-count state for one cell; Unknown has filled=false, and must be distinguished by the enclosing SegmentGeometry::value.

Enums§

MeterError
Validation/capacity errors are reported before changing caller buffers.
MeterValue
Supplied telemetry. Unknown has no implied fraction; Empty fills zero.
SegmentValue
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.