pub struct Rect {
pub x: u32,
pub y: u32,
pub w: u32,
pub h: u32,
}Expand description
A rectangle in cells (cell model) or pixels (graphics model).
Fields§
§x: u32§y: u32§w: u32§h: u32Implementations§
Source§impl Rect
impl Rect
Sourcepub const fn new(x: u32, y: u32, w: u32, h: u32) -> Self
pub const fn new(x: u32, y: u32, w: u32, h: u32) -> Self
Examples found in repository?
examples/graphics_chart.rs (line 105)
92 fn paint(&mut self) {
93 let (cols, rows) = self.pane.size();
94 if rows == 0 {
95 // No geometry yet: a resize will follow.
96 return;
97 }
98 let accent = view::theme().accent;
99 self.pane.clear();
100 self.pane.text(1, 0, "Usage", Style::fg(Colour::FG).bold());
101 for service in 0..SERVICES {
102 let top = TITLE_ROWS + service * SERVICE_ROWS;
103 let name = format!("Service {}", service + 1);
104 self.pane.text(1, top, &name, Style::fg(Colour::FG));
105 let place = Rect::new(1, top + 1, cols.saturating_sub(2), CHART_ROWS);
106 paint_cells(&mut self.pane, service, place);
107 // Runs only where the viewer shows real graphics. Elsewhere the
108 // cells just painted are the chart, and nothing else is needed.
109 let _ = self.pane.draw_graphic(service, place, |canvas| {
110 paint_pixels(canvas, service, accent);
111 });
112 }
113 let _ = self.pane.commit();
114 }pub const fn is_empty(&self) -> bool
pub const fn right(&self) -> u32
pub const fn bottom(&self) -> u32
pub const fn area(&self) -> u64
Sourcepub fn clamp(self, width: u32, height: u32) -> Option<Self>
pub fn clamp(self, width: u32, height: u32) -> Option<Self>
The part inside a width by height surface, or None.
pub fn contains_rect(&self, other: &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 UnsafeUnpin 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