love.graphics.polygon

love.graphics.polygon

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.

When in fill mode, the polygon must be convex and simple or rendering artifacts may occur. love.math.triangulate and love.math.isConvex can be used in 0.9.0+.

Function

Synopsis

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

Arguments

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

Returns

Nothing.

Function

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

Triangle drawn using love.graphics.polygon

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



© 2006–2016 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/love.graphics.polygon

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部