pub struct RectangleVisual { /* private fields */ }Expand description
Filled axis-aligned world-space rectangle rendered by the standard bridge.
Transform2d::translation is the rectangle center and size is its full
width and height in caller-defined world units. Layer and draw-order depth
follow the same ordering rules as CircleVisual. If both visuals belong
to one entity with the same layer and depth, the rectangle is drawn first.
Spawning this component without a Transform2d automatically inserts a
default transform at the world origin. The canonical translation of a
transform supplied in the same bundle takes precedence; normal spawn
snapping may reset its previous interpolation endpoint to that translation.
Implementations§
Source§impl RectangleVisual
impl RectangleVisual
Sourcepub const fn with_matching_collider(self) -> (Self, RectangleCollider2d)
pub const fn with_matching_collider(self) -> (Self, RectangleCollider2d)
Returns (visual, collider) as a spawnable pair matching this full size.
The collider is a one-time geometry snapshot produced by
RectangleCollider2d::from_visual. Corner radius and all other
presentation properties are ignored. Later changes to either returned
value remain independent. The tuple can be nested directly in a larger
spawn bundle.
Source§impl RectangleVisual
impl RectangleVisual
Sourcepub fn new(size: Vec2, color: Color) -> Result<Self, VisualValueError>
pub fn new(size: Vec2, color: Color) -> Result<Self, VisualValueError>
Creates a filled square-cornered rectangle on the default layer at depth zero.
Sourcepub fn rounded(
size: Vec2,
color: Color,
corner_radius: f32,
) -> Result<Self, VisualValueError>
pub fn rounded( size: Vec2, color: Color, corner_radius: f32, ) -> Result<Self, VisualValueError>
Creates a filled rounded rectangle on the default layer at depth zero.
The requested corner radius must be finite and nonnegative. Values
larger than half the smaller side are retained here and clamped only
when Sim;Engine presents the rectangle. This is exactly equivalent to
RectangleVisual::new followed by
RectangleVisual::set_corner_radius.
Sourcepub const fn size(&self) -> Vec2
pub const fn size(&self) -> Vec2
Returns the full width and height in caller-defined world units.
Sourcepub const fn corner_radius(&self) -> f32
pub const fn corner_radius(&self) -> f32
Returns the requested corner radius in world units.
A radius larger than half the smaller side is retained here and clamped only while Sim;Engine presents the rectangle.
Sourcepub const fn draw_order_depth(&self) -> f32
pub const fn draw_order_depth(&self) -> f32
Returns the within-layer draw-order depth.
This value affects ordering only. It is not Sim;Engine pseudo-depth and does not change camera projection.
Sourcepub fn set_size(&mut self, size: Vec2) -> Result<(), VisualValueError>
pub fn set_size(&mut self, size: Vec2) -> Result<(), VisualValueError>
Replaces the full width and height after validation.
Sourcepub fn set_corner_radius(&mut self, radius: f32) -> Result<(), VisualValueError>
pub fn set_corner_radius(&mut self, radius: f32) -> Result<(), VisualValueError>
Replaces the requested corner radius after validation.
Sourcepub fn set_color(&mut self, color: Color) -> Result<(), VisualValueError>
pub fn set_color(&mut self, color: Color) -> Result<(), VisualValueError>
Replaces the fill 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 depth after finite-value validation.
Trait Implementations§
Source§impl Clone for RectangleVisual
impl Clone for RectangleVisual
Source§impl Component for RectangleVisual
Required Components: Transform2d.
impl Component for RectangleVisual
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 RectangleVisual
Source§impl Debug for RectangleVisual
impl Debug for RectangleVisual
Source§impl PartialEq for RectangleVisual
impl PartialEq for RectangleVisual
impl StructuralPartialEq for RectangleVisual
Auto Trait Implementations§
impl Freeze for RectangleVisual
impl RefUnwindSafe for RectangleVisual
impl Send for RectangleVisual
impl Sync for RectangleVisual
impl Unpin for RectangleVisual
impl UnsafeUnpin for RectangleVisual
impl UnwindSafe for RectangleVisual
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.