Skip to main content

Graphics

Description:

  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.

clear

Type: Function.

Description:

  Clears the screen or active Canvas to the specified color.

-- This function is called automatically before love.draw in the default love.run function. See the example in love.run for a typical use of this function.

-- Note that the scissor area bounds the cleared region.

-- In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1.

-- In versions prior to background color instead.

Signature:

clear: function()

clear

Type: Function.

Description:

  Clears the screen or active Canvas to the specified color.

-- This function is called automatically before love.draw in the default love.run function. See the example in love.run for a typical use of this function.

-- Note that the scissor area bounds the cleared region.

-- In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1.

-- In versions prior to background color instead.

Signature:

clear: function(red: number, green: number, blue: number, alpha?: number)

Parameters:

ParameterTypeDescription
rednumberA table in the form of {r, g, b, a} containing the color to clear the first active Canvas to.
greennumberAdditional tables for each active Canvas.
bluenumberWhether to clear the active stencil buffer, if present. It can also be an integer between 0 and 255 to clear the stencil buffer to a specific value. (Default: true.)
alphanumberWhether to clear the active depth buffer, if present. It can also be a number between 0 and 1 to clear the depth buffer to a specific value. (Default: true.)

discard

Type: Function.

Description:

  Discards (trashes) the contents of the screen or active Canvas. This is a performance optimization function with niche use cases. If the active Canvas has just been changed and the 'replace' BlendMode is about to be used to draw something which covers the entire screen, calling love.graphics.discard rather than calling love.graphics.clear or doing nothing may improve performance on mobile devices. On some desktop systems this function may do nothing.

Signature:

discard: function(discard_color?: boolean | {boolean}, discard_depth_stencil?: boolean)

Parameters:

ParameterTypeDescription
discard_colorboolean or {boolean}Whether to discard the texture(s) of the active Canvas(es) (the contents of the screen if no Canvas is active.) (Default: true.)
discard_depth_stencilbooleanWhether to discard the contents of the stencil buffer of the screen / active Canvas. (Default: true.)

flushBatch

Type: Function.

Description:

  Immediately renders any pending automatically batched draws. LÖVE will call this function internally as needed when most state is changed, so it is not necessary to manually call it. The current batch will be automatically flushed by love.graphics state changes (except for the transform stack and the current color), as well as Shader:send and methods on Textures which change their state. Using a different Image in consecutive love.graphics.draw calls will also flush the current batch. SpriteBatches, ParticleSystems, Meshes, and Text objects do their own batching and do not affect automatic batching of other draws, aside from flushing the current batch when they're drawn.

Signature:

flushBatch: function()

setBackgroundColor

Type: Function.

Description:

  Sets the background color.

Signature:

setBackgroundColor: function(red: number, green: number, blue: number, alpha?: number)

Parameters:

ParameterTypeDescription
rednumberThe red component (0-1).
greennumberThe green component (0-1).
bluenumberThe blue component (0-1).
alphanumberThe alpha component (0-1). (Default: 1.)

setBackgroundColor

Type: Function.

Description:

  Sets the background color.

Signature:

setBackgroundColor: function(color: Color)

Parameters:

ParameterTypeDescription
colorColorA numerical indexed table with the red, green, blue and alpha values as numbers. The alpha is optional and defaults to 1 if it is left out.

getBackgroundColor

Type: Function.

Description:

  Gets the current background color. In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1.

Signature:

getBackgroundColor: function(): number, number, number, number

Returns:

Return TypeDescription
numberThe red component (0-1).
numberThe green component (0-1).
numberThe blue component (0-1).
numberThe alpha component (0-1).

setDefaultFilter

Type: Function.

Description:

  Sets the default scaling filters used with Images, Canvases, and Fonts. Overload details:

  1. This function does not apply retroactively to loaded images.

Signature:

setDefaultFilter: function(min_filter: string, mag_filter?: string, anisotropy?: number)

Parameters:

ParameterTypeDescription
min_filterstringFilter mode used when scaling the image down.
mag_filterstringFilter mode used when scaling the image up. (Default: min.)
anisotropynumberMaximum amount of Anisotropic Filtering used. (Default: 1.)

getDefaultFilter

Type: Function.

Description:

  Returns the default scaling filters used with Images, Canvases, and Fonts.

Signature:

getDefaultFilter: function(): string, string, number
setDefaultMipmapFilter: function(filter?: string, sharpness?: number)
getDefaultMipmapFilter: function(): string | nil, number

Parameters:

ParameterTypeDescription
filterstringThe filter parameter.
sharpnessnumberThe sharpness parameter.

Returns:

Return TypeDescription
string or string or nilFilter mode used when scaling the image down.
string or numberFilter mode used when scaling the image up.
numberMaximum amount of Anisotropic Filtering used.

setColor

Type: Function.

Description:

  Sets the color used for drawing. In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1.

Signature:

setColor: function(red: number, green: number, blue: number, alpha?: number)

Parameters:

ParameterTypeDescription
rednumberThe amount of red.
greennumberThe amount of green.
bluenumberThe amount of blue.
alphanumberThe amount of alpha. The alpha value will be applied to all subsequent draw operations, even the drawing of an image. (Default: 1.)

getColor

Type: Function.

Description:

  Gets the current color. In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1.

Signature:

getColor: function(): number, number, number, number

Returns:

Return TypeDescription
numberThe red component (0-1).
numberThe green component (0-1).
numberThe blue component (0-1).
numberThe alpha component (0-1).

setLineWidth

Type: Function.

Description:

  Sets the line width.

Signature:

setLineWidth: function(width: number)

Parameters:

ParameterTypeDescription
widthnumberThe width of the line.

getLineWidth

Type: Function.

Description:

  Gets the current line width. Overload details:

  1. This function does not work in 0.8.0, but has been fixed in version 0.9.0. Use the following snippet to circumvent this in 0.8.0; love.graphics._getLineWidth = love.graphics.getLineWidth love.graphics._setLineWidth = love.graphics.setLineWidth function love.graphics.getLineWidth() return love.graphics.varlinewidth or 1 end function love.graphics.setLineWidth(w) love.graphics.varlinewidth = w; return love.graphics._setLineWidth(w) end

Signature:

getLineWidth: function(): number

Returns:

Return TypeDescription
numberThe current line width.

setLineStyle

Type: Function.

Description:

  Sets the line style.

Signature:

setLineStyle: function(style: string)

Parameters:

ParameterTypeDescription
stylestringThe LineStyle to use. Line styles include smooth and rough.

getLineStyle

Type: Function.

Description:

  Gets the line style.

Signature:

getLineStyle: function(): string

Returns:

Return TypeDescription
stringThe current line style.

setLineJoin

Type: Function.

Description:

  Sets the line join style. See LineJoin for the possible options.

Signature:

setLineJoin: function(join: string)

Parameters:

ParameterTypeDescription
joinstringThe LineJoin to use.

getLineJoin

Type: Function.

Description:

  Gets the line join style.

Signature:

getLineJoin: function(): string

Returns:

Return TypeDescription
stringThe LineJoin style.

setWireframe

Type: Function.

Description:

  Sets whether wireframe lines will be used when drawing.

Signature:

setWireframe: function(enable: boolean)

Parameters:

ParameterTypeDescription
enablebooleanTrue to enable wireframe mode when drawing, false to disable it.

isWireframe

Type: Function.

Description:

  Gets whether wireframe mode is used when drawing.

Signature:

isWireframe: function(): boolean

Returns:

Return TypeDescription
booleanTrue if wireframe lines are used when drawing, false if it's not.

setPointSize

Type: Function.

Description:

  Sets the point size.

Signature:

setPointSize: function(size: number)

Parameters:

ParameterTypeDescription
sizenumberThe new point size.

getPointSize

Type: Function.

Description:

  Gets the point size.

Signature:

getPointSize: function(): number

Returns:

Return TypeDescription
numberThe current point size.

getDimensions

Type: Function.

Description:

  Gets the width and height in pixels of the window.

Signature:

getDimensions: function(): number, number

Returns:

Return TypeDescription
numberThe width of the window.
numberThe height of the window.

getWidth

Type: Function.

Description:

  Gets the width in pixels of the window.

Signature:

getWidth: function(): number

Returns:

Return TypeDescription
numberThe width of the window.

getHeight

Type: Function.

Description:

  Gets the height in pixels of the window.

Signature:

getHeight: function(): number

Returns:

Return TypeDescription
numberThe height of the window.

getPixelDimensions

Type: Function.

Description:

  Gets the width and height in pixels of the window. love.graphics.getDimensions gets the dimensions of the window in units scaled by the screen's DPI scale factor, rather than pixels. Use getDimensions for calculations related to drawing to the screen and using the graphics coordinate system (calculating the center of the screen, for example), and getPixelDimensions only when dealing specifically with underlying pixels (pixel-related calculations in a pixel Shader, for example).

Signature:

getPixelDimensions: function(): number, number

Returns:

Return TypeDescription
numberThe width of the window in pixels.
numberThe height of the window in pixels.

getPixelWidth

Type: Function.

Description:

  Gets the width in pixels of the window. The graphics coordinate system and DPI scale factor, rather than raw pixels. Use getWidth for calculations related to drawing to the screen and using the coordinate system (calculating the center of the screen, for example), and getPixelWidth only when dealing specifically with underlying pixels (pixel-related calculations in a pixel Shader, for example).

Signature:

getPixelWidth: function(): number

Returns:

Return TypeDescription
numberThe width of the window in pixels.

getPixelHeight

Type: Function.

Description:

  Gets the height in pixels of the window. The graphics coordinate system and DPI scale factor, rather than raw pixels. Use getHeight for calculations related to drawing to the screen and using the coordinate system (calculating the center of the screen, for example), and getPixelHeight only when dealing specifically with underlying pixels (pixel-related calculations in a pixel Shader, for example).

Signature:

getPixelHeight: function(): number

Returns:

Return TypeDescription
numberThe height of the window in pixels.

getDPIScale

Type: Function.

Description:

  Gets the DPI scale factor of the window. The DPI scale factor represents relative pixel density. The pixel density inside the window might be greater (or smaller) than the 'size' of the window. For example on a retina screen in Mac OS X with the highdpi window flag enabled, the window may take up the same physical size as an 800x600 window, but the area inside the window uses 1600x1200 pixels. love.graphics.getDPIScale() would return 2 in that case. The love.window.fromPixels and love.window.toPixels functions can also be used to convert between units. The highdpi window flag must be enabled to use the full pixel density of a Retina screen on Mac OS X and iOS. The flag currently does nothing on Windows and Linux, and on Android it is effectively always enabled. Overload details:

  1. The units of love.graphics.getWidth, love.graphics.getHeight, love.mouse.getPosition, mouse events, love.touch.getPosition, and touch events are always in DPI-scaled units rather than pixels. In LÖVE 0.10 and older they were in pixels.

Signature:

getDPIScale: function(): number

Returns:

Return TypeDescription
numberThe pixel scale factor associated with the window.

getSupported

Type: Function.

Description:

  Gets the optional graphics features and whether they're supported on the system. Some older or low-end systems don't always support all graphics features.

Signature:

getSupported: function(target?: any): GraphicsFeatures

Parameters:

ParameterTypeDescription
targetanyThe target parameter.

Returns:

Return TypeDescription
GraphicsFeaturesA table containing GraphicsFeature keys, and boolean values indicating whether each feature is supported.

getTextureTypes

Type: Function.

Description:

  Gets the available texture types, and whether each is supported.

Signature:

getTextureTypes: function(target?: any): {string: boolean}

Parameters:

ParameterTypeDescription
targetanyThe target parameter.

Returns:

Return TypeDescription
{string: boolean}A table containing TextureTypes as keys, and a boolean indicating whether the type is supported as values. Not all systems support all types.

getImageFormats

Type: Function.

Description:

  Gets the raw and compressed pixel formats usable for Images, and whether each is supported.

Signature:

getImageFormats: function(target?: any): {string: boolean}

Parameters:

ParameterTypeDescription
targetanyThe target parameter.

Returns:

Return TypeDescription
{string: boolean}A table containing PixelFormats as keys, and a boolean indicating whether the format is supported as values. Not all systems support all formats.

getRendererInfo

Type: Function.

Description:

  Gets information about the system's video card and drivers.

Signature:

getRendererInfo: function(): string, string, string, string

Returns:

Return TypeDescription
stringThe name of the renderer, e.g. 'OpenGL' or 'OpenGL ES'.
stringThe version of the renderer with some extra driver-dependent version info, e.g. '2.1 INTEL-8.10.44'.
stringThe name of the graphics card vendor, e.g. 'Intel Inc'.
stringThe name of the graphics card, e.g. 'Intel HD Graphics 3000 OpenGL Engine'.

getSystemLimits

Type: Function.

Description:

  Gets the system-dependent maximum values for love.graphics features.

Signature:

getSystemLimits: function(target?: any): GraphicsSystemLimits

Parameters:

ParameterTypeDescription
targetanyThe target parameter.

Returns:

Return TypeDescription
GraphicsSystemLimitsA table containing GraphicsLimit keys, and number values.

getStats

Type: Function.

Description:

  Gets performance-related rendering statistics.

Signature:

getStats: function(): GraphicsStats

Returns:

Return TypeDescription
GraphicsStatsstats — A table with the following fields:

getStats

Type: Function.

Description:

  Gets performance-related rendering statistics.

Signature:

getStats: function(target: any): GraphicsStats

Parameters:

ParameterTypeDescription
targetanyA table which will be filled in with the stat fields below.

Returns:

Return TypeDescription
GraphicsStatsThe table that was passed in above, now containing the following fields:

captureScreenshot

Type: Function.

Description:

  Creates a screenshot once the current frame is done (after love.draw has finished).

-- Since this function enqueues a screenshot capture rather than executing it immediately, it can be called from an input callback or love.update and it will still capture all of what's drawn to the screen in that frame.

Signature:

captureScreenshot: function(filename: string)

Parameters:

ParameterTypeDescription
filenamestringThe filename to save the screenshot to. The encoded image type is determined based on the extension of the filename, and must be one of the ImageFormats.

captureScreenshot

Type: Function.

Description:

  Creates a screenshot once the current frame is done (after love.draw has finished).

-- Since this function enqueues a screenshot capture rather than executing it immediately, it can be called from an input callback or love.update and it will still capture all of what's drawn to the screen in that frame.

Signature:

captureScreenshot: function(callback: function(image_data: ImageData))

Parameters:

ParameterTypeDescription
callbackfunction(image_data: ImageData) Function which gets called once the screenshot has been captured. An ImageData is passed into the function as its only argument.

captureScreenshot

Type: Function.

Description:

  Creates a screenshot once the current frame is done (after love.draw has finished).

-- Since this function enqueues a screenshot capture rather than executing it immediately, it can be called from an input callback or love.update and it will still capture all of what's drawn to the screen in that frame.

Signature:

captureScreenshot: function(channel: Channel)

Parameters:

ParameterTypeDescription
channelChannelThe Channel to push the generated ImageData to.

rectangle

Type: Function.

Description:

  Draws a rectangle. Overload details:

  1. Draws a rectangle with rounded corners.

Signature:

rectangle: function(mode: string, x: number, y: number, width: number, height: number)

Parameters:

ParameterTypeDescription
modestringHow to draw the rectangle.
xnumberThe position of top-left corner along the x-axis.
ynumberThe position of top-left corner along the y-axis.
widthnumberWidth of the rectangle.
heightnumberHeight of the rectangle.

circle

Type: Function.

Description:

  Draws a circle.

Signature:

circle: function(mode: string, x: number, y: number, radius: number)

Parameters:

ParameterTypeDescription
modestringHow to draw the circle.
xnumberThe position of the center along x-axis.
ynumberThe position of the center along y-axis.
radiusnumberThe radius of the circle.

arc

Type: Function.

Description:

  Draws a filled or unfilled arc at position (x, y). The arc is drawn from angle1 to angle2 in radians. The segments parameter determines how many segments are used to draw the arc. The more segments, the smoother the edge.

Signature:

arc: function(mode: DrawMode, x: number, y: number, radius: number, angle1: number, angle2: number, segments?: integer)

Parameters:

ParameterTypeDescription
modeDrawModeHow to draw the arc.
xnumberThe position of the center along x-axis.
ynumberThe position of the center along y-axis.
radiusnumberRadius of the arc.
angle1numberThe angle at which the arc begins.
angle2numberThe angle at which the arc terminates.
segmentsintegerThe number of segments used for drawing the arc. (Default: 10.)

arc

Type: Function.

Description:

  Draws a filled or unfilled arc at position (x, y). The arc is drawn from angle1 to angle2 in radians. The segments parameter determines how many segments are used to draw the arc. The more segments, the smoother the edge.

Signature:

arc: function(mode: DrawMode, arc_mode: ArcMode, x: number, y: number, radius: number, angle1: number, angle2: number, segments?: integer)

Parameters:

ParameterTypeDescription
modeDrawModeHow to draw the arc.
arc_modeArcModeThe type of arc to draw.
xnumberThe position of the center along x-axis.
ynumberThe position of the center along y-axis.
radiusnumberRadius of the arc.
angle1numberThe angle at which the arc begins.
angle2numberThe angle at which the arc terminates.
segmentsintegerThe number of segments used for drawing the arc. (Default: 10.)

ellipse

Type: Function.

Description:

  Draws an ellipse.

Signature:

ellipse: function(mode: string, x: number, y: number, radius_x: number, radius_y: number, segments?: integer)

Parameters:

ParameterTypeDescription
modestringHow to draw the ellipse.
xnumberThe position of the center along x-axis.
ynumberThe position of the center along y-axis.
radius_xnumberThe radius of the ellipse along the x-axis (half the ellipse's width).
radius_ynumberThe radius of the ellipse along the y-axis (half the ellipse's height).
segmentsintegerThe number of segments used for drawing the ellipse.

line

Type: Function.

Description:

  Draws lines between points.

Signature:

line: function(x1: number, y1: number, x2: number, y2: number, coordinates: number...)

Parameters:

ParameterTypeDescription
x1numberThe position of first point on the x-axis.
y1numberThe position of first point on the y-axis.
x2numberThe position of second point on the x-axis.
y2numberThe position of second point on the y-axis.
coordinatesnumber...You can continue passing point positions to draw a polyline.

polygon

Type: Function.

Description:

  Draw a polygon. Following the mode argument, this function can accept multiple numeric arguments or a single table of numeric arguments. In either case the arguments are interpreted as alternating x and y coordinates of the polygon's vertices.

Signature:

polygon: function(mode: string, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, coordinates: number...)

Parameters:

ParameterTypeDescription
modestringHow to draw the polygon.
x1numberThe vertices of the polygon. Depending on the overload: The vertices of the polygon as a table.
y1numberThe y1 parameter.
x2numberThe x2 parameter.
y2numberThe y2 parameter.
x3numberThe x3 parameter.
y3numberThe y3 parameter.
coordinatesnumber...The coordinates parameter.

points

Type: Function.

Description:

  Draws one or more points. Overload details:

  1. Draws one or more individually colored points. In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1. The pixel grid is actually offset to the center of each pixel. So to get clean pixels drawn use 0.5 + integer increments. Points are not affected by size is always in pixels.

Signature:

points: function(x1: number, y1: number, coordinates: number...)

Parameters:

ParameterTypeDescription
x1numberThe position of the first point on the x-axis.
y1numberThe position of the first point on the y-axis.
coordinatesnumber...The x and y coordinates of additional points.

present

Type: Function.

Description:

  Displays the results of drawing operations on the screen. This function is used when writing your own love.run function. It presents all the results of your drawing operations on the screen. See the example in love.run for a typical use of this function. Overload details:

    • If love.window.setMode has vsync equal to true, this function can't run more frequently than the refresh rate (e.g. 60 Hz), and will halt the program until ready if necessary.

Signature:

present: function()

push

Type: Function.

Description:

  Copies and pushes the current coordinate transformation to the transformation stack.

-- This function is always used to prepare for a corresponding pop operation later. It stores the current coordinate transformation state into the transformation stack and keeps it active. Later changes to the transformation can be undone by using the pop operation, which returns the coordinate transform to the state it was in before calling push.

Signature:

push: function()

push

Type: Function.

Description:

  Copies and pushes the current coordinate transformation to the transformation stack.

-- This function is always used to prepare for a corresponding pop operation later. It stores the current coordinate transformation state into the transformation stack and keeps it active. Later changes to the transformation can be undone by using the pop operation, which returns the coordinate transform to the state it was in before calling push.

Signature:

push: function(stack_type: string)

Parameters:

ParameterTypeDescription
stack_typestringThe type of stack to push (e.g. just transformation state, or all love.graphics state).

pop

Type: Function.

Description:

  Pops the current coordinate transformation from the transformation stack. This function is always used to reverse a previous push operation. It returns the current transformation state to what it was before the last preceding push.

Signature:

pop: function()

getStackDepth

Type: Function.

Description:

  Gets the current depth of the transform / state stack (the number of pushes without corresponding pops).

Signature:

getStackDepth: function(): integer

Returns:

Return TypeDescription
integerThe current depth of the transform and state love.graphics stack.

origin

Type: Function.

Description:

  Resets the current coordinate transformation. This function is always used to reverse any previous calls to love.graphics.rotate, love.graphics.scale, love.graphics.shear or love.graphics.translate. It returns the current transformation state to its defaults.

Signature:

origin: function()

translate

Type: Function.

Description:

  Translates the coordinate system in two dimensions. When this function is called with two numbers, dx, and dy, all the following drawing operations take effect as if their x and y coordinates were x+dx and y+dy. Scale and translate are not commutative operations, therefore, calling them in different orders will change the outcome. This change lasts until love.draw() exits or else a love.graphics.pop reverts to a previous love.graphics.push. Translating using whole numbers will prevent tearing/blurring of images and fonts draw after translating.

Signature:

translate: function(dx: number, dy: number)

Parameters:

ParameterTypeDescription
dxnumberThe translation relative to the x-axis.
dynumberThe translation relative to the y-axis.

rotate

Type: Function.

Description:

  Rotates the coordinate system in two dimensions. Calling this function affects all future drawing operations by rotating the coordinate system around the origin by the given amount of radians. This change lasts until love.draw() exits.

Signature:

rotate: function(angle: number)

Parameters:

ParameterTypeDescription
anglenumberThe amount to rotate the coordinate system in radians.

scale

Type: Function.

Description:

  Scales the coordinate system in two dimensions. By default the coordinate system in LÖVE corresponds to the display pixels in horizontal and vertical directions one-to-one, and the x-axis increases towards the right while the y-axis increases downwards. Scaling the coordinate system changes this relation. After scaling by sx and sy, all coordinates are treated as if they were multiplied by sx and sy. Every result of a drawing operation is also correspondingly scaled, so scaling by (2, 2) for example would mean making everything twice as large in both x- and y-directions. Scaling by a negative value flips the coordinate system in the corresponding direction, which also means everything will be drawn flipped or upside down, or both. Scaling by zero is not a useful operation. Scale and translate are not commutative operations, therefore, calling them in different orders will change the outcome. Scaling lasts until love.draw() exits.

Signature:

scale: function(sx: number, sy?: number)

Parameters:

ParameterTypeDescription
sxnumberThe scaling in the direction of the x-axis.
synumberThe scaling in the direction of the y-axis. If omitted, it defaults to same as parameter sx. (Default: sx.)

shear

Type: Function.

Description:

  Shears the coordinate system.

Signature:

shear: function(kx: number, ky: number)

Parameters:

ParameterTypeDescription
kxnumberThe shear factor on the x-axis.
kynumberThe shear factor on the y-axis.

applyTransform

Type: Function.

Description:

  Applies the given Transform object to the current coordinate transformation. This effectively multiplies the existing coordinate transformation's matrix with the Transform object's internal matrix to produce the new coordinate transformation.

Signature:

applyTransform: function(transform: Transform)

Parameters:

ParameterTypeDescription
transformTransformThe Transform object to apply to the current graphics coordinate transform.

replaceTransform

Type: Function.

Description:

  Replaces the current coordinate transformation with the given Transform object.

Signature:

replaceTransform: function(transform: Transform)

Parameters:

ParameterTypeDescription
transformTransformThe Transform object to replace the current graphics coordinate transform with.

transformPoint

Type: Function.

Description:

  Converts the given 2D position from global coordinates into screen-space. This effectively applies the current graphics transformations to the given position. A similar Transform:transformPoint method exists for Transform objects.

Signature:

transformPoint: function(x: number, y: number): number, number

Parameters:

ParameterTypeDescription
xnumberThe x component of the position in global coordinates.
ynumberThe y component of the position in global coordinates.

Returns:

Return TypeDescription
numberThe x component of the position with graphics transformations applied.
numberThe y component of the position with graphics transformations applied.

inverseTransformPoint

Type: Function.

Description:

  Converts the given 2D position from screen-space into global coordinates. This effectively applies the reverse of the current graphics transformations to the given position. A similar Transform:inverseTransformPoint method exists for Transform objects.

Signature:

inverseTransformPoint: function(x: number, y: number): number, number

Parameters:

ParameterTypeDescription
xnumberThe x component of the screen-space position.
ynumberThe y component of the screen-space position.

Returns:

Return TypeDescription
numberThe x component of the position in global coordinates.
numberThe y component of the position in global coordinates.

isActive

Type: Function.

Description:

  Gets whether the graphics module is able to be used. If it is not active, love.graphics function and method calls will not work correctly and may cause the program to crash. The graphics module is inactive if a window is not open, or if the app is in the background on iOS. Typically the app's execution will be automatically paused by the system, in the latter case.

Signature:

isActive: function(): boolean
isCreated: function(): boolean

Returns:

Return TypeDescription
booleanWhether the graphics module is active and able to be used.

isGammaCorrect

Type: Function.

Description:

  Gets whether gamma-correct rendering is supported and enabled. It can be enabled by setting t.gammacorrect = true in love.conf. Not all devices support gamma-correct rendering, in which case it will be automatically disabled and this function will return false. It is supported on desktop systems which have graphics cards that are capable of using OpenGL 3 / DirectX 10, and iOS devices that can use OpenGL ES 3. Overload details:

  1. When gamma-correct rendering is enabled, many functions and objects perform automatic color conversion between sRGB and linear RGB in order for blending and shader math to be mathematically correct (which they aren't if it's not enabled.) * The colors passed into converted from sRGB to linear RGB. * The colors set in text with per-character colors, points with per-point colors, standard custom Meshes which use the 'VertexColor' attribute name will automatically be converted from sRGB to linear RGB when those objects are drawn. * creating the Image. * Everything drawn to the screen will be blended in linear RGB and then the result will be converted to sRGB for display. * Canvases which use the 'normal' or 'srgb' CanvasFormat will have their content blended in linear RGB and the result will be stored in the canvas in sRGB, when drawing to them. When the Canvas itself is drawn, its pixel colors will be converted from sRGB to linear RGB in the same manner as Images. Keeping the canvas pixel data stored as sRGB allows for better precision (less banding) for darker colors compared to 'rgba8'. Because most conversions are automatically handled, your own code doesn't need to worry about sRGB and linear RGB color conversions when gamma-correct rendering is enabled, except in a couple cases: * If a Mesh with custom vertex attributes is used and one of the attributes is meant to be used as a color in a Shader, and the attribute isn't named 'VertexColor'. * If a Shader is used which has uniform / extern variables or other variables that are meant to be used as colors, and Shader:sendColor isn't used. In both cases, love.math.gammaToLinear can be used to convert color values to linear RGB in Lua code, or the gammaCorrectColor (or unGammaCorrectColor if necessary) shader functions can be used inside shader code. Those shader functions ''only'' do conversions if gamma-correct rendering is actually enabled. The LOVE_GAMMA_CORRECT shader preprocessor define will be set if so. Read more about gamma-correct rendering here, here, and here.

Signature:

isGammaCorrect: function(): boolean

Returns:

Return TypeDescription
booleanTrue if gamma-correct rendering is supported and was enabled in love.conf, false otherwise.

reset

Type: Function.

Description:

  Resets the current graphics settings. Calling reset makes the current drawing color white, the current background color black, disables any active color component masks, disables wireframe mode and resets the current graphics transformation to the origin. It also sets both the point and line drawing modes to smooth and their sizes to 1.0.

Signature:

reset: function()

setBlendMode

Type: Function.

Description:

  Sets the blending mode. Overload details:

  1. The default 'alphamultiply' alpha mode should normally be preferred except when drawing content with pre-multiplied alpha. If content is drawn to a Canvas using the 'alphamultiply' mode, the Canvas texture will have pre-multiplied alpha afterwards, so the 'premultiplied' alpha mode should generally be used when drawing a Canvas to the screen.

Signature:

setBlendMode: function(mode: string, alpha_mode?: string)

Parameters:

ParameterTypeDescription
modestringThe blend mode to use.
alpha_modestringWhat to do with the alpha of drawn objects when blending. (Default: 'alphamultiply'.)

getBlendMode

Type: Function.

Description:

  Gets the blending mode.

Signature:

getBlendMode: function(): string, string

Returns:

Return TypeDescription
stringThe current blend mode.
stringThe current blend alpha mode – it determines how the alpha of drawn objects affects blending.

setScissor

Type: Function.

Description:

  Sets or disables scissor.

-- The scissor limits the drawing area to a specified rectangle. This affects all graphics calls, including love.graphics.clear.

-- The dimensions of the scissor is unaffected by graphical transformations (translate, scale, ...).

Signature:

setScissor: function()

setScissor

Type: Function.

Description:

  Sets or disables scissor.

-- The scissor limits the drawing area to a specified rectangle. This affects all graphics calls, including love.graphics.clear.

-- The dimensions of the scissor is unaffected by graphical transformations (translate, scale, ...).

Signature:

setScissor: function(x: number, y: number, width: number, height: number)

Parameters:

ParameterTypeDescription
xnumberx coordinate of upper left corner.
ynumbery coordinate of upper left corner.
widthnumberwidth of clipping rectangle.
heightnumberheight of clipping rectangle.

getScissor

Type: Function.

Description:

  Gets the current scissor box.

Signature:

getScissor: function(): number | nil, number | nil, number | nil, number | nil

Returns:

Return TypeDescription
number or nilThe x-component of the top-left point of the box.
number or nilThe y-component of the top-left point of the box.
number or nilThe width of the box.
number or nilThe height of the box.

intersectScissor

Type: Function.

Description:

  Sets the scissor to the rectangle created by the intersection of the specified rectangle with the existing scissor. If no scissor is active yet, it behaves like love.graphics.setScissor. The scissor limits the drawing area to a specified rectangle. This affects all graphics calls, including love.graphics.clear. The dimensions of the scissor is unaffected by graphical transformations (translate, scale, ...).

Signature:

intersectScissor: function(x: number, y: number, width: number, height: number)

Parameters:

ParameterTypeDescription
xnumberThe x-coordinate of the upper left corner of the rectangle to intersect with the existing scissor rectangle.
ynumberThe y-coordinate of the upper left corner of the rectangle to intersect with the existing scissor rectangle.
widthnumberThe width of the rectangle to intersect with the existing scissor rectangle.
heightnumberThe height of the rectangle to intersect with the existing scissor rectangle.

setColorMask

Type: Function.

Description:

  Sets the color mask. Enables or disables specific color components when rendering and clearing the screen. For example, if '''red''' is set to '''false''', no further changes will be made to the red component of any pixels.

Signature:

setColorMask: function()

setColorMask

Type: Function.

Description:

  Sets the color mask. Enables or disables specific color components when rendering and clearing the screen. For example, if '''red''' is set to '''false''', no further changes will be made to the red component of any pixels.

Signature:

setColorMask: function(red: boolean, green: boolean, blue: boolean, alpha: boolean)

Parameters:

ParameterTypeDescription
redbooleanRender red component.
greenbooleanRender green component.
bluebooleanRender blue component.
alphabooleanRender alpha component.

getColorMask

Type: Function.

Description:

  Gets the active color components used when drawing. Normally all 4 components are active unless love.graphics.setColorMask has been used. The color mask determines whether individual components of the colors of drawn objects will affect the color of the screen. They affect love.graphics.clear and Canvas:clear as well.

Signature:

getColorMask: function(): boolean, boolean, boolean, boolean

Returns:

Return TypeDescription
booleanWhether the red color component is active when rendering.
booleanWhether the green color component is active when rendering.
booleanWhether the blue color component is active when rendering.
booleanWhether the alpha color component is active when rendering.

setDepthMode

Type: Function.

Description:

  Configures depth testing and writing to the depth buffer.

-- This is low-level functionality designed for use with custom vertex shaders and Meshes with custom vertex attributes. No higher level APIs are provided to set the depth of 2D graphics such as shapes, lines, and Images.

Signature:

setDepthMode: function()

setDepthMode

Type: Function.

Description:

  Configures depth testing and writing to the depth buffer.

-- This is low-level functionality designed for use with custom vertex shaders and Meshes with custom vertex attributes. No higher level APIs are provided to set the depth of 2D graphics such as shapes, lines, and Images.

Signature:

setDepthMode: function(compare: CompareMode, write: boolean)

Parameters:

ParameterTypeDescription
compareCompareModeDepth comparison mode used for depth testing.
writebooleanWhether to write update / write values to the depth buffer when rendering.

getDepthMode

Type: Function.

Description:

  Gets the current depth test mode and whether writing to the depth buffer is enabled. This is low-level functionality designed for use with custom vertex shaders and Meshes with custom vertex attributes. No higher level APIs are provided to set the depth of 2D graphics such as shapes, lines, and Images.

Signature:

getDepthMode: function(): string, boolean

Returns:

Return TypeDescription
stringDepth comparison mode used for depth testing.
booleanWhether to write update / write values to the depth buffer when rendering.

setMeshCullMode

Type: Function.

Description:

  Sets whether back-facing triangles in a Mesh are culled. This is designed for use with low level custom hardware-accelerated 3D rendering via custom vertex attributes on Meshes, custom vertex shaders, and depth testing with a depth buffer. By default, both front- and back-facing triangles in Meshes are rendered.

Signature:

setMeshCullMode: function(mode: string)

Parameters:

ParameterTypeDescription
modestringThe Mesh face culling mode to use (whether to render everything, cull back-facing triangles, or cull front-facing triangles).

getMeshCullMode

Type: Function.

Description:

  Gets whether back-facing triangles in a Mesh are culled. Mesh face culling is designed for use with low level custom hardware-accelerated 3D rendering via custom vertex attributes on Meshes, custom vertex shaders, and depth testing with a depth buffer.

Signature:

getMeshCullMode: function(): string

Returns:

Return TypeDescription
stringThe Mesh face culling mode in use (whether to render everything, cull back-facing triangles, or cull front-facing triangles).

setFrontFaceWinding

Type: Function.

Description:

  Sets whether triangles with clockwise- or counterclockwise-ordered vertices are considered front-facing. This is designed for use in combination with Mesh face culling. Other love.graphics shapes, lines, and sprites are not guaranteed to have a specific winding order to their internal vertices.

Signature:

setFrontFaceWinding: function(winding: string)

Parameters:

ParameterTypeDescription
windingstringThe winding mode to use. The default winding is counterclockwise ('ccw').

getFrontFaceWinding

Type: Function.

Description:

  Gets whether triangles with clockwise- or counterclockwise-ordered vertices are considered front-facing. This is designed for use in combination with Mesh face culling. Other love.graphics shapes, lines, and sprites are not guaranteed to have a specific winding order to their internal vertices.

Signature:

getFrontFaceWinding: function(): string

Returns:

Return TypeDescription
stringThe winding mode being used. The default winding is counterclockwise ('ccw').

stencil

Type: Function.

Description:

  Draws geometry as a stencil.

-- The geometry drawn by the supplied function sets invisible stencil values of pixels, instead of setting pixel colors. The stencil buffer (which contains those stencil values) can act like a mask / stencil - love.graphics.setStencilTest can be used afterward to determine how further rendering is affected by the stencil values in each pixel.

-- Stencil values are integers within the range of 255.

Signature:

stencil: function(draw: function(), action?: StencilAction, value?: integer, keep_values_or_clear_value?: boolean)

Parameters:

ParameterTypeDescription
drawfunction() Function which draws geometry. The stencil values of pixels, rather than the color of each pixel, will be affected by the geometry.
actionStencilActionHow to modify any stencil values of pixels that are touched by what's drawn in the stencil function. (Default: 'replace'.)
valueintegerThe new stencil value to use for pixels if the 'replace' stencil action is used. Has no effect with other stencil actions. Must be between 0 and 255. (Default: 1.)
keep_values_or_clear_valuebooleanTrue to preserve old stencil values of pixels, false to re-set every pixel's stencil value to 0 before executing the stencil function. love.graphics.clear will also re-set all stencil values. (Default: false.)

stencil

Type: Function.

Description:

  Draws geometry as a stencil.

-- The geometry drawn by the supplied function sets invisible stencil values of pixels, instead of setting pixel colors. The stencil buffer (which contains those stencil values) can act like a mask / stencil - love.graphics.setStencilTest can be used afterward to determine how further rendering is affected by the stencil values in each pixel.

-- Stencil values are integers within the range of 255.

Signature:

stencil: function(draw: function(), action: StencilAction, value: integer, keep_values_or_clear_value: number)

Parameters:

ParameterTypeDescription
drawfunction() Function which draws geometry. The stencil values of pixels, rather than the color of each pixel, will be affected by the geometry.
actionStencilActionHow to modify any stencil values of pixels that are touched by what's drawn in the stencil function. (Default: 'replace'.)
valueintegerThe new stencil value to use for pixels if the 'replace' stencil action is used. Has no effect with other stencil actions. Must be between 0 and 255. (Default: 1.)
keep_values_or_clear_valuenumberTrue to preserve old stencil values of pixels, false to re-set every pixel's stencil value to 0 before executing the stencil function. love.graphics.clear will also re-set all stencil values. (Default: false.)

setStencilTest

Type: Function.

Description:

  Configures or disables stencil testing.

-- When stencil testing is enabled, the geometry of everything that is drawn afterward will be clipped / stencilled out based on a comparison between the arguments of this function and the stencil value of each pixel that the geometry touches. The stencil values of pixels are affected via love.graphics.stencil.

Signature:

setStencilTest: function()

setStencilTest

Type: Function.

Description:

  Configures or disables stencil testing.

-- When stencil testing is enabled, the geometry of everything that is drawn afterward will be clipped / stencilled out based on a comparison between the arguments of this function and the stencil value of each pixel that the geometry touches. The stencil values of pixels are affected via love.graphics.stencil.

Signature:

setStencilTest: function(compare: CompareMode, value: integer)

Parameters:

ParameterTypeDescription
compareCompareModeThe type of comparison to make for each pixel.
valueintegerThe value to use when comparing with the stencil value of each pixel. Must be between 0 and 255.

getStencilTest

Type: Function.

Description:

  Gets the current stencil test configuration. When stencil testing is enabled, the geometry of everything that is drawn afterward will be clipped / stencilled out based on a comparison between the arguments of this function and the stencil value of each pixel that the geometry touches. The stencil values of pixels are affected via love.graphics.stencil. Each Canvas has its own per-pixel stencil values.

Signature:

getStencilTest: function(): string, integer

Returns:

Return TypeDescription
stringThe type of comparison that is made for each pixel. Will be 'always' if stencil testing is disabled.
integerThe value used when comparing with the stencil value of each pixel.

newFont

Type: Function.

Description:

  Creates a new Font from a TrueType Font or BMFont file. Created fonts are not cached, in that calling this function with the same arguments will always create a new Font object.

-- All variants which accept a filename can also accept a Data object instead.

Signature:

newFont: function(size?: integer): Font

Parameters:

ParameterTypeDescription
sizeintegerThe size of the font in pixels.

Returns:

Return TypeDescription
Fontfont — A Font object which can be used to draw text on screen.

newFont

Type: Function.

Description:

  Creates a new Font from a TrueType Font or BMFont file. Created fonts are not cached, in that calling this function with the same arguments will always create a new Font object.

-- All variants which accept a filename can also accept a Data object instead.

Signature:

newFont: function(filename: string, size?: integer): Font

Parameters:

ParameterTypeDescription
filenamestringThe filepath to the TrueType font file.
sizeintegerThe size of the font in pixels. (Default: 12.)

Returns:

Return TypeDescription
Fontfont — A Font object which can be used to draw text on screen.

setNewFont

Type: Function.

Description:

  Creates and sets a new Font.

Signature:

setNewFont: function(size?: integer): Font

Parameters:

ParameterTypeDescription
sizeintegerThe size of the font. (Default: 12.)

Returns:

Return TypeDescription
Fontfont — The new font.

setNewFont

Type: Function.

Description:

  Creates and sets a new Font.

Signature:

setNewFont: function(filename: string, size?: integer): Font

Parameters:

ParameterTypeDescription
filenamestringThe path and name of the file with the font.
sizeintegerThe size of the font. (Default: 12.)

Returns:

Return TypeDescription
Fontfont — The new font.

newImageFont

Type: Function.

Description:

  Creates a new specifically formatted image.

-- In versions prior to 0.9.0, LÖVE expects ISO 8859-1 encoding for the glyphs string.

Signature:

newImageFont: function(source: string | FileData | ImageData, glyphs: string, extra_spacing?: integer, dpi_scale?: number): Font

Parameters:

ParameterTypeDescription
sourcestringFileData
glyphsstringA string of the characters in the image in order from left to right.
extra_spacingintegerAdditional spacing (positive or negative) to apply to each glyph in the Font. (Default: 0.)
dpi_scalenumberThe DPI scale factor of the font. (Default: 1.)

Returns:

Return TypeDescription
Fontfont — A Font object which can be used to draw text on screen.

newImageFont

Type: Function.

Description:

  Creates a new specifically formatted image.

-- In versions prior to 0.9.0, LÖVE expects ISO 8859-1 encoding for the glyphs string.

Signature:

newImageFont: function(rasterizer: Rasterizer): Font

Parameters:

ParameterTypeDescription
rasterizerRasterizerThe ImageData object to create the font from.

Returns:

Return TypeDescription
Fontfont — A Font object which can be used to draw text on screen.

newText

Type: Function.

Description:

  Creates a new drawable Text object.

Signature:

newText: function(font: Font, text?: any): Text

Parameters:

ParameterTypeDescription
fontFontThe font to use for the text.
textanyThe initial string of text that the new Text object will contain. May be nil. (Default: nil.) Depending on the overload: A table containing colors and strings to add to the object, in the form of {color1, string1, color2, string2, ...}. color1: A table containing red, green, blue, and optional alpha components to use as a color for the next string in the table, in the form of {red, green, blue, alpha}. string1: A string of text which has a color specified by the previous color. color2: A table containing red, green, blue, and optional alpha components to use as a color for the next string in the table, in the form of {red, green, blue, alpha}. string2: A string of text which has a color specified by the previous color. ...: Additional colors and strings.

Returns:

Return TypeDescription
TextThe new drawable Text object.

setFont

Type: Function.

Description:

  Set an already-loaded Font as the current font or create and load a new one from the file and size. It's recommended that Font objects are created with love.graphics.newFont in the loading stage and then passed to this function in the drawing stage.

Signature:

setFont: function(font: Font)

Parameters:

ParameterTypeDescription
fontFontThe Font object to use.

getFont

Type: Function.

Description:

  Gets the current Font object.

Signature:

getFont: function(): Font

Returns:

Return TypeDescription
FontThe current Font. Automatically creates and sets the default font, if none is set yet.

print

Type: Function.

Description:

  Draws text on screen. If no Font is set, one will be created and set (once) if needed. As of LOVE 0.7.1, when using translation and scaling functions while drawing text, this function assumes the scale occurs first. If you don't script with this in mind, the text won't be in the right position, or possibly even on screen. love.graphics.print and love.graphics.printf both support UTF-8 encoding. You'll also need a proper Font for special characters. In versions prior to 11.0, color and byte component values were within the range of 0 to 255 instead of 0 to 1. Overload details:

  1. The color set by love.graphics.setColor will be combined (multiplied) with the colors of the text.

Signature:

print: function(text: string | number, x?: number, y?: number, angle?: number, scale_x?: number, scale_y?: number, origin_x?: number, origin_y?: number, shear_x?: number, shear_y?: number)

Parameters:

ParameterTypeDescription
textstring or numberThe text to draw.
xnumberThe position to draw the object (x-axis). (Default: 0.) Depending on the overload: The position of the text on the x-axis. (Default: 0.)
ynumberThe position to draw the object (y-axis). (Default: 0.) Depending on the overload: The position of the text on the y-axis. (Default: 0.)
anglenumberThe orientation of the text in radians. (Default: 0.)
scale_xnumberScale factor (x-axis). (Default: 1.) Depending on the overload: Scale factor on the x-axis. (Default: 1.)
scale_ynumberScale factor (y-axis). (Default: sx.) Depending on the overload: Scale factor on the y-axis. (Default: sx.)
origin_xnumberOrigin offset (x-axis). (Default: 0.) Depending on the overload: Origin offset on the x-axis. (Default: 0.)
origin_ynumberOrigin offset (y-axis). (Default: 0.) Depending on the overload: Origin offset on the y-axis. (Default: 0.)
shear_xnumberShearing factor (x-axis). (Default: 0.) Depending on the overload: Shearing / skew factor on the x-axis. (Default: 0.)
shear_ynumberShearing factor (y-axis). (Default: 0.) Depending on the overload: Shearing / skew factor on the y-axis. (Default: 0.)

printf

Type: Function.

Description:

  Draws formatted text, with word wrap and alignment. See additional notes in love.graphics.print. The word wrap limit is applied before any scaling, rotation, and other coordinate transformations. Therefore the amount of text per line stays constant given the same wrap limit, even if the scale arguments change. In version 0.9.2 and earlier, wrapping was implemented by breaking up words by spaces and putting them back together to make sure things fit nicely within the limit provided. However, due to the way this is done, extra spaces between words would end up missing when printed on the screen, and some lines could overflow past the provided wrap limit. In version 0.10.0 and newer this is no longer the case. In versions prior to 11.0, color and byte component values were within the range of 0 to 255 instead of 0 to 1. Overload details:

  1. The color set by love.graphics.setColor will be combined (multiplied) with the colors of the text.

Signature:

printf: function(text: string | number, x: number, y: number, limit: number, align?: string, angle?: number, scale_x?: number, scale_y?: number, origin_x?: number, origin_y?: number, shear_x?: number, shear_y?: number)

Parameters:

ParameterTypeDescription
textstring or numberA text string.
xnumberThe position on the x-axis. Depending on the overload: The position of the text (x-axis).
ynumberThe position on the y-axis. Depending on the overload: The position of the text (y-axis).
limitnumberWrap the line after this many horizontal pixels. Depending on the overload: The maximum width in pixels of the text before it gets automatically wrapped to a new line.
alignstringThe alignment. (Default: 'left'.) Depending on the overload: The alignment of the text.
anglenumberOrientation (radians). (Default: 0.)
scale_xnumberScale factor (x-axis). (Default: 1.)
scale_ynumberScale factor (y-axis). (Default: sx.)
origin_xnumberOrigin offset (x-axis). (Default: 0.)
origin_ynumberOrigin offset (y-axis). (Default: 0.)
shear_xnumberShearing factor (x-axis). (Default: 0.) Depending on the overload: Shearing / skew factor (x-axis). (Default: 0.)
shear_ynumberShearing factor (y-axis). (Default: 0.) Depending on the overload: Shearing / skew factor (y-axis). (Default: 0.)

newImage

Type: Function.

Description:

  Creates a new Image from a filepath, FileData, an ImageData, or a CompressedImageData, and optionally generates or specifies mipmaps for the image.

Signature:

newImage: function(filename: string, settings?: ImageSettings): Image

Parameters:

ParameterTypeDescription
filenamestringThe filepath to the image file.
settingsImageSettingsA table containing the following fields: (Default: nil.)

Returns:

Return TypeDescription
Imageimage — A new Image object which can be drawn on screen.

newImage

Type: Function.

Description:

  Creates a new Image from a filepath, FileData, an ImageData, or a CompressedImageData, and optionally generates or specifies mipmaps for the image.

Signature:

newImage: function(data: FileData, settings?: CompressedImageSettings): Image

Parameters:

ParameterTypeDescription
dataFileDataThe FileData containing image file.
settingsCompressedImageSettingsA table containing the following fields: (Default: nil.)

Returns:

Return TypeDescription
Imageimage — A new Image object which can be drawn on screen.

newImage

Type: Function.

Description:

  Creates a new Image from a filepath, FileData, an ImageData, or a CompressedImageData, and optionally generates or specifies mipmaps for the image.

Signature:

newImage: function(data: ImageData, settings?: ImageSettings): Image

Parameters:

ParameterTypeDescription
dataImageDataThe ImageData containing image.
settingsImageSettingsA table containing the following fields: (Default: nil.)

Returns:

Return TypeDescription
Imageimage — A new Image object which can be drawn on screen.

newImage

Type: Function.

Description:

  Creates a new Image from a filepath, FileData, an ImageData, or a CompressedImageData, and optionally generates or specifies mipmaps for the image.

Signature:

newImage: function(data: CompressedImageData, settings?: CompressedImageSettings): Image

Parameters:

ParameterTypeDescription
dataCompressedImageDataA CompressedImageData object. The Image will use this CompressedImageData to reload itself when love.window.setMode is called.
settingsCompressedImageSettingsA table containing the following fields: (Default: nil.)

Returns:

Return TypeDescription
Imageimage — A new Image object which can be drawn on screen.

newVideo

Type: Function.

Description:

  Creates a new drawable Video. Currently only Ogg Theora video files are supported.

Signature:

newVideo: function(filename: string, settings?: any): Video

Parameters:

ParameterTypeDescription
filenamestringThe file path to the Ogg Theora video file.
settingsanyA table containing the following fields: (Default: nil.)

Returns:

Return TypeDescription
Videovideo — A new Video.

newVideo

Type: Function.

Description:

  Creates a new drawable Video. Currently only Ogg Theora video files are supported.

Signature:

newVideo: function(stream: VideoStream, settings?: any): Video
_newVideo: function(filename_or_stream: string | VideoStream, dpi_scale?: number): Video

Parameters:

ParameterTypeDescription
streamVideoStreamThe file path to the Ogg Theora video file.
settingsanyA table containing the following fields: (Default: nil.)

Returns:

Return TypeDescription
Videovideo — A new Video.

newArrayImage

Type: Function.

Description:

  Creates a new array Image. An array image / array texture is a single object which contains multiple 'layers' or 'slices' of 2D sub-images. It can be thought of similarly to a texture atlas or sprite sheet, but it doesn't suffer from the same tile / quad bleeding artifacts that texture atlases do – although every sub-image must have the same dimensions. A specific layer of an array image can be drawn with love.graphics.drawLayer / SpriteBatch:addLayer, or with the Quad variant of love.graphics.draw and Quad:setLayer, or via a custom Shader. To use an array image in a Shader, it must be declared as a ArrayImage or sampler2DArray type (instead of Image or sampler2D). The Texel(ArrayImage image, vec3 texturecoord) shader function must be used to get pixel colors from a slice of the array image. The vec3 argument contains the texture coordinate in the first two components, and the 0-based slice index in the third component. Overload details:

  1. Creates an array Image given a different image file for each slice of the resulting array image object. Illustration of how an array image works: an external illustration A DPI scale of 2 (double the normal pixel density) will result in the image taking up the same space on-screen as an image with half its pixel dimensions that has a DPI scale of 1. This allows for easily swapping out image assets that take the same space on-screen but have different pixel densities, which makes supporting high-dpi / retina resolution require less code logic. In order to use an Array Texture or other non-2D texture types as the main texture in a custom void effect() variant must be used in the pixel shader, and MainTex must be declared as an ArrayImage or sampler2DArray like so: uniform ArrayImage MainTex;.

Signature:

newArrayImage: function(layers: {ImageData}, settings?: LayeredImageSettings): Image

Parameters:

ParameterTypeDescription
layers{ImageData}A table containing filepaths to images (or File, FileData, ImageData, or CompressedImageData objects), in an array. Each sub-image must have the same dimensions. A table of tables can also be given, where each sub-table contains all mipmap levels for the slice index of that sub-table.
settingsLayeredImageSettingsOptional table of settings to configure the array image, containing the following fields: (Default: nil.) mipmaps: True to make the image use mipmaps, false to disable them. Mipmaps will be automatically generated if the image isn't a compressed texture format. (Default: false.) linear: True to treat the image's pixels as linear instead of sRGB, when gamma correct rendering is enabled. Most images are authored as sRGB. (Default: false.) dpiscale: The DPI scale to use when drawing the array image and calling getWidth/getHeight. (Default: 1.)

Returns:

Return TypeDescription
ImageAn Array Image object.

newCubeImage

Type: Function.

Description:

  Creates a new cubemap Image. Cubemap images have 6 faces (sides) which represent a cube. They can't be rendered directly, they can only be used in Shader code (and sent to the shader via Shader:send). To use a cubemap image in a Shader, it must be declared as a CubeImage or samplerCube type (instead of Image or sampler2D). The Texel(CubeImage image, vec3 direction) shader function must be used to get pixel colors from the cubemap. The vec3 argument is a normalized direction from the center of the cube, rather than explicit texture coordinates. Each face in a cubemap image must have square dimensions. For variants of this function which accept a single image containing multiple cubemap faces, they must be laid out in one of the following forms in the image: +y +z +x -z -y -x or: +y -x +z +x -z -y or: +x -x +y -y +z -z or: +x -x +y -y +z -z Overload details:

  1. Creates a cubemap Image given a single image file containing multiple cube faces.
  2. Creates a cubemap Image given a different image file for each cube face.

Signature:

newCubeImage: function(faces: {ImageData}, settings?: LayeredImageSettings): Image

Parameters:

ParameterTypeDescription
faces{ImageData}A table containing 6 filepaths to images (or File, FileData, ImageData, or CompressedImageData objects), in an array. Each face image must have the same dimensions. A table of tables can also be given, where each sub-table contains all mipmap levels for the cube face index of that sub-table.
settingsLayeredImageSettingsOptional table of settings to configure the cubemap image, containing the following fields: (Default: nil.) mipmaps: True to make the image use mipmaps, false to disable them. Mipmaps will be automatically generated if the image isn't a compressed texture format. (Default: false.) linear: True to treat the image's pixels as linear instead of sRGB, when gamma correct rendering is enabled. Most images are authored as sRGB. (Default: false.)

Returns:

Return TypeDescription
ImageAn cubemap Image object.

newVolumeImage

Type: Function.

Description:

  Creates a new volume (3D) Image. Volume images are 3D textures with width, height, and depth. They can't be rendered directly, they can only be used in Shader code (and sent to the shader via Shader:send). To use a volume image in a Shader, it must be declared as a VolumeImage or sampler3D type (instead of Image or sampler2D). The Texel(VolumeImage image, vec3 texcoords) shader function must be used to get pixel colors from the volume image. The vec3 argument is a normalized texture coordinate with the z component representing the depth to sample at (ranging from 1). Volume images are typically used as lookup tables in shaders for color grading, for example, because sampling using a texture coordinate that is partway in between two pixels can interpolate across all 3 dimensions in the volume image, resulting in a smooth gradient even when a small-sized volume image is used as the lookup table. Array images are a much better choice than volume images for storing multiple different sprites in a single array image for directly drawing them. Overload details:

  1. Creates a volume Image given multiple image files with matching dimensions. Volume images are not supported on some older mobile devices. Use love.graphics.getTextureTypes to check at runtime.

Signature:

newVolumeImage: function(slices: {ImageData}, settings?: LayeredImageSettings): Image

Parameters:

ParameterTypeDescription
slices{ImageData}A table containing filepaths to images (or File, FileData, ImageData, or CompressedImageData objects), in an array. A table of tables can also be given, where each sub-table represents a single mipmap level and contains all layers for that mipmap.
settingsLayeredImageSettingsOptional table of settings to configure the volume image, containing the following fields: (Default: nil.) mipmaps: True to make the image use mipmaps, false to disable them. Mipmaps will be automatically generated if the image isn't a compressed texture format. (Default: false.) linear: True to treat the image's pixels as linear instead of sRGB, when gamma correct rendering is enabled. Most images are authored as sRGB. (Default: false.)

Returns:

Return TypeDescription
ImageA volume Image object.

newCanvas

Type: Function.

Description:

  Creates a new Canvas object for offscreen rendering.

Signature:

newCanvas: function(): Canvas

Returns:

Return TypeDescription
Canvascanvas — A new Canvas with dimensions equal to the window's size in pixels.

newCanvas

Type: Function.

Description:

  Creates a new Canvas object for offscreen rendering.

Signature:

newCanvas: function(width: integer, height: integer, settings?: CanvasSettings): Canvas

Parameters:

ParameterTypeDescription
widthintegerThe desired width of the Canvas.
heightintegerThe desired height of the Canvas.
settingsCanvasSettingsA table containing the given fields: (Default: nil.)

Returns:

Return TypeDescription
CanvasA new Canvas with specified width and height.

getCanvasFormats

Type: Function.

Description:

  Gets the available Canvas formats, and whether each is supported.

Signature:

getCanvasFormats: function(readable?: boolean, formats?: {string: boolean}): {string: boolean}

Parameters:

ParameterTypeDescription
readablebooleanIf true, the returned formats will only be indicated as supported if readable flag set to true for that format, and vice versa if the parameter is false.
formats{string: boolean}The formats parameter.

Returns:

Return TypeDescription
{string: boolean}A table containing CanvasFormats as keys, and a boolean indicating whether the format is supported as values. Not all systems support all formats. Depending on the overload: A table containing CanvasFormats as keys, and a boolean indicating whether the format is supported as values (taking into account the readable parameter). Not all systems support all formats.

setCanvas

Type: Function.

Description:

  Captures drawing operations to a Canvas.

Signature:

setCanvas: function()

setCanvas

Type: Function.

Description:

  Captures drawing operations to a Canvas.

Signature:

setCanvas: function(canvas: Canvas, canvases: Canvas...)

Parameters:

ParameterTypeDescription
canvasCanvasThe new render target.
canvasesCanvas...A table specifying the active Canvas(es), their mipmap levels and active layers if applicable, and whether to use a stencil and/or depth buffer.

setCanvas

Type: Function.

Description:

  Captures drawing operations to a Canvas.

Signature:

setCanvas: function(canvases: {Canvas})

Parameters:

ParameterTypeDescription
canvases{Canvas}A table specifying the active Canvas(es), their mipmap levels and active layers if applicable, and whether to use a stencil and/or depth buffer.

setCanvas

Type: Function.

Description:

  Captures drawing operations to a Canvas.

Signature:

setCanvas: function(setup: CanvasSetup)

Parameters:

ParameterTypeDescription
setupCanvasSetupA table specifying the active Canvas(es), their mipmap levels and active layers if applicable, and whether to use a stencil and/or depth buffer.

getCanvas

Type: Function.

Description:

  Gets the current target Canvas.

Signature:

getCanvas: function(): Canvas | nil

Returns:

Return TypeDescription
Canvas or nilThe Canvas set by setCanvas. Returns nil if drawing to the real screen.

newQuad

Type: Function.

Description:

  Creates a new Quad.

-- The purpose of a Quad is to use a fraction of an image to draw objects, as opposed to drawing entire image. It is most useful for sprite sheets and atlases: in a sprite atlas, multiple sprites reside in same image, quad is used to draw a specific sprite from that image; in animated sprites with all frames residing in the same image, quad is used to draw specific frame from the animation.

Signature:

newQuad: function(x: number, y: number, width: number, height: number, image: Image | Canvas): Quad

Parameters:

ParameterTypeDescription
xnumberThe top-left position in the Image along the x-axis.
ynumberThe top-left position in the Image along the y-axis.
widthnumberThe width of the Quad in the Image. (Must be greater than 0.)
heightnumberThe height of the Quad in the Image. (Must be greater than 0.)
imageImageCanvas

Returns:

Return TypeDescription
Quadquad — The new Quad.

newQuad

Type: Function.

Description:

  Creates a new Quad.

-- The purpose of a Quad is to use a fraction of an image to draw objects, as opposed to drawing entire image. It is most useful for sprite sheets and atlases: in a sprite atlas, multiple sprites reside in same image, quad is used to draw a specific sprite from that image; in animated sprites with all frames residing in the same image, quad is used to draw specific frame from the animation.

Signature:

newQuad: function(x: number, y: number, width: number, height: number, texture_width: number, texture_height: number): Quad

Parameters:

ParameterTypeDescription
xnumberThe top-left position in the Image along the x-axis.
ynumberThe top-left position in the Image along the y-axis.
widthnumberThe width of the Quad in the Image. (Must be greater than 0.)
heightnumberThe height of the Quad in the Image. (Must be greater than 0.)
texture_widthnumberThe reference width, the width of the Image. (Must be greater than 0.)
texture_heightnumberThe reference height, the height of the Image. (Must be greater than 0.)

Returns:

Return TypeDescription
Quadquad — The new Quad.

newMesh

Type: Function.

Description:

  Creates a new Mesh.

-- Use Mesh:setTexture if the Mesh should be textured with an Image or Canvas when it's drawn.

-- In versions prior to 11.0, color and byte component values were within the range of 0 to 255 instead of 0 to 1.

Signature:

newMesh: function(vertices: {MeshVertex} | number, draw_mode?: MeshDrawMode, usage?: MeshUsage): Mesh

Parameters:

ParameterTypeDescription
vertices{MeshVertex}number
draw_modeMeshDrawModeHow the vertices are used when drawing. The default mode 'fan' is sufficient for simple convex polygons. (Default: 'fan'.)
usageMeshUsageThe expected usage of the Mesh. The specified usage mode affects the Mesh's memory usage and performance. (Default: 'dynamic'.)

Returns:

Return TypeDescription
Meshmesh — The new mesh.

newMesh

Type: Function.

Description:

  Creates a new Mesh.

-- Use Mesh:setTexture if the Mesh should be textured with an Image or Canvas when it's drawn.

-- In versions prior to 11.0, color and byte component values were within the range of 0 to 255 instead of 0 to 1.

Signature:

newMesh: function(format: {MeshVertexFormat}, vertices: {MeshVertex} | number | Data, draw_mode?: MeshDrawMode, usage?: MeshUsage): Mesh

Parameters:

ParameterTypeDescription
format{MeshVertexFormat}A table in the form of {attribute, ...}. Each attribute is a table which specifies a custom vertex attribute used for each vertex.
vertices{MeshVertex}number
draw_modeMeshDrawModeThe Image or Canvas to use when drawing the Mesh. May be nil to use no texture. (Default: nil.)
usageMeshUsageThe expected usage of the Mesh. The specified usage mode affects the Mesh's memory usage and performance. (Default: 'dynamic'.)

Returns:

Return TypeDescription
Meshmesh — The new mesh.

newSpriteBatch

Type: Function.

Description:

  Creates a new SpriteBatch object.

Signature:

newSpriteBatch: function(texture: Image | Canvas, size?: integer, usage?: string): SpriteBatch

Parameters:

ParameterTypeDescription
textureImage or CanvasThe Image or Canvas to use for the sprites.
sizeintegerThe maximum number of sprites that the SpriteBatch can contain at any given time. Since version 11.0, additional sprites added past this number will automatically grow the spritebatch. (Default: 1000.)
usagestringThe expected usage of the SpriteBatch. The specified usage mode affects the SpriteBatch's memory usage and performance. (Default: 'dynamic'.)

Returns:

Return TypeDescription
SpriteBatchThe new SpriteBatch.

newParticleSystem

Type: Function.

Description:

  Creates a new ParticleSystem.

Signature:

newParticleSystem: function(texture: Image | Canvas, size?: integer): ParticleSystem

Parameters:

ParameterTypeDescription
textureImage or CanvasThe texture (Image or Canvas) to use.
sizeintegerThe max number of particles at the same time. (Default: 1000.)

Returns:

Return TypeDescription
ParticleSystemA new ParticleSystem.

newShader

Type: Function.

Description:

  Creates a new Shader object for hardware-accelerated vertex and pixel effects. A Shader contains either vertex shader code, pixel shader code, or both. Shaders are small programs which are run on the graphics card when drawing. Vertex shaders are run once for each vertex (for example, an image has 4 vertices - one at each corner. A Mesh might have many more.) Pixel shaders are run once for each pixel on the screen which the drawn object touches. Pixel shader code is executed after all the object's vertices have been processed by the vertex shader.

Signature:

newShader: function(source: string | FileData, pixel_source?: string | FileData): Shader

Parameters:

ParameterTypeDescription
sourcestring or FileDataThe pixel shader code, or a filename pointing to a file with the code.
pixel_sourcestring or FileDataThe vertex shader code, or a filename pointing to a file with the code.

Returns:

Return TypeDescription
ShaderA Shader object for use in drawing operations.

validateShader

Type: Function.

Description:

  Validates shader code. Check if specified shader code does not contain any errors.

Signature:

validateShader: function(gles: boolean, source: string | FileData, pixel_source?: string | FileData): boolean, string | nil

Parameters:

ParameterTypeDescription
glesbooleanValidate code as GLSL ES shader.
sourcestring or FileDataThe pixel shader code, or a filename pointing to a file with the code.
pixel_sourcestring or FileDataThe vertex shader code, or a filename pointing to a file with the code.

Returns:

Return TypeDescription
booleantrue if specified shader code doesn't contain any errors. false otherwise.
string or nilReason why shader code validation failed (or nil if validation succeded).

setShader

Type: Function.

Description:

  Sets or resets a Shader as the current pixel effect or vertex shaders. All drawing operations until the next ''love.graphics.setShader'' will be drawn using the Shader object specified.

Signature:

setShader: function()

setShader

Type: Function.

Description:

  Sets or resets a Shader as the current pixel effect or vertex shaders. All drawing operations until the next ''love.graphics.setShader'' will be drawn using the Shader object specified.

Signature:

setShader: function(shader: Shader)

Parameters:

ParameterTypeDescription
shaderShaderThe new shader.

getShader

Type: Function.

Description:

  Gets the current Shader. Returns nil if none is set.

Signature:

getShader: function(): Shader | nil

Returns:

Return TypeDescription
Shader or nilThe currently active Shader, or nil if none is set.

draw

Type: Function.

Description:

  Draws a Drawable object (an Image, Canvas, SpriteBatch, ParticleSystem, Mesh, Text object, or Video) on the screen with optional rotation, scaling and shearing.

-- Objects are drawn relative to their local coordinate system. The origin is by default located at the top left corner of Image and Canvas. All scaling, shearing, and rotation arguments transform the object relative to that point. Also, the position of the origin can be specified on the screen coordinate system.

-- It's possible to rotate an object about its center by offsetting the origin to the center. Angles must be given in radians for rotation. One can also use a negative scaling factor to flip about its centerline.

-- Note that the offsets are applied before rotation, scaling, or shearing; scaling and shearing are applied before rotation.

-- The right and bottom edges of the object are shifted at an angle defined by the shearing factors.

-- When using the default shader anything drawn with this function will be tinted according to the currently selected color. Set it to pure white to preserve the object's original colors.

Signature:

draw: function(image: Image, x?: number, y?: number, angle?: number, scale_x?: number, scale_y?: number, origin_x?: number, origin_y?: number)

Parameters:

ParameterTypeDescription
imageImageA drawable object.
xnumberThe position to draw the object (x-axis). (Default: 0.)
ynumberThe position to draw the object (y-axis). (Default: 0.)
anglenumberOrientation (radians). (Default: 0.)
scale_xnumberScale factor (x-axis). (Default: 1.)
scale_ynumberScale factor (y-axis). (Default: sx.)
origin_xnumberOrigin offset (x-axis). (Default: 0.)
origin_ynumberOrigin offset (y-axis). (Default: 0.)

draw

Type: Function.

Description:

  Draws a Drawable object (an Image, Canvas, SpriteBatch, ParticleSystem, Mesh, Text object, or Video) on the screen with optional rotation, scaling and shearing.

-- Objects are drawn relative to their local coordinate system. The origin is by default located at the top left corner of Image and Canvas. All scaling, shearing, and rotation arguments transform the object relative to that point. Also, the position of the origin can be specified on the screen coordinate system.

-- It's possible to rotate an object about its center by offsetting the origin to the center. Angles must be given in radians for rotation. One can also use a negative scaling factor to flip about its centerline.

-- Note that the offsets are applied before rotation, scaling, or shearing; scaling and shearing are applied before rotation.

-- The right and bottom edges of the object are shifted at an angle defined by the shearing factors.

-- When using the default shader anything drawn with this function will be tinted according to the currently selected color. Set it to pure white to preserve the object's original colors.

Signature:

draw: function(image: Image, quad: Quad, x?: number, y?: number, angle?: number, scale_x?: number, scale_y?: number, origin_x?: number, origin_y?: number)

Parameters:

ParameterTypeDescription
imageImageA drawable object.
quadQuadThe Quad to draw on screen.
xnumberThe position to draw the object (x-axis).
ynumberThe position to draw the object (y-axis).
anglenumberScale factor (x-axis). (Default: 1.)
scale_xnumberScale factor (y-axis). (Default: sx.)
scale_ynumberOrigin offset (x-axis). (Default: 0.)
origin_xnumberOrigin offset (y-axis). (Default: 0.)
origin_ynumberShearing factor (x-axis). (Default: 0.)

draw

Type: Function.

Description:

  Draws a Canvas on the screen with optional rotation, scaling, and shearing.

Signature:

draw: function(canvas: Canvas, x?: number, y?: number, angle?: number, scale_x?: number, scale_y?: number, origin_x?: number, origin_y?: number)

Parameters:

ParameterTypeDescription
canvasCanvasThe Canvas to draw.
xnumberThe position to draw the object on the x-axis. (Default: 0.)
ynumberThe position to draw the object on the y-axis. (Default: 0.)
anglenumberThe orientation in radians. (Default: 0.)
scale_xnumberThe scale factor on the x-axis. (Default: 1.)
scale_ynumberThe scale factor on the y-axis. (Default: scaleX.)
origin_xnumberThe origin offset on the x-axis. (Default: 0.)
origin_ynumberThe origin offset on the y-axis. (Default: 0.)

draw

Type: Function.

Description:

  Draws a Canvas on the screen with optional rotation, scaling, and shearing.

Signature:

draw: function(canvas: Canvas, quad: Quad, x?: number, y?: number, angle?: number, scale_x?: number, scale_y?: number, origin_x?: number, origin_y?: number)

Parameters:

ParameterTypeDescription
canvasCanvasThe Canvas to draw.
quadQuadThe subsection of the drawable to draw.
xnumberThe position to draw the object on the x-axis. (Default: 0.)
ynumberThe position to draw the object on the y-axis. (Default: 0.)
anglenumberThe orientation in radians. (Default: 0.)
scale_xnumberThe scale factor on the x-axis. (Default: 1.)
scale_ynumberThe scale factor on the y-axis. (Default: scaleX.)
origin_xnumberThe origin offset on the x-axis. (Default: 0.)
origin_ynumberThe origin offset on the y-axis. (Default: 0.)

draw

Type: Function.

Description:

  Draws a Mesh on the screen with optional rotation, scaling, and shearing.

Signature:

draw: function(mesh: Mesh, x?: number, y?: number, angle?: number, scale_x?: number, scale_y?: number, origin_x?: number, origin_y?: number, shear_x?: number, shear_y?: number)

Parameters:

ParameterTypeDescription
meshMeshThe Mesh to draw.
xnumberThe position to draw the object on the x-axis. (Default: 0.)
ynumberThe position to draw the object on the y-axis. (Default: 0.)
anglenumberThe orientation in radians. (Default: 0.)
scale_xnumberThe scale factor on the x-axis. (Default: 1.)
scale_ynumberThe scale factor on the y-axis. (Default: scaleX.)
origin_xnumberThe origin offset on the x-axis. (Default: 0.)
origin_ynumberThe origin offset on the y-axis. (Default: 0.)
shear_xnumberThe shearing factor on the x-axis. (Default: 0.)
shear_ynumberThe shearing factor on the y-axis. (Default: 0.)

draw

Type: Function.

Description:

  Draws a SpriteBatch on the screen with optional rotation, scaling, and shearing.

Signature:

draw: function(batch: SpriteBatch, x?: number, y?: number, angle?: number, scale_x?: number, scale_y?: number, origin_x?: number, origin_y?: number, shear_x?: number, shear_y?: number)

Parameters:

ParameterTypeDescription
batchSpriteBatchThe SpriteBatch to draw.
xnumberThe position to draw the object on the x-axis. (Default: 0.)
ynumberThe position to draw the object on the y-axis. (Default: 0.)
anglenumberThe orientation in radians. (Default: 0.)
scale_xnumberThe scale factor on the x-axis. (Default: 1.)
scale_ynumberThe scale factor on the y-axis. (Default: scaleX.)
origin_xnumberThe origin offset on the x-axis. (Default: 0.)
origin_ynumberThe origin offset on the y-axis. (Default: 0.)
shear_xnumberThe shearing factor on the x-axis. (Default: 0.)
shear_ynumberThe shearing factor on the y-axis. (Default: 0.)

draw

Type: Function.

Description:

  Draws a ParticleSystem on the screen with optional rotation, scaling, and shearing.

Signature:

draw: function(particles: ParticleSystem, x?: number, y?: number, angle?: number, scale_x?: number, scale_y?: number, origin_x?: number, origin_y?: number, shear_x?: number, shear_y?: number)

Parameters:

ParameterTypeDescription
particlesParticleSystemThe ParticleSystem to draw.
xnumberThe position to draw the object on the x-axis. (Default: 0.)
ynumberThe position to draw the object on the y-axis. (Default: 0.)
anglenumberThe orientation in radians. (Default: 0.)
scale_xnumberThe scale factor on the x-axis. (Default: 1.)
scale_ynumberThe scale factor on the y-axis. (Default: scaleX.)
origin_xnumberThe origin offset on the x-axis. (Default: 0.)
origin_ynumberThe origin offset on the y-axis. (Default: 0.)
shear_xnumberThe shearing factor on the x-axis. (Default: 0.)
shear_ynumberThe shearing factor on the y-axis. (Default: 0.)

draw

Type: Function.

Description:

  Draws a Text on the screen with optional rotation, scaling, and shearing.

Signature:

draw: function(text: Text, x?: number, y?: number, angle?: number, scale_x?: number, scale_y?: number, origin_x?: number, origin_y?: number, shear_x?: number, shear_y?: number)

Parameters:

ParameterTypeDescription
textTextThe Text object to draw.
xnumberThe position to draw the object on the x-axis. (Default: 0.)
ynumberThe position to draw the object on the y-axis. (Default: 0.)
anglenumberThe orientation in radians. (Default: 0.)
scale_xnumberThe scale factor on the x-axis. (Default: 1.)
scale_ynumberThe scale factor on the y-axis. (Default: scaleX.)
origin_xnumberThe origin offset on the x-axis. (Default: 0.)
origin_ynumberThe origin offset on the y-axis. (Default: 0.)
shear_xnumberThe shearing factor on the x-axis. (Default: 0.)
shear_ynumberThe shearing factor on the y-axis. (Default: 0.)

draw

Type: Function.

Description:

  Draws a Video on the screen with optional rotation, scaling, and shearing.

Signature:

draw: function(video: Video, x?: number, y?: number, angle?: number, scale_x?: number, scale_y?: number, origin_x?: number, origin_y?: number, shear_x?: number, shear_y?: number)

Parameters:

ParameterTypeDescription
videoVideoThe Video to draw.
xnumberThe position to draw the object on the x-axis. (Default: 0.)
ynumberThe position to draw the object on the y-axis. (Default: 0.)
anglenumberThe orientation in radians. (Default: 0.)
scale_xnumberThe scale factor on the x-axis. (Default: 1.)
scale_ynumberThe scale factor on the y-axis. (Default: scaleX.)
origin_xnumberThe origin offset on the x-axis. (Default: 0.)
origin_ynumberThe origin offset on the y-axis. (Default: 0.)
shear_xnumberThe shearing factor on the x-axis. (Default: 0.)
shear_ynumberThe shearing factor on the y-axis. (Default: 0.)

drawLayer

Type: Function.

Description:

  Draws a layer of an Table Texture.

Signature:

drawLayer: function(image: Image, layer: integer, x?: number, y?: number, angle?: number, scale_x?: number, scale_y?: number, origin_x?: number, origin_y?: number)

Parameters:

ParameterTypeDescription
imageImageThe Table Texture to draw.
layerintegerThe index of the layer to use when drawing.
xnumberThe position to draw the texture (x-axis). (Default: 0.)
ynumberThe position to draw the texture (y-axis). (Default: 0.)
anglenumberOrientation (radians). (Default: 0.)
scale_xnumberScale factor (x-axis). (Default: 1.)
scale_ynumberScale factor (y-axis). (Default: sx.)
origin_xnumberOrigin offset (x-axis). (Default: 0.)
origin_ynumberOrigin offset (y-axis). (Default: 0.)

drawLayer

Type: Function.

Description:

  Draws a layer of an Table Texture.

Signature:

drawLayer: function(image: Image, layer: integer, quad: Quad, x?: number, y?: number, angle?: number, scale_x?: number, scale_y?: number, origin_x?: number, origin_y?: number)

Parameters:

ParameterTypeDescription
imageImageThe Table Texture to draw.
layerintegerThe index of the layer to use when drawing.
quadQuadThe subsection of the texture's layer to use when drawing.
xnumberThe position to draw the texture (x-axis). (Default: 0.)
ynumberThe position to draw the texture (y-axis). (Default: 0.)
anglenumberScale factor (x-axis). (Default: 1.)
scale_xnumberScale factor (y-axis). (Default: sx.)
scale_ynumberOrigin offset (x-axis). (Default: 0.)
origin_xnumberOrigin offset (y-axis). (Default: 0.)
origin_ynumberShearing factor (x-axis). (Default: 0.)

drawInstanced

Type: Function.

Description:

  Draws many instances of a Mesh with a single draw call, using hardware geometry instancing. Each instance can have unique properties (positions, colors, etc.) but will not by default unless a custom per-instance vertex attributes or the love_InstanceID GLSL 3 vertex shader variable is used, otherwise they will all render at the same position on top of each other. Instancing is not supported by some older GPUs that are only capable of using OpenGL ES 2 or OpenGL 2. Use love.graphics.getSupported to check.

Signature:

drawInstanced: function(mesh: Mesh, instance_count: integer, x?: number, y?: number, angle?: number, scale_x?: number, scale_y?: number, origin_x?: number, origin_y?: number, shear_x?: number, shear_y?: number)

Parameters:

ParameterTypeDescription
meshMeshThe mesh to render.
instance_countintegerThe number of instances to render.
xnumberThe position to draw the instances (x-axis). (Default: 0.)
ynumberThe position to draw the instances (y-axis). (Default: 0.)
anglenumberOrientation (radians). (Default: 0.)
scale_xnumberScale factor (x-axis). (Default: 1.)
scale_ynumberScale factor (y-axis). (Default: sx.)
origin_xnumberOrigin offset (x-axis). (Default: 0.)
origin_ynumberOrigin offset (y-axis). (Default: 0.)
shear_xnumberShearing factor (x-axis). (Default: 0.)
shear_ynumberShearing factor (y-axis). (Default: 0.)