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

◆ place() [1/2]

AABB2D MayaFlux::Kinesis::place ( AABB2D  anchor,
Side  side,
float  w,
float  h,
float  gap = 0.F,
Align  align = Align::Center 
)
inlinenoexcept

Compute a region of size (w, h) positioned relative to anchor.

Parameters
anchorRegion to place against.
sideDirection of placement.
wWidth in NDC units. Ignored when side is vertical and align is Span.
hHeight in NDC units. Ignored when side is horizontal and align is Span.
gapSeparation from the anchor edge. Ignored for Side::Over.
alignCross-axis alignment.

Definition at line 534 of file Bounds.hpp.

537{
538 const glm::vec2 c = anchor.center();
539
540 if (side == Side::Over) {
541 return { .min = { c.x - w * 0.5F, c.y - h * 0.5F },
542 .max = { c.x + w * 0.5F, c.y + h * 0.5F } };
543 }
544
545 if (side == Side::Below || side == Side::Above) {
546 float x0 {};
547 float x1 {};
548 switch (align) {
549 case Align::Center:
550 x0 = c.x - w * 0.5F;
551 x1 = c.x + w * 0.5F;
552 break;
553 case Align::Start:
554 x0 = anchor.min.x;
555 x1 = anchor.min.x + w;
556 break;
557 case Align::End:
558 x0 = anchor.max.x - w;
559 x1 = anchor.max.x;
560 break;
561 case Align::Span:
562 x0 = anchor.min.x;
563 x1 = anchor.max.x;
564 break;
565 }
566 return side == Side::Below
567 ? AABB2D { .min = { x0, anchor.min.y - gap - h }, .max = { x1, anchor.min.y - gap } }
568 : AABB2D { .min = { x0, anchor.max.y + gap }, .max = { x1, anchor.max.y + gap + h } };
569 }
570
571 float y0 {};
572 float y1 {};
573 switch (align) {
574 case Align::Center:
575 y0 = c.y - h * 0.5F;
576 y1 = c.y + h * 0.5F;
577 break;
578 case Align::Start:
579 y0 = anchor.max.y - h;
580 y1 = anchor.max.y;
581 break;
582 case Align::End:
583 y0 = anchor.min.y;
584 y1 = anchor.min.y + h;
585 break;
586 case Align::Span:
587 y0 = anchor.min.y;
588 y1 = anchor.max.y;
589 break;
590 }
591 return side == Side::Right
592 ? AABB2D { .min = { anchor.max.x + gap, y0 }, .max = { anchor.max.x + gap + w, y1 } }
593 : AABB2D { .min = { anchor.min.x - gap - w, y0 }, .max = { anchor.min.x - gap, y1 } };
594}
uint32_t h
Definition InkPress.cpp:28
glm::vec2 center() const noexcept
Definition Bounds.hpp:40

References Above, Below, MayaFlux::Kinesis::AABB2D::center(), Center, End, h, MayaFlux::Kinesis::AABB2D::min, Over, Right, Span, and Start.

Referenced by place().

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