Difference between revisions of "Geometry"
m |
(Added example for emulating Quad:setViewport) |
||
Line 45: | Line 45: | ||
* [[parent::love.graphics]] | * [[parent::love.graphics]] | ||
* [[love.graphics.draw]] | * [[love.graphics.draw]] | ||
+ | |||
+ | == Examples == | ||
+ | === Emulate 0.8.0's [[Quad:setViewport]] === | ||
+ | <source lang="lua"> | ||
+ | -- Quad:setViewport doesn't exist in 0.9.0+, but we can still create a function which does the same thing. | ||
+ | -- The original image's width and height are needed as well, unlike with 0.8.0's Quad:setViewport. | ||
+ | function setQuadViewport(geometry, x, y, w, h, sw, sh) | ||
+ | geometry:setVertex(1, 0, 0, x/sw, y/sh) | ||
+ | geometry:setVertex(2, 0, h, x/sw, (y+h)/sh) | ||
+ | geometry:setVertex(3, w, h, (x+w)/sw, (y+h)/sh) | ||
+ | geometry:setVertex(4, w, 0, (x+w)/sw, y/sh) | ||
+ | end | ||
+ | </source> | ||
[[Category:Types]] | [[Category:Types]] |
Revision as of 23:26, 21 August 2013
Available since LÖVE 0.9.0 |
This type is not supported in earlier versions. |
A polygonal shape with texture coordinate information.
Geometries can be used to select part of a texture to draw. In this way, one large texture atlas can be loaded, and then split up into sub-images.
Geometries replace the old Quad type completely since they can do the same and more.
Contents
Constructors
None.
Functions
Object:release | Immediately destroys the object's Lua reference. | 11.0 | |
Object:type | Gets the type of the object as a string. | ||
Object:typeOf | Checks whether an object is of a certain type. |
Enums
Supertypes
See Also
Examples
Emulate 0.8.0's Quad:setViewport
-- Quad:setViewport doesn't exist in 0.9.0+, but we can still create a function which does the same thing.
-- The original image's width and height are needed as well, unlike with 0.8.0's Quad:setViewport.
function setQuadViewport(geometry, x, y, w, h, sw, sh)
geometry:setVertex(1, 0, 0, x/sw, y/sh)
geometry:setVertex(2, 0, h, x/sw, (y+h)/sh)
geometry:setVertex(3, w, h, (x+w)/sw, (y+h)/sh)
geometry:setVertex(4, w, 0, (x+w)/sw, y/sh)
end
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
--@todo: add Concept:Current to stuffs when done adding stuffs.