pub struct LogicalRect {
pub x: f64,
pub y: f64,
pub width: f64,
pub height: f64,
}Expand description
A rectangle in logical coordinates.
Serialized as [x, y, width, height], not as an object.
Fields§
§x: f64Left edge.
y: f64Top edge.
width: f64Extent along x. Must be positive.
height: f64Extent along y. Must be positive.
Implementations§
Source§impl LogicalRect
impl LogicalRect
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Whether every component is finite and the extents are positive.
Zero-area rects are rejected: they render as nothing, so they are always a bug in the caller rather than an intentional annotation.
Sourcepub fn center(&self) -> LogicalPoint
pub fn center(&self) -> LogicalPoint
The centre of the rectangle.
Sourcepub fn into_valid(self) -> Option<Self>
pub fn into_valid(self) -> Option<Self>
This rectangle if it is drawable, None if it is not.
For the callers that treat a region as an optional refinement rather than the answer. Something derived from a measurement, a model’s guess, or arithmetic on either can come out degenerate, and dropping it is better than propagating a rect that renders as nothing.
Trait Implementations§
Source§impl Clone for LogicalRect
impl Clone for LogicalRect
Source§fn clone(&self) -> LogicalRect
fn clone(&self) -> LogicalRect
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for LogicalRect
Source§impl Debug for LogicalRect
impl Debug for LogicalRect
Source§impl<'de> Deserialize<'de> for LogicalRect
impl<'de> Deserialize<'de> for LogicalRect
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<LogicalRect> for [f64; 4]
impl From<LogicalRect> for [f64; 4]
Source§fn from(r: LogicalRect) -> Self
fn from(r: LogicalRect) -> Self
Converts to this type from the input type.
Source§impl PartialEq for LogicalRect
impl PartialEq for LogicalRect
Source§impl Serialize for LogicalRect
impl Serialize for LogicalRect
impl StructuralPartialEq for LogicalRect
Auto Trait Implementations§
impl Freeze for LogicalRect
impl RefUnwindSafe for LogicalRect
impl Send for LogicalRect
impl Sync for LogicalRect
impl Unpin for LogicalRect
impl UnsafeUnpin for LogicalRect
impl UnwindSafe for LogicalRect
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