Module ncine.rect

The table containing rectangle related functions

Functions

ncine.rect.create (x, y, w, h) Creates a rect table from top-left point and size
ncine.rect.create_center_size (x, y, w, h) Creates a vec2 table from center and size
ncine.rect.create_min_max (min_x, min_y, max_x, max_y) Creates a vec2 table from its components
ncine.vec2.get_center (rect) Calculates the center of the rectangle
ncine.vec2.get_min (rect) Calculates the minimum coordinates of the rectangle
ncine.vec2.get_max (rect) Calculates the maximum coordinates of the rectangle
ncine.vec2.set_center (rect, x, y) Retains rectangle size but moves its center to another position
ncine.rect.set_min_max (min_x, min_y, max_x, max_y) Sets rectangle minimum and maximum coordinates
ncine.vec2.invert_size (rect) Inverts rectangle size and moves (x, y) to a different angle
ncine.vec2.contains_point (rect, x, y) Returns true if the point is inside this rectangle
ncine.vec2.contains (rect0, rect1) Returns true if the other rectangle is contained inside this one
ncine.vec2.overlaps (rect0, rect1) Returns true if this rect does overlap the other rectangle in any way
ncine.vec2.intersect (rect0, rect1) Intersects this rectangle with the other rectangle

Tables

ncine.rect A rectangle in 2D


Functions

ncine.rect.create (x, y, w, h)
Creates a rect table from top-left point and size

Parameters:

  • x number The top-left X coordinate (left with positive width)
  • y number The top-left Y coordinate (top with positive height)
  • w number The width
  • h number The height

Returns:

    ncine.rect
ncine.rect.create_center_size (x, y, w, h)
Creates a vec2 table from center and size

Parameters:

  • x number The center X coordinate
  • y number The center Y coordinate
  • w number The width
  • h number The height

Returns:

    ncine.rect
ncine.rect.create_min_max (min_x, min_y, max_x, max_y)
Creates a vec2 table from its components

Parameters:

  • min_x number The minimum X coordinate
  • min_y number The minimum Y coordinate
  • max_x number The maximum X coordinate
  • max_y number The maximum Y coordinate

Returns:

    ncine.rect
ncine.vec2.get_center (rect)
Calculates the center of the rectangle

Parameters:

Returns:

    ncine.vec2 The center coordinates
ncine.vec2.get_min (rect)
Calculates the minimum coordinates of the rectangle

Parameters:

Returns:

    ncine.vec2 The minimum coordinates
ncine.vec2.get_max (rect)
Calculates the maximum coordinates of the rectangle

Parameters:

Returns:

    ncine.vec2 The maximum coordinates
ncine.vec2.set_center (rect, x, y)
Retains rectangle size but moves its center to another position

Parameters:

Returns:

    ncine.rect
ncine.rect.set_min_max (min_x, min_y, max_x, max_y)
Sets rectangle minimum and maximum coordinates

Parameters:

  • min_x number
  • min_y number
  • max_x number
  • max_y number

Returns:

    ncine.rect
ncine.vec2.invert_size (rect)
Inverts rectangle size and moves (x, y) to a different angle

Parameters:

Returns:

    ncine.rect
ncine.vec2.contains_point (rect, x, y)
Returns true if the point is inside this rectangle

Parameters:

Returns:

    boolean
ncine.vec2.contains (rect0, rect1)
Returns true if the other rectangle is contained inside this one

Parameters:

Returns:

    boolean
ncine.vec2.overlaps (rect0, rect1)
Returns true if this rect does overlap the other rectangle in any way

Parameters:

Returns:

    boolean
ncine.vec2.intersect (rect0, rect1)
Intersects this rectangle with the other rectangle

Parameters:

Returns:

    ncine.rect

Tables

ncine.rect
A rectangle in 2D

Fields:

  • x number The top-left X coordinate (left with positive width)
  • y number The top-left Y coordinate (top with positive height)
  • w number The width
  • h number The height
generated by LDoc 1.5.0 Last updated 2025-02-14 01:12:44