pub struct Rect<T: Clone> {
pub x: [f32; 4],
pub y: [f32; 4],
pub z: f32,
pub data: NodeData<T>,
}Expand description
A finite rectangle in pixel coordinates that will end up on the screen
Fields§
§x: [f32; 4]x coordinates - as an array because of simd layout tl, tr, bl, br
y: [f32; 4]y coordinates - as an array because of simd layout tl, tr, bl, br
z: f32Z-index is an int in order to achieve z-order sortability
data: NodeData<T>Internal data of the rectangle
Implementations§
Source§impl<T: Clone> Rect<T>
impl<T: Clone> Rect<T>
Sourcepub fn new(
top: f32,
bottom: f32,
left: f32,
right: f32,
z: f32,
data: NodeData<T>,
) -> Self
pub fn new( top: f32, bottom: f32, left: f32, right: f32, z: f32, data: NodeData<T>, ) -> Self
Creates a new rectangle
Sourcepub fn new_wh(
offset_left: f32,
offset_top: f32,
width: f32,
height: f32,
z: f32,
data: NodeData<T>,
) -> Self
pub fn new_wh( offset_left: f32, offset_top: f32, width: f32, height: f32, z: f32, data: NodeData<T>, ) -> Self
Creates a new rectangle with width / height instead of top / bottom
pub fn rotate_center(&mut self, in_angle: f32)
pub fn translate(&mut self, x: f32, y: f32)
Sourcepub fn set_width(&mut self, width: f32)
pub fn set_width(&mut self, width: f32)
Set width from top left corner Warning: may not work well after rotations
Sourcepub fn set_height(&mut self, height: f32)
pub fn set_height(&mut self, height: f32)
Set height from top left corner Warning: may not work well after rotations
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Rect<T>where
T: Freeze,
impl<T> RefUnwindSafe for Rect<T>where
T: RefUnwindSafe,
impl<T> Send for Rect<T>where
T: Send,
impl<T> Sync for Rect<T>where
T: Sync,
impl<T> Unpin for Rect<T>where
T: Unpin,
impl<T> UnwindSafe for Rect<T>where
T: UnwindSafe,
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