Difference between revisions of "love.graphics.polygon"

(updated due to GL_POLYGON restrictions. See http://www.opengl.org/sdk/docs/man/xhtml/glBegin.xml)
m
Line 42: Line 42:
 
[[Category:Functions]]
 
[[Category:Functions]]
 
{{#set:Description=Draw a polygon.}}
 
{{#set:Description=Draw a polygon.}}
 +
== Other Languages ==
 +
{{i18n|love.graphics.polygon}}

Revision as of 20:17, 18 November 2010

Draw a polygon.

Following the mode argument, this function can accept multiple numeric arguments or a single table of numeric arguments. In either case the arguments are interpreted as alternating x and y coordinates of the polygon's vertices.

Note: when in fill mode, the polygon must be convex and simple or rendering artifacts may occur.

Function

Synopsis

love.graphics.polygon( mode, ... )

Arguments

DrawMode mode
How to draw the polygon.
numbers ...
The vertices of the polygon.

Returns

Nothing.

Synopsis

love.graphics.polygon( mode, vertices )

Arguments

DrawMode mode
How to draw the polygon.
table vertices
The vertices of the polygon as a table.

Returns

Nothing.

Examples

Two ways of drawing the same triangle

This example shows how to give the coordinates explicitly and how to pass a table argument.

-- giving the coordinates directly
love.graphics.polygon('fill', 100, 100, 200, 100, 150, 200)

-- defining a table with the coordinates
-- this table could be built incrementally too
local vertices = {100, 100, 200, 100, 150, 200}

-- passing the table to the function as a second argument
love.graphics.polygon('fill', vertices)

See Also

Other Languages