Module gears.geometry - awesome API documentation

# Module `gears.geometry`

Helper functions used to compute geometries.

When this module refer to a geometry table, this assume a table with at least an x, y, width and height keys and numeric values.

### Info:

- Copyright: 2008 Julien Danjou
- Author: Julien Danjou <julien@danjou.info>

## Functions

gears.geometry.rectangle.get_square_distance (geom, x, y) | Get the square distance between a rectangle and a point.
gears.geometry.rectangle.get_closest_by_coord (list, x, y) | Return the closest rectangle from `list` for a given point.
gears.geometry.rectangle.get_by_coord (list, x, y) | Return the rectangle containing the [x, y] point.
gears.geometry.rectangle.get_in_direction (dir, recttbl, cur) | Get the nearest rectangle in the given direction.
gears.geometry.rectangle.area_intersect_area (a, b) | Check if an area intersect another area.
gears.geometry.rectangle.get_intersection (a, b) | Get the intersect area between a and b.
gears.geometry.rectangle.area_remove (areas, elem) | Remove an area from a list, splitting the space between several area that can overlap.

## Functions

Methods

gears.geometry.rectangle.get_square_distance (geom, x, y)
  Get the square distance between a rectangle and a point.
  - geom A rectangle
    - x number The horizontal coordinate
    - y number The vertical coordinate
    - width number The rectangle width
    - height number The rectangle height
  - x number X coordinate of point
  - y number Y coordinate of point

  ### Returns:

  number The squared distance of the rectangle to the provided point
gears.geometry.rectangle.get_closest_by_coord (list, x, y)
  Return the closest rectangle from `list` for a given point.
  - list table A list of geometry tables.
  - x number The x coordinate
  - y number The y coordinate

  ### Returns:

  The key from the closest geometry.
gears.geometry.rectangle.get_by_coord (list, x, y)
  Return the rectangle containing the [x, y] point.

  Note that if multiple element from the geometry list contains the point, the returned result is nondeterministic.

  - list table A list of geometry tables.
  - x number The x coordinate
  - y number The y coordinate

  ### Returns:

  The key from the closest geometry. In case no result is found, nil is returned.
gears.geometry.rectangle.get_in_direction (dir, recttbl, cur)
  Get the nearest rectangle in the given direction. Every rectangle is specified as a table with x, y, width, height keys, the same as client or screen geometries.
  - dir string The direction, can be either up, down, left or right.
  - recttbl table A table of rectangle specifications.
  - cur table The current rectangle.

  ### Returns:

  The index for the rectangle in recttbl closer to cur in the given direction. nil if none found.
gears.geometry.rectangle.area_intersect_area (a, b)
  Check if an area intersect another area.
  - a The area.
  - b The other area.

  ### Returns:

  True if they intersect, false otherwise.
gears.geometry.rectangle.get_intersection (a, b)
  Get the intersect area between a and b.
  - a The area.
    - x number The horizontal coordinate
    - y number The vertical coordinate
    - width number The rectangle width
    - height number The rectangle height
  - b The other area.
    - x number The horizontal coordinate
    - y number The vertical coordinate
    - width number The rectangle width
    - height number The rectangle height

  ### Returns:

  table The intersect area.
gears.geometry.rectangle.area_remove (areas, elem)
  Remove an area from a list, splitting the space between several area that can overlap.
  - areas table Table of areas.
  - elem Area to remove.
    - x number The horizontal coordinate
    - y number The vertical coordinate
    - width number The rectangle width
    - height number The rectangle height

  ### Returns:

  The new area list.

generated by LDoc 1.4.6 Last updated 2020-08-09 06:29:49