The primary responsibility for the love.graphics module is the drawing of lines, shapes, text, Images and other Drawable objects onto the screen. Its secondary responsibilities include loading external files (including Images and Fonts) into memory and managing screen geometry.
Lutro's coordinate system is rooted in the upper-left corner of the screen, which is at location (0, 0). The x axis is horizontal: larger values are further to the right. The y axis is vertical: larger values are further towards the bottom. It is worth noting that the location (0, 0) aligns with the upper-left corner of the pixel as well, meaning that for some functions you may encounter off-by-one problems in the render output when drawing 1 pixel wide lines.
In many cases, you draw images or shapes in terms of their upper-left corner (See the picture above).
Clears the screen to the background color.
love.graphics.clear()
Draws objects on screen. In Lutro, a Drawable is typically an Image.
love.graphics.draw(drawable, x, y, r, sx, sy, ox, oy, kx, ky)
You can also draw a specified Quad from the texture:
love.graphics.draw(texture, quad, x, y, r, sx, sy, ox, oy, kx, ky)
Creates a new Image.
From an image file:
img = love.graphics.newImage("star.png")
From an ImageData:
img = love.graphics.newImage(imgData)
Creates a new Font by loading a specifically formatted image.
From an image file:
font = love.graphics.newImageFont("font.png", "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
You can add an extra parameter to set the letter spacing:
font = love.graphics.newImageFont("font.png", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0)
Note: Lutro defaults to 1 while LÖVE defaults to 0.
From an ImageData:
font = love.graphics.newImageFont(imgData, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
Draws text on screen. A Font need to be set with setFont prior to use.
love.graphics.print(text, x, y)
Draws formatted text, with word wrap and alignment. align
can be "left", "center" or "right".
love.graphics.print(text, x, y, limit, align)
Draws a point.
love.graphics.point(x, y)
Draws one or more points.
love.graphics.points(x, y, ...)
Draws lines between points.
love.graphics.line(x1, y1, x2, y2, ...)
Draws a rectangle. mode
can be "fill" or "line".
love.graphics.rectangle(mode, x, y, width, height)
Draws a polygon. mode
can be "fill" or "line".
love.graphics.polygon(mode, x1, y1, x2, y2, ...)
Sets the color used for drawing.
Returns the current Font.
Set an already-loaded Font as the current font.
Returns the height of the libretro viewport.
Returns the width of the libretro viewport.