header_utils
Loading...
Searching...
No Matches
align+rec2.h
1
4
5#pragma once
6#include "rec2.h"
7#include "align.h"
8
9namespace ghassanpl
10{
11 template <typename T>
12 [[nodiscard]] constexpr trec2<T> aligned(trec2<T> const& smaller, trec2<T> const& larger, align alignment)
13 {
14 return trec2<T>::from_size(
15 larger.position() + glm::tvec2<T>{
16 ghassanpl::aligned<T>(smaller.width(), larger.width(), horizontal_from(alignment)),
17 ghassanpl::aligned<T>(smaller.height(), larger.height(), vertical_from(alignment))
18 },
19 smaller.size()
20 );
21 }
22
23 template <typename T>
24 [[nodiscard]] constexpr trec2<T> aligned(glm::tvec2<T> inner_size, trec2<T> const& larger, align alignment)
25 {
26 return trec2<T>::from_size(
27 larger.position() + glm::tvec2<T>{
28 ghassanpl::aligned<T>(inner_size.x, larger.width(), horizontal_from(alignment)),
29 ghassanpl::aligned<T>(inner_size.y, larger.height(), vertical_from(alignment))
30 },
31 inner_size
32 );
33 }
34
40 template <typename T>
41 [[nodiscard]] constexpr align relative_alignment(glm::tvec2<T> pt, trec2<T> const& rect);
42}
align
Represents an alignment in both axes (horizontal and veritcal).
Definition align.h:52
Primary namespace for everything in this library.
Definition align+rec2.h:10
constexpr align relative_alignment(glm::tvec2< T > pt, trec2< T > const &rect)
Represents a 2D rectangle polygon_shape.
Definition rec2.h:31