Skip to main content

LabelItem

Struct LabelItem 

Source
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: String

Text content to display.

§colour: [f32; 4]

RGBA text colour in linear float format.

§font_size: f32

Font size in logical pixels.

§font: Option<FontHandle>

Font to use. None uses the built-in default font.

§background: bool

Draw a filled rectangle behind the text.

§background_colour: [f32; 4]

RGBA colour of the background rectangle.

§padding: f32

Padding between the text and the background rectangle edge in logical pixels. Only used when background is true. Default: 3.0.

§leader_line: bool

Draw 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: LabelAnchor

Horizontal 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: f32

Overall 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: f32

Corner radius of the background rectangle in logical pixels. Only used when background is true. Default: 0.0 (sharp corners).

§z_order: i32

Explicit draw order. Labels with lower values are drawn first (further back). Labels with equal z_order are drawn in list order.

§occlude: bool

Reserved for depth-based occlusion. Not implemented yet: when true the label is still rendered; behaviour will be defined in a follow-up.

Trait Implementations§

Source§

impl Clone for LabelItem

Source§

fn clone(&self) -> LabelItem

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LabelItem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LabelItem

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,