Difference between revisions of "love.graphics.newQuad"
m (→Use a Quad to display part of an Image:) |
m (→Arguments: disambiguation) |
||
Line 7: | Line 7: | ||
</source> | </source> | ||
=== Arguments === | === Arguments === | ||
− | {{param|number|x|The top-left position along the x-axis.}} | + | {{param|number|x|The top-left position in the [[Image]] along the x-axis.}} |
− | {{param|number|y|The top-left position along the y-axis.}} | + | {{param|number|y|The top-left position in the [[Image]] along the y-axis.}} |
− | {{param|number|width|The width of the Quad. (Must be greater than 0.)}} | + | {{param|number|width|The width of the Quad in the [[Image]]. (Must be greater than 0.)}} |
− | {{param|number|height|The height of the Quad. (Must be greater than 0.)}} | + | {{param|number|height|The height of the Quad in the [[Image]]. (Must be greater than 0.)}} |
{{param|number|sw|The reference width, the width of the [[Image]]. (Must be greater than 0.)}} | {{param|number|sw|The reference width, the width of the [[Image]]. (Must be greater than 0.)}} | ||
{{param|number|sh|The reference height, the height of the [[Image]]. (Must be greater than 0.)}} | {{param|number|sh|The reference height, the height of the [[Image]]. (Must be greater than 0.)}} | ||
+ | |||
=== Returns === | === Returns === | ||
{{param|Quad|quad|The new Quad.}} | {{param|Quad|quad|The new Quad.}} |
Revision as of 14:05, 6 November 2016
Creates a new Quad.
This function can be slow if it is called repeatedly, such as from love.update or love.draw. If you need to use a specific resource often, create it once and store it somewhere it can be reused! |
Contents
Function
Synopsis
quad = love.graphics.newQuad( x, y, width, height, sw, sh )
Arguments
number x
- The top-left position in the Image along the x-axis.
number y
- The top-left position in the Image along the y-axis.
number width
- The width of the Quad in the Image. (Must be greater than 0.)
number height
- The height of the Quad in the Image. (Must be greater than 0.)
number sw
- The reference width, the width of the Image. (Must be greater than 0.)
number sh
- The reference height, the height of the Image. (Must be greater than 0.)
Returns
Quad quad
- The new Quad.
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:
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, img:getDimensions())
-- And here is bottom left:
bottom_left = love.graphics.newQuad(0, 32, 32, 32, img:getDimensions())
function love.draw()
love.graphics.draw(img, top_left, 50, 50)
love.graphics.draw(img, bottom_left, 50, 200)
-- v0.8:
-- love.graphics.drawq(img, top_left, 50, 50)
-- love.graphics.drawq(img, bottom_left, 50, 200)
end
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