pub struct ViewportTransform {
pub pan: CanvasPoint,
pub zoom: f32,
}Expand description
Current viewport transform.
pan is stored in canvas space and zoom is a positive scale factor. Screen projection follows
(canvas + pan) * zoom, matching the existing fit-view helpers and persisted view-state.
Fields§
§pan: CanvasPointCanvas-space pan.
zoom: f32Positive zoom factor.
Implementations§
Source§impl ViewportTransform
impl ViewportTransform
Sourcepub fn new(pan: CanvasPoint, zoom: f32) -> Option<Self>
pub fn new(pan: CanvasPoint, zoom: f32) -> Option<Self>
Creates a viewport transform when pan is finite and zoom is positive finite.
Sourcepub fn is_valid(self) -> bool
pub fn is_valid(self) -> bool
Returns true when the transform can safely participate in viewport math.
Sourcepub fn from_view_state(view_state: &NodeGraphViewState) -> Option<Self>
pub fn from_view_state(view_state: &NodeGraphViewState) -> Option<Self>
Reads the viewport transform from a persisted view-state.
Sourcepub fn screen_point_for_canvas(self, canvas: CanvasPoint) -> Option<CanvasPoint>
pub fn screen_point_for_canvas(self, canvas: CanvasPoint) -> Option<CanvasPoint>
Projects a canvas point into logical screen pixels.
Sourcepub fn canvas_point_at_screen(self, screen: CanvasPoint) -> CanvasPoint
pub fn canvas_point_at_screen(self, screen: CanvasPoint) -> CanvasPoint
Converts a logical screen-pixel point to canvas space.
Trait Implementations§
Source§impl Clone for ViewportTransform
impl Clone for ViewportTransform
Source§fn clone(&self) -> ViewportTransform
fn clone(&self) -> ViewportTransform
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for ViewportTransform
Source§impl Debug for ViewportTransform
impl Debug for ViewportTransform
Source§impl<'de> Deserialize<'de> for ViewportTransform
impl<'de> Deserialize<'de> for ViewportTransform
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ViewportTransform
impl PartialEq for ViewportTransform
Source§fn eq(&self, other: &ViewportTransform) -> bool
fn eq(&self, other: &ViewportTransform) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for ViewportTransform
impl Serialize for ViewportTransform
impl StructuralPartialEq for ViewportTransform
Auto Trait Implementations§
impl Freeze for ViewportTransform
impl RefUnwindSafe for ViewportTransform
impl Send for ViewportTransform
impl Sync for ViewportTransform
impl Unpin for ViewportTransform
impl UnsafeUnpin for ViewportTransform
impl UnwindSafe for ViewportTransform
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