Struct druid::ScaledArea
source · pub struct ScaledArea { /* private fields */ }
Expand description
A specific area scaling state.
This holds the platform area size in pixels and the logical area size in display points.
The platform area size in pixels tends to be limited to integers and ScaledArea
works
under that assumption.
The logical area size in display points is an unrounded conversion, which means that it is
often not limited to integers. This allows for accurate calculations of
the platform area pixel boundaries from the logical area using a Scale
.
Even though the logical area size can be fractional, the integer boundaries of that logical area will still match up with the platform area pixel boundaries as often as the scale factor allows.
A copy of ScaledArea
will be stale as soon as the platform area size changes.
Implementations§
source§impl ScaledArea
impl ScaledArea
sourcepub fn from_px<T>(size: T, scale: Scale) -> ScaledAreawhere
T: Into<Size>,
pub fn from_px<T>(size: T, scale: Scale) -> ScaledAreawhere T: Into<Size>,
Create a new scaled area from pixels.
sourcepub fn from_dp<T>(size: T, scale: Scale) -> ScaledAreawhere
T: Into<Size>,
pub fn from_dp<T>(size: T, scale: Scale) -> ScaledAreawhere T: Into<Size>,
Create a new scaled area from display points.
The calculated size in pixels is rounded away from zero to integers.
That means that the scaled area size in display points isn’t always the same
as the size
given to this function. To find out the new size in points use size_dp
.
Trait Implementations§
source§impl Clone for ScaledArea
impl Clone for ScaledArea
source§fn clone(&self) -> ScaledArea
fn clone(&self) -> ScaledArea
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ScaledArea
impl Debug for ScaledArea
source§impl Default for ScaledArea
impl Default for ScaledArea
source§fn default() -> ScaledArea
fn default() -> ScaledArea
source§impl PartialEq<ScaledArea> for ScaledArea
impl PartialEq<ScaledArea> for ScaledArea
source§fn eq(&self, other: &ScaledArea) -> bool
fn eq(&self, other: &ScaledArea) -> bool
self
and other
values to be equal, and is used
by ==
.