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§
Source§impl Vantage
impl Vantage
Sourcepub 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
Sourcepub fn remap_len(self, len: WorldPx) -> f32
pub fn remap_len(self, len: WorldPx) -> f32
World-space length → screen-space length. The single place a world magnitude (radius, rounding, stroke width, wrap width) loses its unit.
Sourcepub 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.
Sourcepub fn framing(
within: Rect,
viewport_min: Pos2,
content: Rect,
max_zoom: Zoom,
) -> Self
pub fn framing( within: Rect, viewport_min: Pos2, content: Rect, max_zoom: Zoom, ) -> Self
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.
Sourcepub fn zoomed_about(self, origin: Pos2, anchor: Pos2, factor: Factor) -> Self
pub fn zoomed_about(self, origin: Pos2, anchor: Pos2, factor: Factor) -> Self
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.