Difference between revisions of "love.graphics.polygon"
(changed convex condition to simple because of concave hull algo in love) |
(gave a simple example) |
||
Line 23: | Line 23: | ||
=== Returns === | === Returns === | ||
Nothing. | 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. | ||
+ | <source lang="lua"> | ||
+ | -- 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) | ||
+ | </source> | ||
== See Also == | == See Also == |
Revision as of 11:34, 6 July 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 simple or rendering artifacts may occur.
Contents
Function
Synopsis
love.graphics.polygon( mode, ... )
Arguments
Returns
Nothing.
Synopsis
love.graphics.polygon( mode, vertices )
Arguments
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)