pub struct TextureTransform {
pub offset: [f32; 2],
pub scale: [f32; 2],
pub rotation: f32,
pub tile_mode: TileMode,
pub flip_x: bool,
pub flip_y: bool,
}Expand description
Affine transform applied to the texture sample before lookup.
Lets a single texture pan, scale, rotate, tile, and flip independently of the shape it fills. Use for scrolling marquees inside a shape, zooming detail, rotating an icon without rotating the shape, repeating tile art, and mirroring asymmetric assets.
The transform applies to the bounding-box UV in [0, 1] coordinates,
centred at (0.5, 0.5) for scale and rotation. When NineSlice is also
set on the same shape, the 9-slice remap wins and the texture transform
is ignored.
Fields§
§offset: [f32; 2]UV offset added after scale and rotation. [0.0, 0.0] keeps the
sample centred. Drives panning / scrolling.
scale: [f32; 2]UV scale multiplier applied around the centre. [1.0, 1.0] is
1:1. Larger values widen the sampled UV range (more tiles with
TileMode::Tile, or a wider view of the source with Stretch
or Mirror). Smaller values zoom in.
rotation: f32Rotation around the UV centre (0.5, 0.5) in radians, CCW in math
coordinates.
tile_mode: TileModeSampling mode for UV values outside [0, 1]. Stretch clamps to
the edge (default), Tile wraps, Mirror ping-pongs.
flip_x: boolFlip the sample horizontally before lookup.
flip_y: boolFlip the sample vertically before lookup.
Implementations§
Source§impl TextureTransform
impl TextureTransform
Sourcepub fn is_identity(&self) -> bool
pub fn is_identity(&self) -> bool
Returns true when the transform is the identity (no offset, unit
scale, no rotation, no flips, Stretch mode).
Trait Implementations§
Source§impl Clone for TextureTransform
impl Clone for TextureTransform
Source§fn clone(&self) -> TextureTransform
fn clone(&self) -> TextureTransform
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for TextureTransform
Source§impl Debug for TextureTransform
impl Debug for TextureTransform
Source§impl Default for TextureTransform
impl Default for TextureTransform
Source§impl PartialEq for TextureTransform
impl PartialEq for TextureTransform
Source§fn eq(&self, other: &TextureTransform) -> bool
fn eq(&self, other: &TextureTransform) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for TextureTransform
Auto Trait Implementations§
impl Freeze for TextureTransform
impl RefUnwindSafe for TextureTransform
impl Send for TextureTransform
impl Sync for TextureTransform
impl Unpin for TextureTransform
impl UnsafeUnpin for TextureTransform
impl UnwindSafe for TextureTransform
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
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,
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>, which can then be
downcast into Box<dyn 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>, which 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> DowncastSend for T
impl<T> DowncastSend for T
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.