pub struct LabelItem {Show 18 fields
pub world_anchor: Option<[f32; 3]>,
pub screen_anchor: Option<[f32; 2]>,
pub text: String,
pub colour: [f32; 4],
pub font_size: f32,
pub font: Option<FontHandle>,
pub background: bool,
pub background_colour: [f32; 4],
pub padding: f32,
pub leader_line: bool,
pub leader_colour: [f32; 4],
pub anchor_align: LabelAnchor,
pub offset: [f32; 2],
pub opacity: f32,
pub max_width: Option<f32>,
pub border_radius: f32,
pub z_order: i32,
pub occlude: bool,
}Expand description
A text label rendered as a screen-space overlay.
Anchored to a world-space or screen-space position with optional leader line and background box.
§Anchoring
Set world_anchor to pin the label to a 3D position that is reprojected
each frame. Set screen_anchor for a fixed screen position in logical
pixels from the top-left corner. When both are set, screen_anchor takes
precedence. World-anchored labels are frustum-culled: they are not drawn
when the anchor is behind the camera or outside the viewport.
§Examples
let label = LabelItem {
world_anchor: Some([2.0, 3.0, 0.0]),
text: "Peak Pressure: 101.3 kPa".into(),
leader_line: true,
..Default::default()
};Fields§
§world_anchor: Option<[f32; 3]>World-space anchor. Projected to screen by the renderer each frame.
Set screen_anchor instead for fixed screen positions.
screen_anchor: Option<[f32; 2]>Screen-space anchor in logical pixels from top-left.
Takes precedence over world_anchor when both are set.
text: StringText content to display.
colour: [f32; 4]RGBA text colour in linear float format.
font_size: f32Font size in logical pixels.
font: Option<FontHandle>Font to use. None uses the built-in default font.
background: boolDraw a filled rectangle behind the text.
background_colour: [f32; 4]RGBA colour of the background rectangle.
padding: f32Padding between the text and the background rectangle edge in logical
pixels. Only used when background is true. Default: 3.0.
leader_line: boolDraw a line from the projected world_anchor to the label text origin.
Only drawn when world_anchor is set.
leader_colour: [f32; 4]RGBA colour of the leader line.
anchor_align: LabelAnchorHorizontal alignment of the label text relative to its anchor.
offset: [f32; 2]Pixel offset applied after anchor resolution and alignment.
Useful for nudging a label away from its anchor without moving the
leader line endpoint. Default: [0.0, 0.0].
opacity: f32Overall opacity multiplier applied to text, background, and leader line colours. Range 0.0 (invisible) to 1.0 (fully opaque).
max_width: Option<f32>Maximum text width in logical pixels. When set, text that exceeds
this width is wrapped to multiple lines. None disables wrapping.
border_radius: f32Corner radius of the background rectangle in logical pixels.
Only used when background is true. Default: 0.0 (sharp corners).
z_order: i32Explicit draw order. Labels with lower values are drawn first
(further back). Labels with equal z_order are drawn in list order.
occlude: boolReserved for depth-based occlusion. Not implemented yet: when true
the label is still rendered; behaviour will be defined in a follow-up.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LabelItem
impl RefUnwindSafe for LabelItem
impl Send for LabelItem
impl Sync for LabelItem
impl Unpin for LabelItem
impl UnsafeUnpin for LabelItem
impl UnwindSafe for LabelItem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.