23 lines
546 B
C++
23 lines
546 B
C++
#pragma once
|
|
#include <plot/core/types.hpp>
|
|
|
|
namespace plot {
|
|
|
|
/// Axis-aligned rectangle in pixels, origin at the top-left.
|
|
struct Rect {
|
|
f32 x = 0.0f;
|
|
f32 y = 0.0f;
|
|
f32 w = 0.0f;
|
|
f32 h = 0.0f;
|
|
|
|
constexpr f32 right() const noexcept { return x + w; }
|
|
constexpr f32 bottom() const noexcept { return y + h; }
|
|
|
|
/// Half-open containment: the right/bottom edges are outside the rect.
|
|
constexpr bool contains(f32 px, f32 py) const noexcept {
|
|
return px >= x && px < right() && py >= y && py < bottom();
|
|
}
|
|
};
|
|
|
|
} // namespace plot
|