Difference between revisions of "love.graphics.polygon"
m |
m (Newin template) |
||
(10 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{newin|[[0.4.0]]|040|type=function}} | ||
Draw a 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. | 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. | ||
− | + | {{notice|When in '''fill''' mode, the polygon must be [http://en.wikipedia.org/wiki/Convex_polygon convex] and [http://en.wikipedia.org/wiki/Simple_polygon simple] or rendering artifacts may occur. [[love.math.triangulate]] and [[love.math.isConvex]] can be used in [[0.9.0]]+.}} | |
== Function == | == Function == | ||
=== Synopsis === | === Synopsis === | ||
Line 26: | Line 27: | ||
== Examples == | == Examples == | ||
=== Two ways of drawing the same triangle === | === Two ways of drawing the same triangle === | ||
+ | [[File:Polygon_triangle.png|upright=0.5|thumb|right|top|Triangle drawn using love.graphics.polygon]] | ||
This example shows how to give the coordinates explicitly and how to pass a table argument. | This example shows how to give the coordinates explicitly and how to pass a table argument. | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 41: | Line 43: | ||
== See Also == | == See Also == | ||
* [[parent::love.graphics]] | * [[parent::love.graphics]] | ||
+ | * [[love.math.triangulate]] | ||
+ | * [[love.math.isConvex]] | ||
[[Category:Functions]] | [[Category:Functions]] | ||
[[Sub-Category::Drawing| ]] | [[Sub-Category::Drawing| ]] | ||
{{#set:Description=Draw a polygon.}} | {{#set:Description=Draw a polygon.}} | ||
− | |||
== Other Languages == | == Other Languages == | ||
{{i18n|love.graphics.polygon}} | {{i18n|love.graphics.polygon}} |
Revision as of 09:07, 31 December 2019
Available since LÖVE 0.4.0 |
This function is not supported in earlier versions. |
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+. |
Contents
Function
Synopsis
love.graphics.polygon( mode, ... )
Arguments
Returns
Nothing.
Function
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)
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info