Struct Vantage
pub struct Vantage {
pub zoom: Zoom,
pub translation: Vec2,
}Expand description
The whole of what a view-kind undo entry restores.
The two numbers the view holds, not a world rect — a rect would have to be re-framed against a viewport that may have resized since, which would land the camera somewhere the user never was.
The transform is here rather than in a backend because two backends read it: the on-screen painter converts every draw through it, and a recording canvas has to place its marks where the painter would have.
Fields§
§zoom: Zoom§translation: Vec2Implementations§
§impl Vantage
impl Vantage
pub fn world_to_screen(self, origin: Pos2, world: Pos2) -> Pos2
pub fn world_to_screen(self, origin: Pos2, world: Pos2) -> Pos2
origin is the screen corner the viewport was laid out at.
pub fn screen_to_world(self, origin: Pos2, screen: Pos2) -> Pos2
pub fn remap_rect(self, origin: Pos2, world: Rect) -> Rect
pub fn remap_len(self, len: Bounded<WorldPxBounds>) -> f32
pub fn remap_len(self, len: Bounded<WorldPxBounds>) -> f32
World-space length → screen-space length. The single place a world magnitude (radius, rounding, stroke width, wrap width) loses its unit.
pub fn remap_font(self, font: &Font) -> Font
pub fn remap_font(self, font: &Font) -> Font
The same face at the size it is drawn on screen.
pub fn visible(self, viewport: Rect) -> Rect
pub fn visible(self, viewport: Rect) -> Rect
The world rect viewport shows from here.
pub fn framing(
within: Rect,
viewport_min: Pos2,
content: Rect,
max_zoom: Zoom,
) -> Vantage
pub fn framing( within: Rect, viewport_min: Pos2, content: Rect, max_zoom: Zoom, ) -> Vantage
The vantage that frames content centred in within, a screen region
inside the viewport whose corner is viewport_min. within is not
necessarily the whole viewport: floating chrome may leave less of it
clear, and framing against the raw rect lands the model under the
chrome. Padding is the caller’s — it pads content before framing it.
pub fn zoomed_about(self, origin: Pos2, anchor: Pos2, factor: Factor) -> Vantage
pub fn zoomed_about(self, origin: Pos2, anchor: Pos2, factor: Factor) -> Vantage
The same camera zoomed by factor about anchor (screen space, in a
viewport cornered at origin), leaving the world under anchor where
it was. Lands inside [Zoom::WORKED_MIN]..=[Zoom::WORKED_MAX] — a
user working the camera stays in the band, where a framing may use the
whole range.
Trait Implementations§
§impl<'de> Deserialize<'de> for Vantage
impl<'de> Deserialize<'de> for Vantage
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Vantage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Vantage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Serialize for Vantage
impl Serialize for Vantage
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for Vantage
impl StructuralPartialEq for Vantage
Auto Trait Implementations§
impl Freeze for Vantage
impl RefUnwindSafe for Vantage
impl Send for Vantage
impl Sync for Vantage
impl Unpin for Vantage
impl UnsafeUnpin for Vantage
impl UnwindSafe for Vantage
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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