MCPcopy Create free account
hub / github.com/VCVRack/Rack / clamp

Method clamp

include/math.hpp:384–391  ·  view source on GitHub ↗

Clamps the edges of the rectangle to fit within a bound. */

Source from the content-addressed store, hash-verified

382 }
383 /** Clamps the edges of the rectangle to fit within a bound. */
384 Rect clamp(Rect bound) const {
385 Rect r;
386 r.pos.x = math::clampSafe(pos.x, bound.pos.x, bound.pos.x + bound.size.x);
387 r.pos.y = math::clampSafe(pos.y, bound.pos.y, bound.pos.y + bound.size.y);
388 r.size.x = math::clamp(pos.x + size.x, bound.pos.x, bound.pos.x + bound.size.x) - r.pos.x;
389 r.size.y = math::clamp(pos.y + size.y, bound.pos.y, bound.pos.y + bound.size.y) - r.pos.y;
390 return r;
391 }
392 /** Nudges the position to fix inside a bounding box. */
393 Rect nudge(Rect bound) const {
394 Rect r;

Callers

nothing calls this directly

Calls 2

clampSafeFunction · 0.85
clampFunction · 0.70

Tested by

no test coverage detected