Tools for working with bounding boxes.
The tables passed into the Area functions are mutated in-place.
local Area = require('stdlib/area/area')
    
    
    
    | adjust (area, vector) | Adjust an area by shrinking or expanding. | 
| center (area) | Calculates the center of the area and returns the position. | 
| compare (area1, area2) | Returns true if two areas are the same. | 
| construct (x1, y1, x2, y2) | Creates an area from the two positions p1 and p2. | 
| copy (area) | Creates an area that is a copy of the given area. | 
| equals (area1, area2) | Compares the size of two areas. | 
| expand (area, amount) | Expands the size of an area by the given amount. | 
| inside (area, pos) | Tests if a position {x, y} is located in an area (including the border). | 
| iterate (area) | Iterates an area. | 
| less_than (area1, area2) | Is area1 smaller in size than area2 | 
| new (area_arr, copy) | Converts an area in either array or table format to an area with a metatable. | 
| normalize (area) | Normalizes the given area. | 
| offset (area, pos) | Offsets the area by the {x, y} values. | 
    
| rotate (area) | Rotate an area such that its value of the width becomes the height, and its value of the height becomes the width. | 
| round_to_integer (area) | Rounds down the xy-values in area.left_top and rounds up the xy-values in area.right_bottom. | 
    
| shrink (area, amount) | Shrinks the area by the given amount. | 
| size (area) | Gets the properties of the given area. | 
| spiral_iterate (area) | Iterates the given area in a spiral as depicted below, from innermost to the outermost location. | 
| tile_center_points (area) | Gets the center positions of the tiles where the given area's two positions reside. | 
| to_collision_area (entity) | Deprecated see LuaEntity.bounding_box
  Converts an entity and its collision_box to the area around it.  | 
    
| to_selection_area (entity) | Converts an entity and its selection_box to the area around it. | 
| to_table () | Deprecated | 
| tostring (area) | Converts an area to a string. | 
| translate (area, direction, distance) | Translates an area in the given direction. | 
| Metamethods | Area tables are returned with these Metamethods attached. | 
| immutable | By default area tables are mutated in place set this to true to make the tables immutable. | 
Adjust an area by shrinking or expanding.
Imagine pinching & holding with fingers the top-left & bottom-right corners of a 2D box and pulling outwards to expand and pushing inwards to shrink the box.
Parameters:local area = Area.adjust({{-2, -2}, {2, 2}}, {4, -1})
 -- returns {left_top = {x = -6, y = -1}, right_bottom = {x = 6, y = 1}}
    
    
    Calculates the center of the area and returns the position.
Parameters:
Returns true if two areas are the same.
Parameters:
Creates an area from the two positions p1 and p2.
Parameters:
Creates an area that is a copy of the given area.
Parameters:
Compares the size of two areas.
note: The shame of either area is not taking into consideration, see Area.compare
Parameters:Expands the size of an area by the given amount.
Parameters:
Tests if a position {x, y} is located in an area (including the border).
Parameters:
Iterates an area.
Parameters:
for x,y in Area.iterate({{0, -5}, {3, -3}}) do
...
end
    
    
    Is area1 smaller in size than area2
Parameters:
Converts an area in either array or table format to an area with a metatable.
Returns itself if it already has a metatable
Parameters:Normalizes the given area.
right_bottom.x & left_top.x IF right_bottom.x < left_top.x
 right_bottom.y & left_top.y IF right_bottom.y < left_top.y
 Offsets the area by the {x, y} values.
Parameters:
Rotate an area such that its value of the width becomes the height, and its value of the height becomes the width.
Parameters:
Rounds down the xy-values in area.left_top and rounds up the xy-values in area.right_bottom.
Parameters:
local position1 = {x = 1.5, y = 1.5}
local position2 = {x = 1.5, y = 1.5}
local area = {left_top = position1, right_bottom = position2}
Area.round_to_integer(area) --> {left_top = {x = 1, y = 1}, right_bottom = {x = 2, y = 2}}
    
    
    Shrinks the area by the given amount.
The area shrinks inwards from top-left towards the bottom-right, and from bottom-right towards the top-left.
Parameters:Gets the properties of the given area.
This function returns a total of four values that represent the properties of the given area.
Parameters:Iterates the given area in a spiral as depicted below, from innermost to the outermost location.

for x, y in Area.spiral_iterate({{-2, -1}, {2, 1}}) do
print('(' .. x .. ', ' .. y .. ')')
end
prints: (0, 0) (1, 0) (1, 1) (0, 1) (-1, 1) (-1, 0) (-1, -1) (0, -1) (1, -1) (2, -1) (2, 0) (2, 1) (-2, 1) (-2, 0) (-2, -1)
    
    
    Gets the center positions of the tiles where the given area's two positions reside.
Parameters:
Deprecated see LuaEntity.bounding_box
 
Converts an entity and its collision_box to the area around it.
Parameters:
Converts an entity and its selection_box to the area around it.
Parameters:
Deprecated
See also:
Converts an area to a string.
Parameters:
Translates an area in the given direction.
Parameters:
Area tables are returned with these Metamethods attached.
Fields:
By default area tables are mutated in place set this to true to make the tables immutable.