MayaFlux 1.0.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 579 of file Bounds.hpp.

582{
583 const glm::vec2 c = anchor.center();
584
585 if (side == Side::Over) {
586 return { .min = { c.x - w * 0.5F, c.y - h * 0.5F },
587 .max = { c.x + w * 0.5F, c.y + h * 0.5F } };
588 }
589
590 if (side == Side::Below || side == Side::Above) {
591 float x0 {};
592 float x1 {};
593 switch (align) {
594 case Align::Center:
595 x0 = c.x - w * 0.5F;
596 x1 = c.x + w * 0.5F;
597 break;
598 case Align::Start:
599 x0 = anchor.min.x;
600 x1 = anchor.min.x + w;
601 break;
602 case Align::End:
603 x0 = anchor.max.x - w;
604 x1 = anchor.max.x;
605 break;
606 case Align::Span:
607 x0 = anchor.min.x;
608 x1 = anchor.max.x;
609 break;
610 }
611 return side == Side::Below
612 ? AABB2D { .min = { x0, anchor.min.y - gap - h }, .max = { x1, anchor.min.y - gap } }
613 : AABB2D { .min = { x0, anchor.max.y + gap }, .max = { x1, anchor.max.y + gap + h } };
614 }
615
616 float y0 {};
617 float y1 {};
618 switch (align) {
619 case Align::Center:
620 y0 = c.y - h * 0.5F;
621 y1 = c.y + h * 0.5F;
622 break;
623 case Align::Start:
624 y0 = anchor.max.y - h;
625 y1 = anchor.max.y;
626 break;
627 case Align::End:
628 y0 = anchor.min.y;
629 y1 = anchor.min.y + h;
630 break;
631 case Align::Span:
632 y0 = anchor.min.y;
633 y1 = anchor.max.y;
634 break;
635 }
636 return side == Side::Right
637 ? AABB2D { .min = { anchor.max.x + gap, y0 }, .max = { anchor.max.x + gap + w, y1 } }
638 : AABB2D { .min = { anchor.min.x - gap - w, y0 }, .max = { anchor.min.x - gap, y1 } };
639}
uint32_t h
Definition InkPress.cpp:29
glm::vec2 center() const noexcept
Definition Bounds.hpp:82

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: