#[repr(C)]pub struct ImageInstance {
pub position: [f32; 2],
pub size: [f32; 2],
pub uv_min: [f32; 2],
pub uv_max: [f32; 2],
pub tint: [f32; 4],
pub border_radius: f32,
pub texture_index: u32,
pub z_depth: f32,
pub _padding: f32,
}Expand description
Instance data for image rendering.
Each instance represents one image quad to be drawn from a texture. Supports UV coordinates for sprite sheets and tinting.
Fields§
§position: [f32; 2]Position in screen space (top-left corner)
size: [f32; 2]Size of the image quad in screen space
uv_min: [f32; 2]UV coordinates (top-left)
uv_max: [f32; 2]UV coordinates (bottom-right)
tint: [f32; 4]Tint color (RGBA) - multiplied with texture color
border_radius: f32Border radius for rounded corners (0 = sharp corners)
texture_index: u32Texture index (for texture arrays, 0 for single texture)
z_depth: f32Depth value for z-ordering (0.0 = far, 1.0 = near)
_padding: f32Padding to align to 16-byte boundary
Implementations§
Source§impl ImageInstance
impl ImageInstance
Sourcepub fn new(position: Vec2, size: Vec2, z_depth: f32) -> Self
pub fn new(position: Vec2, size: Vec2, z_depth: f32) -> Self
Create a new image instance covering the full texture.
Sourcepub fn with_uv(
position: Vec2,
size: Vec2,
uv_min: [f32; 2],
uv_max: [f32; 2],
z_depth: f32,
) -> Self
pub fn with_uv( position: Vec2, size: Vec2, uv_min: [f32; 2], uv_max: [f32; 2], z_depth: f32, ) -> Self
Create an image instance with specific UV coordinates (for sprites).
Sourcepub fn with_tint(position: Vec2, size: Vec2, tint: Color, z_depth: f32) -> Self
pub fn with_tint(position: Vec2, size: Vec2, tint: Color, z_depth: f32) -> Self
Create an image instance with a tint color.
Sourcepub fn border_radius(self, radius: f32) -> Self
pub fn border_radius(self, radius: f32) -> Self
Set the border radius for rounded corners.
Sourcepub fn texture_index(self, index: u32) -> Self
pub fn texture_index(self, index: u32) -> Self
Set the texture index (for texture arrays).
Sourcepub fn vertex_layout() -> VertexBufferLayout<'static>
pub fn vertex_layout() -> VertexBufferLayout<'static>
Get the WGPU vertex buffer layout for image instances.
Trait Implementations§
Source§impl Clone for ImageInstance
impl Clone for ImageInstance
Source§fn clone(&self) -> ImageInstance
fn clone(&self) -> ImageInstance
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ImageInstance
impl Debug for ImageInstance
impl Copy for ImageInstance
impl Pod for ImageInstance
Auto Trait Implementations§
impl Freeze for ImageInstance
impl RefUnwindSafe for ImageInstance
impl Send for ImageInstance
impl Sync for ImageInstance
impl Unpin for ImageInstance
impl UnsafeUnpin for ImageInstance
impl UnwindSafe for ImageInstance
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> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.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>. 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.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 more