pub struct Window {
pub origin: Pos,
pub size: Size,
}Expand description
A rectangle in the plane: where it starts and how large it is.
An origin and a Size, and not a Footprint, because the two answer different questions:
a window is chosen before anything is drawn and may hold no position at all, while a footprint
exists only once a stamp has reached somewhere. A Buffer is given one of
these, and render is asked for one, so the same rectangle travels through both without being
taken apart into two arguments.
Fields§
§origin: PosThe top-left corner, in the plane.
size: SizeHow far the window reaches from origin, right and down.
Implementations§
Source§impl Window
impl Window
Sourcepub fn contains(self, at: Pos) -> bool
pub fn contains(self, at: Pos) -> bool
Whether at falls inside this window.
The right and bottom edges are outside: a window of width w holds columns origin.x to
origin.x + w - 1, which is the rectangle a buffer stamps into.
Sourcepub fn position(self, at: Offset) -> Option<Pos>
pub fn position(self, at: Offset) -> Option<Pos>
The position at reaches, counted from this window’s top-left corner, or None when the
origin and the offset cannot be added.
The offset is the one a caller already holds — a click arrives as a column and a row of what
was rendered — so nothing is added before this translation, and the window’s origin takes
no other part in the answer.