Module wonderful.geometry
Geometry objects (eg boxes).
Classes and inheritance
Box | A box class, defined by its top-left corner coordinates, width, and height. |
Class Box
Box:__new__(x, y, w, h) | Construct a new box. |
Box:getX() | Get the left coordinate. |
Box:getY() | Get the top coordinate. |
Box:getWidth() | Get the width. |
Box:getHeight() | Get the height. |
Box:set(x, y, w, h) | Set new box values. |
Box:setBox(box) | Copy the values from another box. |
Box:setX(x) | Set the left coordinate. |
Box:setY(y) | Set the top coordinate. |
Box:setWidth(w) | Set the width. |
Box:setHeight(h) | Set the height. |
Box:relative(x, y, w, h) | Create a new box relative to itself. |
Box:has(x, y) | Check if a point belongs to the box. |
Box:intersects(other) | Check if the box intersects with another one. |
Box:intersectsOneOf(others) | Check if the box intersects with any of given. |
Box:intersection(other) | Get an intersection of two boxes. |
Box:unpack() | Unpack the box. |
Box:isStrict() | Check if all parameters are defined. |
Box:isDimStrict() | Check if the width and height are both defined. |
Box:isPosStrict() | Check if the top-left point is defined. |
Box:getX1() | Get the right coordinate. |
Box:getY1() | Get the bottom coordinate. |
Classes and inheritance
Class Box
- Box:__new__(x, y, w, h)
-
Construct a new box.
Parameters:
- x optional number the left coordinate
- y optional number the top coordinate
- w optional number a width
- h optional nubmer a height
- Box:getX()
-
Get the left coordinate.
Returns:
-
optional number
the left coordinate
- Box:getY()
-
Get the top coordinate.
Returns:
-
optional number
the top coordinate
- Box:getWidth()
-
Get the width.
Returns:
-
optional number
the width
- Box:getHeight()
-
Get the height.
Returns:
-
optional number
the height
- Box:set(x, y, w, h)
-
Set new box values. Shorthand for setting each value individually.
Parameters:
- x
- y
- w
- h
- Box:setBox(box)
-
Copy the values from another box.
Parameters:
- box Box the box
- Box:setX(x)
-
Set the left coordinate.
Parameters:
- x optional number the left coordinate
- Box:setY(y)
-
Set the top coordinate.
Parameters:
- y optional number the top coordinate
- Box:setWidth(w)
-
Set the width.
Parameters:
- w optional number the width
- Box:setHeight(h)
-
Set the height.
Parameters:
- h optional number the height
- Box:relative(x, y, w, h)
-
Create a new box relative to itself.
If some arguments are
nil
, the values are copied from self.Parameters:
- x optional number the relative abscissa of the top-left point
- y optional number the relative ordinate of the top-left point
- w optional number a width
- h optional number a height
Returns:
-
wonderful.geometry.Box
the box instance
- Box:has(x, y)
-
Check if a point belongs to the box.
Parameters:
- x number the abscissa of a point
- y number the ordinate of a point
Returns:
-
boolean
- Box:intersects(other)
-
Check if the box intersects with another one.
Parameters:
- other wonderful.geometry.Box
Returns:
-
boolean
- Box:intersectsOneOf(others)
-
Check if the box intersects with any of given.
Parameters:
- others {wonderful.geometry.Box,...} a table of boxes
Returns:
-
boolean
- Box:intersection(other)
-
Get an intersection of two boxes.
Parameters:
- other wonderful.geometry.Box
Returns:
-
wonderful.geometry.Box
the intersection box
- Box:unpack()
-
Unpack the box.
Returns:
- number x
- number y
- number w
- number h
- Box:isStrict()
-
Check if all parameters are defined.
Returns:
-
boolean
whether all paramter are defined
- Box:isDimStrict()
-
Check if the width and height are both defined.
Returns:
-
boolean
whether width and height are both defined
- Box:isPosStrict()
-
Check if the top-left point is defined.
Returns:
-
boolean
whether the top-left point is defined
- Box:getX1()
-
Get the right coordinate.
Returns:
-
number
the right coordinate
- Box:getY1()
-
Get the bottom coordinate.
Returns:
-
number
the bottom coordinate