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

◆ clamp_offset_to_content()

MAYAFLUX_API glm::vec2 MayaFlux::Kinesis::clamp_offset_to_content ( glm::vec2  offset,
glm::vec2  viewport_extent,
AABB2D  content_bounds 
)
noexcept

Clamp a content-space offset so a viewport of the given extent never scrolls past the edges of a content region, per axis.

An axis where content is smaller than the viewport clamps to zero rather than to a degenerate range: there is nothing to scroll on that axis.

Definition at line 13 of file ScrollState.cpp.

17{
18 const float max_x = std::max(0.F, content_bounds.width() - viewport_extent.x);
19 const float max_y = std::max(0.F, content_bounds.height() - viewport_extent.y);
20
21 return { std::clamp(offset.x, 0.F, max_x), std::clamp(offset.y, 0.F, max_y) };
22}
uint64_t offset
Definition Composite.cpp:10
float height() const noexcept
Definition Bounds.hpp:80
float width() const noexcept
Definition Bounds.hpp:79

References offset.

Referenced by apply_scroll().

+ Here is the caller graph for this function: