Difference between revisions of "love.graphics.drawLayer"
m |
m (0.11.0 -> 11.0) |
||
(2 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | {{newin|[[ | + | {{newin|[[11.0]]|110|type=function}} |
Draws a layer of an [[love.graphics.newArrayImage|Array Texture]]. | Draws a layer of an [[love.graphics.newArrayImage|Array Texture]]. | ||
== Function == | == Function == | ||
+ | Draws a layer of an Array Texture. | ||
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 23: | Line 24: | ||
== Function == | == Function == | ||
+ | Draws a layer of an Array Texture using the specified [[Quad]]. | ||
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 46: | Line 48: | ||
== Function == | == Function == | ||
+ | Draws a layer of an Array Texture using the specified [[Transform]]. | ||
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
− | love.graphics. | + | love.graphics.drawLayer( texture, layerindex, transform ) |
</source> | </source> | ||
=== Arguments === | === Arguments === | ||
− | {{param| | + | {{param|Texture|texture|The Array Texture to draw.}} |
{{param|number|layerindex|The index of the layer to use when drawing.}} | {{param|number|layerindex|The index of the layer to use when drawing.}} | ||
{{param|Transform|transform|A transform object.}} | {{param|Transform|transform|A transform object.}} | ||
Line 58: | Line 61: | ||
== Function == | == Function == | ||
+ | Draws a layer of an Array Texture using the specified [[Quad]] and [[Transform]]. | ||
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
− | love.graphics. | + | love.graphics.drawLayer( texture, layerindex, quad, transform ) |
</source> | </source> | ||
=== Arguments === | === Arguments === | ||
− | {{param| | + | {{param|Texture|texture|The Array Texture to draw.}} |
{{param|number|layerindex|The index of the layer to use when drawing.}} | {{param|number|layerindex|The index of the layer to use when drawing.}} | ||
{{param|Quad|quad|The subsection of the texture's layer to use when drawing.}} | {{param|Quad|quad|The subsection of the texture's layer to use when drawing.}} |
Latest revision as of 13:09, 29 December 2018
Available since LÖVE 11.0 |
This function is not supported in earlier versions. |
Draws a layer of an Array Texture.
Contents
Function
Draws a layer of an Array Texture.
Synopsis
love.graphics.drawLayer( texture, layerindex, x, y, r, sx, sy, ox, oy, kx, ky )
Arguments
Texture texture
- The Array Texture to draw.
number layerindex
- The index of the layer to use when drawing.
number x (0)
- The position to draw the texture (x-axis).
number y (0)
- The position to draw the texture (y-axis).
number r (0)
- Orientation (radians).
number sx (1)
- Scale factor (x-axis).
number sy (sx)
- Scale factor (y-axis).
number ox (0)
- Origin offset (x-axis).
number oy (0)
- Origin offset (y-axis).
number kx (0)
- Shearing factor (x-axis).
number ky (0)
- Shearing factor (y-axis).
Returns
Nothing.
Function
Draws a layer of an Array Texture using the specified Quad.
Synopsis
love.graphics.drawLayer( texture, layerindex, quad, x, y, r, sx, sy, ox, oy, kx, ky )
Arguments
Texture texture
- The Array Texture to draw.
number layerindex
- The index of the layer to use when drawing.
Quad quad
- The subsection of the texture's layer to use when drawing.
number x (0)
- The position to draw the texture (x-axis).
number y (0)
- The position to draw the texture (y-axis).
number r (0)
- Orientation (radians).
number sx (1)
- Scale factor (x-axis).
number sy (sx)
- Scale factor (y-axis).
number ox (0)
- Origin offset (x-axis).
number oy (0)
- Origin offset (y-axis).
number kx (0)
- Shearing factor (x-axis).
number ky (0)
- Shearing factor (y-axis).
Returns
Nothing.
Notes
The specified layer index overrides any layer index set on the Quad via Quad:setLayer.
Function
Draws a layer of an Array Texture using the specified Transform.
Synopsis
love.graphics.drawLayer( texture, layerindex, transform )
Arguments
Texture texture
- The Array Texture to draw.
number layerindex
- The index of the layer to use when drawing.
Transform transform
- A transform object.
Returns
Nothing.
Function
Draws a layer of an Array Texture using the specified Quad and Transform.
Synopsis
love.graphics.drawLayer( texture, layerindex, quad, transform )
Arguments
Texture texture
- The Array Texture to draw.
number layerindex
- The index of the layer to use when drawing.
Quad quad
- The subsection of the texture's layer to use when drawing.
Transform transform
- A transform object.
Returns
Nothing.
Notes
The specified layer index overrides any layer index set on the Quad via Quad:setLayer.
Notes
In order to use an Array Texture or other non-2D texture types as the main texture in a custom Shader, the void effect() variant must be used in the pixel shader, and MainTex must be declared as an ArrayImage or sampler2DArray like so: uniform ArrayImage MainTex;
.
Examples
Draw multiple layers of an Array Image
function love.load()
local sprites = {"sprite1.png", "sprite2.png"}
image = love.graphics.newArrayImage(sprites)
end
function love.draw()
love.graphics.drawLayer(image, 1, 50, 50)
love.graphics.drawLayer(image, 2, 250, 50)
end
Use a custom shader with love.graphics.drawLayer
shader = love.graphics.newShader[[
uniform ArrayImage MainTex;
void effect() {
// Texel uses a third component of the texture coordinate for the layer index, when an Array Texture is passed in.
// love sets up the texture coordinates to contain the layer index specified in love.graphics.drawLayer, when
// rendering the Array Texture.
love_PixelColor = Texel(MainTex, VaryingTexCoord.xyz) * VaryingColor;
}
]]
function love.load()
local sprites = {"sprite1.png", "sprite2.png"}
image = love.graphics.newArrayImage(sprites)
end
function love.draw()
love.graphics.setShader(shader)
love.graphics.drawLayer(image, 1, 50, 50)
love.graphics.drawLayer(image, 2, 250, 50)
end
See Also
- love.graphics
- love.graphics.newArrayImage
- love.graphics.newCanvas
- love.graphics.newShader
- TextureType
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