Difference between revisions of "love.graphics.newQuad"

m
(Function)
Line 3: Line 3:
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
quad = love.graphics.newQuad( x, y, w, h, sw, sh )
+
quad = love.graphics.newQuad( x, y, width, height, sw, sh )
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
 
{{param|number|x|The top-left position along the x-axis.}}
 
{{param|number|x|The top-left position along the x-axis.}}
 
{{param|number|y|The top-left position along the y-axis.}}
 
{{param|number|y|The top-left position along the y-axis.}}
{{param|number|w|The width of the Quad.}}
+
{{param|number|width|The width of the Quad.}}
{{param|number|h|The height of the Quad.}}
+
{{param|number|height|The height of the Quad.}}
 
{{param|number|sw|The reference width.}}
 
{{param|number|sw|The reference width.}}
 
{{param|number|sh|The reference height.}}
 
{{param|number|sh|The reference height.}}
 
=== Returns ===
 
=== Returns ===
 
{{param|Quad|quad|The new Quad.}}
 
{{param|Quad|quad|The new Quad.}}
 +
 
== Examples ==
 
== Examples ==
 
=== Use a Quad to display part of an Image: ===
 
=== Use a Quad to display part of an Image: ===

Revision as of 02:39, 25 January 2011

Creates a new Quad.

Function

Synopsis

quad = love.graphics.newQuad( x, y, width, height, sw, sh )

Arguments

number x
The top-left position along the x-axis.
number y
The top-left position along the y-axis.
number width
The width of the Quad.
number height
The height of the Quad.
number sw
The reference width.
number sh
The reference height.

Returns

Quad quad
The new Quad.

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, 64, 64)

-- And here is bottom left:
bottom_left = love.graphics.newQuad(0, 32, 32, 32, 64, 64)

function love.draw()
	love.graphics.drawq(img, top_left, 50, 50)
	love.graphics.drawq(img, bottom_left, 50, 200)
end

See Also

Other Languages