Difference between revisions of "Shape:getBoundingBox"

(Counterclockwise -> clockwise (you lazy farts))
(Corrected vertex order, and added a little more info to the returns.)
Line 7: Line 7:
 
x1, y1, x2, y2, x3, y3, x4, y4 = Shape:getBoundingBox( )
 
x1, y1, x2, y2, x3, y3, x4, y4 = Shape:getBoundingBox( )
 
</source>
 
</source>
Vertexes are returned starting in the top-left in a clockwise fashion (bottem-left, top-left, top-right, bottom-right).
+
Vertexes are returned starting in the top-left in a clockwise fashion (top-left, top-right, bottom-right, bottom-left).
  
 
=== Arguments ===
 
=== Arguments ===
 
None.
 
None.
 
=== Returns ===
 
=== Returns ===
{{param|number|x1|The x-component of the first vertex.}}
+
{{param|number|x1|The x-component of the first vertex, top-left.}}
{{param|number|y1|The y-component of the first vertex.}}
+
{{param|number|y1|The y-component of the first vertex, top-left.}}
{{param|number|x2|The x-component of the second vertex.}}
+
{{param|number|x2|The x-component of the second vertex, top-right.}}
{{param|number|y2|The y-component of the second vertex.}}
+
{{param|number|y2|The y-component of the second vertex, top-right.}}
{{param|number|x3|The x-component of the third vertex.}}
+
{{param|number|x3|The x-component of the third vertex, bottom-right.}}
{{param|number|y3|The y-component of the third vertex.}}
+
{{param|number|y3|The y-component of the third vertex, bottom-right.}}
{{param|number|x4|The x-component of the fourth vertex.}}
+
{{param|number|x4|The x-component of the fourth vertex, bottom-left.}}
{{param|number|y4|The y-component of the fourth vertex.}}
+
{{param|number|y4|The y-component of the fourth vertex, bottom-left.}}
 
== See Also ==
 
== See Also ==
 
* [[parent::Shape]]
 
* [[parent::Shape]]

Revision as of 03:39, 16 August 2010

Gets the bounding box of the shape. This function can be used in a nested fashion with love.graphics.polygon.

Function

Synopsis

A bounding box is the smallest rectangle that encapsulates the entire polygon.

x1, y1, x2, y2, x3, y3, x4, y4 = Shape:getBoundingBox( )

Vertexes are returned starting in the top-left in a clockwise fashion (top-left, top-right, bottom-right, bottom-left).

Arguments

None.

Returns

number x1
The x-component of the first vertex, top-left.
number y1
The y-component of the first vertex, top-left.
number x2
The x-component of the second vertex, top-right.
number y2
The y-component of the second vertex, top-right.
number x3
The x-component of the third vertex, bottom-right.
number y3
The y-component of the third vertex, bottom-right.
number x4
The x-component of the fourth vertex, bottom-left.
number y4
The y-component of the fourth vertex, bottom-left.

See Also