Difference between revisions of "love.graphics.rectangle"
(→Examples: Added example for rotated rectangle.) |
m (Use New feature template) |
||
Line 2: | Line 2: | ||
Draws a rectangle. | Draws a rectangle. | ||
== Function == | == Function == | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 29: | Line 12: | ||
{{param|number|width|Width of the rectangle.}} | {{param|number|width|Width of the rectangle.}} | ||
{{param|number|height|Height of the rectangle.}} | {{param|number|height|Height of the rectangle.}} | ||
− | {{param|number|rx|The x-axis radius of each round corner. Cannot be greater than half the rectangle's width.}} | + | {{New feature|0.10.0| |
+ | {{param|number|rx (nil)|The x-axis radius of each round corner. Cannot be greater than half the rectangle's width.}} | ||
{{param|number|ry (rx)|The y-axis radius of each round corner. Cannot be greater than half the rectangle's height.}} | {{param|number|ry (rx)|The y-axis radius of each round corner. Cannot be greater than half the rectangle's height.}} | ||
{{param|number|segments (nil)|The number of segments used for drawing the round corners. A default amount will be chosen if no number is given.}} | {{param|number|segments (nil)|The number of segments used for drawing the round corners. A default amount will be chosen if no number is given.}} | ||
+ | |100}} | ||
=== Returns === | === Returns === | ||
Nothing. | Nothing. |
Revision as of 15:17, 21 August 2021
Available since LÖVE 0.3.2 |
This function is not supported in earlier versions. |
Draws a rectangle.
Contents
Function
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.
Available since LÖVE 0.10.0
number rx (nil)
- 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
Draw a rectangle at 20,50 with a size of 60x120
function love.draw()
love.graphics.rectangle("fill", 20,50, 60,120)
end
Draw a rotated rectangle
function drawRotatedRectangle(mode, x, y, width, height, angle)
-- We cannot rotate the rectangle directly, but we
-- can move and rotate the coordinate system.
love.graphics.push()
love.graphics.translate(x, y)
love.graphics.rotate(angle)
love.graphics.rectangle(mode, 0, 0, width, height)
love.graphics.pop()
end
function love.draw()
local angle = os.clock() -- Rotate the rectangle over time.
drawRotatedRectangle("fill", 150,150, 100,60, angle)
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