pub struct Transform2D {
pub rotation: f32,
pub scale_x: f32,
pub scale_y: f32,
pub translate: Point,
}Expand description
2D 仿射变换(平移+旋转+均匀缩放)
实际应用矩阵(在 shader 中):
- 绕 layer 中心 (cx, cy) 旋转 + 缩放
- 之后平移
translate像素
数学:world_p = R(rot) * S(sx, sy) * (local_p - center) + center + translate
两轴可独立缩放(scale_x != scale_y 即非均匀缩放),FittedBox 的
BoxFit::Fill 依赖这一能力;均匀缩放场景下两者相等。
Fields§
§rotation: f32旋转角度(弧度,顺时针)
scale_x: f32x 轴缩放(1.0 = 原大小)
scale_y: f32y 轴缩放(1.0 = 原大小)
translate: Point相对 layer 中心的额外平移(像素)
Implementations§
Source§impl Transform2D
impl Transform2D
Sourcepub fn is_identity(&self) -> bool
pub fn is_identity(&self) -> bool
是否是恒等变换(可走 shader 无开销分支)
Trait Implementations§
Source§impl Clone for Transform2D
impl Clone for Transform2D
impl Copy for Transform2D
Source§impl Debug for Transform2D
impl Debug for Transform2D
Source§impl Default for Transform2D
impl Default for Transform2D
Source§impl PartialEq for Transform2D
impl PartialEq for Transform2D
impl StructuralPartialEq for Transform2D
Auto Trait Implementations§
impl Forget for Transform2D
impl Freeze for Transform2D
impl Move for Transform2D
impl RefUnwindSafe for Transform2D
impl Send for Transform2D
impl Sync for Transform2D
impl Unpin for Transform2D
impl UnsafeUnpin for Transform2D
impl UnwindSafe for Transform2D
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
Mutably borrows from an owned value. Read more