Struct rsvg::aspect_ratio::AspectRatio
source · pub struct AspectRatio {
defer: bool,
align: Option<Align>,
}
Fields§
§defer: bool
§align: Option<Align>
Implementations§
source§impl AspectRatio
impl AspectRatio
sourcepub fn none() -> AspectRatio
pub fn none() -> AspectRatio
Produces the equivalent of preserveAspectRatio="none"
.
pub fn is_slice(&self) -> bool
pub fn compute(&self, vbox: &ViewBox, viewport: &Rect) -> Rect
sourcepub fn viewport_to_viewbox_transform(
&self,
vbox: Option<ViewBox>,
viewport: &Rect
) -> Result<Option<ValidTransform>, InvalidTransform>
pub fn viewport_to_viewbox_transform( &self, vbox: Option<ViewBox>, viewport: &Rect ) -> Result<Option<ValidTransform>, InvalidTransform>
Computes the viewport to viewbox transformation.
Given a viewport, returns a transformation that will create a coordinate
space inside it. The (vbox.x0, vbox.y0)
will be mapped to the viewport’s
upper-left corner, and the (vbox.x1, vbox.y1)
will be mapped to the viewport’s
lower-right corner.
If the vbox or viewport are empty, returns Ok(None)
. Per the SVG spec, either
of those mean that the corresponding element should not be rendered.
If the vbox would create an invalid transform (say, a vbox with huge numbers that
leads to a near-zero scaling transform), returns an Err(())
.
Trait Implementations§
source§impl Clone for AspectRatio
impl Clone for AspectRatio
source§fn clone(&self) -> AspectRatio
fn clone(&self) -> AspectRatio
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for AspectRatio
impl Debug for AspectRatio
source§impl Default for AspectRatio
impl Default for AspectRatio
source§fn default() -> AspectRatio
fn default() -> AspectRatio
Returns the “default value” for a type. Read more
source§impl Parse for AspectRatio
impl Parse for AspectRatio
source§fn parse<'i>(parser: &mut Parser<'i, '_>) -> Result<AspectRatio, ParseError<'i>>
fn parse<'i>(parser: &mut Parser<'i, '_>) -> Result<AspectRatio, ParseError<'i>>
Parses a value out of the
parser
. Read moresource§impl PartialEq for AspectRatio
impl PartialEq for AspectRatio
source§fn eq(&self, other: &AspectRatio) -> bool
fn eq(&self, other: &AspectRatio) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Copy for AspectRatio
impl Eq for AspectRatio
impl StructuralPartialEq for AspectRatio
Auto Trait Implementations§
impl RefUnwindSafe for AspectRatio
impl Send for AspectRatio
impl Sync for AspectRatio
impl Unpin for AspectRatio
impl UnwindSafe for AspectRatio
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
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.