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.
In many cases, you draw images or shapes in terms of their upper-left corner (See the picture above).
Many of the functions are used to manipulate the graphics coordinate system, which is essentially the the way coordinates are mapped to the display. You can change the position, scale, and even rotation in this way.
Contents
Types
Canvas | Off-screen render target. |
Drawable | Superclass for all things that can be drawn on screen. |
Font | Defines the shape of characters than can be drawn onto the screen. |
Framebuffer | Off-screen render target. |
Image | Drawable image type. |
Mesh | A 2D polygon mesh used for drawing arbitrary textured shapes. |
ParticleSystem | Used to create cool effects, like fire. |
PixelEffect | Pixel shader effect. |
Quad | A quadrilateral with texture coordinate information. |
Shader | Shader effect. |
SpriteBatch | Store image positions in a buffer, and draw it in one call. |
Text | Drawable text. |
Texture | Superclass for drawable objects which represent a texture. |
Video | A drawable video. |
Functions
Drawing
love.graphics.arc | Draws an arc. |
love.graphics.circle | Draws a circle. |
love.graphics.clear | Clears the screen or active Canvas to the specified color. |
love.graphics.discard | Discards the contents of the screen or active Canvas. |
love.graphics.draw | Draws objects on screen. |
love.graphics.drawInstanced | Draws many instances of a Mesh with a single draw call, using hardware geometry instancing. |
love.graphics.drawLayer | Draws a layer of an Array Texture. |
love.graphics.drawq | Draw a Quad with the specified Image on screen. |
love.graphics.ellipse | Draws an ellipse. |
love.graphics.flushBatch | Immediately renders any pending automatically batched draws. |
love.graphics.line | Draws lines between points. |
love.graphics.point | Draws a point. |
love.graphics.points | Draws one or more points. |
love.graphics.polygon | Draw a polygon. |
love.graphics.present | Displays the results of drawing operations on the screen. |
love.graphics.print | Draws text on screen. If no Font is set, one will be created and set (once) if needed. |
love.graphics.printf | Draws formatted text, with word wrap and alignment. |
love.graphics.quad | Draws a quadrilateral shape. |
love.graphics.rectangle | Draws a rectangle. |
love.graphics.stencil | Draws geometry as a stencil. |
love.graphics.triangle | Draws a triangle. |
Object creation
Coordinate system
love.graphics.applyTransform | Applies the given Transform object to the current coordinate transformation. |
love.graphics.inverseTransformPoint | Converts the given 2D position from screen-space into global coordinates. |
love.graphics.origin | Resets the current coordinate transformation. |
love.graphics.pop | Pops the current coordinate transformation from the transformation stack. |
love.graphics.push | Copies and pushes the current coordinate transformation to the transformation stack. |
love.graphics.replaceTransform | Replaces the current coordinate transformation with the given Transform object. |
love.graphics.rotate | Rotates the coordinate system in two dimensions. |
love.graphics.scale | Scales the coordinate system in two dimensions. |
love.graphics.shear | Shears the coordinate system. |
love.graphics.transformPoint | Converts the given 2D position from global coordinates into screen-space. |
love.graphics.translate | Translates the coordinate system in two dimensions. |
Graphics state
love.graphics.getBackgroundColor | Gets the current background color. |
love.graphics.getBlendMode | Gets the blending mode. |
love.graphics.getCanvas | Returns the current target Canvas. |
love.graphics.getColor | Gets the current color. |
love.graphics.getColorMask | Gets the active color components used when drawing. |
love.graphics.getColorMode | Gets the color mode (which controls how images are affected by the current color). |
love.graphics.getDefaultFilter | Returns the default scaling filters used with Images, Canvases, and Fonts. |
love.graphics.getDefaultImageFilter | Returns the default scaling filters. |
love.graphics.getDepthMode | Gets the current depth test mode and whether writing to the depth buffer is enabled. |
love.graphics.getFont | Gets the current Font object. |
love.graphics.getFrontFaceWinding | Gets whether triangles with clockwise- or counterclockwise-ordered vertices are considered front-facing. |
love.graphics.getLineJoin | Gets the line join style. |
love.graphics.getLineStipple | Gets the current line stipple. |
love.graphics.getLineStyle | Gets the line style. |
love.graphics.getLineWidth | Gets the current line width. |
love.graphics.getMeshCullMode | Gets whether back-facing triangles in a Mesh are culled. |
love.graphics.getPixelEffect | Returns the current PixelEffect. |
love.graphics.getPointSize | Gets the point size. |
love.graphics.getPointStyle | Gets the current point style. |
love.graphics.getScissor | Gets the current scissor box. |
love.graphics.getShader | Gets the current Shader. |
love.graphics.getStackDepth | Gets the current depth of the transform / state stack (the number of pushes without corresponding pops). |
love.graphics.getStencilTest | Gets the current stencil test configuration. |
love.graphics.intersectScissor | Sets the scissor to the rectangle created by the intersection of the specified rectangle with the existing scissor. |
love.graphics.isActive | Gets whether the graphics module is able to be used. |
love.graphics.isGammaCorrect | Gets whether gamma-correct rendering is enabled. |
love.graphics.isSupported | Checks for the support of graphics related functions. |
love.graphics.isWireframe | Gets whether wireframe mode is used when drawing. |
love.graphics.reset | Resets the current graphics settings. |
love.graphics.setBackgroundColor | Sets the background color. |
love.graphics.setBlendMode | Sets the blending mode. |
love.graphics.setCanvas | Captures drawing operations to a Canvas |
love.graphics.setColor | Sets the color used for drawing. |
love.graphics.setColorMask | Sets the color mask. Enables or disables specific color components when rendering. |
love.graphics.setColorMode | Sets the color mode (which controls how images are affected by the current color). |
love.graphics.setDefaultFilter | Sets the default scaling filters used with Images, Canvases, and Fonts. |
love.graphics.setDefaultImageFilter | Sets the default scaling filters. |
love.graphics.setDepthMode | Configures depth testing and writing to the depth buffer. |
love.graphics.setFont | Set an already-loaded Font as the current font. |
love.graphics.setFrontFaceWinding | Sets whether triangles with clockwise- or counterclockwise-ordered vertices are considered front-facing. |
love.graphics.setInvertedStencil | Defines an inverted stencil. |
love.graphics.setLine | Sets the line width and style. |
love.graphics.setLineJoin | Sets the line join style. |
love.graphics.setLineStipple | Sets the line stipple pattern. |
love.graphics.setLineStyle | Sets the line style. |
love.graphics.setLineWidth | Sets the line width. |
love.graphics.setMeshCullMode | Sets whether back-facing triangles in a Mesh are culled. |
love.graphics.setPixelEffect | Routes drawing operations through a pixel shader. |
love.graphics.setPoint | Sets the point size and style. |
love.graphics.setPointSize | Sets the point size. |
love.graphics.setPointStyle | Sets the point style. |
love.graphics.setRenderTarget | Captures drawing operations to a Framebuffer |
love.graphics.setScissor | Sets or disables scissor. |
love.graphics.setShader | Routes drawing operations through a shader. |
love.graphics.setStencil | Defines or releases a stencil. |
love.graphics.setStencilTest | Configures or disables stencil testing. |
love.graphics.setWireframe | Sets whether wireframe lines will be used when drawing. |
Window
love.graphics.checkMode | Checks if a display mode is supported. |
love.graphics.getCaption | Gets the window caption. |
love.graphics.getDPIScale | Gets the DPI scale factor of the window. |
love.graphics.getDimensions | Gets the width and height of the window. |
love.graphics.getHeight | Gets the height in pixels of the window. |
love.graphics.getMode | Returns the current display mode. |
love.graphics.getModes | Gets a list of supported fullscreen modes. |
love.graphics.getPixelDimensions | Gets the width and height in pixels of the window. |
love.graphics.getPixelHeight | Gets the height in pixels of the window. |
love.graphics.getPixelWidth | Gets the width in pixels of the window. |
love.graphics.getWidth | Gets the width in pixels of the window. |
love.graphics.hasFocus | Checks if the game window has keyboard focus. |
love.graphics.isCreated | Checks if the window has been created. |
love.graphics.setCaption | Sets the window caption. |
love.graphics.setIcon | Set window icon. |
love.graphics.setMode | Changes the display mode. |
love.graphics.toggleFullscreen | Toggles fullscreen. |
Enums
AlignMode | Text alignment. |
ArcType | Different types of arcs that can be drawn. |
AttributeDataType | Data types used in a Mesh's vertex format. |
BlendAlphaMode | Different ways alpha affects color blending. |
BlendMode | Different ways to do color blending. |
BufferDataUsage | Usage hints for SpriteBatches, Meshes, and GraphicsBuffers to optimize data storage and access. |
CanvasFormat | Canvas texture formats. |
ColorMode | Controls how drawn images are affected by current color. |
CompareMode | Different types of stencil test and depth test comparisons. |
CullMode | How Mesh geometry is culled when rendering. |
DrawMode | Controls whether shapes are drawn as an outline, or filled. |
FilterMode | How the image is filtered when scaling. |
GraphicsFeature | Graphics features that can be checked for with love.graphics.getSupported. |
GraphicsLimit | Types of system-dependent graphics limits. |
IndexDataType | Vertex map datatype. |
LineJoin | Line join style. |
LineStyle | The styles in which lines are drawn. |
MeshDrawMode | How a Mesh's vertices are used when drawing. |
MipmapMode | Controls whether a Canvas has mipmaps, and its behaviour when it does. |
PixelFormat | Pixel formats for Textures, ImageData, and CompressedImageData. |
PointStyle | How points should be drawn. |
StackType | Graphics state stack types used with love.graphics.push. |
StencilAction | How a stencil function modifies the stencil values of pixels it touches. |
TextureFormat | Controls the canvas texture format. |
TextureType | Types of textures (2D, cubemap, etc.) |
VertexAttributeStep | The frequency at which a vertex shader fetches the vertex attribute's data from the Mesh when it's drawn. |
VertexWinding | Vertex winding. |
WrapMode | How the image wraps inside a large Quad. |
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