MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ apply_pan_zoom_pan()

MAYAFLUX_API void MayaFlux::Kinesis::apply_pan_zoom_pan ( PanZoom2DState &  state,
float  dx,
float  dy,
float  viewport_width,
float  viewport_height 
)

Pan by a pixel delta, scaled to world units by the current zoom level.

Scaling by zoom ensures pan speed stays proportionate to zoom level.

Parameters
statePanZoom2D state (pan mutated).
dxHorizontal pixel delta (positive = right).
dyVertical pixel delta (positive = up).
viewport_widthFramebuffer width in pixels.
viewport_heightFramebuffer height in pixels.

Definition at line 33 of file PanZoom2DState.cpp.

35{
36 const float aspect = viewport_width / viewport_height;
37 const glm::vec2 delta = drag_to_offset_delta(
38 { dx, dy },
39 { 2.0F * st.zoom * aspect, 2.0F * st.zoom },
40 { viewport_width, viewport_height });
41
42 st.pan.x -= delta.x;
43 st.pan.y += delta.y;
44}
glm::vec2 drag_to_offset_delta(glm::vec2 pixel_delta, glm::vec2 visible_extent, glm::vec2 viewport_size_pixels) noexcept
Convert a pixel-space drag delta into a content-space delta.

References drag_to_offset_delta(), MayaFlux::Kinesis::PanZoom2DState::pan, and MayaFlux::Kinesis::PanZoom2DState::zoom.

Referenced by MayaFlux::bind_pan_zoom_preset().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: