MapViewport
struct · ferroui-livecharts · v0.5.0
struct MapViewport
The pan and zoom of a map (MapViewportTransform, GeoMapChart.ZoomLevel and PanOffset):
a projected position p is drawn at p * zoom + center * (1 - zoom) + pan, where center
is the centre of the control. The stroke of the lands scales with the zoom, as the source's
canvas matrix scales it.
Members
zoom
zoom: f64
pan
pan: ferroui_base::Point
new
fn new(zoom: f64, pan: Point) -> Self
is_identity
fn is_identity(self: &Self) -> bool
Whether the viewport changes nothing (the opposite of IsActive).
transform
fn transform(self: &Self, point: Point, center: Point) -> Point
The screen position of a projected position.
inverse
fn inverse(self: &Self, point: Point, center: Point) -> Point
The projected position of a screen position (InverseViewportTransform); a zoom of 0 is
taken as 1.
panned
fn panned(self: &Self, delta: Point) -> Self
The viewport moved by a screen distance (MapFactory.Pan).
zoomed
fn zoomed(self: &Self, pivot: Point, direction: ZoomDirection, speed: f64, min_zoom: f64, max_zoom: f64, center: Point) -> Self
One zoom step about a screen position, which stays in place (MapFactory.Zoom). The
speed is clamped to [0.1, 0.95]; a step in multiplies the zoom by 1 / (1 - speed), a step
out by 1 - speed. The zoom stays at most max_zoom and at least 0.8 * min_zoom, the
overshoot that the bounce back of a release takes back.
bounce_back_target
fn bounce_back_target(self: &Self, control: Size, min_zoom: f64) -> Option<Self>
Where a release settles the viewport (BounceBack): the zoom back to at least
min_zoom and the map, the size of the control at that zoom, panned to cover the control.
None when the viewport is already there.
interpolate
fn interpolate(self: &Self, to: &Self, t: f64) -> Self
The viewport t of the way from this one to to.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedPropertyValueAnyValueClassDefaultsErasedDestructorIntoEitherCloneCopyDebugStructuralPartialEqPartialEqDefault
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.