Documentation for <wlr/util/box.h>
Table of contents
struct wlr_box ¶
struct wlr_box { int x, y; int width, height; };
A box representing a rectangle region in a 2D space.
The x and y coordinates are inclusive, and the width and height lengths are exclusive. In other words, the box starts from the coordinates (x, y), and goes up to but not including (x + width, y + height).
wlr_box_closest_point() ¶
void wlr_box_closest_point(const struct wlr_box *box, double x, double y, double *dest_x, double *dest_y);
Finds the closest point within the box bounds.
Returns NAN if the box is empty.
wlr_box_contains_box() ¶
bool wlr_box_contains_box(const struct wlr_box *bigger, const struct wlr_box *smaller);
Verifies that a box is fully contained within another box.
Returns true if the "smaller" box is fully contained within the "bigger" box. If either of the boxes are empty, false is returned.
wlr_box_contains_point() ¶
bool wlr_box_contains_point(const struct wlr_box *box, double x, double y);
Verifies if a point is contained within the bounds of a given struct wlr_box.
For example:
- A point at (100, 50) is not contained in the box (0, 0, 100, 50). - A point at (10, 10) is contained in the box (10, 0, 50, 50).
wlr_box_empty() ¶
bool wlr_box_empty(const struct wlr_box *box);
Checks whether a box is empty or not.
A box is considered empty if its width and/or height is zero or negative.
wlr_box_equal() ¶
bool wlr_box_equal(const struct wlr_box *a, const struct wlr_box *b);
Returns true if the two boxes are equal, false otherwise.
wlr_box_intersection() ¶
bool wlr_box_intersection(struct wlr_box *dest, const struct wlr_box *box_a, const struct wlr_box *box_b);
Gives the intersecting box between two struct wlr_box.
Returns an empty box if the provided boxes don't intersect.
wlr_box_intersects() ¶
bool wlr_box_intersects(const struct wlr_box *a, const struct wlr_box *b);
Checks whether two boxes intersect.
Returns false if either box is empty.
wlr_box_transform() ¶
void wlr_box_transform(struct wlr_box *dest, const struct wlr_box *box, enum wl_output_transform transform, int width, int height);
Transforms a box inside a (0, 0, width, height) box.
struct wlr_fbox ¶
struct wlr_fbox { double x, y; double width, height; };
A floating-point box representing a rectangle region in a 2D space.
struct wlr_fbox has the same semantics as struct wlr_box.
wlr_fbox_empty() ¶
bool wlr_fbox_empty(const struct wlr_fbox *box);
Checks whether a box is empty or not.
A box is considered empty if its width and/or height is zero or negative.
wlr_fbox_equal() ¶
bool wlr_fbox_equal(const struct wlr_fbox *a, const struct wlr_fbox *b);
Returns true if the two boxes are equal, false otherwise.
wlr_fbox_transform() ¶
void wlr_fbox_transform(struct wlr_fbox *dest, const struct wlr_fbox *box, enum wl_output_transform transform, double width, double height);
Transforms a floating-point box inside a (0, 0, width, height) box.