pub struct Viewport {
pub dpi: Dpi,
pub vbox: ViewBox,
pub transform: ValidTransform,
}Expand description
Holds the size of the current viewport in the user’s coordinate system.
Fields§
§dpi: Dpi§vbox: ViewBoxCorners of the current coordinate space.
transform: ValidTransformThe viewport’s coordinate system, or “user coordinate system” in SVG terms.
Implementations§
Source§impl Viewport
impl Viewport
Sourcepub fn new(dpi: Dpi, view_box_width: f64, view_box_height: f64) -> Viewport
pub fn new(dpi: Dpi, view_box_width: f64, view_box_height: f64) -> Viewport
FIXME: this is just used in Handle::with_height_to_user(), and in length.rs’s test suite. Find a way to do this without involving a default identity transform.
Sourcepub fn with_units(&self, units: CoordUnits) -> Viewport
pub fn with_units(&self, units: CoordUnits) -> Viewport
Creates a new viewport suitable for a certain kind of units.
For objectBoundingBox, CSS lengths which are in percentages
refer to the size of the current viewport. Librsvg implements
that by keeping the same current transformation matrix, and
setting a viewport size of (1.0, 1.0).
For userSpaceOnUse, we just duplicate the current viewport,
since that kind of units means to use the current coordinate
system unchanged.
Sourcepub fn with_view_box(&self, width: f64, height: f64) -> Viewport
pub fn with_view_box(&self, width: f64, height: f64) -> Viewport
Returns a viewport with a new size for normalizing Length values.
Sourcepub fn with_explicit_transform(&self, transform: ValidTransform) -> Viewport
pub fn with_explicit_transform(&self, transform: ValidTransform) -> Viewport
Copies the viewport, but just uses a new transform.
This is used when we are about to draw in a temporary surface: the transform for that surface is computed independenly of the one in the current viewport.
pub fn with_composed_transform( &self, transform: ValidTransform, ) -> Result<Viewport, InvalidTransform>
pub fn empty_bbox(&self) -> Box<BoundingBox>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Viewport
impl RefUnwindSafe for Viewport
impl Send for Viewport
impl Sync for Viewport
impl Unpin for Viewport
impl UnwindSafe for Viewport
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. 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>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.