love.graphics.rectangle

Available since LÖVE 0.3.2
This function is not supported in earlier versions.

Draws a rectangle.

Function

Synopsis

love.graphics.rectangle( mode, x, y, width, height )

Arguments

DrawMode mode
How to draw the rectangle.
number x
The position of top-left corner along the x-axis.
number y
The position of top-left corner along the y-axis.
number width
Width of the rectangle.
number height
Height of the rectangle.

Returns

Nothing.

Function

Available since LÖVE 0.10.0
This variant is not supported in earlier versions.

Draws a rectangle with rounded corners.

Synopsis

love.graphics.rectangle( mode, x, y, width, height, rx, ry, segments )

Arguments

DrawMode mode
How to draw the rectangle.
number x
The position of top-left corner along the x-axis.
number y
The position of top-left corner along the y-axis.
number width
Width of the rectangle.
number height
Height of the rectangle.
number rx
The x-axis radius of each round corner. Cannot be greater than half the rectangle's width.
number ry (rx)
The y-axis radius of each round corner. Cannot be greater than half the rectangle's height.
number segments (nil)
The number of segments used for drawing the round corners. A default amount will be chosen if no number is given.

Returns

Nothing.

Notes

Custom shaders may not work correctly since this function (and other functions that draw primitives) doesn't have UV coordinates associated in it.

Examples

Draws a rectangle at 20,50 with a width of 60 and a height of 120

function love.draw()
    love.graphics.rectangle("fill", 20, 50, 60, 120 )
end

See Also


© 2006–2020 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/love.graphics.rectangle