pub struct LineVisual { /* private fields */ }Expand description
A world-axis line segment anchored at an entity’s Transform2d.
The interpolated transform translation is the segment start. vector is
added in caller-defined world units to obtain its end and is not rotated or
scaled. Only the transform translation is interpolated; vector and style
changes are sampled at extraction like other visual geometry.
Stroke width is measured in logical screen pixels and remains readable as the camera zooms. Rendering uses butt caps, so the segment body stops at its mathematical endpoints. A zero vector is valid and emits no resolved record or Scene command.
Lower layers and then lower draw-order depths are drawn first, followed by
stable entity identity. On an otherwise exact tie, rectangles are drawn
before circles and lines are drawn last, which keeps a line visible over a
body on the same entity. Spawning without a Transform2d supplies an
origin transform. An explicit transform in the same spawn bundle takes
precedence; normal spawn snapping may reset its previous interpolation
endpoint to its canonical translation.
Implementations§
Source§impl LineVisual
impl LineVisual
Sourcepub fn new(
vector: Vec2,
stroke_width_logical_pixels: f32,
color: Color,
) -> Result<Self, VisualValueError>
pub fn new( vector: Vec2, stroke_width_logical_pixels: f32, color: Color, ) -> Result<Self, VisualValueError>
Creates an anchored line on the default layer at draw-order depth zero.
Validation order is vector, logical-pixel width, then color. Zero is a valid vector and represents an omitted line.
Sourcepub const fn vector(&self) -> Vec2
pub const fn vector(&self) -> Vec2
Returns the world-axis offset from the transform anchor to the endpoint.
Sourcepub const fn stroke_width_logical_pixels(&self) -> f32
pub const fn stroke_width_logical_pixels(&self) -> f32
Returns stroke width in logical screen pixels.
Sourcepub const fn draw_order_depth(&self) -> f32
pub const fn draw_order_depth(&self) -> f32
Returns the within-layer draw-order value.
This affects ordering only and is not Sim;Engine projection depth.
Sourcepub fn set_vector(&mut self, vector: Vec2) -> Result<(), VisualValueError>
pub fn set_vector(&mut self, vector: Vec2) -> Result<(), VisualValueError>
Replaces the world-axis vector after finite-value validation.
Zero is accepted and omits the line at extraction. A rejected value leaves the previous vector unchanged.
Sourcepub fn set_stroke_width_logical_pixels(
&mut self,
width: f32,
) -> Result<(), VisualValueError>
pub fn set_stroke_width_logical_pixels( &mut self, width: f32, ) -> Result<(), VisualValueError>
Replaces the logical-pixel stroke width after Sim;Engine validation.
A rejected value leaves the previous width unchanged.
Sourcepub fn set_color(&mut self, color: Color) -> Result<(), VisualValueError>
pub fn set_color(&mut self, color: Color) -> Result<(), VisualValueError>
Replaces the stroke color after normalized-color validation.
Sourcepub fn set_draw_order_depth(
&mut self,
depth: f32,
) -> Result<(), VisualValueError>
pub fn set_draw_order_depth( &mut self, depth: f32, ) -> Result<(), VisualValueError>
Replaces within-layer draw order after finite-value validation.
Trait Implementations§
Source§impl Clone for LineVisual
impl Clone for LineVisual
Source§impl Component for LineVisual
Required Components: Transform2d.
impl Component for LineVisual
Required Components: Transform2d.
A component’s Required Components are inserted whenever it is inserted. Note that this will also insert the required components of the required components, recursively, in depth-first order.
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
_requiree: ComponentId,
required_components: &mut RequiredComponentsRegistrator<'_, '_>,
)
fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
ComponentRelationshipAccessor required for working with relationships in dynamic contexts. Read moreSource§fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreimpl Copy for LineVisual
Source§impl Debug for LineVisual
impl Debug for LineVisual
Source§impl PartialEq for LineVisual
impl PartialEq for LineVisual
impl StructuralPartialEq for LineVisual
Auto Trait Implementations§
impl Freeze for LineVisual
impl RefUnwindSafe for LineVisual
impl Send for LineVisual
impl Sync for LineVisual
impl Unpin for LineVisual
impl UnsafeUnpin for LineVisual
impl UnwindSafe for LineVisual
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<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>
Source§fn get_component_ids(
components: &Components,
) -> impl Iterator<Item = Option<ComponentId>>
fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>
Source§impl<C> BundleFromComponents for Cwhere
C: Component,
impl<C> BundleFromComponents for Cwhere
C: Component,
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
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>. Box<dyn Any> can
then be further downcast into Box<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>. Rc<Any> 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.