Difference between revisions of "love.graphics.newGeometry"

(Added non-table variant and optional draw mode and vertex map parameters)
(Removed)
 
Line 1: Line 1:
{{newin|[[0.9.0]]|090|type=function}}
 
Creates a new [[Geometry]].
 
  
== Function ==
 
=== Synopsis ===
 
<source lang="lua">
 
geometry = love.graphics.newGeometry( vertices, draw_mode, vertex_map )
 
</source>
 
=== Arguments ===
 
{{param|table|vertices|The table filled with vertex information tables for each vertex as follows:}}
 
{{subparam|number|[1]|The position of the vertex on the x-axis.}}
 
{{subparam|number|[2]|The position of the vertex on the y-axis.}}
 
{{subparam|number|[3]|The u texture coordinate. Texture coordinates are normally in the range of [0, 1], but can be greater or less (see [[WrapMode]].)}}
 
{{subparam|number|[4]|The v texture coordinate. Texture coordinates are normally in the range of [0, 1], but can be greater or less (see [[WrapMode]].)}}
 
{{subparam|number|[5] (255)|The red color component.}}
 
{{subparam|number|[6] (255)|The green color component.}}
 
{{subparam|number|[7] (255)|The blue color component.}}
 
{{subparam|number|[8] (255)|The alpha color component.}}
 
{{param|GeometryDrawMode|draw_mode ("fan")|How the vertices are used when drawing. The default mode "fan" is sufficient for simple convex polygons.}}
 
{{param|table|vertex_map ({1, 2, 3, ...})|A table describing the order of the vertices when they are drawn. The vertex map allows you to re-order or reuse vertices when drawing without changing the actual vertex parameters.}}
 
=== Returns ===
 
{{param|Geometry|geometry|The new geometry.}}
 
 
== Function ==
 
=== Synopsis ===
 
<source lang="lua">
 
geometry = love.graphics.newGeometry( vertex1, vertex2, vertex3, ..., draw_mode, vertex_map )
 
</source>
 
=== Arguments ===
 
{{param|table|vertex1|The vertex information table for the first vertex.}}
 
{{param|table|vertex2|The vertex information table for the second vertex.}}
 
{{param|table|vertex3|The vertex information table for the third vertex.}}
 
{{param|GeometryDrawMode|draw_mode ("fan")|How the vertices are used when drawing. The default mode "fan" is sufficient for simple convex polygons.}}
 
{{param|table|vertex_map ({1, 2, 3, ...})|A table describing the order of the vertices when they are drawn. The vertex map allows you to re-order or reuse vertices when drawing without changing the actual vertex parameters.}}
 
=== Returns ===
 
{{param|Geometry|geometry|The new geometry.}}
 
 
<!--
 
Transform this to apply to geometries.
 
=== Note ===
 
The purpose of a Quad is to describe the result of the following transformation on any drawable object. The object is first scaled to dimensions sw × sh. The Quad then describes the rectangular area of dimensions width × height whose upper left corner is at position (x, y) inside the scaled object.
 
 
== Examples ==
 
=== Use a Quad to display part of an Image: ===
 
<source lang="lua">
 
img = love.graphics.newImage("mushroom-64x64.png")
 
 
-- Let's say we want to display only the top-left
 
-- 32x32 quadrant of the Image:
 
top_left = love.graphics.newQuad(0, 0, 32, 32, 64, 64)
 
 
-- And here is bottom left:
 
bottom_left = love.graphics.newQuad(0, 32, 32, 32, 64, 64)
 
 
function love.draw()
 
love.graphics.draw(img, top_left, 50, 50)
 
love.graphics.draw(img, bottom_left, 50, 200)
 
end
 
</source>
 
-->
 
== See Also ==
 
* [[parent::love.graphics]]
 
* [[Constructs::Geometry]]
 
[[Category:Functions]]
 
[[Sub-Category::Object Creation| ]]
 
{{#set:Description=Creates a new [[Geometry]].}}
 
== Other Languages ==
 
{{i18n|love.graphics.newGeometry}}
 

Latest revision as of 18:20, 8 October 2013