5#include "roo_logging.h"
17 [[
deprecated(
"Use `Box::ClipResult::kEmpty` instead.")]]
19 [[
deprecated(
"Use `Box::ClipResult::kReduced` instead.")]]
21 [[
deprecated(
"Use `Box::ClipResult::kUnchanged` instead.")]]
62 bool empty()
const {
return xMax_ < xMin_ || yMax_ < yMin_; }
92 return (
other.xMin() >= xMin_ &&
other.xMax() <= xMax_ &&
93 other.yMin() >= yMin_ &&
other.yMax() <= yMax_);
98 return other.xMin() <= xMax_ &&
other.xMax() >= xMin_ &&
99 other.yMin() <= yMax_ &&
other.yMax() >= yMin_;
107 if (xMin_ < clip_box.
xMin()) {
108 xMin_ = clip_box.
xMin();
111 if (xMax_ > clip_box.
xMax()) {
112 xMax_ = clip_box.
xMax();
115 if (yMin_ < clip_box.
yMin()) {
116 yMin_ = clip_box.
yMin();
119 if (yMax_ > clip_box.
yMax()) {
120 yMax_ = clip_box.
yMax();
128 return Box(xMin_ + x_offset, yMin_ + y_offset, xMax_ + x_offset,
134 return Box(xMin_ * x_scale, yMin_ * y_scale, xMax_ * x_scale,
166 int16_t xMin_, yMin_, xMax_, yMax_;
179roo_logging::Stream&
operator<<(roo_logging::Stream& os,
const Box& box);
182roo_logging::Stream&
operator<<(roo_logging::Stream& os,
187#if defined(__linux__) || defined(__linux) || defined(linux)
195 os <<
"[" << box.
xMin() <<
", " << box.
yMin() <<
", " << box.
xMax() <<
", "
196 << box.
yMax() <<
"]";
Axis-aligned integer rectangle.
Box rotateRight() const
Return a copy rotated 90 degrees clockwise around the origin.
int16_t width() const
Width in pixels (inclusive coordinates).
Box rotateUpsideDown() const
Return a copy rotated 180 degrees around the origin.
static constexpr ClipResult CLIP_RESULT_EMPTY
ClipResult
Result of clipping a box to a clip region.
int16_t xMin() const
Minimum x (inclusive).
static constexpr ClipResult CLIP_RESULT_UNCHANGED
int16_t xMax() const
Maximum x (inclusive).
bool empty() const
Return whether the box is empty.
static Box MaximumBox()
Return a large sentinel box used for unbounded extents.
int16_t height() const
Height in pixels (inclusive coordinates).
Box & operator=(Box &&)=default
Box scale(int16_t x_scale, int16_t y_scale) const
Return a scaled copy of this box.
Box translate(int16_t x_offset, int16_t y_offset) const
Return a translated copy of this box.
bool contains(int16_t x, int16_t y) const
Return whether the point (x, y) lies within the box.
Box & operator=(const Box &)=default
Box extend(int16_t x, int16_t y)
Return the minimal box containing this box and the given point.
constexpr Box(int16_t xMin, int16_t yMin, int16_t xMax, int16_t yMax)
Construct a box from inclusive coordinates.
ClipResult clip(const Box &clip_box)
Clip this box to the given clip box.
int16_t yMax() const
Maximum y (inclusive).
static constexpr ClipResult CLIP_RESULT_REDUCED
Box flipX() const
Return a copy mirrored across the Y-axis.
Box swapXY() const
Return a copy with x and y axes swapped.
bool intersects(const Box &other) const
Return whether this box intersects the other box.
Box rotateLeft() const
Return a copy rotated 90 degrees counter-clockwise around the origin.
int32_t area() const
Area in pixels.
static Box Extent(const Box &a, const Box &b)
Return the smallest box that contains both input boxes.
bool contains(const Box &other) const
Return whether this box fully contains the other box.
static Box Intersect(const Box &a, const Box &b)
Return the intersection of two boxes (may be empty).
Box flipY() const
Return a copy mirrored across the X-axis.
int16_t yMin() const
Minimum y (inclusive).
Defines 140 opaque HTML named colors.
constexpr bool operator==(const Color &a, const Color &b)
Equality operator for colors.
constexpr bool operator!=(const Color &a, const Color &b)
Inequality operator for colors.
roo_logging::Stream & operator<<(roo_logging::Stream &os, BlendingMode mode)