pub struct ScreenImageVisual { /* private fields */ }Expand description
An immutable image drawn in logical screen pixels above world content.
Position is the top-left corner, x increases rightward, and y increases
downward. Finite offscreen placement is allowed. Geometry, tint, layer, and
draw-order depth use the same validation as ScreenRectangleVisual. The
component needs no Transform, window, or GPU, and FrameUpdate may change it.
Extraction samples current values and excludes disabled entities.
Construction validates image-region dimensions from the issued handle; extraction also checks that its application registry owns the image. A foreign handle is not made valid by constructing this component. Within screen content, layer, depth, and stable entity identity control ordering; a rectangle precedes an image on an exact same-entity tie. No input capture or hit testing is implied by visibility.
Implementations§
Source§impl ScreenImageVisual
impl ScreenImageVisual
Sourcepub const fn rotation(&self) -> f32
pub const fn rotation(&self) -> f32
Returns clockwise radians about the destination rectangle’s center. The top-left position and size describe the unrotated rectangle.
Sourcepub fn set_rotation(&mut self, radians: f32) -> Result<(), ImageVisualError>
pub fn set_rotation(&mut self, radians: f32) -> Result<(), ImageVisualError>
Sets clockwise center rotation, reducing finite angles to 0..TAU.
No image pixels are recreated. Failure leaves the visual unchanged.
Sourcepub fn contains_pointer(&self, sample: PointerSample) -> bool
pub fn contains_pointer(&self, sample: PointerSample) -> bool
Tests the rotated destination and fixed clip, not individual texel alpha. The caller still selects eligibility and resolves overlapping targets.
Sourcepub const fn clip(&self) -> ScreenClip
pub const fn clip(&self) -> ScreenClip
Returns the fixed-screen clip; content placement does not move it.
Sourcepub fn set_clip(&mut self, clip: ScreenClip)
pub fn set_clip(&mut self, clip: ScreenClip)
Replaces the screen clip, independent of source texels and destination.
Sourcepub fn new(
image: ImageAssetId,
position: LogicalScreenPosition,
size: LogicalScreenVector,
) -> Result<Self, ImageVisualError>
pub fn new( image: ImageAssetId, position: LogicalScreenPosition, size: LogicalScreenVector, ) -> Result<Self, ImageVisualError>
Places the full image with white tint and nearest-texel sampling.
The default layer and depth zero match screen rectangles. Position must be finite; size must be positive and finite, with finite, increasing far bounds. Geometry is independent from the image’s texel dimensions.
Sourcepub const fn image(&self) -> ImageAssetId
pub const fn image(&self) -> ImageAssetId
Returns the immutable application image handle used by this visual.
Sourcepub const fn source_region(&self) -> Option<ImageRegion>
pub const fn source_region(&self) -> Option<ImageRegion>
Returns the source texel rectangle, or None for the complete image.
Sourcepub const fn filter(&self) -> ImageFilter
pub const fn filter(&self) -> ImageFilter
Returns the sampling policy used when scaling this image.
Sourcepub const fn position(&self) -> LogicalScreenPosition
pub const fn position(&self) -> LogicalScreenPosition
Returns the top-left destination in logical screen pixels.
Sourcepub const fn size(&self) -> LogicalScreenVector
pub const fn size(&self) -> LogicalScreenVector
Returns the positive destination width and height in logical pixels.
Sourcepub const fn tint(&self) -> Color
pub const fn tint(&self) -> Color
Returns the normalized straight-linear RGBA multiplication tint.
Sourcepub const fn draw_order_depth(&self) -> f32
pub const fn draw_order_depth(&self) -> f32
Returns the finite within-layer draw order, unrelated to camera depth.
Sourcepub fn set_image(&mut self, image: ImageAssetId) -> Result<(), ImageVisualError>
pub fn set_image(&mut self, image: ImageAssetId) -> Result<(), ImageVisualError>
Replaces the image while retaining its source region and presentation.
If the existing region does not fit the new image, nothing changes. With no explicit region, the new image’s complete extent is selected. Application provenance is checked later by extraction.
Sourcepub fn set_source_region(
&mut self,
region: Option<ImageRegion>,
) -> Result<(), ImageVisualError>
pub fn set_source_region( &mut self, region: Option<ImageRegion>, ) -> Result<(), ImageVisualError>
Selects exact source texels, or resets to the full image with None.
A region outside the selected image leaves every component field unchanged. This changes sampling, not destination position or size.
Sourcepub fn set_filter(&mut self, filter: ImageFilter)
pub fn set_filter(&mut self, filter: ImageFilter)
Replaces the sampling policy without changing image or geometry.
Sourcepub fn set_geometry(
&mut self,
position: LogicalScreenPosition,
size: LogicalScreenVector,
) -> Result<(), ImageVisualError>
pub fn set_geometry( &mut self, position: LogicalScreenPosition, size: LogicalScreenVector, ) -> Result<(), ImageVisualError>
Replaces position and size together using screen rectangle validation.
Invalid values leave the component unchanged. Finite negative and offscreen positions are accepted without clamping or source cropping.
Sourcepub fn set_position(
&mut self,
position: LogicalScreenPosition,
) -> Result<(), ImageVisualError>
pub fn set_position( &mut self, position: LogicalScreenPosition, ) -> Result<(), ImageVisualError>
Replaces position while retaining size; invalid bounds change nothing.
Sourcepub fn set_size(
&mut self,
size: LogicalScreenVector,
) -> Result<(), ImageVisualError>
pub fn set_size( &mut self, size: LogicalScreenVector, ) -> Result<(), ImageVisualError>
Replaces size while retaining position; invalid bounds change nothing.
Sourcepub fn set_tint(&mut self, tint: Color) -> Result<(), ImageVisualError>
pub fn set_tint(&mut self, tint: Color) -> Result<(), ImageVisualError>
Replaces normalized straight-linear RGBA tint atomically.
A non-finite channel or value outside 0.0..=1.0 changes nothing.
Sourcepub fn set_layer(&mut self, layer: Layer)
pub fn set_layer(&mut self, layer: Layer)
Replaces the primary ordering layer within screen content.
Sourcepub fn set_draw_order_depth(
&mut self,
depth: f32,
) -> Result<(), ImageVisualError>
pub fn set_draw_order_depth( &mut self, depth: f32, ) -> Result<(), ImageVisualError>
Replaces finite within-layer ordering depth; invalid input changes nothing.
Negative depths are valid and do not change camera projection.
Trait Implementations§
Source§impl Clone for ScreenImageVisual
impl Clone for ScreenImageVisual
Source§impl Component for ScreenImageVisual
impl Component for ScreenImageVisual
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 ScreenImageVisual
Source§impl Debug for ScreenImageVisual
impl Debug for ScreenImageVisual
Source§impl PartialEq for ScreenImageVisual
impl PartialEq for ScreenImageVisual
impl StructuralPartialEq for ScreenImageVisual
Auto Trait Implementations§
impl Freeze for ScreenImageVisual
impl RefUnwindSafe for ScreenImageVisual
impl Send for ScreenImageVisual
impl Sync for ScreenImageVisual
impl Unpin for ScreenImageVisual
impl UnsafeUnpin for ScreenImageVisual
impl UnwindSafe for ScreenImageVisual
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.