MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
PlacementInputs.cpp
Go to the documentation of this file.
1#include "PlacementInputs.hpp"
2
4
5std::optional<Kinesis::AABB2D> region_of(const RectPlacementInputs& placement, std::string& error)
6{
7 const glm::vec4 rect = placement.rect;
8 if (!(rect.z > 0.F) || !(rect.w > 0.F)) {
9 error = "rect needs a positive width and height";
10 return std::nullopt;
11 }
12 return Kinesis::AABB2D::from_origin_size({ rect.x, rect.y }, { rect.z, rect.w });
13}
14
15std::optional<Kinesis::AABB2D> region_of(const RadialPlacementInputs& placement, std::string& error)
16{
17 if (!(placement.radius > 0.F)) {
18 error = "radius needs to be positive";
19 return std::nullopt;
20 }
21 return Kinesis::AABB2D::from_ndc(placement.center, glm::vec2(placement.radius));
22}
23
24}
std::optional< Kinesis::AABB2D > region_of(const RectPlacementInputs &placement, std::string &error)
The surface region a rect placement covers.
static AABB2D from_ndc(glm::vec2 center, glm::vec2 half) noexcept
Definition Bounds.hpp:94
static AABB2D from_origin_size(glm::vec2 origin, glm::vec2 size) noexcept
Construct from a minimum corner and a size.
Definition Bounds.hpp:104
A placement by origin and size: x, y, width, height.