Rectangle
Eina » Tools

These functions provide rectangle management. More...

## Data Structures

struct | _Eina_Position2D
| A 2D position in pixel coordinates. More...
struct | _Eina_Size2D
| A 2D size in pixel coordinates. More...
struct | _Eina_Rectangle
union | _Eina_Rect

## Macros

#define | EINA_RECTANGLE_INIT { 0, 0, 0, 0}
| A zero-size rectangle.
#define | EINA_RECTANGLE_FORMAT "dx%d - %dx%d"
| A format string useful for printf-like functions.
#define | EINA_RECTANGLE_ARGS(r)
| Separates the components of the rectangle structure into a comma-separated list, so they can be used as parameters.
#define | EINA_RECT(x, y, w, h)
| Creates an instance of an Eina_Rect.
#define | EINA_RECT_ZERO()
| A zero-size rectangle that can be used to initialize Eina_Rect structures.
#define | EINA_RECT_EMPTY()
| A zero-size rectangle that can be used to initialize Eina_Rect structures.
#define | EINA_POSITION2D(x, y)
| Creates an instance of an Eina_Position2D.
#define | EINA_SIZE2D(x, y)
| Creates an instance of an Eina_Size2D.
#define | EINA_SIZE2D_EQ(a, b)
| convenience macro for comparing two Eina_Size2D structs
#define | EINA_POSITION2D_EQ(a, b)
| convenience macro for comparing two Eina_Position2D structs
#define | EINA_POSITION2D_DISTANCE(a, b)
| Convenience macro for getting the distance from one point to another.
#define | EINA_RECTANGLE_SET(Rectangle, X, Y, W, H)
| Definition for the macro to set the values of a Eina_Rectangle.
#define | EINA_RECT_SET(rect, x, y, w, h)
| Functionally equivalent to EINA_RECTANGLE_SET.

## Typedefs

typedef struct _Eina_Position2D | Eina_Position2D
| A 2D position in pixel coordinates.
typedef struct _Eina_Size2D | Eina_Size2D
| A 2D size in pixel coordinates.
typedef struct _Eina_Rectangle | Eina_Rectangle
| Simple rectangle structure.
typedef union _Eina_Rect | Eina_Rect
| A convenient rectangle structure which can be accessed in different ways.
typedef struct _Eina_Rectangle_Pool | Eina_Rectangle_Pool
| Type for an opaque pool of rectangles.

## Enumerations

enum | Eina_Rectangle_Packing { Eina_Packing_Descending , Eina_Packing_Ascending , Eina_Packing_Bottom_Left , Eina_Packing_Bottom_Left_Skyline , Eina_Packing_Bottom_Left_Skyline_Improved }
| Type for an Eina Pool based on a packing algorithm. More...
enum | Eina_Rectangle_Outside { EINA_RECTANGLE_OUTSIDE_TOP = 1 , EINA_RECTANGLE_OUTSIDE_LEFT = 2 , EINA_RECTANGLE_OUTSIDE_BOTTOM = 4 , EINA_RECTANGLE_OUTSIDE_RIGHT = 8 }
| Enumeration of the positions around a rectangle. More...

## Functions

static int | eina_spans_intersect (int c1, int l1, int c2, int l2)
| Checks if the given spans intersect.
static Eina_Bool | eina_rectangle_is_empty (const Eina_Rectangle *rect)
| Checks if the given rectangle is empty.
static void | eina_rectangle_coords_from (Eina_Rectangle *rect, int x, int y, int w, int h)
| Sets the coordinates and size of a rectangle.
static Eina_Bool | eina_rectangles_intersect (const Eina_Rectangle *rect1, const Eina_Rectangle *rect2)
| Checks if two rectangles intersect.
static Eina_Bool | eina_rectangle_xcoord_inside (const Eina_Rectangle *rect, int x)
| Checks if the given X-coordinate is in the rectangle.
static Eina_Bool | eina_rectangle_ycoord_inside (const Eina_Rectangle *rect, int y)
| Checks if the given Y-coordinate is in the rectangle.
static Eina_Bool | eina_rectangle_coords_inside (const Eina_Rectangle *rect, int x, int y)
| Checks if the given point is inside the rectangle.
static void | eina_rectangle_union (Eina_Rectangle *dst, const Eina_Rectangle *src)
| Gets the union of two rectangles.
static Eina_Bool | eina_rectangle_intersection (Eina_Rectangle *dst, const Eina_Rectangle *src)
| Gets the intersection of two rectangles.
static void | eina_rectangle_rescale_in (const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res)
| FIXME I am useless and used by no one.
static void | eina_rectangle_rescale_out (const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res)
| FIXME I am useless and used by no one.
static Eina_Bool | eina_rectangle_is_valid (const Eina_Rectangle *rect)
| Tells whether a rectangle is valid.
static int | eina_rectangle_max_x (Eina_Rectangle *rect)
| Gets the rectangle's maximum X coordinate.
static int | eina_rectangle_max_y (Eina_Rectangle *rect)
| Gets the rectangle maximum Y coordinate.
static Eina_Bool | eina_rectangle_x_cut (Eina_Rectangle *rect, Eina_Rectangle *slice, Eina_Rectangle *remainder, int amount)
| Slices a rectangle vertically into two subrectangles.
static Eina_Bool | eina_rectangle_y_cut (Eina_Rectangle *rect, Eina_Rectangle *slice, Eina_Rectangle *remainder, int amount)
| Slices a rectangle horizontally into two subrectangles.
static Eina_Bool | eina_rectangle_width_cut (Eina_Rectangle *rect, Eina_Rectangle *slice, Eina_Rectangle *remainder, int amount)
| Slices a rectangle vertically starting from right edge.
static Eina_Bool | eina_rectangle_height_cut (Eina_Rectangle *rect, Eina_Rectangle *slice, Eina_Rectangle *remainder, int amount)
| Slices a rectangle horizontally starting from top edge.
static Eina_Bool | eina_rectangle_subtract (Eina_Rectangle *rect, Eina_Rectangle *other, Eina_Rectangle out[4])
| Subtracts two rectangles and returns the differences.
EINA_API Eina_Rectangle_Pool * | eina_rectangle_pool_new (int w, int h)
| Adds a rectangle in a new pool.
EINA_API Eina_Rectangle_Pool * | eina_rectangle_pool_get (Eina_Rectangle *rect)
| Returns the pool of the given rectangle.
EINA_API Eina_Bool | eina_rectangle_pool_geometry_get (Eina_Rectangle_Pool *pool, int *w, int *h)
| Returns the width and height of the given pool.
EINA_API void * | eina_rectangle_pool_data_get (Eina_Rectangle_Pool *pool)
| Gets the data from the given pool.
EINA_API void | eina_rectangle_pool_data_set (Eina_Rectangle_Pool *pool, const void *data)
| Sets the data to the given pool.
EINA_API void | eina_rectangle_pool_free (Eina_Rectangle_Pool *pool)
| Frees the given pool.
EINA_API int | eina_rectangle_pool_count (Eina_Rectangle_Pool *pool)
| Returns the number of rectangles in the given pool.
EINA_API Eina_Rectangle * | eina_rectangle_pool_request (Eina_Rectangle_Pool *pool, int w, int h)
| Requests a rectangle of given size in the given pool.
EINA_API void | eina_rectangle_pool_release (Eina_Rectangle *rect)
| Removes the given rectangle from the pool.
EINA_API Eina_Rectangle * | eina_rectangle_new (int x, int y, int w, int h)
| Creates a new rectangle.
EINA_API void | eina_rectangle_free (Eina_Rectangle *rect)
| Frees the given rectangle.
EINA_API void | eina_rectangle_pool_packing_set (Eina_Rectangle_Pool *pool, Eina_Rectangle_Packing type)
| Sets the type of given rectangle pool.
EINA_API Eina_Rectangle_Outside | eina_rectangle_outside_position (Eina_Rectangle *rect1, Eina_Rectangle *rect2)
| calculates where rect2 is outside of rect1.
static Eina_Bool | eina_rectangle_equal (const Eina_Rectangle *rect1, const Eina_Rectangle *rect2)
| Compares two rectangles for equality.

## Detailed Description

These functions provide rectangle management.

## Macro Definition Documentation

## EINA_RECTANGLE_ARGS

#define EINA_RECTANGLE_ARGS | ( |  | r | ) |

Value:
(r)->x, (r)->y, (r)->w, (r)->h

Separates the components of the rectangle structure into a comma-separated list, so they can be used as parameters.

## EINA_RECT

#define EINA_RECT | ( |  | x,
|  |  | y,
|  |  | w,
|  |  | h )

Value:
((Eina_Rect) { { (x), (y), (w), (h) } })
Eina_Rect
union _Eina_Rect Eina_Rect
A convenient rectangle structure which can be accessed in different ways.

Creates an instance of an Eina_Rect.

Referenced by elm_photocam_image_region_bring_in(), elm_photocam_image_region_show(), evas_object_geometry_set(), evas_object_image_data_update_add(), and evas_object_top_in_rectangle_get().

## EINA_RECT_ZERO

#define EINA_RECT_ZERO | ( |  | ) |

Value:
{ EINA_RECTANGLE_INIT }
EINA_RECTANGLE_INIT
#define EINA_RECTANGLE_INIT
A zero-size rectangle.
Definition eina_rectangle.h:43

A zero-size rectangle that can be used to initialize Eina_Rect structures.

Referenced by edje_object_parts_extends_calc().

## EINA_RECT_EMPTY

#define EINA_RECT_EMPTY | ( |  | ) |

Value:
((Eina_Rect) EINA_RECT_ZERO())
EINA_RECT_ZERO
#define EINA_RECT_ZERO()
A zero-size rectangle that can be used to initialize Eina_Rect structures.
Definition eina_rectangle.h:53

A zero-size rectangle that can be used to initialize Eina_Rect structures.

## EINA_POSITION2D

#define EINA_POSITION2D | ( |  | x,
|  |  | y )

Value:
((Eina_Position2D) { (x), (y) })
Eina_Position2D
struct _Eina_Position2D Eina_Position2D
A 2D position in pixel coordinates.

Creates an instance of an Eina_Position2D.

Referenced by evas_object_move(), evas_object_pointer_coords_inside_get(), evas_object_polygon_point_add(), evas_object_top_at_pointer_get(), and evas_vg_node_geometry_set().

## EINA_SIZE2D

#define EINA_SIZE2D | ( |  | x,
|  |  | y )

Value:
((Eina_Size2D) { (x), (y) })
Eina_Size2D
struct _Eina_Size2D Eina_Size2D
A 2D size in pixel coordinates.

Creates an instance of an Eina_Size2D.

Referenced by ecore_evas_drag_start(), edje_object_size_min_restricted_calc(), elm_bg_load_size_set(), elm_drag_start(), elm_glview_size_set(), elm_image_prescale_set(), elm_textpath_circle_set(), elm_win_size_base_set(), elm_win_size_step_set(), evas_object_resize(), evas_object_size_hint_aspect_set(), evas_object_size_hint_max_set(), evas_object_size_hint_min_set(), and evas_vg_node_geometry_set().

## EINA_SIZE2D_EQ

#define EINA_SIZE2D_EQ | ( |  | a,
|  |  | b )

Value:
(((a).w == (b).w) && ((a).h == (b).h))

convenience macro for comparing two Eina_Size2D structs

Parameters

  [in] | a | An Eina_Size2D
  [in] | b | An Eina_Size2D

Returns
  1 if the structs are equal, 0 if they are not

Since
  1.24

## EINA_POSITION2D_EQ

#define EINA_POSITION2D_EQ | ( |  | a,
|  |  | b )

Value:
(((a).x == (b).x) && ((a).y == (b).y))

convenience macro for comparing two Eina_Position2D structs

Parameters

  [in] | a | An Eina_Position2D
  [in] | b | An Eina_Position2D

Returns
  1 if the structs are equal, 0 if they are not

Since
  1.24

## EINA_POSITION2D_DISTANCE

#define EINA_POSITION2D_DISTANCE | ( |  | a,
|  |  | b )

Value:
sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y))

Convenience macro for getting the distance from one point to another.

Parameters

  [in] | a | An Eina_Position2D
  [in] | b | An Eina_Position2D

Returns
  The distance between the two points.

Since
  1.24

## EINA_RECTANGLE_SET

#define EINA_RECTANGLE_SET | ( |  | Rectangle,
|  |  | X,
|  |  | Y,
|  |  | W,
|  |  | H )

Value:
{ \
(Rectangle)->x = X; \
(Rectangle)->y = Y; \
(Rectangle)->w = W; \
(Rectangle)->h = H; \
}

Definition for the macro to set the values of a Eina_Rectangle.

Parameters

  [out] | Rectangle | The rectangle.
  [in] | X | The X coordinate of the top left corner of the rectangle.
  [in] | Y | The Y coordinate of the top left corner of the rectangle.
  [in] | W | The width of the rectangle.
  [in] | H | The height of the rectangle.

This macro set the values of `Rectangle`. `X` and `Y` are the coordinates of the top left corner of `Rectangle`, `W` is its width and `H` is its height.

Referenced by eina_quadtree_collide(), and eina_rectangle_new().

## EINA_RECT_SET

#define EINA_RECT_SET | ( |  | rect,
|  |  | x,
|  |  | y,
|  |  | w,
|  |  | h )

Value:
do { EINA_RECTANGLE_SET((&rect), x, y, w, h) } while (0)
EINA_RECTANGLE_SET
#define EINA_RECTANGLE_SET(Rectangle, X, Y, W, H)
Definition for the macro to set the values of a Eina_Rectangle.
Definition eina_rectangle.h:538

Functionally equivalent to EINA_RECTANGLE_SET.

## Enumeration Type Documentation

## Eina_Rectangle_Packing

enum Eina_Rectangle_Packing

Type for an Eina Pool based on a packing algorithm.

Since
  1.11

Enumerator
Eina_Packing_Descending | Current.
Eina_Packing_Ascending | sorting in ascending order
Eina_Packing_Bottom_Left | sorting in bottom left fashion
Eina_Packing_Bottom_Left_Skyline | bottom left skyline
Eina_Packing_Bottom_Left_Skyline_Improved | optimized bottom left skyline

## Eina_Rectangle_Outside

enum Eina_Rectangle_Outside

Enumeration of the positions around a rectangle.

Since
  1.19

Enumerator
EINA_RECTANGLE_OUTSIDE_TOP | Position is over the rectangle.
EINA_RECTANGLE_OUTSIDE_LEFT | Position is to the left of the rectangle.
EINA_RECTANGLE_OUTSIDE_BOTTOM | Position is below the rectangle.
EINA_RECTANGLE_OUTSIDE_RIGHT | Position is to the right of the rectangle.

## Function Documentation

## eina_spans_intersect()

int eina_spans_intersect | ( | int | c1,
|  | int | l1,
|  | int | c2,
|  | int | l2 )

inline static

Checks if the given spans intersect.

Parameters

  [in] | c1 | The column of the first span.
  [in] | l1 | The length of the first span.
  [in] | c2 | The column of the second span.
  [in] | l2 | The length of the second span.

Returns
  EINA_TRUE if the given spans intersect, EINA_FALSE otherwise.

References EINA_WARN_UNUSED_RESULT.

## eina_rectangle_is_empty()

Eina_Bool eina_rectangle_is_empty | ( | const Eina_Rectangle * | rect | ) |

inline static

Checks if the given rectangle is empty.

Parameters

  [in] | rect | The rectangle to check.

Returns
  EINA_TRUE if the rectangle `r` is empty, EINA_FALSE otherwise.

No check is done on `r`, so it must be a valid rectangle.

References EINA_WARN_UNUSED_RESULT.

## eina_rectangle_coords_from()

void eina_rectangle_coords_from | ( | Eina_Rectangle * | rect,
|  | int | x,
|  | int | y,
|  | int | w,
|  | int | h )

inline static

Sets the coordinates and size of a rectangle.

Parameters

  [out] | rect | The rectangle.
  [in] | x | The X coordinate of the rectangle's top-left corner.
  [in] | y | The Y coordinate of the rectangle's top-left corner.
  [in] | w | The width of the rectangle.
  [in] | h | The height of the rectangle.

This function sets its top-left X coordinate to `x`, its top-left Y coordinate to `y`, its width to `w` and its height to `h`.

No check is done on `r`, so it must be a valid rectangle.

References EINA_ARG_NONNULL.

## eina_rectangles_intersect()

Eina_Bool eina_rectangles_intersect | ( | const Eina_Rectangle * | rect1,
|  | const Eina_Rectangle * | rect2 )

inline static

Checks if two rectangles intersect.

Parameters

  [in] | rect1 | The first rectangle.
  [in] | rect2 | The second rectangle.

Returns
  EINA_TRUE if the rectangles `rect1` and `rect2` intersect, EINA_FALSE otherwise.

No check is done on `rect1` and `rect2`, so they must be valid rectangles.

References EINA_ARG_NONNULL, and EINA_WARN_UNUSED_RESULT.

## eina_rectangle_xcoord_inside()

Eina_Bool eina_rectangle_xcoord_inside | ( | const Eina_Rectangle * | rect,
|  | int | x )

inline static

Checks if the given X-coordinate is in the rectangle.

Parameters

  [in] | rect | The rectangle.
  [in] | x | The X coordinate.

Returns
  EINA_TRUE if `x` is between the rectangle's left and right edges, EINA_FALSE otherwise.

No check is done on `r`, so it must be a valid rectangle.

References EINA_ARG_NONNULL, and EINA_WARN_UNUSED_RESULT.

## eina_rectangle_ycoord_inside()

Eina_Bool eina_rectangle_ycoord_inside | ( | const Eina_Rectangle * | rect,
|  | int | y )

inline static

Checks if the given Y-coordinate is in the rectangle.

Parameters

  [in] | rect | The rectangle.
  [in] | y | The Y coordinate.

Returns
  EINA_TRUE if `y` is between the rectangle's top and bottom edges, EINA_FALSE otherwise.

No check is done on `r`, so it must be a valid rectangle.

References EINA_ARG_NONNULL, and EINA_WARN_UNUSED_RESULT.

## eina_rectangle_coords_inside()

Eina_Bool eina_rectangle_coords_inside | ( | const Eina_Rectangle * | rect,
|  | int | x,
|  | int | y )

inline static

Checks if the given point is inside the rectangle.

Parameters

  [in] | rect | The rectangle.
  [in] | x | The x coordinate of the point.
  [in] | y | The y coordinate of the point.

Returns
  EINA_TRUE if the point (`x`, `y`) is within the edges of `r`, EINA_FALSE otherwise.

No check is done on `r`, so it must be a valid rectangle.

References EINA_ARG_NONNULL, and EINA_WARN_UNUSED_RESULT.

## eina_rectangle_union()

void eina_rectangle_union | ( | Eina_Rectangle * | dst,
|  | const Eina_Rectangle * | src )

inline static

Gets the union of two rectangles.

Parameters

  [in,out] | dst | The first rectangle.
  [in] | src | The second rectangle.

Changes `dst` to be the bounding box of both rectangles `dst` and `src`.

No check is done on `dst` or `src`, so they must be valid rectangles.

References EINA_ARG_NONNULL.

## eina_rectangle_intersection()

Eina_Bool eina_rectangle_intersection | ( | Eina_Rectangle * | dst,
|  | const Eina_Rectangle * | src )

inline static

Gets the intersection of two rectangles.

Parameters

  [in,out] | dst | The first rectangle.
  [in] | src | The second rectangle.

Returns
  EINA_TRUE if the rectangles intersect, EINA_FALSE otherwise.

Changes `dst` to be the rectangle represented by the intersection of `dst` and `src`. `dst` is unchanged if the two rectangles do not intersect.

No check is done on `dst` or `src`, so they must be valid rectangles.

References EINA_ARG_NONNULL, and EINA_WARN_UNUSED_RESULT.

## eina_rectangle_rescale_in()

void eina_rectangle_rescale_in | ( | const Eina_Rectangle * | out,
|  | const Eina_Rectangle * | in,
|  | Eina_Rectangle * | res )

inline static

FIXME I am useless and used by no one.

Parameters

  in | The inner rectangle.
  out | The outer rectangle.
  res | The resulting rectangle.

References EINA_ARG_NONNULL.

## eina_rectangle_rescale_out()

void eina_rectangle_rescale_out | ( | const Eina_Rectangle * | out,
|  | const Eina_Rectangle * | in,
|  | Eina_Rectangle * | res )

inline static

FIXME I am useless and used by no one.

Parameters

  in | The inner rectangle.
  out | The outer rectangle.
  res | The resulting rectangle.

References EINA_ARG_NONNULL.

## eina_rectangle_is_valid()

Eina_Bool eina_rectangle_is_valid | ( | const Eina_Rectangle * | rect | ) |

inline static

Tells whether a rectangle is valid.

Parameters

  [in] | rect | The rectangle.

Returns
  EINA_TRUE if the rectangle is valid, EINA_FALSE otherwise.

This function checks if both width and height attributes of the rectangle are positive integers. If so, the rectangle is considered valid, else the rectangle is invalid.

References EINA_ARG_NONNULL.

## eina_rectangle_max_x()

int eina_rectangle_max_x | ( | Eina_Rectangle * | rect | ) |

inline static

Gets the rectangle's maximum X coordinate.

Parameters

  [in] | rect | The rectangle.

Returns
  The maximum X coordinate.

This function calculates the maximum X coordinate of the rectangle by summing the `width` with the current `x` coordinate of the rectangle.

References EINA_ARG_NONNULL.

## eina_rectangle_max_y()

int eina_rectangle_max_y | ( | Eina_Rectangle * | rect | ) |

inline static

Gets the rectangle maximum Y coordinate.

Parameters

  [in] | rect | The rectangle.

Returns
  The maximum Y coordinate.

This function calculates the maximum Y coordinate of the rectangle by summing the `height` with the current `y` coordinate of the rectangle.

References EINA_ARG_NONNULL.

## eina_rectangle_x_cut()

Eina_Bool eina_rectangle_x_cut | ( | Eina_Rectangle * | rect,
|  | Eina_Rectangle * | slice,
|  | Eina_Rectangle * | remainder,
|  | int | amount )

inline static

Slices a rectangle vertically into two subrectangles.

Parameters

  [in] | rect | The rectangle to slice.
  [out] | slice | The sliced part of the rectangle.
  [out] | remainder | The left over part of the rectangle after slicing.
  [in] | amount | The slice location's horizontal distance from the left.

Returns
  EINA_TRUE if the cut succeeds, EINA_FALSE otherwise.

Cut a rectangle vertically at a distance `amount` from the rectangle's left edge. If the `amount` value is greater than the rectangle's width, no cut is performed and EINA_FALSE is returned.

References EINA_ARG_NONNULL.

## eina_rectangle_y_cut()

Eina_Bool eina_rectangle_y_cut | ( | Eina_Rectangle * | rect,
|  | Eina_Rectangle * | slice,
|  | Eina_Rectangle * | remainder,
|  | int | amount )

inline static

Slices a rectangle horizontally into two subrectangles.

Parameters

  [in] | rect | The rectangle to slice.
  [out] | slice | The sliced part of the rectangle.
  [out] | remainder | The left over part of the rectangle after slicing.
  [in] | amount | The slice location's vertical distance from the bottom.

Returns
  EINA_TRUE if the cut succeeds, EINA_FALSE otherwise

Cut a rectangle horizontally at a distance `amount` from the rectangle's bottom edge. If the `amount` value is greater than the rectangle's height, no cut is performed and EINA_FALSE is returned.

References EINA_ARG_NONNULL.

## eina_rectangle_width_cut()

Eina_Bool eina_rectangle_width_cut | ( | Eina_Rectangle * | rect,
|  | Eina_Rectangle * | slice,
|  | Eina_Rectangle * | remainder,
|  | int | amount )

inline static

Slices a rectangle vertically starting from right edge.

Parameters

  [in] | rect | The rectangle to slice.
  [out] | slice | The sliced part of the rectangle.
  [out] | remainder | The left over part of the rectangle after slicing.
  [in] | amount | The slice location's horizontal distance from the right.

Returns
  EINA_TRUE if the cut succeeds, EINA_FALSE otherwise

Cut a rectangle vertically at a distance `amount` from the rectangle's right edge. If the `amount` value is greater than the rectangle's width, no cut is performed and EINA_FALSE is returned.

References EINA_ARG_NONNULL.

## eina_rectangle_height_cut()

Eina_Bool eina_rectangle_height_cut | ( | Eina_Rectangle * | rect,
|  | Eina_Rectangle * | slice,
|  | Eina_Rectangle * | remainder,
|  | int | amount )

inline static

Slices a rectangle horizontally starting from top edge.

Parameters

  [in] | rect | The rectangle to slice.
  [out] | slice | The sliced part of the rectangle.
  [out] | remainder | The left over part of the rectangle after slicing.
  [in] | amount | The slice location's vertical distance from the top.

Returns
  EINA_TRUE if the cut succeeds, EINA_FALSE otherwise.

Cut a rectangle horizontally at a distance `amount` from the rectangle's top edge. If the `amount` value is greater than the rectangle width, no cut is performed and EINA_FALSE is returned.

References EINA_ARG_NONNULL.

## eina_rectangle_subtract()

Eina_Bool eina_rectangle_subtract | ( | Eina_Rectangle * | rect,
|  | Eina_Rectangle * | other,
|  | Eina_Rectangle | out[4] )

inline static

Subtracts two rectangles and returns the differences.

Parameters

  [in] | rect | The minuend rectangle.
  [in] | other | The subtrahend rectangle.
  [out] | out | An array of differences between the two rectangles.

Returns
  EINA_TRUE on success, EINA_FALSE otherwise.

This function subtracts two rectangles and stores the resulting differences into the `out` array. There will be at most four differences; use eina_rectangle_is_valid to confirm the exact number.

References EINA_API, EINA_ARG_NONNULL, EINA_MALLOC, eina_rectangle_pool_count(), eina_rectangle_pool_data_get(), eina_rectangle_pool_data_set(), eina_rectangle_pool_free(), eina_rectangle_pool_geometry_get(), eina_rectangle_pool_get(), eina_rectangle_pool_new(), eina_rectangle_pool_release(), eina_rectangle_pool_request(), and EINA_WARN_UNUSED_RESULT.

## eina_rectangle_pool_new()

EINA_API Eina_Rectangle_Pool * eina_rectangle_pool_new | ( | int | w,
|  | int | h )

Adds a rectangle in a new pool.

Parameters

  [in] | w | The width of the rectangle.
  [in] | h | The height of the rectangle.

Returns
  A newly allocated pool on success, `NULL` otherwise.

This function adds the rectangle of size (`width`, `height`) to a new pool. If the pool can not be created, `NULL` is returned. Otherwise the newly allocated pool is returned.

References DBG, EINA_FALSE, eina_list_append(), EINA_MAGIC_SET, Eina_Packing_Ascending, and eina_rectangle_new().

Referenced by eina_rectangle_subtract().

## eina_rectangle_pool_get()

EINA_API Eina_Rectangle_Pool * eina_rectangle_pool_get | ( | Eina_Rectangle * | rect | ) |

Returns the pool of the given rectangle.

Parameters

  [in] | rect | The rectangle.

Returns
  The pool of the given rectangle.

This function returns the pool in which `rect` is. If `rect` is `NULL`, `NULL` is returned.

References EINA_SAFETY_ON_NULL_RETURN_VAL.

Referenced by eina_rectangle_subtract().

## eina_rectangle_pool_geometry_get()

EINA_API Eina_Bool eina_rectangle_pool_geometry_get | ( | Eina_Rectangle_Pool * | pool,
|  | int * | w,
|  | int * | h )

Returns the width and height of the given pool.

Parameters

  [in] | pool | The pool.
  [out] | w | The returned width.
  [out] | h | The returned height.

Returns
  EINA_TRUE on success, EINA_FALSE otherwise.

This function returns the width and height of `pool` and store them in respectively `w` and `h` if they are not `NULL`. If `pool` is `NULL`, EINA_FALSE is returned. Otherwise EINA_TRUE is returned.

References EINA_FALSE, EINA_SAFETY_ON_NULL_RETURN_VAL, and EINA_TRUE.

Referenced by eina_rectangle_subtract().

## eina_rectangle_pool_data_get()

EINA_API void * eina_rectangle_pool_data_get | ( | Eina_Rectangle_Pool * | pool | ) |

Gets the data from the given pool.

Parameters

  [in] | pool | The pool.

Returns
  The returned data.

This function gets the data from `pool` set by eina_rectangle_pool_data_set(). If `pool` is `NULL`, this function returns `NULL`.

References EINA_SAFETY_ON_NULL_RETURN_VAL.

Referenced by eina_rectangle_subtract().

## eina_rectangle_pool_data_set()

EINA_API void eina_rectangle_pool_data_set | ( | Eina_Rectangle_Pool * | pool,
|  | const void * | data )

Sets the data to the given pool.

Parameters

  [in,out] | pool | The pool.
  [in] | data | The data to set.

This function sets `data` to `pool`. If `pool` is `NULL`, this function does nothing.

References DBG, and EINA_SAFETY_ON_NULL_RETURN.

Referenced by eina_rectangle_subtract().

## eina_rectangle_pool_free()

EINA_API void eina_rectangle_pool_free | ( | Eina_Rectangle_Pool * | pool | ) |

Frees the given pool.

Parameters

  [in] | pool | The pool to free.

This function frees the allocated data of `pool`. If `pool` is `NULL`, this function returned immediately.

References DBG, EINA_INLIST_GET, EINA_LIST_FREE, EINA_MAGIC_NONE, EINA_MAGIC_SET, eina_rectangle_free(), and EINA_SAFETY_ON_NULL_RETURN.

Referenced by eina_rectangle_subtract().

## eina_rectangle_pool_count()

EINA_API int eina_rectangle_pool_count | ( | Eina_Rectangle_Pool * | pool | ) |

Returns the number of rectangles in the given pool.

Parameters

  [in] | pool | The pool.

Returns
  The number of rectangles in the pool.

This function returns the number of rectangles in `pool`.

References EINA_SAFETY_ON_NULL_RETURN_VAL.

Referenced by eina_rectangle_subtract().

## eina_rectangle_pool_request()

EINA_API Eina_Rectangle * eina_rectangle_pool_request | ( | Eina_Rectangle_Pool * | pool,
|  | int | w,
|  | int | h )

Requests a rectangle of given size in the given pool.

Parameters

  [in,out] | pool | The pool.
  [in] | w | The width of the rectangle to request.
  [in] | h | The height of the rectangle to request.

Returns
  The requested rectangle on success, `NULL` otherwise.

This function retrieves from `pool` the rectangle of width `w` and height `h`. If `pool` is `NULL`, or `w` or `h` are non-positive, the function returns `NULL`. If `w` or `h` are greater than the pool size, the function returns `NULL`. On success, the function returns the rectangle which matches the size (`w`, `h`). Otherwise it returns `NULL`.

References DBG, EINA_FALSE, EINA_INLIST_GET, eina_inlist_prepend(), eina_list_sort(), EINA_MAGIC_SET, Eina_Packing_Bottom_Left_Skyline_Improved, EINA_SAFETY_ON_NULL_RETURN_VAL, and EINA_TRUE.

Referenced by eina_rectangle_subtract().

## eina_rectangle_pool_release()

EINA_API void eina_rectangle_pool_release | ( | Eina_Rectangle * | rect | ) |

Removes the given rectangle from the pool.

Parameters

  [in,out] | rect | The rectangle to remove from the pool.

This function removes `rect` from the pool. If `rect` is `NULL`, the function returns immediately. Otherwise it removes `rect` from the pool.

References DBG, EINA_FALSE, EINA_INLIST_FOREACH, EINA_INLIST_GET, eina_inlist_remove(), EINA_MAGIC_NONE, EINA_MAGIC_SET, Eina_Packing_Bottom_Left_Skyline_Improved, eina_rectangle_new(), and EINA_SAFETY_ON_NULL_RETURN.

Referenced by eina_rectangle_subtract().

## eina_rectangle_new()

EINA_API Eina_Rectangle * eina_rectangle_new | ( | int | x,
|  | int | y,
|  | int | w,
|  | int | h )

Creates a new rectangle.

Parameters

  [in] | x | The X coordinate of the top left corner of the rectangle.
  [in] | y | The Y coordinate of the top left corner of the rectangle.
  [in] | w | The width of the rectangle.
  [in] | h | The height of the rectangle.

Returns
  The new rectangle on success, @ NULL otherwise.

This function creates a rectangle whose top left corner has the coordinates (`x`, `y`), with height `w` and height `h` and adds it to the rectangles pool.

No check is done on `w` and `h`.

References EINA_RECTANGLE_SET.

Referenced by eina_rectangle_pool_new(), and eina_rectangle_pool_release().

## eina_rectangle_free()

EINA_API void eina_rectangle_free | ( | Eina_Rectangle * | rect | ) |

Frees the given rectangle.

Parameters

  [in] | rect | The rectangle to free.

This function removes `rect` from the rectangles pool.

References EINA_SAFETY_ON_NULL_RETURN.

Referenced by eina_rectangle_pool_free(), evas_norender_with_updates(), and evas_render_updates_free().

## eina_rectangle_pool_packing_set()

EINA_API void eina_rectangle_pool_packing_set | ( | Eina_Rectangle_Pool * | pool,
|  | Eina_Rectangle_Packing | type )

Sets the type of given rectangle pool.

Parameters

  [in,out] | pool | The rectangle pool for which type is to be set.
  [in] | type | Type of Eina Pool based on packing algorithm.

This function sets `type` of `pool`.

See also
  Eina_Rectangle_Packing

Since
  1.11

References DBG, Eina_Packing_Ascending, Eina_Packing_Descending, and EINA_SAFETY_ON_NULL_RETURN.

## eina_rectangle_outside_position()

EINA_API Eina_Rectangle_Outside eina_rectangle_outside_position | ( | Eina_Rectangle * | rect1,
|  | Eina_Rectangle * | rect2 )

calculates where rect2 is outside of rect1.

Parameters

  [in] | rect1 | The rect to use as anchor
  [in] | rect2 | The rect to look for outside positions

Returns
  An OR'd map of Eina_Rectangle_Outside values

Since
  1.19

References EINA_RECTANGLE_OUTSIDE_BOTTOM, EINA_RECTANGLE_OUTSIDE_LEFT, EINA_RECTANGLE_OUTSIDE_RIGHT, EINA_RECTANGLE_OUTSIDE_TOP, _Eina_Rectangle::h, _Eina_Rectangle::w, _Eina_Rectangle::x, and _Eina_Rectangle::y.

## eina_rectangle_equal()

Eina_Bool eina_rectangle_equal | ( | const Eina_Rectangle * | rect1,
|  | const Eina_Rectangle * | rect2 )

inline static

Compares two rectangles for equality.

Parameters

  [in] | rect1 | First rectangle. Must not be NULL.
  [in] | rect2 | Second rectangle. Must not be NULL.

Returns
  EINA_TRUE if the rectangles are equal (x, y, w and h are all equal).

No check is made on the rectangles, so they should be valid and non NULL for this function to be meaningful.

Since
  1.21

References EINA_WARN_UNUSED_RESULT.