pub struct Rect {
pub pos: Pair<Pos>,
pub size: Pair<Size>,
}Fields§
§pos: Pair<Pos>§size: Pair<Size>Implementations§
Source§impl Rect
impl Rect
Sourcepub fn new(pos: Pair<Pos>, size: Pair<Size>) -> Self
pub fn new(pos: Pair<Pos>, size: Pair<Size>) -> Self
Examples found in repository?
examples/03_element.rs (line 21)
16fn view(_model: &Model, area: &mut Area) {
17 // Split the screen into three sections, one upper and two lower.
18 let upper = area.size().map_y(|y| y / 2).as_rect();
19
20 let lower_size = area.size().map(|xy| xy / 2);
21 let lower_left = Rect::new(lower_size.with_x(0).into(), lower_size);
22 let lower_right = Rect::new(lower_size.into(), lower_size);
23
24 area.push_element(upper, Box::new(center("top text".to_owned())));
25 area.push_element(lower_left, Box::new(center("lower left text".to_owned())));
26 area.push_element(lower_right, Box::new(center("lower right text".to_owned())));
27}pub fn from_size(size: Pair<Size>) -> Self
pub fn with_pos(&self, pos: Pair<Pos>) -> Self
pub fn with_size(&self, size: Pair<Size>) -> Self
pub fn map_pos(&self, f: impl Fn(Pair<Pos>) -> Pair<Pos>) -> Self
pub fn map_size(&self, f: impl Fn(Pair<Size>) -> Pair<Size>) -> Self
pub fn pad(&self, padding: u16) -> Self
pub fn pad_x(&self, padding: u16) -> Self
pub fn pad_y(&self, padding: u16) -> Self
pub fn pad_left(&self, padding: u16) -> Self
pub fn pad_right(&self, padding: u16) -> Self
pub fn pad_top(&self, padding: u16) -> Self
pub fn pad_bottom(&self, padding: u16) -> Self
pub fn center_in(&self, outer: Self) -> Self
pub fn center(&self) -> Pair<Pos>
pub fn corner(&self) -> Pair<Pos>
pub fn is_inside(&self, outer: Self) -> bool
Trait Implementations§
impl Copy for Rect
impl Eq for Rect
impl StructuralPartialEq for Rect
Auto Trait Implementations§
impl Freeze for Rect
impl RefUnwindSafe for Rect
impl Send for Rect
impl Sync for Rect
impl Unpin for Rect
impl UnwindSafe for Rect
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