love.graphics

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, creating specialized objects (such as ParticleSystems or Canvases) and managing screen geometry.

LÖVE’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. You can try aligning the coordinate system with the center of pixels rather than their upper-left corner. Do this by passing x + 0.5 and y + 0.5 or using love.graphics.translate(). </b></i>

Functions

Name Description Notes
arc Draws an arc  
applyTransform Applies the given Transform object to the current coordinate transformation  
circle Draws a circle  
clear Clears the screen or active Canvas to the specified color  
draw Draws objects on screen  
ellipse Draws an ellipse  
getActiveScreen Gets the currently rendering screen  
getBackgroundColor Gets the current background color  
getBlendFactor Gets the current blend factor [0 - 1] Only available on Nintendo 3DS
getColor Gets the current color  
getDefaultFilter Returns the default scaling filters used with Images, Canvases, and Fonts  
getDimensions Gets the width and height of the window On 3DS, you may pass “top” or “bottom” to get a specific screen’s size
getFont Gets the currently set Font object  
getHeight Gets the height in pixels of the window  
getLineWidth Gets the current line width  
getPointSize Gets the current point size  
getStereoscopicDepth Gets the current 3D slider value on 3DS (0 ~ 1), useful for “3D rendering” This will throw an error on Switch as it is not supported on there
getRendererInfo Gets information about the system’s video card and drivers  
getScissor Gets the current scissor box  
getScreens Get the names of the renderable screens  
getWidth Gets the width in pixels of the window On 3DS, you may pass “top” or “bottom” to get a specific screen’s width
instersectScissor Sets the scissor to the rectangle created by the intersection of the specified rectangle with the existing scissor  
inverseTransformPoint Converts the given 2D position from screen-space into global coordinates  
line Draws lines between points  
newCanvas Creates a new Canvas  
newFont Creates a new Font 3DS: convert fonts to bcfnt; Switch: only TrueType right now
newImage Creates a new Image 3DS: convert images to t3x; Switch: png and jpg are supported
newText Creates a new drawable Text object  
newQuad Creates a new Quad  
origin Resets the current coordinate transformation  
polygon Draw a polygon  
pop Pops the current coordinate transformation from the transformation stack  
points Draws one or more points Not implemented on 3DS yet
present Displays the results of drawing operations on the screen  
print Draws text on screen. If no Font is set, one will be created and set (once) if needed  
printf Draws formatted text, with word wrap and alignment LÖVE and Switch both do by character wrapping, 3DS does by word
push Copies and pushes the current coordinate transformation to the transformation stack  
rectangle Draws a rectangle  
replaceTransform Replaces the current coordinate transformation with the given Transform object  
reset Resets the current graphics settings  
rotate Rotates the coordinate system in two dimensions  
scale Scales the coordinate system in two dimensions  
shear Shears the coordinate system  
setActiveScreen Sets the current screen to be rendered Used internally, do not call this
setBackgroundColor Sets the background color  
setBlendFactor Sets the blend factor [0 - 1]; Nintendo 3DS Only num >= 0 enables colorized tinting for images and 0 disables it
setCanvas Captures drawing operations to a Canvas  
setColor Sets the color used for drawing On 3DS, only the alpha component will affect textures due to a limitation
setDefaultFilter Sets the default scaling filters used with Images, Canvases, and Fonts  
setLineWidth Sets the line width  
setNewFont Creates and sets a new Font  
setPointSize Sets the point size  
setFont Set an already-loaded Font as the current font  
setScissor Sets or disables scissor  
transformPoint Converts the given 2D position from global coordinates into screen-space  
translate Translates the coordinate system in two dimensions  

Types

Texture

Superclass for drawable objects which represent a texture.
All Textures can be drawn with Quads. This is an abstract type that can’t be created directly. </b>

See also:

Name Description Notes
getTextureType Gets the type of the Texture  
getWidth Gets the width of the Texture  
getHeight Gets the height of the Texture  
getDimensions Gets the width and height of the Texture  
setFilter Sets the filter mode of the Texture  
getFilter Gets the filter mode of the Texture  
setWrap Sets the wrapping properties of a Texture  
getWrap Gets the wrapping properties of a Texture  

Canvas

A Canvas is used for off-screen rendering.
Think of it as an invisible screen that you can draw to, but that will not be visible until you draw it to the actual visible screen.
It is also known as “render to texture”.

By drawing things that do not change position often (such as background items) to the Canvas, and then drawing the entire Canvas instead of each item, you can reduce the number of draw operations performed each frame </b></i>

See also:

Name Description Notes
renderTo Render to a Canvas using a function  

Image

Drawable image type. </b>

!> Images on 3DS will need to be converted to a *.t3x format prior to use. See compatability for more information.

See also:

A quadrilateral (a polygon with four sides and four corners) with Texture coordinate information.
Quads can be used to select part of a texture to draw. In this way, one large texture atlas can be loaded, and then split up into sub-images. </b>

See also:

Name Description Notes
getTextureDimensions Gets reference texture dimensions initially specified in love.graphics.newQuad  
getViewport Gets the current viewport of this Quad  
setViewport Sets the texture coordinates according to a viewport  

!> On Nintendo 3DS, Text and Font objects (via love.graphics.print) have a limit of 512 characters that can be printed at one time. This is due to the tight limitations on the console. System fonts also do not carry the tab character (\t) and will render as a [?] glyph.

Font

Defines the shape of characters that can be drawn onto the screen. </b>

!> Fonts on 3DS will need to be converted to a *.bcfnt format prior to use. See compatability for more information.

See also:

Name Description Notes
getHeight Gets the height of the Font in pixels  
getWidth Gets the width of the given text  

Text

</i> Drawable text. </i>

See also:

Name Description Notes
add Adds additional colored text to the Text object at the specified position  
addf Adds additional formatted / colored text to the Text object at the specified position On 3DS, text can be added, but it does not allow multiple wrap and align modes
clear Clears the contents of the Text object  
getDimensions Gets the width and height of the text  
getFont Gets the Font used with the Text object  
getHeight Gets the height of the text  
getWidth Gets the width of the text  
set Replaces the contents of the Text object with a new string  
setf Replaces the contents of the Text object with a new formatted string  
setFont Replaces the Font used with the text