code
stringlengths
2.5k
150k
kind
stringclasses
1 value
love love.window.getDesktopDimensions love.window.getDesktopDimensions ================================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the width and height of the desktop. Function -------- ### Synopsis ``` width, height = love.window.getDesktopDimensions( display ) ``` ### Arguments `[number](number "number") display (1)` The index of the display, if multiple monitors are available. ### Returns `[number](number "number") width` The width of the desktop. `[number](number "number") height` The height of the desktop. Examples -------- ### Show the resolution of the monitor the window is currently in ``` function love.draw() local _, _, flags = love.window.getMode()   -- The window's flags contain the index of the monitor it's currently in. local width, height = love.window.getDesktopDimensions(flags.display)   love.graphics.print(("display %d: %d x %d"):format(flags.display, width, height), 4, 10) end ``` See Also -------- * [love.window](love.window "love.window") love RevoluteJoint:isLimitsEnabled RevoluteJoint:isLimitsEnabled ============================= **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [RevoluteJoint:hasLimitsEnabled](revolutejoint-haslimitsenabled "RevoluteJoint:hasLimitsEnabled"). Checks whether limits are enabled. Function -------- ### Synopsis ``` enabled = RevoluteJoint:isLimitsEnabled( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") enabled` True if enabled, false otherwise. See Also -------- * [RevoluteJoint](revolutejoint "RevoluteJoint") love love.physics.newRopeJoint love.physics.newRopeJoint ========================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Creates a joint between two bodies. Its only function is enforcing a max distance between these bodies. There is a bug in version 0.8.0 where the coordinates of the anchors are divided by the number from [love.physics.getMeter](love.physics.getmeter "love.physics.getMeter"). As a workaround, multiply your anchor coordinates with that number and it should work like expected. Function -------- ### Synopsis ``` joint = love.physics.newRopeJoint( body1, body2, x1, y1, x2, y2, maxLength, collideConnected ) ``` ### Arguments `[Body](body "Body") body1` The first body to attach to the joint. `[Body](body "Body") body2` The second body to attach to the joint. `[number](number "number") x1` The x position of the first anchor point. `[number](number "number") y1` The y position of the first anchor point. `[number](number "number") x2` The x position of the second anchor point. `[number](number "number") y2` The y position of the second anchor point. `[number](number "number") maxLength` The maximum distance for the bodies. `[boolean](boolean "boolean") collideConnected (false)` Specifies whether the two bodies should collide with each other. ### Returns `[RopeJoint](ropejoint "RopeJoint") joint` The new RopeJoint. See Also -------- * [love.physics](love.physics "love.physics") * [RopeJoint](ropejoint "RopeJoint") * [Joint](joint "Joint") love love.conf love.conf ========= Introduction ------------ If a file called `conf.lua` is present in your game folder (or .love file), it is run *before* the LÖVE modules are loaded. You can use this file to overwrite the `love.conf` function, which is later called by the LÖVE 'boot' script. Using the `love.conf` function, you can set some configuration options, and change things like the default size of the window, which modules are loaded, and other stuff. love.conf --------- The `love.conf` function takes one argument: a table filled with all the default values which you can overwrite to your liking. If you want to change the default window size, for instance, do: ``` function love.conf(t) t.window.width = 1024 t.window.height = 768 end ``` If you don't need the physics module or joystick module, do the following. ``` function love.conf(t) t.modules.joystick = false t.modules.physics = false end ``` Setting unused modules to false is encouraged when you release your game. It reduces startup time slightly (especially if the joystick module is disabled) and reduces memory usage (slightly). Note that you can't disable [love.filesystem](love.filesystem "love.filesystem") and [love.data](love.data "love.data"); it's mandatory. The same goes for the [love](love "love") module itself. [love.graphics](love.graphics "love.graphics") needs [love.window](love.window "love.window") to be enabled. In LÖVE version 0.9.2 and earlier, errors in the config file will cause the game to not launch and no error message to appear. If the game doesn't load, check the config file for errors first. In version 0.10.2 and later, errors in the config will now show the blue error screen showing the error in the config file. Current Configuration File -------------------------- Here is a full list of options and their default values for LÖVE [11.3](https://love2d.org/wiki/11.3 "11.3"): ``` function love.conf(t) t.identity = nil -- The name of the save directory (string) t.appendidentity = false -- Search files in source directory before save directory (boolean) t.version = "11.3" -- The LÖVE version this game was made for (string) t.console = false -- Attach a console (boolean, Windows only) t.accelerometerjoystick = true -- Enable the accelerometer on iOS and Android by exposing it as a Joystick (boolean) t.externalstorage = false -- True to save files (and read from the save directory) in external storage on Android (boolean) t.gammacorrect = false -- Enable gamma-correct rendering, when supported by the system (boolean)   t.audio.mic = false -- Request and use microphone capabilities in Android (boolean) t.audio.mixwithsystem = true -- Keep background music playing when opening LOVE (boolean, iOS and Android only)   t.window.title = "Untitled" -- The window title (string) t.window.icon = nil -- Filepath to an image to use as the window's icon (string) t.window.width = 800 -- The window width (number) t.window.height = 600 -- The window height (number) t.window.borderless = false -- Remove all border visuals from the window (boolean) t.window.resizable = false -- Let the window be user-resizable (boolean) t.window.minwidth = 1 -- Minimum window width if the window is resizable (number) t.window.minheight = 1 -- Minimum window height if the window is resizable (number) t.window.fullscreen = false -- Enable fullscreen (boolean) t.window.fullscreentype = "desktop" -- Choose between "desktop" fullscreen or "exclusive" fullscreen mode (string) t.window.vsync = 1 -- Vertical sync mode (number) t.window.msaa = 0 -- The number of samples to use with multi-sampled antialiasing (number) t.window.depth = nil -- The number of bits per sample in the depth buffer t.window.stencil = nil -- The number of bits per sample in the stencil buffer t.window.display = 1 -- Index of the monitor to show the window in (number) t.window.highdpi = false -- Enable high-dpi mode for the window on a Retina display (boolean) t.window.usedpiscale = true -- Enable automatic DPI scaling when highdpi is set to true as well (boolean) t.window.x = nil -- The x-coordinate of the window's position in the specified display (number) t.window.y = nil -- The y-coordinate of the window's position in the specified display (number)   t.modules.audio = true -- Enable the audio module (boolean) t.modules.data = true -- Enable the data module (boolean) t.modules.event = true -- Enable the event module (boolean) t.modules.font = true -- Enable the font module (boolean) t.modules.graphics = true -- Enable the graphics module (boolean) t.modules.image = true -- Enable the image module (boolean) t.modules.joystick = true -- Enable the joystick module (boolean) t.modules.keyboard = true -- Enable the keyboard module (boolean) t.modules.math = true -- Enable the math module (boolean) t.modules.mouse = true -- Enable the mouse module (boolean) t.modules.physics = true -- Enable the physics module (boolean) t.modules.sound = true -- Enable the sound module (boolean) t.modules.system = true -- Enable the system module (boolean) t.modules.thread = true -- Enable the thread module (boolean) t.modules.timer = true -- Enable the timer module (boolean), Disabling it will result 0 delta time in love.update t.modules.touch = true -- Enable the touch module (boolean) t.modules.video = true -- Enable the video module (boolean) t.modules.window = true -- Enable the window module (boolean) end ``` Flags ----- #### identity This flag determines the name of the save directory for your game. Note that you can only specify the name, not the location where it will be created: ``` t.identity = "gabe_HL3" -- Correct t.identity = "c:/Users/gabe/HL3" -- Incorrect ``` Alternatively [love.filesystem.setIdentity](love.filesystem.setidentity "love.filesystem.setIdentity") can be used to set the save directory outside of the config file. #### appendidentity **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This flag is not supported in earlier versions. This flag determines if game directory should be searched first then save directory (`true`) or otherwise (`false`) #### version **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This flag is not supported in earlier versions. `t.version` should be a string, representing the version of LÖVE for which your game was made. Before [11.0](https://love2d.org/wiki/11.0 "11.0"), it should be formatted as `"*X.Y.Z*"` where `*X*` is the major release number, `*Y*` the minor, and `*Z*` the patch level. Since 11.0, it should be formatted as `"*X.Y*"` where `*X*` and `*Y*` are the major and minor release respectively. If set in the config file of the game, LÖVE will display a warning if the game isn't compatible with the current version of LÖVE being used to run the game. Its default is the version of LÖVE running. #### console Determines whether a console should be opened alongside the game window (Windows only) or not. Note: On OSX you can get console output by running LÖVE through the terminal, or on Windows with LÖVE [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2"), by running `lovec.exe` instead of `love.exe`. #### accelerometerjoystick **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This flag is not supported in earlier versions. Sets whether the device accelerometer on iOS and Android should be exposed as a 3-axis [Joystick](joystick "Joystick"). Disabling the accelerometer when it's not used may reduce CPU usage. #### externalstorage **Available since LÖVE [0.10.1](https://love2d.org/wiki/0.10.1 "0.10.1")** This flag is not supported in earlier versions. Sets whether files are saved in external storage (true) or internal storage (false) on Android. #### gammacorrect **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This flag is not supported in earlier versions. Determines whether [gamma-correct rendering](love.graphics.isgammacorrect "love.graphics.isGammaCorrect") is enabled, when the system supports it. #### audio.mic **Available since LÖVE [11.3](https://love2d.org/wiki/11.3 "11.3")** This flag is not supported in earlier versions. Request microphone permission from the user. When user allows it, [love.audio.getRecordingDevices](love.audio.getrecordingdevices "love.audio.getRecordingDevices") will lists recording devices available. Otherwise, [love.audio.getRecordingDevices](love.audio.getrecordingdevices "love.audio.getRecordingDevices") returns empty table and a message is shown to inform user when called. #### audio.mixwithsystem **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This flag is not supported in earlier versions. Sets whether background audio / music from other apps should play while LÖVE is open. See [love.system.hasBackgroundMusic](love.system.hasbackgroundmusic "love.system.hasBackgroundMusic") for more details. #### window **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** These flags are not supported in earlier versions. It is possible to defer window creation until [love.window.setMode](love.window.setmode "love.window.setMode") is first called in your code. To do so, set `t.window = nil` in love.conf (or `t.screen = nil` in older versions.) If this is done, LÖVE may crash if any function from [love.graphics](love.graphics "love.graphics") is called before the first [love.window.setMode](love.window.setmode "love.window.setMode") in your code. The `t.window` table was named `t.screen` in versions prior to [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0"). The `t.screen` table doesn't exist in love.conf in 0.9.0, and the `t.window` table doesn't exist in love.conf in 0.8.0. This means **love.conf** will fail to execute (therefore it will fall back to default values) if care is not taken to use the correct table for the LÖVE version being used. #### window.title **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This flag is not supported in earlier versions. Sets the title of the window the game is in. Alternatively [love.window.setTitle](love.window.settitle "love.window.setTitle") can be used to change the window title outside of the config file. #### window.icon **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This flag is not supported in earlier versions. A filepath to an image to use as the window's icon. Not all operating systems support very large icon images. The icon can also be changed with [love.window.setIcon](love.window.seticon "love.window.setIcon"). #### window.width & window.height **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** These flags are not supported in earlier versions. Sets the window's dimensions. If these flags are set to 0 LÖVE automatically uses the user's desktop dimensions. #### window.borderless **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This flag is not supported in earlier versions. Removes all border visuals from the window. Note that the effects may wary between operating systems. #### window.resizable **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This flag is not supported in earlier versions. If set to true this allows the user to resize the game's window. #### window.minwidth & window.minheight **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** These flags are not supported in earlier versions. Sets the minimum width and height for the game's window if it can be resized by the user. If you set lower values to `window.width` and `window.height` LÖVE will always favor the minimum dimensions set via `window.minwidth` and `window.minheight`. #### window.fullscreen **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This flag is not supported in earlier versions. Wether to run the game in fullscreen (`true`) or windowed (`false`) mode. The fullscreen can also be toggled via [love.window.setFullscreen](love.window.setfullscreen "love.window.setFullscreen") or [love.window.setMode](love.window.setmode "love.window.setMode"). In [11.3](https://love2d.org/wiki/11.3 "11.3") for Android, setting this to `true` hides the status bar. #### window.fullscreentype **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This flag is not supported in earlier versions. Specifies the [type of fullscreen](fullscreentype "FullscreenType") mode to use (`exclusive` or `desktop`). Generally the `desktop` is recommended, as it is less restrictive than `exclusive` mode on some operating systems. (Note: In [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2") and earlier, use `normal` instead of `exclusive`.) #### window.vsync **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This flag is not supported in earlier versions. Enables or deactivates vertical synchronization. Vsync tries to keep the game at a steady framerate and can prevent issues like screen tearing. It is recommended to keep vsync activated if you don't know about the possible implications of turning it off. Before LÖVE 11.0, this value was boolean (`true` or `false`). Since LÖVE 11.0, this value is number (1 to enable vsync, 0 to disable vsync, -1 to use adaptive vsync when supported). Note that in iOS, vertical synchronization is always enabled and cannot be changed. #### window.depth **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This flag is not supported in earlier versions. The number of bits per sample in the depth buffer (16/24/32, default `nil`) #### window.stencil **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This flag is not supported in earlier versions. Then number of bits per sample in the stencil buffer (generally 8, default `nil`) #### window.msaa **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This flag is not supported in earlier versions. The number of samples to use with multi-sampled antialiasing. #### window.display **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This flag is not supported in earlier versions. The index of the display to show the window in, if multiple monitors are available. #### window.highdpi **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This flag is not supported in earlier versions. See [love.window.getDPIScale](love.window.getdpiscale "love.window.getDPIScale"). Allows the window's backbuffer to use the full pixel density of high-DPI displays on supported operating systems. LOVE will automatically scale things accordingly and use DPI-scaled units instead of pixels for most things (since [11.0](https://love2d.org/wiki/11.0 "11.0")) when this is true, unless the `usedpiscale` flag is set to false. When `highdpi` is false, the OS will keep things consistent between low-DPI and high-DPI displays by rendering to a low-resolution backbuffer and scaling that up on its own, when a high-DPI display is used. This flag currently does nothing on Windows, and on Android it's effectively always enabled. #### window.usedpiscale **Available since LÖVE [11.3](https://love2d.org/wiki/11.3 "11.3")** This flag is not supported in earlier versions. Disables LOVE's automatic DPI scaling on high-DPI displays when false. This only has an effect when the `highdpi` flag is set to true, since the OS (rather than LOVE) takes care of everything otherwise. #### window.x & window.y **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** These flags are not supported in earlier versions. Determines the position of the window on the user's screen. Alternatively [love.window.setPosition](love.window.setposition "love.window.setPosition") can be used to change the position on the fly. #### window.fsaa **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This flag has been replaced by the window.msaa flag. The number of samples to use with multi-sampled antialiasing. #### window.srgb **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This flag has been replaced by the gammacorrect flag. Enabling this window flag will automatically convert the colors of everything drawn to the main screen from the linear RGB colorspace to the sRGB colorspace - the window's surface is treated as gamma-space sRGB. This is only one component of gamma-correct rendering, an advanced topic which is easy to mess up, so it's recommended to keep this option disabled if you're not sure about its implications. #### Release Mode **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This flag is not supported in earlier or later versions. If `t.release` is enabled, LÖVE uses the [release error handler](love.releaseerrhand "love.releaseerrhand"), which is sparse on information by default, and can, of course, be overridden. The default release mode error handler also outputs a message to the player informing them to contact the author using the values *title, author and url* as specified in conf.lua. When a fused game in release mode is run it will not save in the love save dir, but rather one for itself, whereas previously it would be %APPDATA%\\LOVE\\game on Windows, it now is %APPDATA%\\game. This concept applies to other platforms as well. Older Versions -------------- Here is a full list of options and their default values for LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0") until [11.2](https://love2d.org/wiki/11.2 "11.2"): ``` function love.conf(t) t.identity = nil -- The name of the save directory (string) t.appendidentity = false -- Search files in source directory before save directory (boolean) t.version = "11.0" -- The LÖVE version this game was made for (string) t.console = false -- Attach a console (boolean, Windows only) t.accelerometerjoystick = true -- Enable the accelerometer on iOS and Android by exposing it as a Joystick (boolean) t.externalstorage = false -- True to save files (and read from the save directory) in external storage on Android (boolean) t.gammacorrect = false -- Enable gamma-correct rendering, when supported by the system (boolean)   t.audio.mixwithsystem = true -- Keep background music playing when opening LOVE (boolean, iOS and Android only)   t.window.title = "Untitled" -- The window title (string) t.window.icon = nil -- Filepath to an image to use as the window's icon (string) t.window.width = 800 -- The window width (number) t.window.height = 600 -- The window height (number) t.window.borderless = false -- Remove all border visuals from the window (boolean) t.window.resizable = false -- Let the window be user-resizable (boolean) t.window.minwidth = 1 -- Minimum window width if the window is resizable (number) t.window.minheight = 1 -- Minimum window height if the window is resizable (number) t.window.fullscreen = false -- Enable fullscreen (boolean) t.window.fullscreentype = "desktop" -- Choose between "desktop" fullscreen or "exclusive" fullscreen mode (string) t.window.vsync = 1 -- Vertical sync mode (number) t.window.msaa = 0 -- The number of samples to use with multi-sampled antialiasing (number) t.window.depth = nil -- The number of bits per sample in the depth buffer t.window.stencil = nil -- The number of bits per sample in the stencil buffer t.window.display = 1 -- Index of the monitor to show the window in (number) t.window.highdpi = false -- Enable high-dpi mode for the window on a Retina display (boolean) t.window.x = nil -- The x-coordinate of the window's position in the specified display (number) t.window.y = nil -- The y-coordinate of the window's position in the specified display (number)   t.modules.audio = true -- Enable the audio module (boolean) t.modules.data = true -- Enable the data module (boolean) t.modules.event = true -- Enable the event module (boolean) t.modules.font = true -- Enable the font module (boolean) t.modules.graphics = true -- Enable the graphics module (boolean) t.modules.image = true -- Enable the image module (boolean) t.modules.joystick = true -- Enable the joystick module (boolean) t.modules.keyboard = true -- Enable the keyboard module (boolean) t.modules.math = true -- Enable the math module (boolean) t.modules.mouse = true -- Enable the mouse module (boolean) t.modules.physics = true -- Enable the physics module (boolean) t.modules.sound = true -- Enable the sound module (boolean) t.modules.system = true -- Enable the system module (boolean) t.modules.thread = true -- Enable the thread module (boolean) t.modules.timer = true -- Enable the timer module (boolean), Disabling it will result 0 delta time in love.update t.modules.touch = true -- Enable the touch module (boolean) t.modules.video = true -- Enable the video module (boolean) t.modules.window = true -- Enable the window module (boolean) end ``` Here is a full list of options and their default values for LÖVE [0.10.1](https://love2d.org/wiki/0.10.1 "0.10.1") and [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2"): ``` function love.conf(t) t.identity = nil -- The name of the save directory (string) t.version = "0.10.2" -- The LÖVE version this game was made for (string) t.console = false -- Attach a console (boolean, Windows only) t.accelerometerjoystick = true -- Enable the accelerometer on iOS and Android by exposing it as a Joystick (boolean) t.externalstorage = false -- True to save files (and read from the save directory) in external storage on Android (boolean) t.gammacorrect = false -- Enable gamma-correct rendering, when supported by the system (boolean)   t.window.title = "Untitled" -- The window title (string) t.window.icon = nil -- Filepath to an image to use as the window's icon (string) t.window.width = 800 -- The window width (number) t.window.height = 600 -- The window height (number) t.window.borderless = false -- Remove all border visuals from the window (boolean) t.window.resizable = false -- Let the window be user-resizable (boolean) t.window.minwidth = 1 -- Minimum window width if the window is resizable (number) t.window.minheight = 1 -- Minimum window height if the window is resizable (number) t.window.fullscreen = false -- Enable fullscreen (boolean) t.window.fullscreentype = "desktop" -- Choose between "desktop" fullscreen or "exclusive" fullscreen mode (string) t.window.vsync = true -- Enable vertical sync (boolean) t.window.msaa = 0 -- The number of samples to use with multi-sampled antialiasing (number) t.window.display = 1 -- Index of the monitor to show the window in (number) t.window.highdpi = false -- Enable high-dpi mode for the window on a Retina display (boolean) t.window.x = nil -- The x-coordinate of the window's position in the specified display (number) t.window.y = nil -- The y-coordinate of the window's position in the specified display (number)   t.modules.audio = true -- Enable the audio module (boolean) t.modules.event = true -- Enable the event module (boolean) t.modules.graphics = true -- Enable the graphics module (boolean) t.modules.image = true -- Enable the image module (boolean) t.modules.joystick = true -- Enable the joystick module (boolean) t.modules.keyboard = true -- Enable the keyboard module (boolean) t.modules.math = true -- Enable the math module (boolean) t.modules.mouse = true -- Enable the mouse module (boolean) t.modules.physics = true -- Enable the physics module (boolean) t.modules.sound = true -- Enable the sound module (boolean) t.modules.system = true -- Enable the system module (boolean) t.modules.timer = true -- Enable the timer module (boolean), Disabling it will result 0 delta time in love.update t.modules.touch = true -- Enable the touch module (boolean) t.modules.video = true -- Enable the video module (boolean) t.modules.window = true -- Enable the window module (boolean) t.modules.thread = true -- Enable the thread module (boolean) end ``` Here is a full list of options and their default values for LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0"): ``` function love.conf(t) t.identity = nil -- The name of the save directory (string) t.version = "0.10.0" -- The LÖVE version this game was made for (string) t.console = false -- Attach a console (boolean, Windows only) t.accelerometerjoystick = true -- Enable the accelerometer on iOS and Android by exposing it as a Joystick (boolean) t.gammacorrect = false -- Enable gamma-correct rendering, when supported by the system (boolean)   t.window.title = "Untitled" -- The window title (string) t.window.icon = nil -- Filepath to an image to use as the window's icon (string) t.window.width = 800 -- The window width (number) t.window.height = 600 -- The window height (number) t.window.borderless = false -- Remove all border visuals from the window (boolean) t.window.resizable = false -- Let the window be user-resizable (boolean) t.window.minwidth = 1 -- Minimum window width if the window is resizable (number) t.window.minheight = 1 -- Minimum window height if the window is resizable (number) t.window.fullscreen = false -- Enable fullscreen (boolean) t.window.fullscreentype = "desktop" -- Choose between "desktop" fullscreen or "exclusive" fullscreen mode (string) t.window.vsync = true -- Enable vertical sync (boolean) t.window.msaa = 0 -- The number of samples to use with multi-sampled antialiasing (number) t.window.display = 1 -- Index of the monitor to show the window in (number) t.window.highdpi = false -- Enable high-dpi mode for the window on a Retina display (boolean) t.window.x = nil -- The x-coordinate of the window's position in the specified display (number) t.window.y = nil -- The y-coordinate of the window's position in the specified display (number)   t.modules.audio = true -- Enable the audio module (boolean) t.modules.event = true -- Enable the event module (boolean) t.modules.graphics = true -- Enable the graphics module (boolean) t.modules.image = true -- Enable the image module (boolean) t.modules.joystick = true -- Enable the joystick module (boolean) t.modules.keyboard = true -- Enable the keyboard module (boolean) t.modules.math = true -- Enable the math module (boolean) t.modules.mouse = true -- Enable the mouse module (boolean) t.modules.physics = true -- Enable the physics module (boolean) t.modules.sound = true -- Enable the sound module (boolean) t.modules.system = true -- Enable the system module (boolean) t.modules.timer = true -- Enable the timer module (boolean), Disabling it will result 0 delta time in love.update t.modules.touch = true -- Enable the touch module (boolean) t.modules.video = true -- Enable the video module (boolean) t.modules.window = true -- Enable the window module (boolean) t.modules.thread = true -- Enable the thread module (boolean) end ``` Here is a full list of options and their default values for LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2"): ``` function love.conf(t) t.identity = nil -- The name of the save directory (string) t.version = "0.9.2" -- The LÖVE version this game was made for (string) t.console = false -- Attach a console (boolean, Windows only)   t.window.title = "Untitled" -- The window title (string) t.window.icon = nil -- Filepath to an image to use as the window's icon (string) t.window.width = 800 -- The window width (number) t.window.height = 600 -- The window height (number) t.window.borderless = false -- Remove all border visuals from the window (boolean) t.window.resizable = false -- Let the window be user-resizable (boolean) t.window.minwidth = 1 -- Minimum window width if the window is resizable (number) t.window.minheight = 1 -- Minimum window height if the window is resizable (number) t.window.fullscreen = false -- Enable fullscreen (boolean) t.window.fullscreentype = "normal" -- Choose between "normal" fullscreen or "desktop" fullscreen mode (string) t.window.vsync = true -- Enable vertical sync (boolean) t.window.fsaa = 0 -- The number of samples to use with multi-sampled antialiasing (number) t.window.display = 1 -- Index of the monitor to show the window in (number) t.window.highdpi = false -- Enable high-dpi mode for the window on a Retina display (boolean) t.window.srgb = false -- Enable sRGB gamma correction when drawing to the screen (boolean) t.window.x = nil -- The x-coordinate of the window's position in the specified display (number) t.window.y = nil -- The y-coordinate of the window's position in the specified display (number)   t.modules.audio = true -- Enable the audio module (boolean) t.modules.event = true -- Enable the event module (boolean) t.modules.graphics = true -- Enable the graphics module (boolean) t.modules.image = true -- Enable the image module (boolean) t.modules.joystick = true -- Enable the joystick module (boolean) t.modules.keyboard = true -- Enable the keyboard module (boolean) t.modules.math = true -- Enable the math module (boolean) t.modules.mouse = true -- Enable the mouse module (boolean) t.modules.physics = true -- Enable the physics module (boolean) t.modules.sound = true -- Enable the sound module (boolean) t.modules.system = true -- Enable the system module (boolean) t.modules.timer = true -- Enable the timer module (boolean), Disabling it will result 0 delta time in love.update t.modules.window = true -- Enable the window module (boolean) t.modules.thread = true -- Enable the thread module (boolean) end ``` Here is a full list of options and their default values for LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1"): ``` function love.conf(t) t.identity = nil -- The name of the save directory (string) t.version = "0.9.1" -- The LÖVE version this game was made for (string) t.console = false -- Attach a console (boolean, Windows only)   t.window.title = "Untitled" -- The window title (string) t.window.icon = nil -- Filepath to an image to use as the window's icon (string) t.window.width = 800 -- The window width (number) t.window.height = 600 -- The window height (number) t.window.borderless = false -- Remove all border visuals from the window (boolean) t.window.resizable = false -- Let the window be user-resizable (boolean) t.window.minwidth = 1 -- Minimum window width if the window is resizable (number) t.window.minheight = 1 -- Minimum window height if the window is resizable (number) t.window.fullscreen = false -- Enable fullscreen (boolean) t.window.fullscreentype = "normal" -- Standard fullscreen or desktop fullscreen mode (string) t.window.vsync = true -- Enable vertical sync (boolean) t.window.fsaa = 0 -- The number of samples to use with multi-sampled antialiasing (number) t.window.display = 1 -- Index of the monitor to show the window in (number) t.window.highdpi = false -- Enable high-dpi mode for the window on a Retina display (boolean) t.window.srgb = false -- Enable sRGB gamma correction when drawing to the screen (boolean)   t.modules.audio = true -- Enable the audio module (boolean) t.modules.event = true -- Enable the event module (boolean) t.modules.graphics = true -- Enable the graphics module (boolean) t.modules.image = true -- Enable the image module (boolean) t.modules.joystick = true -- Enable the joystick module (boolean) t.modules.keyboard = true -- Enable the keyboard module (boolean) t.modules.math = true -- Enable the math module (boolean) t.modules.mouse = true -- Enable the mouse module (boolean) t.modules.physics = true -- Enable the physics module (boolean) t.modules.sound = true -- Enable the sound module (boolean) t.modules.system = true -- Enable the system module (boolean) t.modules.timer = true -- Enable the timer module (boolean) t.modules.window = true -- Enable the window module (boolean) t.modules.thread = true -- Enable the thread module (boolean) end ``` Here is a full list of options and their default values for LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0"): ``` function love.conf(t) t.identity = nil -- The name of the save directory (string) t.version = "0.9.0" -- The LÖVE version this game was made for (string) t.console = false -- Attach a console (boolean, Windows only)   t.window.title = "Untitled" -- The window title (string) t.window.icon = nil -- Filepath to an image to use as the window's icon (string) t.window.width = 800 -- The window width (number) t.window.height = 600 -- The window height (number) t.window.borderless = false -- Remove all border visuals from the window (boolean) t.window.resizable = false -- Let the window be user-resizable (boolean) t.window.minwidth = 1 -- Minimum window width if the window is resizable (number) t.window.minheight = 1 -- Minimum window height if the window is resizable (number) t.window.fullscreen = false -- Enable fullscreen (boolean) t.window.fullscreentype = "normal" -- Standard fullscreen or desktop fullscreen mode (string) t.window.vsync = true -- Enable vertical sync (boolean) t.window.fsaa = 0 -- The number of samples to use with multi-sampled antialiasing (number) t.window.display = 1 -- Index of the monitor to show the window in (number)   t.modules.audio = true -- Enable the audio module (boolean) t.modules.event = true -- Enable the event module (boolean) t.modules.graphics = true -- Enable the graphics module (boolean) t.modules.image = true -- Enable the image module (boolean) t.modules.joystick = true -- Enable the joystick module (boolean) t.modules.keyboard = true -- Enable the keyboard module (boolean) t.modules.math = true -- Enable the math module (boolean) t.modules.mouse = true -- Enable the mouse module (boolean) t.modules.physics = true -- Enable the physics module (boolean) t.modules.sound = true -- Enable the sound module (boolean) t.modules.system = true -- Enable the system module (boolean) t.modules.timer = true -- Enable the timer module (boolean) t.modules.window = true -- Enable the window module (boolean) t.modules.thread = true -- Enable the thread module (boolean) end ``` Here is a full list of options and their default values for LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0"): ``` function love.conf(t) t.title = "Untitled" -- The title of the window the game is in (string) t.author = "Unnamed" -- The author of the game (string) t.url = nil -- The website of the game (string) t.identity = nil -- The name of the save directory (string) t.version = "0.8.0" -- The LÖVE version this game was made for (string) t.console = false -- Attach a console (boolean, Windows only) t.release = false -- Enable release mode (boolean) t.screen.width = 800 -- The window width (number) t.screen.height = 600 -- The window height (number) t.screen.fullscreen = false -- Enable fullscreen (boolean) t.screen.vsync = true -- Enable vertical sync (boolean) t.screen.fsaa = 0 -- The number of MSAA samples (number) t.modules.joystick = true -- Enable the joystick module (boolean) t.modules.audio = true -- Enable the audio module (boolean) t.modules.keyboard = true -- Enable the keyboard module (boolean) t.modules.event = true -- Enable the event module (boolean) t.modules.image = true -- Enable the image module (boolean) t.modules.graphics = true -- Enable the graphics module (boolean) t.modules.timer = true -- Enable the timer module (boolean) t.modules.mouse = true -- Enable the mouse module (boolean) t.modules.sound = true -- Enable the sound module (boolean) t.modules.physics = true -- Enable the physics module (boolean) t.modules.thread = true -- Enable the thread module (boolean) end ``` Here is a full list of options and their default values for LÖVE [0.7.2](https://love2d.org/wiki/0.7.2 "0.7.2") and earlier: ``` function love.conf(t) t.title = "Untitled" -- The title of the window the game is in (string) t.author = "Unnamed" -- The author of the game (string) t.identity = nil -- The name of the save directory (string) t.version = 0 -- The LÖVE version this game was made for (number) t.console = false -- Attach a console (boolean, Windows only) t.screen.width = 800 -- The window width (number) t.screen.height = 600 -- The window height (number) t.screen.fullscreen = false -- Enable fullscreen (boolean) t.screen.vsync = true -- Enable vertical sync (boolean) t.screen.fsaa = 0 -- The number of MSAA samples (number) t.modules.joystick = true -- Enable the joystick module (boolean) t.modules.audio = true -- Enable the audio module (boolean) t.modules.keyboard = true -- Enable the keyboard module (boolean) t.modules.event = true -- Enable the event module (boolean) t.modules.image = true -- Enable the image module (boolean) t.modules.graphics = true -- Enable the graphics module (boolean) t.modules.timer = true -- Enable the timer module (boolean) t.modules.mouse = true -- Enable the mouse module (boolean) t.modules.sound = true -- Enable the sound module (boolean) t.modules.physics = true -- Enable the physics module (boolean) end ``` See Also -------- * [love](love "love")
programming_docs
love Thread:set Thread:set ========== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been moved to the [Channel](channel "Channel") API. Sets a value in the message box of the thread. The name of the message can be any string. The value of the message can be a boolean, string, number or a LÖVE userdata. Foreign userdata (Lua's files, LuaSocket, ...), functions or tables are not supported. Function -------- ### Synopsis ``` Thread:set(name, value) ``` ### Arguments `[string](string "string") name` The name of the message. `[boolean, string, number or LÖVE userdata](https://love2d.org/w/index.php?title=boolean,_string,_number_or_L%C3%96VE_userdata&action=edit&redlink=1 "boolean, string, number or LÖVE userdata (page does not exist)") value` The contents of the message. ### Returns None. See Also -------- * [Thread](thread "Thread") * [Thread:get](thread-get "Thread:get") love GlyphData:getAdvance GlyphData:getAdvance ==================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Gets glyph advance. Function -------- ### Synopsis ``` advance = GlyphData:getAdvance() ``` ### Arguments None. ### Returns `[number](number "number") advance` Glyph advance. See Also -------- * [GlyphData](glyphdata "GlyphData") love BezierCurve:renderSegment BezierCurve:renderSegment ========================= **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Get a list of coordinates on a specific part of the curve, to be used with [love.graphics.line](love.graphics.line "love.graphics.line"). This function samples the Bézier curve using recursive subdivision. You can control the recursion depth using the depth parameter. If you are just need to know the position on the curve given a parameter, use [BezierCurve:evaluate](beziercurve-evaluate "BezierCurve:evaluate"). Function -------- ### Synopsis ``` coordinates = BezierCurve:renderSegment( startpoint, endpoint, depth ) ``` ### Arguments `[number](number "number") startpoint` The starting point along the curve. Must be between 0 and 1. `[number](number "number") endpoint` The end of the segment to render. Must be between 0 and 1. `[number](number "number") depth (5)` Number of recursive subdivision steps. ### Returns `[table](table "table") coordinates` List of x,y-coordinate pairs of points on the specified part of the curve. Example ------- ### Draw a segment of a bezier curve ``` curve = love.math.newBezierCurve({25,25,75,50,125,25}) function love.draw() love.graphics.line(curve:renderSegment(0, .75)) end ``` See Also -------- * [BezierCurve](beziercurve "BezierCurve") * [BezierCurve:render](beziercurve-render "BezierCurve:render") * [BezierCurve:evaluate](beziercurve-evaluate "BezierCurve:evaluate") * [love.math](love.math "love.math") love Joystick:getVibration Joystick:getVibration ===================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the current vibration motor strengths on a Joystick with rumble support. Function -------- ### Synopsis ``` left, right = Joystick:getVibration( ) ``` ### Arguments None. ### Returns `[number](number "number") left` Current strength of the left vibration motor on the Joystick. `[number](number "number") right` Current strength of the right vibration motor on the Joystick. See Also -------- * [Joystick](joystick "Joystick") * [Joystick:setVibration](joystick-setvibration "Joystick:setVibration") * [Joystick:isVibrationSupported](joystick-isvibrationsupported "Joystick:isVibrationSupported") love love.visible love.visible ============ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This callback is not supported in earlier versions. Callback function triggered when window is minimized/hidden or unminimized by the user. Function -------- ### Synopsis ``` love.visible( visible ) ``` ### Arguments `[boolean](boolean "boolean") visible` True if the window is visible, false if it isn't. ### Returns Nothing. Example ------- ``` function love.visible(v) print(v and "Window is visible!" or "Window is not visible!"); end ``` See Also -------- * [love](love "love") love love.math.colorFromBytes love.math.colorFromBytes ======================== **Available since LÖVE [11.3](https://love2d.org/wiki/11.3 "11.3")** This function is not supported in earlier versions. Converts a color from 0..255 to 0..1 range. Function -------- ### Synopsis ``` r, g, b, a = love.math.colorFromBytes( rb, gb, bb, ab ) ``` ### Arguments `[number](number "number") rb` Red color component in 0..255 range. `[number](number "number") gb` Green color component in 0..255 range. `[number](number "number") bb` Blue color component in 0..255 range. `[number](number "number") ab (nil)` Alpha color component in 0..255 range. ### Returns `[number](number "number") r` Red color component in 0..1 range. `[number](number "number") g` Green color component in 0..1 range. `[number](number "number") b` Blue color component in 0..1 range. `[number](number "number") a (nil)` Alpha color component in 0..1 range or nil if alpha is not specified. Notes ----- Here's implementation for [11.2](https://love2d.org/wiki/11.2 "11.2") and earlier. ``` function love.math.colorFromBytes(r, g, b, a) if type(r) == "table" then r, g, b, a = r[1], r[2], r[3], r[4] end r = clamp01(floor(r + 0.5) / 255) g = clamp01(floor(g + 0.5) / 255) b = clamp01(floor(b + 0.5) / 255) a = a ~= nil and clamp01(floor(a + 0.5) / 255) or nil return r, g, b, a end ``` Where `clamp01` is defined as follows ``` local function clamp01(x) return math.min(math.max(x, 0), 1) end ``` See Also -------- * [love.math](love.math "love.math") * [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor") * [love.math.colorToBytes](love.math.colortobytes "love.math.colorToBytes") love CompressedImageData:getDimensions CompressedImageData:getDimensions ================================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the width and height of the [CompressedImageData](compressedimagedata "CompressedImageData"). Function -------- ### Synopsis ``` width, height = CompressedImageData:getDimensions( ) ``` ### Arguments None. ### Returns `[number](number "number") width` The width of the CompressedImageData. `[number](number "number") height` The height of the CompressedImageData. Function -------- ### Synopsis ``` width, height = CompressedImageData:getDimensions( level ) ``` ### Arguments `[number](number "number") level` A mipmap level. Must be in the range of [1, [CompressedImageData:getMipmapCount()](compressedimagedata-getmipmapcount "CompressedImageData:getMipmapCount")]. ### Returns `[number](number "number") width` The width of a specific mipmap level of the CompressedImageData. `[number](number "number") height` The height of a specific mipmap level of the CompressedImageData. See Also -------- * [CompressedImageData](compressedimagedata "CompressedImageData") * [CompressedImageData:getMipmapCount](compressedimagedata-getmipmapcount "CompressedImageData:getMipmapCount") love SpriteBatch:setColor SpriteBatch:setColor ==================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Sets the color that will be used for the next add and set operations. Calling the function without arguments will disable all per-sprite colors for the SpriteBatch. In versions prior to [11.0](https://love2d.org/wiki/11.0 "11.0"), color component values were within the range of 0 to 255 instead of 0 to 1. In version [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2") and older, the global color set with love.graphics.setColor will not work on the SpriteBatch if any of the sprites has its own color. Function -------- ### Synopsis ``` SpriteBatch:setColor( r, g, b, a ) ``` ### Arguments `[number](number "number") r` The amount of red. `[number](number "number") g` The amount of green. `[number](number "number") b` The amount of blue. `[number](number "number") a (1)` The amount of alpha. ### Returns Nothing. Function -------- Disables all per-sprite colors for this SpriteBatch. ### Synopsis ``` SpriteBatch:setColor( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [SpriteBatch](spritebatch "SpriteBatch") * [SpriteBatch:getColor](spritebatch-getcolor "SpriteBatch:getColor") * [SpriteBatch:add](spritebatch-add "SpriteBatch:add") * [SpriteBatch:set](spritebatch-set "SpriteBatch:set") love World:setAllowSleeping World:setAllowSleeping ====================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [World:setSleepingAllowed](world-setsleepingallowed "World:setSleepingAllowed"). Sets the sleep behaviour of the world. Function -------- ### Synopsis ``` World:setAllowSleeping( allowSleep ) ``` ### Arguments `[boolean](boolean "boolean") allowSleep` True if the bodies are allowed to sleep or false if not. ### Returns Nothing. See Also -------- * [World](world "World") * [World:getAllowSleeping](world-getallowsleeping "World:getAllowSleeping") love Body:getAngularDamping Body:getAngularDamping ====================== Gets the Angular damping of the Body The angular damping is the *rate of decrease of the angular velocity over time*: A spinning body with no damping and no external forces will continue spinning indefinitely. A spinning body with damping will gradually stop spinning. Damping is not the same as friction - they can be modelled together. However, only damping is provided by Box2D (and LOVE). Damping parameters should be between 0 and infinity, with 0 meaning no damping, and infinity meaning full damping. Normally you will use a damping value between 0 and 0.1. Function -------- ### Synopsis ``` damping = Body:getAngularDamping( ) ``` ### Arguments None. ### Returns `[number](number "number") damping` The value of the angular damping. See Also -------- * [Body](body "Body") * [Body:setAngularDamping](body-setangulardamping "Body:setAngularDamping") * [Body:getLinearDamping](body-getlineardamping "Body:getLinearDamping") love Body:getMass Body:getMass ============ Get the mass of the body. Static bodies always have a mass of 0. Function -------- ### Synopsis ``` mass = Body:getMass( ) ``` ### Arguments None. ### Returns `[number](number "number") mass` The mass of the body (in kilograms). See Also -------- * [Body](body "Body") love RandomGenerator:setState RandomGenerator:setState ======================== **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. Sets the current state of the random number generator. The value used as an argument for this function is an opaque string and should only originate from a previous call to [RandomGenerator:getState](randomgenerator-getstate "RandomGenerator:getState") in the same major version of LÖVE. This is different from [RandomGenerator:setSeed](randomgenerator-setseed "RandomGenerator:setSeed") in that setState directly sets the RandomGenerator's current implementation-dependent state, whereas setSeed gives it a new seed value. Function -------- ### Synopsis ``` RandomGenerator:setState( state ) ``` ### Arguments `[string](string "string") state` The new state of the RandomGenerator object, represented as a string. This should originate from a previous call to [RandomGenerator:getState](randomgenerator-getstate "RandomGenerator:getState"). ### Returns Nothing. Notes ----- The effect of the state string does not depend on the current operating system. Examples -------- ``` rng = love.math.newRandomGenerator(os.time())   for i=1, 100 do -- Use some random numbers. rng:random() end   -- Make a new RandomGenerator and set its state to the current state of the first one. rng2 = love.math.newRandomGenerator() rng2:setState(rng:getState())   -- Both 'rng' and 'rng2' will now give the same results. assert(rng:random() == rng2:random()) ``` See Also -------- * [RandomGenerator](randomgenerator "RandomGenerator") * [RandomGenerator:getState](randomgenerator-getstate "RandomGenerator:getState") love Fixture:setCategory Fixture:setCategory =================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Sets the categories the fixture belongs to. There can be up to 16 categories represented as a number from 1 to 16. All fixture's default category is 1. Function -------- ### Synopsis ``` Fixture:setCategory( category1, category2, ... ) ``` ### Arguments `[number](number "number") category1` The first category. `[number](number "number") category2` The second category. ### Returns Nothing. See Also -------- * [Fixture](fixture "Fixture") * [Fixture:getCategory](fixture-getcategory "Fixture:getCategory") love Fixture:getUserData Fixture:getUserData =================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the Lua value associated with this fixture. Use this function in one thread and one thread only. Using it in more threads will make Lua cry and most likely crash. Function -------- ### Synopsis ``` value = Fixture:getUserData( ) ``` ### Arguments None. ### Returns `[any](https://love2d.org/w/index.php?title=any&action=edit&redlink=1 "any (page does not exist)") value` The Lua value associated with the fixture. See Also -------- * [Fixture](fixture "Fixture") * [Fixture:setUserData](fixture-setuserdata "Fixture:setUserData") love Thread:getError Thread:getError =============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Retrieves the error string from the thread if it produced an error. Function -------- ### Synopsis ``` err = Thread:getError( ) ``` ### Arguments None. ### Returns `[string](string "string") err (nil)` The error message, or nil if the Thread has not caused an error. See Also -------- * [Thread](thread "Thread") * [love.threaderror](love.threaderror "love.threaderror") love RevoluteJoint:enableLimit RevoluteJoint:enableLimit ========================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [RevoluteJoint:setLimitsEnabled](revolutejoint-setlimitsenabled "RevoluteJoint:setLimitsEnabled"). Enables or disables the joint limits. Function -------- ### Synopsis ``` RevoluteJoint:enableLimit( enable ) ``` ### Arguments `[boolean](boolean "boolean") enable` True to enable, false to disable. ### Returns Nothing. See Also -------- * [RevoluteJoint](revolutejoint "RevoluteJoint") * [RevoluteJoint:isLimitsEnabled](revolutejoint-islimitsenabled "RevoluteJoint:isLimitsEnabled") * [RevoluteJoint:setLimits](revolutejoint-setlimits "RevoluteJoint:setLimits") love Shape:isSensor Shape:isSensor ============== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in that and later versions. Checks whether a Shape is a sensor or not. Function -------- ### Synopsis ``` s = Shape:isSensor( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") s` True if sensor, false otherwise. See Also -------- * [Shape](shape "Shape") love love.font.newGlyphData love.font.newGlyphData ====================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Creates a new GlyphData. Function -------- ### Synopsis ``` glyphData = love.font.newGlyphData( rasterizer, glyph ) ``` ### Arguments `[Rasterizer](rasterizer "Rasterizer") rasterizer` The Rasterizer containing the font. `[number](number "number") glyph` The character code of the glyph. ### Returns `[GlyphData](glyphdata "GlyphData") glyphData` The GlyphData. See Also -------- * [love.font](love.font "love.font") * [GlyphData](glyphdata "GlyphData") love love.mouse.setX love.mouse.setX =============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Sets the current X position of the mouse. Non-integer values are floored. Function -------- ### Synopsis ``` love.mouse.setX( x ) ``` ### Arguments `[number](number "number") x` The new position of the mouse along the x-axis. ### Returns Nothing. See Also -------- * [love.mouse](love.mouse "love.mouse") * [love.mouse.setPosition](love.mouse.setposition "love.mouse.setPosition") * [love.mouse.setY](love.mouse.sety "love.mouse.setY") * [love.mouse.getX](love.mouse.getx "love.mouse.getX") love love.graphics.newFramebuffer love.graphics.newFramebuffer ============================ **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0") and removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been renamed to [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas"). Creates a new framebuffer object for offscreen rendering. Versions prior to 0.8.0 have Framebuffers that are susceptible to [power of 2 syndrome](https://love2d.org/wiki/PO2_Syndrome "PO2 Syndrome"). This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- ### Synopsis ``` framebuffer = love.graphics.newFramebuffer( ) ``` ### Arguments None. ### Returns `[Framebuffer](framebuffer "Framebuffer") framebuffer` A new framebuffer with width/height equal to the window width/height. Function -------- ### Synopsis ``` framebuffer = love.graphics.newFramebuffer( width, height ) ``` ### Arguments `[number](number "number") width` The desired width of the framebuffer. `[number](number "number") height` The desired height of the framebuffer. ### Returns `[Framebuffer](framebuffer "Framebuffer") framebuffer` A new framebuffer with specified width and height. See Also -------- * [love.graphics](love.graphics "love.graphics") * [Framebuffer](framebuffer "Framebuffer") * [love.graphics.setRenderTarget](love.graphics.setrendertarget "love.graphics.setRenderTarget") love Shape:computeAABB Shape:computeAABB ================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Returns the points of the bounding box for the transformed shape. Function -------- ### Synopsis ``` topLeftX, topLeftY, bottomRightX, bottomRightY = Shape:computeAABB( tx, ty, tr, childIndex ) ``` ### Arguments `[number](number "number") tx` The translation of the shape on the x-axis. `[number](number "number") ty` The translation of the shape on the y-axis. `[number](number "number") tr` The shape rotation. `[number](number "number") childIndex (1)` The index of the child to compute the bounding box of. ### Returns `[number](number "number") topLeftX` The x position of the top-left point. `[number](number "number") topLeftY` The y position of the top-left point. `[number](number "number") bottomRightX` The x position of the bottom-right point. `[number](number "number") bottomRightY` The y position of the bottom-right point. See Also -------- * [Shape](shape "Shape")
programming_docs
love PrismaticJoint:setMotorEnabled PrismaticJoint:setMotorEnabled ============================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in that version. **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed again. Enables/disables the joint motor. Function -------- ### Synopsis ``` PrismaticJoint:setMotorEnabled( enable ) ``` ### Arguments `[boolean](boolean "boolean") enable` True to enable, false to disable. ### Returns Nothing. See Also -------- * [PrismaticJoint](prismaticjoint "PrismaticJoint") love AttributeDataType AttributeDataType ================= Data types used in a Mesh's Vertex format Constants --------- byte An 8-bit normalized (from 0 to 1) value. unorm16 A 16-bit normalized (from 0 to 1) value. float A floating point number. See Also -------- * [Mesh:getVertexFormat](mesh-getvertexformat "Mesh:getVertexFormat") * [love.graphics.newMesh](love.graphics.newmesh "love.graphics.newMesh") * [Mesh](mesh "Mesh") love love.graphics.getColorMask love.graphics.getColorMask ========================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the active color components used when drawing. Normally all 4 components are active unless [love.graphics.setColorMask](love.graphics.setcolormask "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](love.graphics.clear "love.graphics.clear") and [Canvas:clear](canvas-clear "Canvas:clear") as well. Function -------- ### Synopsis ``` r, g, b, a = love.graphics.getColorMask( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") r` Whether the red color component is active when rendering. `[boolean](boolean "boolean") g` Whether the green color component is active when rendering. `[boolean](boolean "boolean") b` Whether the blue color component is active when rendering. `[boolean](boolean "boolean") a` Whether the alpha color component is active when rendering. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setColorMask](love.graphics.setcolormask "love.graphics.setColorMask") love love.graphics.setDefaultImageFilter love.graphics.setDefaultImageFilter =================================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [love.graphics.setDefaultFilter](love.graphics.setdefaultfilter "love.graphics.setDefaultFilter"). Sets the default scaling filters. Function -------- ### Synopsis ``` love.graphics.setDefaultImageFilter( min, mag ) ``` ### Arguments `[FilterMode](filtermode "FilterMode") min` Filter mode used when scaling the image down. `[FilterMode](filtermode "FilterMode") mag` Filter mode used when scaling the image up. ### Returns Nothing. Notes ----- This function does not apply retroactively to loaded images. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getDefaultImageFilter](love.graphics.getdefaultimagefilter "love.graphics.getDefaultImageFilter") love Rasterizer:getGlyphCount Rasterizer:getGlyphCount ======================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Gets number of glyphs in font. Function -------- ### Synopsis ``` count = Rasterizer:getGlyphCount() ``` ### Arguments None. ### Returns `[number](number "number") count` Glyphs count. See Also -------- * [Rasterizer](rasterizer "Rasterizer") * [GlyphData](glyphdata "GlyphData") love MeshDrawMode MeshDrawMode ============ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This enum is not supported in earlier versions. How a [Mesh](mesh "Mesh")'s vertices are used when drawing. Constants --------- fan The vertices create a "fan" shape with the first vertex acting as the hub point. Can be easily used to draw simple convex polygons. strip The vertices create a series of connected triangles using vertices 1, 2, 3, then 3, 2, 4 (note the order), then 3, 4, 5, and so on. triangles The vertices create unconnected triangles. points The vertices are drawn as unconnected points (see [love.graphics.setPointSize](love.graphics.setpointsize "love.graphics.setPointSize").) Notes ----- If the Mesh has a custom [vertex map](mesh-setvertexmap "Mesh:setVertexMap"), then that will determine the order in which the vertices are interpreted by the draw mode. The vertex map can also be used to make the draw mode reuse vertices, for example if the Mesh has 4 vertices and is using the "triangles" draw mode, the vertex map could be set to {1, 2, 3, 1, 3, 4} to draw 2 triangles using only 4 vertices, effectively drawing a quad using triangles. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.newMesh](love.graphics.newmesh "love.graphics.newMesh") * [Mesh](mesh "Mesh") love ParticleSystem:isActive ParticleSystem:isActive ======================= Checks whether the particle system is actively emitting particles. Function -------- ### Synopsis ``` active = ParticleSystem:isActive( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") active` True if system is active, false otherwise. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:isPaused](particlesystem-ispaused "ParticleSystem:isPaused") * [ParticleSystem:isStopped](particlesystem-isstopped "ParticleSystem:isStopped") love Transform:translate Transform:translate =================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Applies a translation to the Transform's coordinate system. This method does not reset any previously applied transformations. Function -------- ### Synopsis ``` transform = Transform:translate( dx, dy ) ``` ### Arguments `[number](number "number") dx` The relative translation along the x-axis. `[number](number "number") dy` The relative translation along the y-axis. ### Returns `[Transform](transform "Transform") transform` The Transform object the method was called on. Allows easily chaining Transform methods. See Also -------- * [Transform](transform "Transform") * [Transform:reset](transform-reset "Transform:reset") * [Transform:rotate](transform-rotate "Transform:rotate") * [Transform:scale](transform-scale "Transform:scale") * [Transform:shear](transform-shear "Transform:shear") * [Transform:setTransformation](transform-settransformation "Transform:setTransformation") love love.graphics.newPixelEffect love.graphics.newPixelEffect ============================ **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [love.graphics.newShader](love.graphics.newshader "love.graphics.newShader"). Creates a new PixelEffect object for hardware-accelerated pixel level effects. A PixelEffect contains at least one function, named `effect`, which is the effect itself, but it can contain additional functions. Function -------- ### Synopsis ``` pixeleffect = love.graphics.newPixelEffect( code ) ``` ### Arguments `[string](string "string") code` The pixel effect code. ### Returns `[PixelEffect](pixeleffect "PixelEffect") pixeleffect` A PixelEffect object for use in drawing operations. Effect Language --------------- Pixel effects are not programmed in Lua, but by using a special effect language instead. The effect language is basically [GLSL 1.20](https://www.opengl.org/sdk/docs/manglsl/) ([specs](https://www.opengl.org/registry/doc/GLSLangSpec.Full.1.20.8.pdf)) with a few aliases added for existing types: | GLSL | Effect language | | --- | --- | | float | number | | sampler2D | Image | | uniform | extern | | texture2D(tex, uv) | Texel(tex, uv) | Effect Function --------------- ### Synopsis ``` vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords ) ``` ### Arguments `[vec4](https://love2d.org/w/index.php?title=vec4&action=edit&redlink=1 "vec4 (page does not exist)") color` The drawing color set with [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor"). `[Image](image "Image") texture` The texture of the image or canvas being drawn. `[vec2](https://love2d.org/w/index.php?title=vec2&action=edit&redlink=1 "vec2 (page does not exist)") texture_coords` Coordinates of the pixel relative to the texture. The y-axis of canvases are inverted. Coordinates (1,1) would be the top right corner of the canvas. `[vec2](https://love2d.org/w/index.php?title=vec2&action=edit&redlink=1 "vec2 (page does not exist)") screen_coords` Coordinates of the pixel on the screen. Pixel coordinates are not normalized (unlike texture coordinates). (0.5, 0.5) is the bottom left of the screen. ### Returns `[vec4](https://love2d.org/w/index.php?title=vec4&action=edit&redlink=1 "vec4 (page does not exist)") output_color` The color of the pixel. See Also -------- * [love.graphics](love.graphics "love.graphics") * [PixelEffect](pixeleffect "PixelEffect") * [love.graphics.setPixelEffect](love.graphics.setpixeleffect "love.graphics.setPixelEffect") love love.graphics.getPointSize love.graphics.getPointSize ========================== Gets the [point](love.graphics.point "love.graphics.point") size. Function -------- ### Synopsis ``` size = love.graphics.getPointSize( ) ``` ### Arguments None. ### Returns `[number](number "number") size` The current point size. Examples -------- Increase the point size by 1 by using [love.graphics.setPointSize](love.graphics.setpointsize "love.graphics.setPointSize"). ``` function love.draw() local s = love.graphics.getPointSize() + 1; love.graphics.setPointSize(s); love.graphics.point(100, 100); end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.point](love.graphics.point "love.graphics.point") * [love.graphics.setPointSize](love.graphics.setpointsize "love.graphics.setPointSize") * [love.graphics.getMaxPointSize](love.graphics.getmaxpointsize "love.graphics.getMaxPointSize") love enet.peer:round trip time enet.peer:round trip time ========================= Returns or sets the current round trip time (i.e. ping). If value is [nil](nil "nil") the current value of the [peer](enet.peer "enet.peer") is returned. Otherwise the round trip time is set to the specified value and returned. ENet performs some filtering on the round trip times and it takes some time until the parameters are accurate. To speed it up, set the [last round trip time](enet.peer-last_round_trip_time "enet.peer:last round trip time") to an accurate guess. Function -------- ### Synopsis ``` peer:round_trip_time() ``` ### Arguments None. ### Returns `[number](number "number") roundtriptime` The [peer's](enet.peer "enet.peer") current round trip time in milliseconds. ### Synopsis ``` peer:round_trip_time(value) ``` ### Arguments `[number](number "number") value` Integer value to be used as the new round trip time. ### Returns Nothing. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.peer](enet.peer "enet.peer") * [enet.peer:last\_round\_trip\_time](enet.peer-last_round_trip_time "enet.peer:last round trip time") love LÖVE LÖVE ==== Welcome ------- As you probably know by now, [LÖVE](https://love2d.org) is a framework for making 2D games in the Lua programming language. LÖVE is totally free, and can be used in anything from friendly open-source hobby projects, to evil, closed-source commercial ones. Some interesting places to go from here: * [Getting Started](https://love2d.org/wiki/Getting_Started "Getting Started") * [Building LÖVE](building_l%C3%96ve "Building LÖVE") * [Tutorials](https://love2d.org/wiki/Category:Tutorials "Category:Tutorials") * [love](love "love") (The module) * [Game Distribution](https://love2d.org/wiki/Game_Distribution "Game Distribution") * [Config Files](love.conf "Config Files") * [License](https://love2d.org/wiki/License "License") (Free!) * [Games](https://love2d.org/wiki/Category:Games "Category:Games") * [Libraries](https://love2d.org/wiki/Category:Libraries "Category:Libraries") * [Software](https://love2d.org/wiki/Category:Software "Category:Software") * [Snippets](https://love2d.org/wiki/Category:Snippets "Category:Snippets") * [Version History](https://love2d.org/wiki/Version_History "Version History") If you want to read this wiki without an internet connection, you can download a weekly generated package for offline viewing [here](https://love2d.org/wiki.zip). Lua --- Never used Lua before? It's a really cool language! This manual won't teach you Lua, but fortunately there are other good resources for that. * [Programming in Lua (first edition)](https://lua.org/pil) * [Lua-Users Tutorials](http://lua-users.org/wiki/TutorialDirectory) * [Lua 5.1 Reference Manual](https://www.lua.org/manual/5.1/) Hello World ----------- This is the full source for 'hello world' in LÖVE. Running this code will cause an 800 by 600 window to appear, and display white text on a black background. ``` function love.draw() love.graphics.print('Hello World!', 400, 300) end ``` love (File):read (File):read =========== Read a number of bytes from a file. Function -------- ### Synopsis ``` contents, size = File:read( bytes ) ``` ### Arguments `[number](number "number") bytes (all)` The number of bytes to read. ### Returns `[string](string "string") contents` The contents of the read bytes. `[number](number "number") size` How many bytes have been read. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. Reads the contents of a file into either a string or a [FileData](filedata "FileData") object. ### Synopsis ``` contents, size = File:read( container, bytes ) ``` ### Arguments `[ContainerType](containertype "ContainerType") container` What type to return the file's contents as. `[number](number "number") bytes (all)` The number of bytes to read. ### Returns `[value](value "value") contents` [FileData](filedata "FileData") or string containing the read bytes. `[number](number "number") size` How many bytes have been read. See Also -------- * [File](file "File") love Joystick:getGamepadAxis Joystick:getGamepadAxis ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the direction of a virtual gamepad axis. If the Joystick isn't recognized as a [gamepad](joystick-isgamepad "Joystick:isGamepad") or isn't connected, this function will always return 0. Function -------- ### Synopsis ``` direction = Joystick:getGamepadAxis( axis ) ``` ### Arguments `[GamepadAxis](gamepadaxis "GamepadAxis") axis` The virtual axis to be checked. ### Returns `[number](number "number") direction` Current value of the axis. Examples -------- ### Move x and y values based on a gamepad thumbstick ``` function love.load() x = 0 y = 0 p1joystick = nil end   function love.joystickadded(joystick) p1joystick = joystick end   function love.update(dt) -- Check if joystick connected if p1joystick ~= nil then -- getGamepadAxis returns a value between -1 and 1. -- It returns 0 when it is at rest   x = x + p1joystick:getGamepadAxis("leftx") y = y + p1joystick:getGamepadAxis("lefty") end end ``` See Also -------- * [Joystick](joystick "Joystick") * [Joystick:isGamepad](joystick-isgamepad "Joystick:isGamepad") * [Joystick:isGamepadDown](joystick-isgamepaddown "Joystick:isGamepadDown") * [Joystick:isConnected](joystick-isconnected "Joystick:isConnected") * [love.gamepadaxis](love.gamepadaxis "love.gamepadaxis") love World:getContacts World:getContacts ================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** It has been renamed from [World:getContactList](world-getcontactlist "World:getContactList"). Returns a table with all [Contacts](contact "Contact"). Function -------- ### Synopsis ``` contacts = World:getContacts( ) ``` ### Arguments None. ### Returns `[table](table "table") contacts` A [sequence](sequence "sequence") with all [Contacts](contact "Contact"). See Also -------- * [World](world "World") love love.data.encode love.data.encode ================ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Encode Data or a string to a Data or string in one of the [EncodeFormats](encodeformat "EncodeFormat"). Function -------- ### Synopsis ``` encoded = love.data.encode( container, format, sourceString, linelength ) ``` ### Arguments `[ContainerType](containertype "ContainerType") container` What type to return the encoded data as. `[EncodeFormat](encodeformat "EncodeFormat") format` The format of the output data. `[string](string "string") sourceString` The raw data to encode. `[number](number "number") linelength (0)` The maximum line length of the output. Only supported for base64, ignored if 0. ### Returns `[value](value "value") encoded` [ByteData](bytedata "ByteData")/[string](string "string") which contains the encoded version of source. Function -------- ### Synopsis ``` encoded = love.data.encode( container, format, sourceData, linelength ) ``` ### Arguments `[ContainerType](containertype "ContainerType") container` What type to return the encoded data as. `[EncodeFormat](encodeformat "EncodeFormat") format` The format of the output data. `[Data](data "Data") sourceData` The raw data to encode. `[number](number "number") linelength (0)` The maximum line length of the output. Only supported for base64, ignored if 0. ### Returns `[value](value "value") encoded` [ByteData](bytedata "ByteData")/[string](string "string") which contains the encoded version of source. See Also -------- * [love.data](love.data "love.data") * [love.data.decode](love.data.decode "love.data.decode") love World:setSleepingAllowed World:setSleepingAllowed ======================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [World:setAllowSleeping](world-setallowsleeping "World:setAllowSleeping"). Sets the sleep behaviour of the world. Function -------- ### Synopsis ``` World:setSleepingAllowed( allow ) ``` ### Arguments `[boolean](boolean "boolean") allow` True if bodies in the world are allowed to sleep, or false if not. ### Returns Nothing. See Also -------- * [World](world "World") * [World:isSleepingAllowed](world-issleepingallowed "World:isSleepingAllowed") love Variant Variant ======= The **Variant** type is not a real lua type, but instead indicates what lua values LÖVE can store internally. It is used in [love.thread](love.thread "love.thread") and [love.event](love.event "love.event"). Indeed, as it is a "virtual" type, it has no specific representation in lua, and no methods. Types ----- A **Variant** can be a [table](table "table"), a [boolean](boolean "boolean"), a [string](string "string"), a [number](number "number") or LÖVE [Objects](object "Object"). Notes ----- Foreign userdata (Lua's files, LuaSocket, ENet, ...), and functions are not supported. Nested tables are not officially supported in versions prior to [11.0](https://love2d.org/wiki/11.0 "11.0"). See Also -------- * [love](love "love")
programming_docs
love GlyphData:getBearing GlyphData:getBearing ==================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Gets glyph bearing. Function -------- ### Synopsis ``` bx, by = GlyphData:getBearing() ``` ### Arguments None. ### Returns `[number](number "number") bx` Glyph bearing X. `[number](number "number") by` Glyph bearing Y. See Also -------- * [GlyphData](glyphdata "GlyphData") love love.timer love.timer ========== Provides high-resolution timing functionality. Functions --------- | | | | | | --- | --- | --- | --- | | [love.timer.getAverageDelta](love.timer.getaveragedelta "love.timer.getAverageDelta") | Returns the average delta time over the last second. | 0.9.0 | | | [love.timer.getDelta](love.timer.getdelta "love.timer.getDelta") | Returns the time between the last two frames. | | | | [love.timer.getFPS](love.timer.getfps "love.timer.getFPS") | Returns the current frames per second. | | | | [love.timer.getMicroTime](love.timer.getmicrotime "love.timer.getMicroTime") | Returns the value of a timer with microsecond precision. | | 0.9.0 | | [love.timer.getTime](love.timer.gettime "love.timer.getTime") | Returns the amount of time since some time in the past. | 0.3.2 | | | [love.timer.sleep](love.timer.sleep "love.timer.sleep") | Pauses the current thread for the specified amount of time. | 0.2.1 | | | [love.timer.step](love.timer.step "love.timer.step") | Measures the time between two frames. | | | See Also -------- * [love](love "love") love love.graphics.getDepthMode love.graphics.getDepthMode ========================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. 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](love.graphics.newshader "love.graphics.newShader") and [Meshes](mesh "Mesh") with custom vertex attributes. No higher level APIs are provided to set the depth of 2D graphics such as shapes, lines, and Images. Depth testing and depth writes will have no effect unless the depth field is set to true in a table passed to [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas"), or a custom Canvas with a depth [PixelFormat](pixelformat "PixelFormat") is set in the depthstencil field in a table passed to [setCanvas](love.graphics.setcanvas "love.graphics.setCanvas"). Writing to the depth buffer is generally incompatible with rendering alpha-blended sprites / images. By default depth is determined by geometry (vertices) instead of texture alpha values, the depth buffer only stores a single depth value per pixel, and alpha blending **requires** back-to-front rendering for blending to be correct. Function -------- ### Synopsis ``` comparemode, write = love.graphics.getDepthMode( ) ``` ### Arguments None. ### Returns `[CompareMode](comparemode "CompareMode") comparemode` Depth comparison mode used for depth testing. `[boolean](boolean "boolean") write` Whether to write update / write values to the depth buffer when rendering. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setDepthMode](love.graphics.setdepthmode "love.graphics.setDepthMode") * [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas") love EffectType EffectType ========== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This enum is not supported in earlier versions. The different types of effects supported by [love.audio.setEffect](love.audio.seteffect "love.audio.setEffect"). Constants --------- chorus Plays multiple copies of the sound with slight pitch and time variation. Used to make sounds sound "fuller" or "thicker". `[EffectWaveform](effectwaveform "EffectWaveform") waveform` `[number](number "number") phase` `[number](number "number") rate` `[number](number "number") depth` `[number](number "number") feedback` `[number](number "number") delay` compressor Decreases the dynamic range of the sound, making the loud and quiet parts closer in volume, producing a more uniform amplitude throughout time. `[boolean](boolean "boolean") enable` distortion Alters the sound by amplifying it until it clips, shearing off parts of the signal, leading to a compressed and distorted sound. `[number](number "number") gain` `[number](number "number") edge` `[number](number "number") lowcut` `[number](number "number") center` `[number](number "number") bandwidth` echo Decaying feedback based effect, on the order of seconds. Also known as delay; causes the sound to repeat at regular intervals at a decreasing volume. `[number](number "number") delay` `[number](number "number") tapdelay` `[number](number "number") damping` `[number](number "number") feedback` `[number](number "number") spread` equalizer Adjust the frequency components of the sound using a 4-band (low-shelf, two band-pass and a high-shelf) equalizer. `[number](number "number") lowgain` `[number](number "number") lowcut` `[number](number "number") lowmidgain` `[number](number "number") lowmidfrequency` `[number](number "number") lowmidbandwidth` `[number](number "number") highmidgain` `[number](number "number") highmidfrequency` `[number](number "number") highmidbandwidth` `[number](number "number") highgain` `[number](number "number") highcut` flanger Plays two copies of the sound; while varying the phase, or equivalently delaying one of them, by amounts on the order of milliseconds, resulting in phasing sounds. `[EffectWaveform](effectwaveform "EffectWaveform") waveform` `[number](number "number") phase` `[number](number "number") rate` `[number](number "number") depth` `[number](number "number") feedback` `[number](number "number") delay` reverb Decaying feedback based effect, on the order of milliseconds. Used to simulate the reflection off of the surroundings. `[number](number "number") gain` `[number](number "number") highgain` `[number](number "number") density` `[number](number "number") diffusion` `[number](number "number") decaytime` `[number](number "number") decayhighratio` `[number](number "number") earlygain` `[number](number "number") earlydelay` `[number](number "number") lategain` `[number](number "number") latedelay` `[number](number "number") roomrolloff` `[number](number "number") airabsorption` `[boolean](boolean "boolean") highlimit` ringmodulator An implementation of amplitude modulation; multiplies the source signal with a simple waveform, to produce either volume changes, or inharmonic overtones. `[EffectWaveform](effectwaveform "EffectWaveform") waveform` `[number](number "number") frequency` `[number](number "number") highcut` See Also -------- * [love.audio](love.audio "love.audio") * [love.audio.setEffect](love.audio.seteffect "love.audio.setEffect") love Shader Variables Shader Variables ================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** These built-in shader variables are not supported in earlier versions. There are several built-in variables LÖVE provides in vertex and pixel shaders. All built-in variables are read-only unless otherwise specified. Global built-in variables ------------------------- `[mat4](https://love2d.org/w/index.php?title=mat4&action=edit&redlink=1 "mat4 (page does not exist)") TransformMatrix` The transformation matrix affected by [love.graphics.translate](love.graphics.translate "love.graphics.translate") and friends. Note that automatically batched vertices are transformed on the CPU, and their TransformMatrix will be an identity matrix. `[mat4](https://love2d.org/w/index.php?title=mat4&action=edit&redlink=1 "mat4 (page does not exist)") ProjectionMatrix` The orthographic projection matrix. `[mat4](https://love2d.org/w/index.php?title=mat4&action=edit&redlink=1 "mat4 (page does not exist)") TransformProjectionMatrix` The combined transform and projection matrices. Used as the `transform_projection` argument to the [vertex shader position](love.graphics.newshader#Vertex_Shader_Function "love.graphics.newShader") function. `[vec4](https://love2d.org/w/index.php?title=vec4&action=edit&redlink=1 "vec4 (page does not exist)") VaryingTexCoord` The interpolated per-vertex texture coordinate. Automatically set to the value of `VertexTexCoord` in the vertex shader before the [position](love.graphics.newshader#Vertex_Shader_Function "love.graphics.newShader") function is called. Used as the `texture_coords` argument to the [pixel shader effect](love.graphics.newshader#Pixel_Shader_Function "love.graphics.newShader") function. Writable in the vertex shader. Use this variable to change the texture coordinate in the vertex shader. `[vec4](https://love2d.org/w/index.php?title=vec4&action=edit&redlink=1 "vec4 (page does not exist)") VaryingColor` The interpolated per-vertex color. Automatically set to the value of `ConstantColor * gammaCorrectColor(VertexColor)` in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0") and newer, or `VertexColor` in [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2") and older, in the vertex shader before the [position](love.graphics.newshader#Vertex_Shader_Function "love.graphics.newShader") function is called. Used as the `color` argument to the [pixel shader effect](love.graphics.newshader#Pixel_Shader_Function "love.graphics.newShader") function. Writable in the vertex shader. Use this variable to change the per-vertex or constant color in the vertex shader. **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This shader variable is not supported in earlier versions. `[vec4](https://love2d.org/w/index.php?title=vec4&action=edit&redlink=1 "vec4 (page does not exist)") love_ScreenSize` The width and height of the screen (or canvas) currently being rendered to, stored in the x and y components of the variable. The z and w components are used internally by LÖVE. You can convert it to a vec2 with `love_ScreenSize.xy` or `vec2(love_ScreenSize)`. Vertex Shader built-in variables -------------------------------- `[vec4](https://love2d.org/w/index.php?title=vec4&action=edit&redlink=1 "vec4 (page does not exist)") VertexPosition` The pre-transformed position of the vertex. Used as the `vertex_position` argument to the [vertex shader position](love.graphics.newshader#Vertex_Shader_Function "love.graphics.newShader") function. The third and fourth components of the vector are normally (0, 1). `[vec4](https://love2d.org/w/index.php?title=vec4&action=edit&redlink=1 "vec4 (page does not exist)") VertexTexCoord` The texture coordinate of the vertex. The third and fourth components of the vector are normally (0, 1). [Meshes](mesh "Mesh") allow for custom texture coordinates. `[vec4](https://love2d.org/w/index.php?title=vec4&action=edit&redlink=1 "vec4 (page does not exist)") VertexColor` The color of the vertex, sprite, or text character if a [Mesh](mesh "Mesh"), [SpriteBatch](spritebatch "SpriteBatch"), or [Text](text "Text") object with per-vertex colors is drawn, or in LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2") and older the global color set with [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor"). It does not have [gamma-correction](love.graphics.isgammacorrect "love.graphics.isGammaCorrect") applied. **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This shader variable is not supported in earlier versions. `[vec4](https://love2d.org/w/index.php?title=vec4&action=edit&redlink=1 "vec4 (page does not exist)") ConstantColor` The global color set with [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor"). If global [gamma-correction](love.graphics.isgammacorrect "love.graphics.isGammaCorrect") is enabled, it will already be gamma-corrected. Pixel Shader built-in variables ------------------------------- `[vec4 array](https://love2d.org/w/index.php?title=vec4_array&action=edit&redlink=1 "vec4 array (page does not exist)") love_Canvases[]` Array used to set per-canvas pixel colors when multiple canvases are set with [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas") and the [effects](love.graphics.newshader#Pixel_Shader_Function "love.graphics.newShader") function is used instead of `effect`. Note that arrays in shaders are 0-based. Writable in the pixel shader when the **effects** function is used. `[vec2](https://love2d.org/w/index.php?title=vec2&action=edit&redlink=1 "vec2 (page does not exist)") love_PixelCoord` Coordinates of the pixel on screen. The same as `screen_coords` passed to the `vec4 effect` [Shader function](love.graphics.newshader#Pixel_Shader_Function "love.graphics.newShader") ### Notes If you wish to access the texture used for the drawing operation, you may define a uniform called `MainTex` of the appropriate type yourself, e.g. `uniform Image MainTex;` See Also -------- * [Shader](shader "Shader") * [love.graphics.newShader](love.graphics.newshader "love.graphics.newShader") love ParticleSystem:setEmissionRate ParticleSystem:setEmissionRate ============================== Sets the amount of particles emitted per second. Function -------- ### Synopsis ``` ParticleSystem:setEmissionRate( rate ) ``` ### Arguments `[number](number "number") rate` The amount of particles per second. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love love.graphics.getCanvas love.graphics.getCanvas ======================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Gets the current target [Canvas](canvas "Canvas"). Function -------- ### Synopsis ``` canvas = love.graphics.getCanvas( ) ``` ### Arguments None. ### Returns `[Canvas](canvas "Canvas") canvas` The Canvas set by [setCanvas](love.graphics.setcanvas "love.graphics.setCanvas"). Returns nil if drawing to the real screen. See Also -------- * [love.graphics](love.graphics "love.graphics") * [Canvas](canvas "Canvas") * [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas") love CompressedImageData CompressedImageData =================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** In versions prior to [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0") it was named CompressedData, however that name is used for something else now. Represents compressed image data designed to stay compressed in RAM. CompressedImageData encompasses standard compressed texture formats such as [DXT1, DXT5, and BC5 / 3Dc](http://renderingpipeline.com/2012/07/texture-compression/). You can't draw CompressedImageData directly to the screen. See [Image](image "Image") for that. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.image.newCompressedData](love.image.newcompresseddata "love.image.newCompressedData") | Create a new **CompressedImageData** object from a compressed image file. | 0.9.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [CompressedImageData:getDimensions](compressedimagedata-getdimensions "CompressedImageData:getDimensions") | Gets the width and height of the CompressedImageData. | 0.9.0 | | | [CompressedImageData:getFormat](compressedimagedata-getformat "CompressedImageData:getFormat") | Gets the format of the CompressedImageData. | 0.9.0 | | | [CompressedImageData:getHeight](compressedimagedata-getheight "CompressedImageData:getHeight") | Gets the height of the CompressedImageData. | 0.9.0 | | | [CompressedImageData:getMipmapCount](compressedimagedata-getmipmapcount "CompressedImageData:getMipmapCount") | Gets the number of mipmap levels in the CompressedImageData. | 0.9.0 | | | [CompressedImageData:getWidth](compressedimagedata-getwidth "CompressedImageData:getWidth") | Gets the width of the CompressedImageData. | 0.9.0 | | | [Data:clone](data-clone "Data:clone") | Creates a new copy of the Data object. | 11.0 | | | [Data:getFFIPointer](data-getffipointer "Data:getFFIPointer") | Gets an FFI pointer to the Data. | 11.3 | | | [Data:getPointer](data-getpointer "Data:getPointer") | Gets a pointer to the Data. | | | | [Data:getSize](data-getsize "Data:getSize") | Gets the [Data](data "Data")'s size in bytes. | | | | [Data:getString](data-getstring "Data:getString") | Gets the full Data as a string. | 0.9.0 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Enums ----- | | | | | | --- | --- | --- | --- | | [CompressedImageFormat](compressedimageformat "CompressedImageFormat") | Compressed image data formats. | 0.9.0 | | Supertypes ---------- * [Data](data "Data") * [Object](object "Object") See Also -------- * [love.image](love.image "love.image") * [love.image.newCompressedData](love.image.newcompresseddata "love.image.newCompressedData") * [love.image.isCompressed](love.image.iscompressed "love.image.isCompressed") * [Image](image "Image") love RandomGenerator:setSeed RandomGenerator:setSeed ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Sets the seed of the random number generator using the specified integer number. Function -------- ### Synopsis ``` RandomGenerator:setSeed( seed ) ``` ### Arguments `[number](number "number") seed` The integer number with which you want to seed the randomization. Must be within the range of [1, 2^53]. ### Returns Nothing. ### Notes Due to Lua's use of double-precision floating point numbers, values above 2^53 cannot be accurately represented. Use the other variant of this function if your seed will have a larger value. Function -------- Combines two 32-bit integer numbers into a 64-bit integer value and sets the seed of the random number generator using the value. ### Synopsis ``` RandomGenerator:setSeed( low, high ) ``` ### Arguments `[number](number "number") low` The lower 32 bits of the seed value. Must be within the range of [0, 2^32 - 1]. `[number](number "number") high` The higher 32 bits of the seed value. Must be within the range of [0, 2^32 - 1]. ### Returns Nothing. Examples -------- Creates a new RandomGenerator object, sets the seed to the system clock's time, then generates a number between 1 and 100 inclusive. Note that the seed can be any number within the range of [0, 2^53 - 1]. ``` function love.load() rng = love.math.newRandomGenerator() rng:setSeed(os.time()) randomNumber = rng:random(1,100) end ``` See Also -------- * [RandomGenerator](randomgenerator "RandomGenerator") * [RandomGenerator:getSeed](randomgenerator-getseed "RandomGenerator:getSeed") * [love.math](love.math "love.math") love (Image):replacePixels (Image):replacePixels ===================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function replaces [Image:refresh]((image)-refresh "(Image):refresh"). Replace the contents of an Image. Function -------- ### Synopsis ``` Image:replacePixels( data, slice, mipmap, x, y, reloadmipmaps ) ``` ### Arguments `[ImageData](imagedata "ImageData") data` The new [ImageData](imagedata "ImageData") to replace the contents with. `[number](number "number") slice` Which [cubemap face, array index, or volume layer](texturetype "TextureType") to replace, if applicable. `[number](number "number") mipmap (1)` The mimap level to replace, if the Image has mipmaps. `[number](number "number") x (0)` The x-offset in pixels from the top-left of the image to replace. The given ImageData's width plus this value must not be greater than the pixel width of the Image's specified mipmap level. `[number](number "number") y (0)` The y-offset in pixels from the top-left of the image to replace. The given ImageData's height plus this value must not be greater than the pixel height of the Image's specified mipmap level. `[boolean](boolean "boolean") reloadmipmaps` Whether to generate new mipmaps after replacing the Image's pixels. True by default if the Image was created with automatically generated mipmaps, false by default otherwise. ### Returns Nothing. Examples -------- ``` function love.load() imagedata = love.image.newImageData("pig.png") image = love.graphics.newImage(imagedata) end   function love.draw() love.graphics.draw(image) end   function love.keypressed(key) if key == "e" then -- Modify the original ImageData and apply the changes to the Image. imagedata:mapPixel(function(x, y, r, g, b, a) return r/2, g/2, b/2, a/2 end) image:replacePixels(imagedata) end end ``` See Also -------- * [Image](image "Image")
programming_docs
love FileData:getExtension FileData:getExtension ===================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Gets the extension of the FileData. Function -------- ### Synopsis ``` ext = FileData:getExtension( ) ``` ### Arguments None. ### Returns `[string](string "string") ext` The extension of the file the FileData represents. See Also -------- * [FileData](filedata "FileData") love GearJoint:getRatio GearJoint:getRatio ================== Get the ratio of a [gear joint.](gearjoint "GearJoint") Function -------- ### Synopsis ``` ratio = GearJoint:getRatio( ) ``` ### Arguments None. ### Returns `[number](number "number") ratio` The ratio of the joint. See Also -------- * [GearJoint](gearjoint "GearJoint") love World:isLocked World:isLocked ============== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns if the world is updating its state. This will return true inside the callbacks from [World:setCallbacks](world-setcallbacks "World:setCallbacks"). Function -------- ### Synopsis ``` locked = World:isLocked( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") locked` Will be true if the world is in the process of updating its state. See Also -------- * [World](world "World") love Transform:reset Transform:reset =============== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Resets the Transform to an identity state. All previously applied transformations are erased. Function -------- ### Synopsis ``` transform = Transform:reset( ) ``` ### Arguments None. ### Returns `[Transform](transform "Transform") transform` The Transform object the method was called on. Allows easily chaining Transform methods. See Also -------- * [Transform](transform "Transform") love RecordingDevice:getSampleCount RecordingDevice:getSampleCount ============================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the number of currently recorded samples. Function -------- ### Synopsis ``` samples = RecordingDevice:getSampleCount( ) ``` ### Arguments None. ### Returns `[number](number "number") samples` The number of samples that have been recorded so far. See Also -------- * [RecordingDevice](recordingdevice "RecordingDevice") * [RecordingDevice:getData](recordingdevice-getdata "RecordingDevice:getData") * [RecordingDevice:start](recordingdevice-start "RecordingDevice:start") * [RecordingDevice:stop](recordingdevice-stop "RecordingDevice:stop") love SpriteBatch:getImage SpriteBatch:getImage ==================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. **Removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** Use [SpriteBatch:getTexture](spritebatch-gettexture "SpriteBatch:getTexture") instead. Returns the image used by the SpriteBatch. Function -------- ### Synopsis ``` image = SpriteBatch:getImage( ) ``` ### Arguments None ### Returns `[Image](image "Image") image` The image for the sprites. See Also -------- * [SpriteBatch](spritebatch "SpriteBatch") * [SpriteBatch:setImage](spritebatch-setimage "SpriteBatch:setImage") love Contact:getRestitution Contact:getRestitution ====================== Get the restitution between two shapes that are in contact. Function -------- ### Synopsis ``` restitution = Contact:getRestitution( ) ``` ### Arguments None. ### Returns `[number](number "number") restitution` The restitution between the two shapes. See Also -------- * [Contact](contact "Contact") love love.window.getVSync love.window.getVSync ==================== **Available since LÖVE [11.3](https://love2d.org/wiki/11.3 "11.3")** This function is not supported in earlier versions. Gets current vertical synchronization (vsync). Function -------- ### Synopsis ``` vsync = love.window.getVSync( ) ``` ### Arguments None. ### Returns `[number](number "number") vsync` Current vsync status. 1 if enabled, 0 if disabled, and -1 for adaptive vsync. Notes ----- This can be less expensive alternative to [love.window.getMode](love.window.getmode "love.window.getMode") if you want to get current vsync status. See Also -------- * [love.window](love.window "love.window") * [love.window.setVSync](love.window.setvsync "love.window.setVSync") love Body:isFixedRotation Body:isFixedRotation ==================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns whether the body rotation is locked. Function -------- ### Synopsis ``` fixed = Body:isFixedRotation( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") fixed` True if the body's rotation is locked or false if not. See Also -------- * [Body](body "Body") love ParticleSystem:getSpeed ParticleSystem:getSpeed ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the speed of the particles. Function -------- ### Synopsis ``` min, max = ParticleSystem:getSpeed( ) ``` ### Arguments Nothing. ### Returns `[number](number "number") min` The minimum linear speed of the particles. `[number](number "number") max` The maximum linear speed of the particles. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setSpeed](particlesystem-setspeed "ParticleSystem:setSpeed") love love.audio.getPosition love.audio.getPosition ====================== Returns the position of the listener. Please note that positional audio only works for mono (i.e. non-stereo) sources. Function -------- ### Synopsis ``` x, y, z = love.audio.getPosition( ) ``` ### Arguments None. ### Returns `[number](number "number") x` The X position of the listener. `[number](number "number") y` The Y position of the listener. `[number](number "number") z` The Z position of the listener. See Also -------- * [love.audio](love.audio "love.audio") love love.graphics.newImage love.graphics.newImage ====================== Creates a new [Image](image "Image") from a filepath, [FileData](filedata "FileData"), an [ImageData](imagedata "ImageData"), or a [CompressedImageData](compressedimagedata "CompressedImageData"), and optionally generates or specifies mipmaps for the image. Version [11.0](https://love2d.org/wiki/11.0 "11.0") updated love.graphics.newImage to treat file names ending with "@2x", "@3x", etc. as a pixel density scale factor if none is explicitly supplied. This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- ### Synopsis ``` image = love.graphics.newImage( filename ) ``` ### Arguments `[string](string "string") filename` The filepath to the image file. ### Returns `[Image](image "Image") image` An Image object which can be drawn on screen. Function -------- ### Synopsis ``` image = love.graphics.newImage( imageData ) ``` ### Arguments `[ImageData](imagedata "ImageData") imageData` An ImageData object. The Image will use this ImageData to reload itself when [love.window.setMode](love.window.setmode "love.window.setMode") is called. ### Returns `[Image](image "Image") image` An Image object which can be drawn on screen. Function -------- **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in earlier versions. ### Synopsis ``` image = love.graphics.newImage( compressedImageData ) ``` ### Arguments `[CompressedImageData](compressedimagedata "CompressedImageData") compressedImageData` A CompressedImageData object. The Image will use this CompressedImageData to reload itself when [love.window.setMode](love.window.setmode "love.window.setMode") is called. ### Returns `[Image](image "Image") image` An Image object which can be drawn on screen. Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. ### Synopsis ``` image = love.graphics.newImage( filename, flags ) ``` ### Arguments `[string](string "string") filename` The filepath to the image file (or a [FileData](filedata "FileData") or [ImageData](imagedata "ImageData") or [CompressedImageData](compressedimagedata "CompressedImageData") or [ByteData](bytedata "ByteData") object). `[table](table "table") flags` A table containing the following fields: `[boolean](boolean "boolean") linear (false)` True if the image's pixels should be interpreted as being linear RGB rather than sRGB-encoded, if [gamma-correct rendering](love.graphics.isgammacorrect "love.graphics.isGammaCorrect") is enabled. Has no effect otherwise. `[boolean or table](https://love2d.org/w/index.php?title=boolean_or_table&action=edit&redlink=1 "boolean or table (page does not exist)") mipmaps (false)` If true, mipmaps for the image will be automatically generated (or taken from the images's file if possible, if the image originated from a [CompressedImageData](compressedimagedata "CompressedImageData")). If this value is a table, it should contain a list of other filenames of images of the same format that have progressively half-sized dimensions, all the way down to 1x1. Those images will be used as this Image's mipmap levels. ### Returns `[Image](image "Image") image` A new Image object which can be drawn on screen. Function -------- **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier or later versions. ### Synopsis ``` image = love.graphics.newImage( filename, format ) ``` ### Arguments `[string](string "string") filename` The filepath to the image file (or a [FileData](filedata "FileData") or [ImageData](imagedata "ImageData") or [CompressedImageData](compressedimagedata "CompressedImageData") object.) `[TextureFormat](textureformat "TextureFormat") format` The format to interpret the image's data as. ### Returns `[Image](image "Image") image` An Image object which can be drawn on screen. Examples -------- ### Draw a bunny on the screen ``` function love.load() bunny = love.graphics.newImage("MyBunny.png") end function love.draw() love.graphics.draw(bunny, 0, 0) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [Image](image "Image") love DistanceJoint:getLength DistanceJoint:getLength ======================= Gets the equilibrium distance between the two Bodies. Function -------- ### Synopsis ``` l = DistanceJoint:getLength( ) ``` ### Arguments None. ### Returns `[number](number "number") l` The length between the two Bodies. See Also -------- * [DistanceJoint](distancejoint "DistanceJoint") love love.math.setRandomState love.math.setRandomState ======================== **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. Sets the current state of the random number generator. The value used as an argument for this function is an opaque implementation-dependent string and should only originate from a previous call to [love.math.getRandomState](love.math.getrandomstate "love.math.getRandomState"). This is different from [love.math.setRandomSeed](love.math.setrandomseed "love.math.setRandomSeed") in that setRandomState directly sets the random number generator's current implementation-dependent state, whereas setRandomSeed gives it a new seed value. Function -------- ### Synopsis ``` love.math.setRandomState( state ) ``` ### Arguments `[string](string "string") state` The new state of the random number generator, represented as a string. This should originate from a previous call to [love.math.getRandomState](love.math.getrandomstate "love.math.getRandomState"). ### Returns Nothing. Notes ----- The effect of the state string does not depend on the current operating system. See Also -------- * [love.math](love.math "love.math") * [love.math.getRandomState](love.math.getrandomstate "love.math.getRandomState") love love.graphics.setMeshCullMode love.graphics.setMeshCullMode ============================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Sets whether [back-facing](love.graphics.setfrontfacewinding "love.graphics.setFrontFaceWinding") triangles in a [Mesh](mesh "Mesh") are culled. This is designed for use with low level custom hardware-accelerated 3D rendering via [custom vertex attributes](love.graphics.newmesh "love.graphics.newMesh") on Meshes, custom [vertex shaders](love.graphics.newshader "love.graphics.newShader"), and [depth testing](love.graphics.setdepthmode "love.graphics.setDepthMode") with a [depth buffer](pixelformat "PixelFormat"). By default, both front- and back-facing triangles in Meshes are rendered. Function -------- ### Synopsis ``` love.graphics.setMeshCullMode( mode ) ``` ### Arguments `[CullMode](cullmode "CullMode") mode` The Mesh face culling mode to use (whether to render everything, cull back-facing triangles, or cull front-facing triangles). ### Returns Nothing. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getMeshCullMode](love.graphics.getmeshcullmode "love.graphics.getMeshCullMode") * [love.graphics.setFrontFaceWinding](love.graphics.setfrontfacewinding "love.graphics.setFrontFaceWinding") * [love.graphics.setDepthMode](love.graphics.setdepthmode "love.graphics.setDepthMode") * [Mesh](mesh "Mesh") love love.event love.event ========== **Available since LÖVE [0.6.0](https://love2d.org/wiki/0.6.0 "0.6.0")** This module is not supported in earlier versions. Manages events, like keypresses. It is possible to define new events by appending the table `love.handlers`. Such functions can be invoked as usual, via [love.event.push](love.event.push "love.event.push") using the table index as an argument. Functions --------- | | | | | | --- | --- | --- | --- | | [love.event.clear](love.event.clear "love.event.clear") | Clears the event queue. | 0.7.2 | | | [love.event.poll](love.event.poll "love.event.poll") | Returns an iterator for messages in the event queue. | 0.6.0 | | | [love.event.pump](love.event.pump "love.event.pump") | Pump events into the event queue. | 0.6.0 | | | [love.event.push](love.event.push "love.event.push") | Adds an event to the event queue. | 0.6.0 | | | [love.event.quit](love.event.quit "love.event.quit") | Exits or restart the LÖVE program. | 0.8.0 | | | [love.event.wait](love.event.wait "love.event.wait") | Like love.event.poll(), but blocks until there is an event in the queue. | 0.6.0 | | Enums ----- | | | | | | --- | --- | --- | --- | | [Event](event "Event") | Arguments to love.event.push() and the like. | 0.6.0 | | See Also -------- * [love](love "love") love love.mouse.getY love.mouse.getY =============== Returns the current y-position of the mouse. Function -------- ### Synopsis ``` y = love.mouse.getY( ) ``` ### Arguments None. ### Returns `[number](number "number") y` The position of the mouse along the y-axis. Examples -------- Draw a horizontal [line](love.graphics.line "love.graphics.line") at the mouse's y-position. ``` function love.draw() local y = love.mouse.getY() love.graphics.line(0,y, love.graphics.getWidth(),y) end ``` See Also -------- * [love.mouse](love.mouse "love.mouse") * [love.mouse.getX](love.mouse.getx "love.mouse.getX") * [love.mouse.getPosition](love.mouse.getposition "love.mouse.getPosition") love Contact:setEnabled Contact:setEnabled ================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Enables or disables the contact. Function -------- ### Synopsis ``` Contact:setEnabled( enabled ) ``` ### Arguments `[boolean](boolean "boolean") enabled` True to enable or false to disable. ### Returns Nothing. See Also -------- * [Contact](contact "Contact") * [Contact:isEnabled](contact-isenabled "Contact:isEnabled") love ParticleSystem:clone ParticleSystem:clone ==================== **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. Creates an identical copy of the ParticleSystem in the stopped state. Function -------- ### Synopsis ``` particlesystem = ParticleSystem:clone( ) ``` ### Arguments None. ### Returns `[ParticleSystem](particlesystem "ParticleSystem") particlesystem` The new identical copy of this ParticleSystem. Notes ----- Cloned ParticleSystem inherit all the set-able state of the original ParticleSystem, but they are initialized stopped. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love love.audio.getDistanceModel love.audio.getDistanceModel =========================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Returns the distance attenuation model. Function -------- ### Synopsis ``` model = love.audio.getDistanceModel( ) ``` ### Arguments None. ### Returns `[DistanceModel](distancemodel "DistanceModel") model` The current distance model. The default is 'inverseclamped'. See Also -------- * [love.audio](love.audio "love.audio") love love.graphics.newText love.graphics.newText ===================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Creates a new drawable [Text](text "Text") object. This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- ### Synopsis ``` text = love.graphics.newText( font, textstring ) ``` ### Arguments `[Font](font "Font") font` The font to use for the text. `[string](string "string") textstring (nil)` The initial string of text that the new Text object will contain. May be nil. ### Returns `[Text](text "Text") text` The new drawable Text object. Function -------- ### Synopsis ``` text = love.graphics.newText( font, coloredtext ) ``` ### Arguments `[Font](font "Font") font` The font to use for the text. `[table](table "table") coloredtext` A table containing colors and strings to add to the object, in the form of `{color1, string1, color2, string2, ...}`. `[table](table "table") 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}`. `[string](string "string") string1` A string of text which has a color specified by the previous color. `[table](table "table") 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}`. `[string](string "string") string2` A string of text which has a color specified by the previous color. `[tables and strings](https://love2d.org/w/index.php?title=tables_and_strings&action=edit&redlink=1 "tables and strings (page does not exist)") ...` Additional colors and strings. ### Returns `[Text](text "Text") text` The new drawable Text object. ### Example ``` local font = love.graphics.getFont() --regular text local plainText = love.graphics.newText(font, "Hello world") --colored text local coloredText = love.graphics.newText(font, {{1, 0, 0}, "Hello ", {0, 0, 1}, " world"}) ``` ### Notes The color set by [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor") will be combined (multiplied) with the colors of the text, when drawing the Text object. See Also -------- * [love.graphics](love.graphics "love.graphics") * [Text](text "Text") * [Font](font "Font")
programming_docs
love DisplayOrientation DisplayOrientation ================== **Available since LÖVE [11.3](https://love2d.org/wiki/11.3 "11.3")** This enum is not supported in earlier versions. Types of device display orientation. Constants --------- unknown Orientation cannot be determined. landscape Landscape orientation. landscapeflipped Landscape orientation (flipped). portrait Portrait orientation. portraitflipped Portrait orientation (flipped). See Also -------- * [love.window](love.window "love.window") * [love.window.getDisplayOrientation](love.window.getdisplayorientation "love.window.getDisplayOrientation") * [love.displayrotated](love.displayrotated "love.displayrotated") love love.window.setTitle love.window.setTitle ==================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Sets the window title. Constantly updating the window title can lead to issues on some systems and therefore is discouraged. Function -------- ### Synopsis ``` love.window.setTitle( title ) ``` ### Arguments `[string](string "string") title` The new window title. ### Returns Nothing. See Also -------- * [love.window](love.window "love.window") * [love.window.getTitle](love.window.gettitle "love.window.getTitle") love Mesh:setVertexColors Mesh:setVertexColors ==================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** It has been replaced by [Mesh:setAttributeEnabled](mesh-setattributeenabled "Mesh:setAttributeEnabled")("VertexColor", enable). Sets whether per-vertex colors are used instead of the constant color when drawing the Mesh (constant color being [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor").) Per-vertex colors are enabled by default for a Mesh if at least one vertex color was not the default (255, 255, 255, 255) when the Mesh was [created](love.graphics.newmesh "love.graphics.newMesh"). Function -------- ### Synopsis ``` Mesh:setVertexColors( on ) ``` ### Arguments `[boolean](boolean "boolean") on` True to use per-vertex coloring, otherwise [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor") is used when drawing. ### Returns Nothing. See Also -------- * [Mesh](mesh "Mesh") * [Mesh:hasVertexColors](mesh-hasvertexcolors "Mesh:hasVertexColors") * [love.graphics.newMesh](love.graphics.newmesh "love.graphics.newMesh") love RevoluteJoint:setMotorSpeed RevoluteJoint:setMotorSpeed =========================== Sets the motor speed. Function -------- ### Synopsis ``` RevoluteJoint:setMotorSpeed( s ) ``` ### Arguments `[number](number "number") s` The motor speed, radians per second. ### Returns Nothing. See Also -------- * [RevoluteJoint](revolutejoint "RevoluteJoint") love love.filesystem.getInfo love.filesystem.getInfo ======================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function replaces [love.filesystem.exists](love.filesystem.exists "love.filesystem.exists"), [isFile](love.filesystem.isfile "love.filesystem.isFile"), [isDirectory](love.filesystem.isdirectory "love.filesystem.isDirectory"), [isSymlink](love.filesystem.issymlink "love.filesystem.isSymlink"), [getLastModified](love.filesystem.getlastmodified "love.filesystem.getLastModified"), and [getSize](love.filesystem.getsize "love.filesystem.getSize"). Gets information about the specified file or directory. Function -------- ### Synopsis ``` info = love.filesystem.getInfo( path, filtertype ) ``` ### Arguments `[string](string "string") path` The file or directory path to check. `[FileType](filetype "FileType") filtertype (nil)` If supplied, this parameter causes getInfo to only return the info table if the item at the given path matches the specified file type. ### Returns `[table](table "table") info (nil)` A table containing information about the specified path, or nil if nothing exists at the path. The table contains the following fields: `[FileType](filetype "FileType") type` The type of the object at the path (file, directory, symlink, etc.) `[number](number "number") size (nil)` The size in bytes of the file, or nil if it can't be determined. `[number](number "number") modtime (nil)` The file's last modification time in seconds since the unix epoch, or nil if it can't be determined. Function -------- This variant accepts an existing table to fill in, instead of creating a new one. ### Synopsis ``` info = love.filesystem.getInfo( path, info ) ``` ### Arguments `[string](string "string") path` The file or directory path to check. `[table](table "table") info` A table which will be filled in with info about the specified path. ### Returns `[table](table "table") info (nil)` The table given as an argument, or nil if nothing exists at the path. The table will be filled in with the following fields: `[FileType](filetype "FileType") type` The type of the object at the path (file, directory, symlink, etc.) `[number](number "number") size (nil)` The size in bytes of the file, or nil if it can't be determined. `[number](number "number") modtime (nil)` The file's last modification time in seconds since the unix epoch, or nil if it can't be determined. Function -------- This variant only returns info if the item at the given path is the same file type as specified in the filtertype argument, and accepts an existing table to fill in, instead of creating a new one. ### Synopsis ``` info = love.filesystem.getInfo( path, filtertype, info ) ``` ### Arguments `[string](string "string") path` The file or directory path to check. `[FileType](filetype "FileType") filtertype` Causes getInfo to only return the info table if the item at the given path matches the specified file type. `[table](table "table") info` A table which will be filled in with info about the specified path. ### Returns `[table](table "table") info (nil)` The table given as an argument, or nil if nothing exists at the path. The table will be filled in with the following fields: `[FileType](filetype "FileType") type` The type of the object at the path (file, directory, symlink, etc.) `[number](number "number") size (nil)` The size in bytes of the file, or nil if it can't be determined. `[number](number "number") modtime (nil)` The file's last modification time in seconds since the unix epoch, or nil if it can't be determined. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [love.filesystem.setSymlinksEnabled](love.filesystem.setsymlinksenabled "love.filesystem.setSymlinksEnabled") * [love.filesystem.areSymlinksEnabled](love.filesystem.aresymlinksenabled "love.filesystem.areSymlinksEnabled") love GraphicsLimit GraphicsLimit ============= **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This enum is not supported in earlier versions. Types of system-dependent graphics limits checked for using [love.graphics.getSystemLimits](love.graphics.getsystemlimits "love.graphics.getSystemLimits"). Constants --------- pointsize The maximum size of [points](love.graphics.points "love.graphics.points"). texturesize The maximum width or height of [Images](image "Image") and [Canvases](canvas "Canvas"). multicanvas The maximum number of simultaneously active canvases (via [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas").) canvasmsaa Available since 0.10.0 The maximum number of antialiasing samples for a [Canvas](love.graphics.newcanvas "love.graphics.newCanvas"). texturelayers Available since 11.0 The maximum number of layers in an [Array texture](texturetype "TextureType"). volumetexturesize Available since 11.0 The maximum width, height, or depth of a [Volume texture](texturetype "TextureType"). cubetexturesize Available since 11.0 The maximum width or height of a [Cubemap texture](texturetype "TextureType"). anisotropy Available since 11.0 The maximum amount of anisotropic filtering. [Texture:setMipmapFilter](texture-setmipmapfilter "Texture:setMipmapFilter") internally clamps the given anisotropy value to the system's limit. canvasfsaa Removed in 0.10.0 The maximum number of antialiasing samples for a [Canvas](love.graphics.newcanvas "love.graphics.newCanvas"). Notes ----- Attempting to create an [Image](image "Image") with a width **or** height greater than the maximum supported will create a checkerboard-patterned image instead. Doing the same for a [Canvas](canvas "Canvas") will result in an error. It's safe to assume the maximum texture size will always be 2048 or greater. There is an [online database](http://feedback.wildfiregames.com/report/opengl/feature/GL_MAX_TEXTURE_SIZE) which has collected info about the max texture size for various systems. The value for the **multicanvas** system limit will generally be either 1, 4, or 8. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getSystemLimits](love.graphics.getsystemlimits "love.graphics.getSystemLimits") * [Canvas:getMSAA](canvas-getmsaa "Canvas:getMSAA") love BezierCurve:setControlPoint BezierCurve:setControlPoint =========================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Set coordinates of the i-th control point. Indices start with 1. Function -------- ### Synopsis ``` BezierCurve:setControlPoint(i, x, y) ``` ### Arguments `[number](number "number") i` Index of the control point. `[number](number "number") x` Position of the control point along the x axis. `[number](number "number") y` Position of the control point along the y axis. ### Returns Nothing. See Also -------- * [BezierCurve](beziercurve "BezierCurve") * [BezierCurve:getDegree](beziercurve-getdegree "BezierCurve:getDegree") * [BezierCurve:getControlPoint](beziercurve-getcontrolpoint "BezierCurve:getControlPoint") * [BezierCurve:insertControlPoint](beziercurve-insertcontrolpoint "BezierCurve:insertControlPoint") * [love.math](love.math "love.math") love (File):getSize (File):getSize ============== Returns the [file](file "File") size. Function -------- ### Synopsis ``` size = File:getSize( ) ``` ### Arguments None. ### Returns `[number](number "number") size` The file size in bytes. See Also -------- * [File](file "File") love enet.peer:receive enet.peer:receive ================= Attempts to dequeue an incoming packet for this [peer](enet.peer "enet.peer"). Returns [nil](nil "nil") if there are no packets waiting. Otherwise returns two values: The string representing the packet data, and the channel the packet came from. Function -------- ### Synopsis ``` peer:receive() ``` ### Arguments None. ### Returns `[string](string "string") data` Data from the received packet in a string. `[number](number "number") channel` Channel the packet was received from. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.peer](enet.peer "enet.peer") love Body:getContacts Body:getContacts ================ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** It has been renamed from [Body:getContactList](body-getcontactlist "Body:getContactList"). Gets a list of all [Contacts](contact "Contact") attached to the Body. The list can change multiple times during a [World:update](world-update "World:update") call, so some collisions may be missed if the World collide callbacks are not used at all. Function -------- ### Synopsis ``` contacts = Body:getContacts( ) ``` ### Arguments None. ### Returns `[table](table "table") contacts` A list with all contacts associated with the Body. See Also -------- * [Body](body "Body") * [World:getContacts](world-getcontacts "World:getContacts") * [World:setCallbacks](world-setcallbacks "World:setCallbacks") love Fixture:getRestitution Fixture:getRestitution ====================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the restitution of the fixture. Function -------- ### Synopsis ``` restitution = Fixture:getRestitution( ) ``` ### Arguments None. ### Returns `[number](number "number") restitution` The fixture restitution. See Also -------- * [Fixture](fixture "Fixture") * [Fixture:setRestitution](fixture-setrestitution "Fixture:setRestitution") love Source:pause Source:pause ============ **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Pauses the Source. Function -------- ### Synopsis ``` Source:pause() ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Source](source "Source") love love.math love.math ========= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This module is not supported in earlier versions. Provides system-independent mathematical functions. Types ----- | | | | | | --- | --- | --- | --- | | [BezierCurve](beziercurve "BezierCurve") | A Bézier curve object that can evaluate and render Bézier curves of arbitrary degree. | 0.9.0 | | | [RandomGenerator](randomgenerator "RandomGenerator") | A random number generation object which has its own random state. | 0.9.0 | | | [Transform](transform "Transform") | Object containing a coordinate system transformation. | 11.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [love.math.colorFromBytes](love.math.colorfrombytes "love.math.colorFromBytes") | Converts a color from 0..255 to 0..1 range. | 11.3 | | | [love.math.colorToBytes](love.math.colortobytes "love.math.colorToBytes") | Converts a color from 0..1 to 0..255 range. | 11.3 | | | [love.math.compress](love.math.compress "love.math.compress") | Compresses a string or data using a specific compression algorithm. | 0.10.0 | 11.0 | | [love.math.decompress](love.math.decompress "love.math.decompress") | Decompresses a [CompressedData](compresseddata "CompressedData") or previously compressed string or [Data](data "Data") object. | 0.10.0 | 11.0 | | [love.math.gammaToLinear](love.math.gammatolinear "love.math.gammaToLinear") | Converts a color from gamma-space (sRGB) to linear-space (RGB). | 0.9.1 | | | [love.math.getRandomSeed](love.math.getrandomseed "love.math.getRandomSeed") | Gets the seed of the random number generator. | 0.9.0 | | | [love.math.getRandomState](love.math.getrandomstate "love.math.getRandomState") | Gets the current state of the random number generator. | 0.9.1 | | | [love.math.isConvex](love.math.isconvex "love.math.isConvex") | Checks whether a polygon is convex. | 0.9.0 | | | [love.math.linearToGamma](love.math.lineartogamma "love.math.linearToGamma") | Converts a color from linear-space (RGB) to gamma-space (sRGB). | 0.9.1 | | | [love.math.newBezierCurve](love.math.newbeziercurve "love.math.newBezierCurve") | Creates a new [BezierCurve](beziercurve "BezierCurve") object. | 0.9.0 | | | [love.math.newRandomGenerator](love.math.newrandomgenerator "love.math.newRandomGenerator") | Creates a new [RandomGenerator](randomgenerator "RandomGenerator") object. | 0.9.0 | | | [love.math.newTransform](love.math.newtransform "love.math.newTransform") | Creates a new [Transform](transform "Transform") object. | 11.0 | | | [love.math.noise](love.math.noise "love.math.noise") | Generates a Simplex noise value in 1-4 dimensions. | 0.9.0 | | | [love.math.random](love.math.random "love.math.random") | Get uniformly distributed pseudo-random number | 0.9.0 | | | [love.math.randomNormal](love.math.randomnormal "love.math.randomNormal") | Get a normally distributed pseudo random number. | 0.9.0 | | | [love.math.setRandomSeed](love.math.setrandomseed "love.math.setRandomSeed") | Sets the seed of the random number generator. | 0.9.0 | | | [love.math.setRandomState](love.math.setrandomstate "love.math.setRandomState") | Sets the current state of the random number generator. | 0.9.1 | | | [love.math.triangulate](love.math.triangulate "love.math.triangulate") | Decomposes a simple polygon into triangles. | 0.9.0 | | Enums ----- See Also -------- * [love](love "love") love love.graphics.flushBatch love.graphics.flushBatch ======================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. 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](love.graphics "love.graphics") state changes (except for the transform stack and the current [color](love.graphics.setcolor "love.graphics.setColor")), as well as [Shader:send](shader-send "Shader:send") and methods on [Textures](texture "Texture") which change their state. Using a different Image in consecutive [love.graphics.draw](love.graphics.draw "love.graphics.draw") calls will also flush the current batch. [SpriteBatches](spritebatch "SpriteBatch"), [ParticleSystems](particlesystem "ParticleSystem"), [Meshes](mesh "Mesh"), and [Text](text "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. Function -------- ### Synopsis ``` love.graphics.flushBatch( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [love.graphics](love.graphics "love.graphics") love love.filesystem.getRequirePath love.filesystem.getRequirePath ============================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets the filesystem paths that will be searched when [require](https://www.lua.org/manual/5.1/manual.html#pdf-require) is called. The paths string returned by this function is a sequence of path templates separated by semicolons. The argument passed to *require* will be inserted in place of any question mark ("?") character in each template (after the dot characters in the argument passed to *require* are replaced by directory separators.) The paths are relative to the game's source and save directories, as well as any paths mounted with [love.filesystem.mount](love.filesystem.mount "love.filesystem.mount"). Function -------- ### Synopsis ``` paths = love.filesystem.getRequirePath( ) ``` ### Arguments None. ### Returns `[string](string "string") paths` The paths that the *require* function will check in love's filesystem. Notes ----- The default paths string is `"?.lua;?/init.lua"`, which makes `require("cool")` try to load `cool.lua` and then try `cool/init.lua` if cool.lua doesn't exist. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [love.filesystem.setRequirePath](love.filesystem.setrequirepath "love.filesystem.setRequirePath") love Shape:getChildCount Shape:getChildCount =================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Returns the number of children the shape has. Function -------- ### Synopsis ``` count = Shape:getChildCount( ) ``` ### Arguments None. ### Returns `[number](number "number") count` The number of children. See Also -------- * [Shape](shape "Shape") love Joint:setUserData Joint:setUserData ================= **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This method is not supported in earlier versions. Associates a Lua value with the Joint. To delete the reference, explicitly pass nil. Use this function in one thread and one thread only. Using it in more threads will make Lua cry and most likely crash. Function -------- ### Synopsis ``` Joint:setUserData( value ) ``` ### Arguments `[Variant](variant "Variant") value` The Lua value to associate with the Joint. ### Returns Nothing. See Also -------- * [Joint](joint "Joint") * [Joint:getUserData](joint-getuserdata "Joint:getUserData")
programming_docs
love PrismaticJoint:getJointSpeed PrismaticJoint:getJointSpeed ============================ Get the current joint angle speed. Function -------- ### Synopsis ``` s = PrismaticJoint:getJointSpeed( ) ``` ### Arguments None. ### Returns `[number](number "number") s` Joint angle speed in meters/second. See Also -------- * [PrismaticJoint](prismaticjoint "PrismaticJoint") love love.mouse.newCursor love.mouse.newCursor ==================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Creates a new hardware [Cursor](cursor "Cursor") object from an image file or [ImageData](imagedata "ImageData"). Hardware cursors are framerate-independent and work the same way as normal operating system cursors. Unlike drawing an image at the mouse's current coordinates, hardware cursors never have visible lag between when the mouse is moved and when the cursor position updates, even at low framerates. The hot spot is the point the operating system uses to determine what was clicked and at what position the mouse cursor is. For example, the normal arrow pointer normally has its hot spot at the top left of the image, but a crosshair cursor might have it in the middle. This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- ### Synopsis ``` cursor = love.mouse.newCursor( imageData, hotx, hoty ) ``` ### Arguments `[ImageData](imagedata "ImageData") imageData` The ImageData to use for the new Cursor. `[number](number "number") hotx (0)` The x-coordinate in the ImageData of the cursor's hot spot. `[number](number "number") hoty (0)` The y-coordinate in the ImageData of the cursor's hot spot. ### Returns `[Cursor](cursor "Cursor") cursor` The new Cursor object. Function -------- ### Synopsis ``` cursor = love.mouse.newCursor( filename, hotx, hoty ) ``` ### Arguments `[string](string "string") filename` Path to the image to use for the new Cursor. `[number](number "number") hotx (0)` The x-coordinate in the image of the cursor's hot spot. `[number](number "number") hoty (0)` The y-coordinate in the image of the cursor's hot spot. ### Returns `[Cursor](cursor "Cursor") cursor` The new Cursor object. Function -------- ### Synopsis ``` cursor = love.mouse.newCursor( fileData, hotx, hoty ) ``` ### Arguments `[FileData](filedata "FileData") fileData` Data representing the image to use for the new Cursor. `[number](number "number") hotx (0)` The x-coordinate in the image of the cursor's hot spot. `[number](number "number") hoty (0)` The y-coordinate in the image of the cursor's hot spot. ### Returns `[Cursor](cursor "Cursor") cursor` The new Cursor object. See Also -------- * [love.mouse](love.mouse "love.mouse") * [love.mouse.setCursor](love.mouse.setcursor "love.mouse.setCursor") * [love.mouse.getCursor](love.mouse.getcursor "love.mouse.getCursor") * [Cursor](cursor "Cursor") love RevoluteJoint:getMotorSpeed RevoluteJoint:getMotorSpeed =========================== Gets the motor speed. Function -------- ### Synopsis ``` s = RevoluteJoint:getMotorSpeed( ) ``` ### Arguments None. ### Returns `[number](number "number") s` The motor speed, radians per second. See Also -------- * [RevoluteJoint](revolutejoint "RevoluteJoint") love Channel:performAtomic Channel:performAtomic ===================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Executes the specified function atomically with respect to this Channel. Calling multiple methods in a row on the same Channel is often useful. However if multiple [Threads](thread "Thread") are calling this Channel's methods at the same time, the different calls on each Thread might end up interleaved (e.g. one or more of the second thread's calls may happen in between the first thread's calls.) This method avoids that issue by making sure the Thread calling the method has exclusive access to the Channel until the specified function has returned. Long-running or otherwise expensive code should be avoided in the function given to this method. Function -------- ### Synopsis ``` ret1, ... = Channel:performAtomic( func, arg1, ... ) ``` ### Arguments `[function](function "function") func` The function to call, the form of `function(channel, arg1, arg2, ...) end`. The Channel is passed as the first argument to the function when it is called. `[any](https://love2d.org/w/index.php?title=any&action=edit&redlink=1 "any (page does not exist)") arg1` Additional arguments that the given function will receive when it is called. `[any](https://love2d.org/w/index.php?title=any&action=edit&redlink=1 "any (page does not exist)") ...` Additional arguments that the given function will receive when it is called. ### Returns `[any](https://love2d.org/w/index.php?title=any&action=edit&redlink=1 "any (page does not exist)") ret1` The first return value of the given function (if any.) `[any](https://love2d.org/w/index.php?title=any&action=edit&redlink=1 "any (page does not exist)") ...` Any other return values. Examples -------- ### Re-set a Channel's contents to only have a single value ``` local function setChannel(channel, value) channel:clear() channel:push(value) end   local c = love.thread.getChannel("MyChannel") c:performAtomic(setChannel, "hello world") ``` See Also -------- * [Channel](channel "Channel") * [Thread](thread "Thread") love GlyphData:getWidth GlyphData:getWidth ================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Gets glyph width. Function -------- ### Synopsis ``` width = GlyphData:getWidth() ``` ### Arguments None. ### Returns `[number](number "number") width` Glyph width. See Also -------- * [GlyphData](glyphdata "GlyphData") love Source:isPlaying Source:isPlaying ================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Returns whether the Source is playing. Function -------- ### Synopsis ``` playing = Source:isPlaying( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") playing` True if the Source is playing, false otherwise. See Also -------- * [Source](source "Source") love love.audio.pause love.audio.pause ================ Pauses specific or all currently played [Sources](source "Source"). Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. Pauses all currently active [Sources](source "Source") and returns them. ### Synopsis ``` sources = love.audio.pause( ) ``` ### Arguments None. ### Returns `[table](table "table") Sources` A table containing a list of Sources that were paused by this call. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. Pauses the given [Sources](source "Source"). ### Synopsis ``` love.audio.pause( source, ... ) ``` ### Arguments `[Source](source "Source") source` The first Source to pause. `[Source](source "Source") ...` Additional Sources to pause. ### Returns Nothing. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. Pauses the given [Sources](source "Source"). ### Synopsis ``` love.audio.pause( sources ) ``` ### Arguments `[table](table "table") sources` A table containing a list of Sources to pause. ### Returns Nothing. Function -------- **Removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in that and later versions. Pauses all currently active [Sources](source "Source"). ### Synopsis ``` love.audio.pause( ) ``` ### Arguments None. ### Returns Nothing. Function -------- **Removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in that and later versions. Pauses a specific [Source](source "Source"). ### Synopsis ``` love.audio.pause( source ) ``` ### Arguments `[Source](source "Source") source` The source on which to pause the playback. ### Returns Nothing. See Also -------- * [love.audio](love.audio "love.audio") love love.graphics.setMode love.graphics.setMode ===================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** Moved to the [love.window](love.window "love.window") module as [love.window.setMode](love.window.setmode "love.window.setMode"). Changes the window size, or the display mode if fullscreen. If width or height is 0, setMode will use the width or height of the desktop. Changing the display mode may have side effects: for example, [Canvases](canvas "Canvas") will be cleared; make sure to save their contents beforehand. Function -------- ### Synopsis ``` success = love.graphics.setMode( width, height, fullscreen, vsync, fsaa ) ``` ### Arguments `[number](number "number") width` Display width. `[number](number "number") height` Display height. `[boolean](boolean "boolean") fullscreen (false)` Fullscreen (true), or windowed (false). `[boolean](boolean "boolean") vsync (true)` True if LÖVE should wait for vsync, false otherwise. `[number](number "number") fsaa (0)` The number of MSAA samples. ### Returns `[boolean](boolean "boolean") success` True if successful, false otherwise. Notes ----- If you have disabled the screen in [conf.lua](love.conf "Config Files") and use this function to manually create the window, then you must not call any other [love.graphics](love.graphics "love.graphics").\* function before this one. Doing so will result in undefined behavior and/or crashes. See Also -------- * [love.graphics](love.graphics "love.graphics") love Transform Transform ========= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This type is not supported in earlier versions. Object containing a coordinate system transformation. The [love.graphics](love.graphics "love.graphics") module has several functions and function variants which accept Transform objects. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.math.newTransform](love.math.newtransform "love.math.newTransform") | Creates a new **Transform** object. | 11.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | | [Transform:apply](transform-apply "Transform:apply") | Applies the given other Transform object to this one. | 11.0 | | | [Transform:clone](transform-clone "Transform:clone") | Creates a new copy of this Transform. | 11.0 | | | [Transform:getMatrix](transform-getmatrix "Transform:getMatrix") | Gets the internal transformation matrix stored by this Transform. | 11.0 | | | [Transform:inverse](transform-inverse "Transform:inverse") | Creates a new Transform containing the inverse of this Transform. | 11.0 | | | [Transform:inverseTransformPoint](transform-inversetransformpoint "Transform:inverseTransformPoint") | Applies the reverse of the Transform object's transformation to the given 2D position. | 11.0 | | | [Transform:isAffine2DTransform](transform-isaffine2dtransform "Transform:isAffine2DTransform") | Checks whether the Transform is an affine transformation. | 11.0 | | | [Transform:reset](transform-reset "Transform:reset") | Resets the Transform to an identity state. | 11.0 | | | [Transform:rotate](transform-rotate "Transform:rotate") | Applies a rotation to the Transform's coordinate system. | 11.0 | | | [Transform:scale](transform-scale "Transform:scale") | Scales the Transform's coordinate system. | 11.0 | | | [Transform:setMatrix](transform-setmatrix "Transform:setMatrix") | Directly sets the Transform's internal transformation matrix. | 11.0 | | | [Transform:setTransformation](transform-settransformation "Transform:setTransformation") | Resets the Transform to the specified transformation parameters. | 11.0 | | | [Transform:shear](transform-shear "Transform:shear") | Applies a [shear factor](https://en.wikipedia.org/wiki/Shear_mapping) (skew) to the Transform's coordinate system. | 11.0 | | | [Transform:transformPoint](transform-transformpoint "Transform:transformPoint") | Applies the Transform object's transformation to the given 2D position. | 11.0 | | | [Transform:translate](transform-translate "Transform:translate") | Applies a translation to the Transform's coordinate system. | 11.0 | | Enums ----- | | | | | | --- | --- | --- | --- | | [MatrixLayout](matrixlayout "MatrixLayout") | The layout of matrix elements (row-major or column-major). | 11.0 | | Supertypes ---------- * [Object](object "Object") Notes ----- Transform objects have a custom `*` (multiplication) operator. `result = tA * tB` is equivalent to `result = tA:clone():apply(tB)`. It maps to the matrix multiplication operation that [Transform:apply](transform-apply "Transform:apply") performs. The `*` operator creates a new Transform object, so it is not recommended to use it heavily in per-frame code. See Also -------- * [love.math](love.math "love.math") * [love.graphics.applyTransform](love.graphics.applytransform "love.graphics.applyTransform") * [love.graphics.replaceTransform](love.graphics.replacetransform "love.graphics.replaceTransform") * [love.graphics.draw](love.graphics.draw "love.graphics.draw") * [love.graphics.print](love.graphics.print "love.graphics.print") * [SpriteBatch:add](spritebatch-add "SpriteBatch:add") * [Text:add](text-add "Text:add") * [Shader:send](shader-send "Shader:send") love RandomGenerator RandomGenerator =============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This type is not supported in earlier versions. A random number generation object which has its own random state. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.math.newRandomGenerator](love.math.newrandomgenerator "love.math.newRandomGenerator") | Creates a new **RandomGenerator** object. | 0.9.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | | [RandomGenerator:getSeed](randomgenerator-getseed "RandomGenerator:getSeed") | Gets the seed of the random number generator. | 0.9.0 | | | [RandomGenerator:getState](randomgenerator-getstate "RandomGenerator:getState") | Gets the current state of the random number generator. | 0.9.1 | | | [RandomGenerator:random](randomgenerator-random "RandomGenerator:random") | Generates a pseudo-random number in a platform independent manner. | 0.9.0 | | | [RandomGenerator:randomNormal](randomgenerator-randomnormal "RandomGenerator:randomNormal") | Get a normally distributed pseudo random number. | 0.9.0 | | | [RandomGenerator:setSeed](randomgenerator-setseed "RandomGenerator:setSeed") | Sets the seed of the random number generator. | 0.9.0 | | | [RandomGenerator:setState](randomgenerator-setstate "RandomGenerator:setState") | Sets the current state of the random number generator. | 0.9.1 | | Supertypes ---------- * [Object](object "Object") See Also -------- * [love.math](love.math "love.math") love love.joystick.loadGamepadMappings love.joystick.loadGamepadMappings ================================= **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Loads a gamepad mappings string or file created with [love.joystick.saveGamepadMappings](love.joystick.savegamepadmappings "love.joystick.saveGamepadMappings"). It also recognizes any SDL gamecontroller mapping string, such as those created with Steam's Big Picture controller configure interface, or this [nice database](https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt). If a new mapping is loaded for an already known controller GUID, the later version will overwrite the one currently loaded. Function -------- Loads a gamepad mappings string from a file. ### Synopsis ``` love.joystick.loadGamepadMappings( filename ) ``` ### Arguments `[string](string "string") filename` The filename to load the mappings string from. ### Returns Nothing. Function -------- Loads a gamepad mappings string directly. ### Synopsis ``` love.joystick.loadGamepadMappings( mappings ) ``` ### Arguments `[string](string "string") mappings` The mappings string to load. ### Returns Nothing. See Also -------- * [love.joystick](love.joystick "love.joystick") * [love.joystick.saveGamepadMappings](love.joystick.savegamepadmappings "love.joystick.saveGamepadMappings") * [love.joystick.setGamepadMapping](love.joystick.setgamepadmapping "love.joystick.setGamepadMapping") * [Joystick:getGamepadMapping](joystick-getgamepadmapping "Joystick:getGamepadMapping") * [Joystick:isGamepad](joystick-isgamepad "Joystick:isGamepad") love SoundData:setSample SoundData:setSample =================== Sets the value of the sample-point at the specified position. For stereo SoundData objects, the data from the left and right channels are interleaved in that order. Function -------- ### Synopsis ``` SoundData:setSample( i, sample ) ``` ### Arguments `[number](number "number") i` An integer value specifying the position of the sample (starting at 0). `[number](number "number") sample` The normalized samplepoint (range -1.0 to 1.0). ### Returns Nothing. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. Sets the value of a sample using an explicit sample index instead of interleaving them in the sample position parameter. ### Synopsis ``` SoundData:setSample( i, channel, sample ) ``` ### Arguments `[number](number "number") i` An integer value specifying the position of the sample (starting at 0). `[number](number "number") channel` The index of the channel to set within the given sample. `[number](number "number") sample` The normalized samplepoint (range -1.0 to 1.0). ### Returns Nothing. See Also -------- * [SoundData](sounddata "SoundData") love Source:setEffect Source:setEffect ================ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Applies an audio [effect](effecttype "EffectType") to the Source. The effect must have been previously defined using [love.audio.setEffect](love.audio.seteffect "love.audio.setEffect"). Function -------- Applies the given previously defined effect to this Source. ### Synopsis ``` success = Source:setEffect( name, enable ) ``` ### Arguments `[string](string "string") name` The name of the effect previously set up with [love.audio.setEffect](love.audio.seteffect "love.audio.setEffect"). `[boolean](boolean "boolean") enable (true)` If false and the given effect name was previously enabled on this Source, disables the effect. ### Returns `[boolean](boolean "boolean") success` Whether the effect was successfully applied to this Source. Function -------- Applies the given previously defined effect to this Source, and applies a [filter](source-setfilter "Source:setFilter") to the Source which affects the sound fed into the effect. ### Synopsis ``` success = Source:setEffect( name, filtersettings ) ``` ### Arguments `[string](string "string") name` The name of the effect previously set up with [love.audio.setEffect](love.audio.seteffect "love.audio.setEffect"). `[table](table "table") filtersettings` The filter settings to apply prior to the effect, with the following fields: `[FilterType](filtertype "FilterType") type` The type of filter to use. `[number](number "number") volume` The overall volume of the audio. Must be between 0 and 1. `[number](number "number") highgain` Volume of high-frequency audio. Only applies to low-pass and band-pass filters. Must be between 0 and 1. `[number](number "number") lowgain` Volume of low-frequency audio. Only applies to high-pass and band-pass filters. Must be between 0 and 1. ### Returns `[boolean](boolean "boolean") success` Whether the effect and filter were successfully applied to this Source. Notes ----- Audio effect functionality is not supported on iOS. See Also -------- * [Source](source "Source") * [Source:getEffect](source-geteffect "Source:getEffect") * [Source:setFilter](source-setfilter "Source:setFilter") * [love.audio.setEffect](love.audio.seteffect "love.audio.setEffect")
programming_docs
love love.graphics.stencil love.graphics.stencil ===================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** Together with [love.graphics.setStencilTest](love.graphics.setstenciltest "love.graphics.setStencilTest"), it has replaced [love.graphics.setStencil](love.graphics.setstencil "love.graphics.setStencil"). 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](love.graphics.setstenciltest "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 [0, 255]. Starting with version [11.0](https://love2d.org/wiki/11.0 "11.0"), a stencil buffer must be set or requested in [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas") when using stencils with a Canvas. `love.graphics.setCanvas{canvas, stencil=true}` is an easy way to use an automatically provided temporary stencil buffer in that case. Function -------- ### Synopsis ``` love.graphics.stencil( stencilfunction, action, value, keepvalues ) ``` ### Arguments `[function](function "function") stencilfunction` Function which draws geometry. The stencil values of pixels, rather than the color of each pixel, will be affected by the geometry. `[StencilAction](stencilaction "StencilAction") action ("replace")` How to modify any stencil values of pixels that are touched by what's drawn in the stencil function. `[number](number "number") value (1)` The 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. `[boolean](boolean "boolean") keepvalues (false)` True 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](love.graphics.clear "love.graphics.clear") will also re-set all stencil values. ### Returns Nothing. Notes ----- It is possible to draw to the screen and to the stencil values of pixels at the same time, by using [love.graphics.setColorMask](love.graphics.setcolormask "love.graphics.setColorMask") inside the stencil function to enable drawing to all color components. Examples -------- ### Drawing circles masked by a rectangle ``` local function myStencilFunction() love.graphics.rectangle("fill", 225, 200, 350, 300) end   function love.draw() -- draw a rectangle as a stencil. Each pixel touched by the rectangle will have its stencil value set to 1. The rest will be 0. love.graphics.stencil(myStencilFunction, "replace", 1)   -- Only allow rendering on pixels which have a stencil value greater than 0. love.graphics.setStencilTest("greater", 0)   love.graphics.setColor(1, 0, 0, 0.45) love.graphics.circle("fill", 300, 300, 150, 50)   love.graphics.setColor(0, 1, 0, 0.45) love.graphics.circle("fill", 500, 300, 150, 50)   love.graphics.setColor(0, 0, 1, 0.45) love.graphics.circle("fill", 400, 400, 150, 50)   love.graphics.setStencilTest() end ``` ### Using an Image as a stencil mask ``` -- a black/white mask image: black pixels will mask, white pixels will pass. local mask = love.graphics.newImage("mymask.png")   local mask_shader = love.graphics.newShader[[ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) { if (Texel(texture, texture_coords).rgb == vec3(0.0)) { // a discarded pixel wont be applied as the stencil. discard; } return vec4(1.0); } ]]   local function myStencilFunction() love.graphics.setShader(mask_shader) love.graphics.draw(mask, 0, 0) love.graphics.setShader() end   function love.draw() love.graphics.stencil(myStencilFunction, "replace", 1) love.graphics.setStencilTest("greater", 0) love.graphics.rectangle("fill", 0, 0, 256, 256) love.graphics.setStencilTest() end ``` ### Allow drawing everywhere except where multiple circles intersect ``` local function myStencilFunction() -- Draw four overlapping circles as a stencil. love.graphics.circle("fill", 200, 250, 100) love.graphics.circle("fill", 300, 250, 100) love.graphics.circle("fill", 250, 200, 100) love.graphics.circle("fill", 250, 300, 100) end   function love.draw() -- Each pixel touched by each circle will have its stencil value incremented by 1. -- The stencil values for pixels where the circles overlap will be at least 2. love.graphics.stencil(myStencilFunction, "increment")   -- Only allow drawing in areas which have stencil values that are less than 2. love.graphics.setStencilTest("less", 2)   -- Draw a big rectangle. love.graphics.rectangle("fill", 0, 0, 500, 500)   love.graphics.setStencilTest() end ``` The [love.graphics.setStencilTest](love.graphics.setstenciltest "love.graphics.setStencilTest") wiki page includes more examples. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setStencilTest](love.graphics.setstenciltest "love.graphics.setStencilTest") * [love.graphics.clear](love.graphics.clear "love.graphics.clear") love GlyphData:getDimensions GlyphData:getDimensions ======================= **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Gets glyph dimensions. Function -------- ### Synopsis ``` width, height = GlyphData:getDimensions() ``` ### Arguments None. ### Returns `[number](number "number") width` Glyph width. `[number](number "number") height` Glyph height. See Also -------- * [GlyphData](glyphdata "GlyphData") love love.event.wait love.event.wait =============== **Available since LÖVE [0.6.0](https://love2d.org/wiki/0.6.0 "0.6.0")** This function is not supported in earlier versions. Like `[love.event.poll](love.event.poll "love.event.poll")()`, but blocks until there is an event in the queue. Function -------- ### Synopsis ``` n, a, b, c, d, e, f, ... = love.event.wait( ) ``` ### Arguments None. ### Returns `[Event](event "Event") n (nil)` The name of event, or nil if the event is unrecognized. `[Variant](variant "Variant") a` First event argument. `[Variant](variant "Variant") b` Second event argument. `[Variant](variant "Variant") c` Third event argument. `[Variant](variant "Variant") d` Available since 0.8.0 Fourth event argument. `[Variant](variant "Variant") e` Available since 0.10.0 Fifth event argument. `[Variant](variant "Variant") f` Available since 0.10.0 Sixth event argument. `[Variant](variant "Variant") ...` Available since 0.10.0 Further event arguments may follow. Examples -------- An example that replace `[love.event.poll](love.event.poll "love.event.poll")()` with this function. ``` function love.run() if love.load then love.load(love.arg.parseGameArguments(arg), arg) end   -- Main loop time. return function() -- Process events. if love.event then local name, a,b,c,d,e,f = love.event.wait() if name then if name == "quit" then if not love.quit or not love.quit() then return a or 0 end end love.handlers[name](a,b,c,d,e,f) end end   -- Call update and draw if love.update then love.update(0) end   if love.graphics and love.graphics.isActive() then love.graphics.origin() love.graphics.clear(love.graphics.getBackgroundColor())   if love.draw then love.draw() end   love.graphics.present() end end end ``` See Also -------- * [love.event](love.event "love.event") * [love.event.poll](love.event.poll "love.event.poll") love MouseJoint MouseJoint ========== For controlling objects with the mouse. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.physics.newMouseJoint](love.physics.newmousejoint "love.physics.newMouseJoint") | Create a joint between a body and the mouse. | | | Functions --------- | | | | | | --- | --- | --- | --- | | [Joint:destroy](joint-destroy "Joint:destroy") | Explicitly destroys the Joint. | | | | [Joint:getAnchors](joint-getanchors "Joint:getAnchors") | Get the anchor points of the joint. | | | | [Joint:getBodies](joint-getbodies "Joint:getBodies") | Gets the [bodies](body "Body") that the Joint is attached to. | 0.9.2 | | | [Joint:getCollideConnected](joint-getcollideconnected "Joint:getCollideConnected") | Gets whether the connected Bodies collide. | | | | [Joint:getReactionForce](joint-getreactionforce "Joint:getReactionForce") | Returns the reaction force on the second body. | | | | [Joint:getReactionTorque](joint-getreactiontorque "Joint:getReactionTorque") | Returns the reaction torque on the second body. | | | | [Joint:getType](joint-gettype "Joint:getType") | Gets a string representing the type. | | | | [Joint:getUserData](joint-getuserdata "Joint:getUserData") | Returns the Lua value associated with this Joint. | 0.9.2 | | | [Joint:isDestroyed](joint-isdestroyed "Joint:isDestroyed") | Gets whether the Joint is destroyed. | 0.9.2 | | | [Joint:setCollideConnected](joint-setcollideconnected "Joint:setCollideConnected") | Sets whether the connected Bodies should collide with each other. | | 0.8.0 | | [Joint:setUserData](joint-setuserdata "Joint:setUserData") | Associates a Lua value with the Joint. | 0.9.2 | | | [MouseJoint:getDampingRatio](mousejoint-getdampingratio "MouseJoint:getDampingRatio") | Returns the damping ratio. | 0.8.0 | | | [MouseJoint:getFrequency](mousejoint-getfrequency "MouseJoint:getFrequency") | Returns the frequency. | 0.8.0 | | | [MouseJoint:getMaxForce](mousejoint-getmaxforce "MouseJoint:getMaxForce") | Gets the highest allowed force. | | | | [MouseJoint:getTarget](mousejoint-gettarget "MouseJoint:getTarget") | Gets the target point. | | | | [MouseJoint:setDampingRatio](mousejoint-setdampingratio "MouseJoint:setDampingRatio") | Sets a new damping ratio. | 0.8.0 | | | [MouseJoint:setFrequency](mousejoint-setfrequency "MouseJoint:setFrequency") | Sets a new frequency. | 0.8.0 | | | [MouseJoint:setMaxForce](mousejoint-setmaxforce "MouseJoint:setMaxForce") | Sets the highest allowed force. | | | | [MouseJoint:setTarget](mousejoint-settarget "MouseJoint:setTarget") | Sets the target point. | | | Supertypes ---------- * [Joint](joint "Joint") * [Object](object "Object") See Also -------- * [love.physics](love.physics "love.physics") love love.joystickhat love.joystickhat ================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This callback is not supported in earlier versions. Called when a joystick hat direction changes. Function -------- ### Synopsis ``` love.joystickhat( joystick, hat, direction ) ``` ### Arguments `[Joystick](joystick "Joystick") joystick` The joystick object. `[number](number "number") hat` The hat number. `[JoystickHat](joystickhat "JoystickHat") direction` The new hat direction. ### Returns Nothing. See Also -------- * [love](love "love") love love.mouse.setCursor love.mouse.setCursor ==================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Sets the current mouse cursor. Function -------- ### Synopsis ``` love.mouse.setCursor( cursor ) ``` ### Arguments `[Cursor](cursor "Cursor") cursor` The Cursor object to use as the current mouse cursor. ### Returns Nothing. Function -------- ### Synopsis ``` love.mouse.setCursor( ) ``` ### Arguments None. ### Returns Nothing. ### Notes Resets the current mouse cursor to the default. Examples -------- ``` function love.load() cursor = love.mouse.getSystemCursor("hand") -- Alternative: cursor = love.mouse.newCursor("pig.png", 0, 0) end   function love.mousepressed(x, y, button) -- Use a custom cursor when the left mouse button is pressed. if button == 1 then love.mouse.setCursor(cursor) end end   function love.mousereleased(x, y, button) -- Go back to the default cursor when the left mouse button is released. if button == 1 then love.mouse.setCursor() end end ``` See Also -------- * [love.mouse](love.mouse "love.mouse") * [love.mouse.newCursor](love.mouse.newcursor "love.mouse.newCursor") * [love.mouse.getCursor](love.mouse.getcursor "love.mouse.getCursor") love Source:seek Source:seek =========== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Sets the currently playing position of the Source. Function -------- ### Synopsis ``` Source:seek( offset, unit ) ``` ### Arguments `[number](number "number") offset` The position to seek to. `[TimeUnit](timeunit "TimeUnit") unit ("seconds")` The unit of the position value. ### Returns Nothing. See Also -------- * [Source:tell](source-tell "Source:tell") * [Source:getDuration](source-getduration "Source:getDuration") * [Source](source "Source") love Shape:rayCast Shape:rayCast ============= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Casts a ray against the shape and returns the surface normal vector and the line position where the ray hit. If the ray missed the shape, nil will be returned. The Shape can be transformed to get it into the desired position. The ray starts on the first point of the input line and goes towards the second point of the line. The fourth argument is the maximum distance the ray is going to travel as a scale factor of the input line length. The childIndex parameter is used to specify which child of a parent shape, such as a ChainShape, will be ray casted. For ChainShapes, the index of 1 is the first edge on the chain. Ray casting a parent shape will only test the child specified so if you want to test every shape of the parent, you must loop through all of its children. The world position of the impact can be calculated by multiplying the line vector with the third return value and adding it to the line starting point. ``` hitx, hity = x1 + (x2 - x1) * fraction, y1 + (y2 - y1) * fraction ``` There is a bug in [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") where the normal vector returned by this function gets scaled by [love.physics.getMeter](love.physics.getmeter "love.physics.getMeter"). Function -------- ### Synopsis ``` xn, yn, fraction = Shape:rayCast( x1, y1, x2, y2, maxFraction, tx, ty, tr, childIndex ) ``` ### Arguments `[number](number "number") x1` The x position of the input line starting point. `[number](number "number") y1` The y position of the input line starting point. `[number](number "number") x2` The x position of the input line end point. `[number](number "number") y2` The y position of the input line end point. `[number](number "number") maxFraction` Ray length parameter. `[number](number "number") tx` The translation of the shape on the x-axis. `[number](number "number") ty` The translation of the shape on the y-axis. `[number](number "number") tr` The shape rotation. `[number](number "number") childIndex (1)` The index of the child the ray gets cast against. ### Returns `[number](number "number") xn` The x component of the normal vector of the edge where the ray hit the shape. `[number](number "number") yn` The y component of the normal vector of the edge where the ray hit the shape. `[number](number "number") fraction` The position on the input line where the intersection happened as a factor of the line length. Examples -------- ### Casting 2 different rays against a box. ``` function love.load() -- Setting this to 1 to avoid all current scaling bugs. love.physics.setMeter(1)   Box = {} Box.x, Box.y, Box.r = 400, 300, 3.3 Box.Shape = love.physics.newRectangleShape(150, 150)     Ray1 = { point1 = {}, point2 = {}, } Ray1.point1.x, Ray1.point1.y = 50, 50 Ray1.point2.x, Ray1.point2.y = 400, 300 Ray1.scale = 1   Ray2 = { point1 = {}, point2 = {}, } Ray2.point1.x, Ray2.point1.y = 500, 400 Ray2.point2.x, Ray2.point2.y = Ray2.point1.x + math.cos(math.pi*1.45), Ray2.point1.y + math.sin(math.pi*1.45) Ray2.scale = 150 end   function love.draw() -- Drawing the box. love.graphics.setColor(255, 255, 255) love.graphics.push() -- For great point rotation! love.graphics.translate(Box.x, Box.y) love.graphics.rotate(Box.r) love.graphics.polygon("line", Box.Shape:getPoints()) love.graphics.pop()   -- Drawing the input lines of the rays and the reach of ray 2 in gray. love.graphics.setLineWidth(3) love.graphics.setColor(50, 50, 50) love.graphics.line(Ray2.point1.x, Ray2.point1.y, Ray2.point1.x + (Ray2.point2.x - Ray2.point1.x) * Ray2.scale, Ray2.point1.y + (Ray2.point2.y - Ray2.point1.y) * Ray2.scale) love.graphics.setColor(255, 255, 255) love.graphics.line(Ray1.point1.x, Ray1.point1.y, Ray1.point2.x, Ray1.point2.y) love.graphics.line(Ray2.point1.x, Ray2.point1.y, Ray2.point2.x, Ray2.point2.y) love.graphics.setLineWidth(1)   -- Remember that the ray cast can return nil if it hits nothing. local r1nx, r1ny, r1f = Box.Shape:rayCast(Ray1.point1.x, Ray1.point1.y, Ray1.point2.x, Ray1.point2.y, Ray1.scale, Box.x, Box.y, Box.r) local r2nx, r2ny, r2f = Box.Shape:rayCast(Ray2.point1.x, Ray2.point1.y, Ray2.point2.x, Ray2.point2.y, Ray2.scale, Box.x, Box.y, Box.r)   if r1nx then -- Calculating the world position where the ray hit. local r1HitX = Ray1.point1.x + (Ray1.point2.x - Ray1.point1.x) * r1f local r1HitY = Ray1.point1.y + (Ray1.point2.y - Ray1.point1.y) * r1f   -- Drawing the ray from the starting point to the position on the shape. love.graphics.setColor(255, 0, 0) love.graphics.line(Ray1.point1.x, Ray1.point1.y, r1HitX, r1HitY)   -- We also get the surface normal of the edge the ray hit. Here drawn in green love.graphics.setColor(0, 255, 0) love.graphics.line(r1HitX, r1HitY, r1HitX + r1nx * 25, r1HitY + r1ny * 25) end   if r2nx then -- Calculating the world position where the ray hit. local r2HitX = Ray2.point1.x + (Ray2.point2.x - Ray2.point1.x) * r2f local r2HitY = Ray2.point1.y + (Ray2.point2.y - Ray2.point1.y) * r2f   -- Drawing the ray from the starting point to the position on the shape. love.graphics.setColor(255, 0, 0) love.graphics.line(Ray2.point1.x, Ray2.point1.y, r2HitX, r2HitY)   -- We also get the surface normal of the edge the ray hit. Here drawn in green love.graphics.setColor(0, 255, 0) love.graphics.line(r2HitX, r2HitY, r2HitX + r2nx * 25, r2HitY + r2ny * 25) end end ``` Screenshot of how the example could look like. See Also -------- * [Shape](shape "Shape") love love.window.getSafeArea love.window.getSafeArea ======================= **Available since LÖVE [11.3](https://love2d.org/wiki/11.3 "11.3")** This function is not supported in earlier versions. Gets area inside the window which is known to be unobstructed by a system title bar, the iPhone X notch, etc. Useful for making sure UI elements can be seen by the user. Function -------- ### Synopsis ``` x, y, w, h = love.window.getSafeArea( ) ``` ### Arguments None. ### Returns `[number](number "number") x` Starting position of safe area (x-axis). `[number](number "number") y` Starting position of safe area (y-axis). `[number](number "number") w` Width of safe area. `[number](number "number") h` Height of safe area. Notes ----- Values returned are in DPI-scaled units (the same coordinate system as most other window-related APIs), not in pixels. See Also -------- * [love.window](love.window "love.window")
programming_docs
love love.setDeprecationOutput love.setDeprecationOutput ========================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Sets whether LÖVE displays warnings when using deprecated functionality. It is disabled by default in [fused mode](love.filesystem.isfused "love.filesystem.isFused"), and enabled by default otherwise. When deprecation output is enabled, the first use of a formally deprecated LÖVE API will show a message at the bottom of the screen for a short time, and print the message to the console. Function -------- ### Synopsis ``` love.setDeprecationOutput( enable ) ``` ### Arguments `[boolean](boolean "boolean") enable` Whether to enable or disable deprecation output. ### Returns Nothing. See Also -------- * [love](love "love") * [love.hasDeprecationOutput](love.hasdeprecationoutput "love.hasDeprecationOutput") love love.graphics.setPointStyle love.graphics.setPointStyle =========================== **Removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in that and later versions. Sets the [point](love.graphics.point "love.graphics.point") style. Smooth points are notoriously buggy on a lot of graphics drivers. Use "rough" [point style](pointstyle "PointStyle") for increased consistency between different drivers. Function -------- ### Synopsis ``` love.graphics.setPointStyle( style ) ``` ### Arguments `[PointStyle](pointstyle "PointStyle") style` The new point style. ### Returns Nothing. Examples -------- Toggle between [point styles](pointstyle "PointStyle") with the help of [love.graphics.getPointStyle](love.graphics.getpointstyle "love.graphics.getPointStyle"). ``` if love.graphics.getPointStyle() == "rough" then love.graphics.setPointStyle("smooth") else love.graphics.setPointStyle("rough") end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.point](love.graphics.point "love.graphics.point") * [love.graphics.setPointSize](love.graphics.setpointsize "love.graphics.setPointSize") * [love.graphics.getPointStyle](love.graphics.getpointstyle "love.graphics.getPointStyle") love love.graphics.getColorMode love.graphics.getColorMode ========================== **Available since LÖVE [0.2.0](https://love2d.org/wiki/0.2.0 "0.2.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier or later versions. Gets the color mode (which controls how images are affected by the current color). Function -------- ### Synopsis ``` mode = love.graphics.getColorMode( ) ``` ### Arguments None. ### Returns `[ColorMode](colormode "ColorMode") mode` The current color mode. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setColorMode](love.graphics.setcolormode "love.graphics.setColorMode") love Rasterizer Rasterizer ========== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This type is not supported in earlier versions. A Rasterizer handles font rendering, containing the font data (image or TrueType font) and drawable glyphs. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.font.newBMFontRasterizer](love.font.newbmfontrasterizer "love.font.newBMFontRasterizer") | Creates a new BMFont Rasterizer. | 0.7.0 | | | [love.font.newImageRasterizer](love.font.newimagerasterizer "love.font.newImageRasterizer") | Creates a new Image Rasterizer. | 0.7.0 | | | [love.font.newRasterizer](love.font.newrasterizer "love.font.newRasterizer") | Creates a new Rasterizer. | 0.7.0 | | | [love.font.newTrueTypeRasterizer](love.font.newtruetyperasterizer "love.font.newTrueTypeRasterizer") | Creates a new TrueType Rasterizer. | 0.7.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | | [Rasterizer:getAdvance](rasterizer-getadvance "Rasterizer:getAdvance") | Gets font advance. | 0.7.0 | | | [Rasterizer:getAscent](rasterizer-getascent "Rasterizer:getAscent") | Gets ascent height. | 0.7.0 | | | [Rasterizer:getDescent](rasterizer-getdescent "Rasterizer:getDescent") | Gets descent height. | 0.7.0 | | | [Rasterizer:getGlyphCount](rasterizer-getglyphcount "Rasterizer:getGlyphCount") | Gets number of glyphs in font. | 0.7.0 | | | [Rasterizer:getGlyphData](rasterizer-getglyphdata "Rasterizer:getGlyphData") | Gets glyph data of a specified glyph. | 0.7.0 | | | [Rasterizer:getHeight](rasterizer-getheight "Rasterizer:getHeight") | Gets font height. | 0.7.0 | | | [Rasterizer:getLineHeight](rasterizer-getlineheight "Rasterizer:getLineHeight") | Gets line height of a font. | 0.7.0 | | | [Rasterizer:hasGlyphs](rasterizer-hasglyphs "Rasterizer:hasGlyphs") | Checks if font contains specified glyphs. | 0.7.0 | | Supertypes ---------- * [Object](object "Object") See Also -------- * [love.font](love.font "love.font") love RecordingDevice:getSampleRate RecordingDevice:getSampleRate ============================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the number of samples per second currently being recorded. Function -------- ### Synopsis ``` rate = RecordingDevice:getSampleRate( ) ``` ### Arguments None. ### Returns `[number](number "number") rate` The number of samples being recorded per second (sample rate). See Also -------- * [RecordingDevice](recordingdevice "RecordingDevice") * [RecordingDevice:start](recordingdevice-start "RecordingDevice:start") love Source:getDirection Source:getDirection =================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Gets the direction of the Source. Function -------- ### Synopsis ``` x, y, z = Source:getDirection( ) ``` ### Arguments None. ### Returns `[number](number "number") x` The X part of the direction vector. `[number](number "number") y` The Y part of the direction vector. `[number](number "number") z` The Z part of the direction vector. See Also -------- * [Source](source "Source") love RecordingDevice RecordingDevice =============== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This type is not supported in earlier versions. Represents an audio input device capable of recording sounds. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.audio.getRecordingDevices](love.audio.getrecordingdevices "love.audio.getRecordingDevices") | Gets a list of **RecordingDevices** on the system. | 11.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | | [RecordingDevice:getBitDepth](recordingdevice-getbitdepth "RecordingDevice:getBitDepth") | Gets the number of bits per sample in the data currently being recorded. | 11.0 | | | [RecordingDevice:getChannelCount](recordingdevice-getchannelcount "RecordingDevice:getChannelCount") | Gets the number of channels currently being recorded (mono or stereo). | 11.0 | | | [RecordingDevice:getData](recordingdevice-getdata "RecordingDevice:getData") | Gets all recorded audio [SoundData](sounddata "SoundData") stored in the device's internal ring buffer. | 11.0 | | | [RecordingDevice:getName](recordingdevice-getname "RecordingDevice:getName") | Gets the name of the recording device. | 11.0 | | | [RecordingDevice:getSampleCount](recordingdevice-getsamplecount "RecordingDevice:getSampleCount") | Gets the number of currently recorded samples. | 11.0 | | | [RecordingDevice:getSampleRate](recordingdevice-getsamplerate "RecordingDevice:getSampleRate") | Gets the number of samples per second currently being recorded. | 11.0 | | | [RecordingDevice:isRecording](recordingdevice-isrecording "RecordingDevice:isRecording") | Gets whether the device is currently recording. | 11.0 | | | [RecordingDevice:start](recordingdevice-start "RecordingDevice:start") | Begins recording audio using this device. | 11.0 | | | [RecordingDevice:stop](recordingdevice-stop "RecordingDevice:stop") | Stops recording audio from this device. | 11.0 | | Supertypes ---------- * [Object](object "Object") See Also -------- * [love.audio](love.audio "love.audio") love Body:getLinearDamping Body:getLinearDamping ===================== Gets the linear damping of the Body. The linear damping is the *rate of decrease of the linear velocity over time*. A moving body with no damping and no external forces will continue moving indefinitely, as is the case in space. A moving body with damping will gradually stop moving. Damping is not the same as [friction](fixture-setfriction "Fixture:setFriction") - they can be modelled together. Function -------- ### Synopsis ``` damping = Body:getLinearDamping( ) ``` ### Arguments None. ### Returns `[number](number "number") damping` The value of the linear damping. See Also -------- * [Body](body "Body") love ParticleSystem:setTexture ParticleSystem:setTexture ========================= **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** It has been renamed from [ParticleSystem:setImage](particlesystem-setimage "ParticleSystem:setImage"). Sets the texture ([Image](image "Image") or [Canvas](canvas "Canvas")) to be used for the particles. Function -------- ### Synopsis ``` ParticleSystem:setTexture( texture ) ``` ### Arguments `[Texture](texture "Texture") texture` An [Image](image "Image") or [Canvas](canvas "Canvas") to use for the particles. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:getTexture](particlesystem-gettexture "ParticleSystem:getTexture") love love.audio.getOrientation love.audio.getOrientation ========================= Returns the orientation of the listener. Function -------- ### Synopsis ``` fx, fy, fz, ux, uy, uz = love.audio.getOrientation( ) ``` ### Arguments None. ### Returns `[number](number "number") fx, fy, fz` Forward vector of the listener orientation. `[number](number "number") ux, uy, uz` Up vector of the listener orientation. See Also -------- * [love.audio](love.audio "love.audio") love love.releaseerrhand love.releaseerrhand =================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This callback is not supported in that and later versions. Function -------- ### Synopsis ``` love.releaseerrhand( msg ) ``` ### Arguments `[string](string "string") msg` The error message. ### Returns Nothing. Examples -------- ### The default function used if you don't supply your own. ``` function love.releaseerrhand(msg) print("An error has occured, the game has been stopped.")   if not love.graphics or not love.event or not love.graphics.isCreated() then return end   love.graphics.setCanvas() love.graphics.setPixelEffect()   -- Load. if love.audio then love.audio.stop() end love.graphics.reset() love.graphics.setBackgroundColor(89, 157, 220) local font = love.graphics.newFont(14) love.graphics.setFont(font)   love.graphics.setColor(255, 255, 255, 255)   love.graphics.clear()   local err = {}   p = string.format("An error has occured that caused %s to stop.\nYou can notify %s about this%s.", love._release.title or "this game", love._release.author or "the author", love._release.url and " at " .. love._release.url or "")   local function draw() love.graphics.clear() love.graphics.printf(p, 70, 70, love.graphics.getWidth() - 70) love.graphics.present() end   draw()   local e, a, b, c while true do e, a, b, c = love.event.wait()   if e == "quit" then return end if e == "keypressed" and a == "escape" then return end   draw()   end end ``` See Also -------- * [love](love "love") love love.font.newTrueTypeRasterizer love.font.newTrueTypeRasterizer =============================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Creates a new TrueType Rasterizer. Function -------- Create a TrueTypeRasterizer with the default font. ### Synopsis ``` rasterizer = love.font.newTrueTypeRasterizer( size, hinting, dpiscale ) ``` ### Arguments `[number](number "number") size (12)` The font size. `[HintingMode](hintingmode "HintingMode") hinting ("normal")` Available since 0.10.0 True Type hinting mode. `[number](number "number") dpiscale ([love.window.getDPIScale](love.window.getdpiscale "love.window.getDPIScale")())` Available since 11.0 The font DPI scale. ### Returns `[Rasterizer](rasterizer "Rasterizer") rasterizer` The rasterizer. Function -------- Create a TrueTypeRasterizer with custom font. ### Synopsis ``` rasterizer = love.font.newTrueTypeRasterizer( fileName, size, hinting, dpiscale ) ``` ### Arguments `[string](string "string") fileName` Path to font file. `[number](number "number") size (12)` The font size. `[HintingMode](hintingmode "HintingMode") hinting ("normal")` Available since 0.10.0 True Type hinting mode. `[number](number "number") dpiscale ([love.window.getDPIScale](love.window.getdpiscale "love.window.getDPIScale")())` Available since 11.0 The font DPI scale. ### Returns `[Rasterizer](rasterizer "Rasterizer") rasterizer` The rasterizer. Function -------- Create a TrueTypeRasterizer with custom font. ### Synopsis ``` rasterizer = love.font.newTrueTypeRasterizer( fileData, size, hinting, dpiscale ) ``` ### Arguments `[FileData](filedata "FileData") fileData` File data containing font. `[number](number "number") size (12)` The font size. `[HintingMode](hintingmode "HintingMode") hinting ("normal")` Available since 0.10.0 True Type hinting mode. `[number](number "number") dpiscale ([love.window.getDPIScale](love.window.getdpiscale "love.window.getDPIScale")())` Available since 11.0 The font DPI scale. ### Returns `[Rasterizer](rasterizer "Rasterizer") rasterizer` The rasterizer. See Also -------- * [love.font](love.font "love.font") * [love.font.newRasterizer](love.font.newrasterizer "love.font.newRasterizer") * [love.font.newBMFontRasterizer](love.font.newbmfontrasterizer "love.font.newBMFontRasterizer") * [love.font.newImageRasterizer](love.font.newimagerasterizer "love.font.newImageRasterizer") * [Rasterizer](rasterizer "Rasterizer") love Transform:getMatrix Transform:getMatrix =================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the internal 4x4 transformation matrix stored by this Transform. The matrix is returned in [row-major](matrixlayout "MatrixLayout") order. Function -------- ### Synopsis ``` e1_1, e1_2, ..., e4_4 = Transform:getMatrix( ) ``` ### Arguments None. ### Returns `[number](number "number") e1_1` The first column of the first row of the matrix. `[number](number "number") e1_2` The second column of the first row of the matrix. `[number](number "number") ...` Additional matrix elements. `[number](number "number") e4_4` The fourth column of the fourth row of the matrix. See Also -------- * [Transform](transform "Transform") * [Transform:setMatrix](transform-setmatrix "Transform:setMatrix") love love.mousereleased love.mousereleased ================== Callback function triggered when a mouse button is released. Function -------- ### Synopsis ``` love.mousereleased( x, y, button, istouch, presses ) ``` ### Arguments `[number](number "number") x` Mouse x position, in pixels. `[number](number "number") y` Mouse y position, in pixels. `[number](number "number") button` The button index that was released. 1 is the primary mouse button, 2 is the secondary mouse button and 3 is the middle button. Further buttons are mouse dependent. `[boolean](boolean "boolean") istouch` True if the mouse button release originated from a touchscreen touch-release. `[number](number "number") presses` Available since 11.0 The number of presses in a short time frame and small area, used to simulate double, triple clicks ### Returns Nothing. Function -------- **Removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in that and later versions. ### Synopsis ``` love.mousereleased( x, y, button ) ``` ### Arguments `[number](number "number") x` Mouse x position. `[number](number "number") y` Mouse y position. `[MouseConstant](mouseconstant "MouseConstant") button` Mouse button released, except Mouse Wheel. ### Returns Nothing. Examples -------- Position a string ("Text") wherever the user releases the primary mouse button. ``` function love.load() printx = 0 printy = 0 end   function love.draw() love.graphics.print("Text", printx, printy) end   function love.mousereleased(x, y, button) if button == 1 then printx = x printy = y end end ``` See Also -------- * [love](love "love") love love.audio.setMixWithSystem love.audio.setMixWithSystem =========================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Sets whether the system should mix the audio with the system's audio. Function -------- ### Synopsis ``` success = love.audio.setMixWithSystem( mix ) ``` ### Arguments `[boolean](boolean "boolean") mix` True to enable mixing, false to disable it. ### Returns `[boolean](boolean "boolean") success` True if the change succeeded, false otherwise. See Also -------- * [love.audio](love.audio "love.audio") love FileData FileData ======== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This object is not supported in earlier versions. [Data](data "Data") representing the contents of a file. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.filesystem.newFileData](love.filesystem.newfiledata "love.filesystem.newFileData") | Creates a new **FileData** object from a file on disk, or from a string in memory. | 0.7.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Data:clone](data-clone "Data:clone") | Creates a new copy of the Data object. | 11.0 | | | [Data:getFFIPointer](data-getffipointer "Data:getFFIPointer") | Gets an FFI pointer to the Data. | 11.3 | | | [Data:getPointer](data-getpointer "Data:getPointer") | Gets a pointer to the Data. | | | | [Data:getSize](data-getsize "Data:getSize") | Gets the [Data](data "Data")'s size in bytes. | | | | [Data:getString](data-getstring "Data:getString") | Gets the full Data as a string. | 0.9.0 | | | [FileData:getExtension](filedata-getextension "FileData:getExtension") | Gets the extension of the FileData. | 0.7.0 | | | [FileData:getFilename](filedata-getfilename "FileData:getFilename") | Gets the filename of the FileData. | 0.7.0 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Supertypes ---------- * [Data](data "Data") * [Object](object "Object") See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [File](file "File")
programming_docs
love Source:getDuration Source:getDuration ================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets the duration of the Source. For [streaming](sourcetype "SourceType") Sources it may not always be sample-accurate, and may return -1 if the duration cannot be determined at all. Function -------- ### Synopsis ``` duration = Source:getDuration( unit ) ``` ### Arguments `[TimeUnit](timeunit "TimeUnit") unit ("seconds")` The time unit for the return value. ### Returns `[number](number "number") duration` The duration of the Source, or -1 if it cannot be determined. See Also -------- * [Source:tell](source-tell "Source:tell") * [Source:seek](source-seek "Source:seek") * [Source](source "Source") * [Decoder:getDuration](decoder-getduration "Decoder:getDuration") * [SoundData:getDuration](sounddata-getduration "SoundData:getDuration") love love.filesystem.getAppdataDirectory love.filesystem.getAppdataDirectory =================================== Returns the application data directory (could be the same as getUserDirectory) Function -------- ### Synopsis ``` path = love.filesystem.getAppdataDirectory( ) ``` ### Arguments None. ### Returns `[string](string "string") path` The path of the application data directory See Also -------- * [love.filesystem](love.filesystem "love.filesystem") love Quad Quad ==== A quadrilateral (a polygon with four sides and four corners) with texture coordinate information. Quads can be used to select part of a texture to draw. In this way, one large [texture atlas](https://en.wikipedia.org/wiki/Texture_atlas) can be loaded, and then split up into sub-images. Quads 'bleed' when scaled, rotated or drawn at non-integer coordinates, even within [SpriteBatches](spritebatch "SpriteBatch"), to compensate for this, use 1px borders around the textures inside the texture atlas (preferably with the same colors as the actual border) Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.graphics.newQuad](love.graphics.newquad "love.graphics.newQuad") | Creates a new **Quad**. | | | Functions --------- | | | | | | --- | --- | --- | --- | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | | [Quad:flip](quad-flip "Quad:flip") | Flips this quad horizontally, vertically, or both. | | 0.9.0 | | [Quad:getTextureDimensions](quad-gettexturedimensions "Quad:getTextureDimensions") | Gets reference texture dimensions initially specified in [love.graphics.newQuad](love.graphics.newquad "love.graphics.newQuad"). | 0.10.2 | | | [Quad:getViewport](quad-getviewport "Quad:getViewport") | Gets the current viewport of this Quad. | | | | [Quad:setViewport](quad-setviewport "Quad:setViewport") | Sets the texture coordinates according to a viewport. | | | Supertypes ---------- * [Object](object "Object") See Also -------- * [love.graphics](love.graphics "love.graphics") love enet.event enet.event ========== Description ----------- An **event** is a table generated by [host:service()](enet.host-service "enet.host:service") or [peer:receive()](enet.peer-receive "enet.peer:receive") which will **always** contain a [string](string "string") named *type*, a [enet.peer](enet.peer "enet.peer") named *peer*, and a [string](string "string") or [number](number "number") named *data* depending on the kind of event. Though be wary that [host:service()](enet.host-service "enet.host:service") and [peer:receive()](enet.peer-receive "enet.peer:receive") can return [nil](nil "nil") if no events are in the queue. Structure --------- | event.type | event.peer | event.data | | --- | --- | --- | | "receive" | [peer](enet.peer "enet.peer") | [string](string "string") | | "disconnect" | [peer](enet.peer "enet.peer") | [number](number "number") | | "connect" | [peer](enet.peer "enet.peer") | [number](number "number") | See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.host:service](enet.host-service "enet.host:service") * [enet.peer:receive](enet.peer-receive "enet.peer:receive") love love.window.getMode love.window.getMode =================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** Moved from [love.graphics.getMode](love.graphics.getmode "love.graphics.getMode"). Gets the display mode and properties of the window. Function -------- ### Synopsis ``` width, height, flags = love.window.getMode( ) ``` ### Arguments None. ### Returns `[number](number "number") width` Window width. `[number](number "number") height` Window height. `[table](table "table") flags` Table with the window properties: `[boolean](boolean "boolean") fullscreen` Fullscreen (true), or windowed (false). `[FullscreenType](fullscreentype "FullscreenType") fullscreentype` The type of fullscreen mode used. `[number](number "number") vsync` 1 if the graphics framerate is synchronized with the monitor's refresh rate, 0 otherwise. `[number](number "number") msaa` The number of antialiasing samples used (0 if MSAA is disabled). `[boolean](boolean "boolean") resizable` True if the window is resizable in windowed mode, false otherwise. `[boolean](boolean "boolean") borderless` True if the window is borderless in windowed mode, false otherwise. `[boolean](boolean "boolean") centered` True if the window is centered in windowed mode, false otherwise. `[number](number "number") display` The index of the display the window is currently in, if multiple monitors are available. `[number](number "number") minwidth` The minimum width of the window, if it's resizable. `[number](number "number") minheight` The minimum height of the window, if it's resizable. `[boolean](boolean "boolean") highdpi` Available since 0.9.1 True if [high-dpi mode](love.window.getpixelscale "love.window.getPixelScale") is allowed on Retina displays in OS X. Does nothing on non-Retina displays. `[number](number "number") refreshrate` Available since 0.9.2 The refresh rate of the screen's current display mode, in Hz. May be 0 if the value can't be determined. `[number](number "number") x` Available since 0.9.2 The x-coordinate of the window's position in its current display. `[number](number "number") y` Available since 0.9.2 The y-coordinate of the window's position in its current display. `[boolean](boolean "boolean") srgb` Available since 0.9.1 and removed in LÖVE 0.10.0 Removed in [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0") (use [love.graphics.isGammaCorrect](love.graphics.isgammacorrect "love.graphics.isGammaCorrect") instead). True if sRGB gamma correction is applied when drawing to the screen. See Also -------- * [love.window](love.window "love.window") * [love.window.setMode](love.window.setmode "love.window.setMode") love Video:getDimensions Video:getDimensions =================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets the width and height of the Video in pixels. Function -------- ### Synopsis ``` width, height = Video:getDimensions( ) ``` ### Arguments None. ### Returns `[number](number "number") width` The width of the Video. `[number](number "number") height` The height of the Video. See Also -------- * [Video](video "Video") * [Video:getWidth](video-getwidth "Video:getWidth") * [Video:getHeight](video-getheight "Video:getHeight") love ParticleSystem:getSpinVariation ParticleSystem:getSpinVariation =============================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the amount of spin variation (0 meaning no variation and 1 meaning full variation between start and end). Function -------- ### Synopsis ``` variation = ParticleSystem:getSpinVariation( ) ``` ### Arguments Nothing. ### Returns `[number](number "number") variation` The amount of variation (0 meaning no variation and 1 meaning full variation between start and end). See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setSpinVariation](particlesystem-setspinvariation "ParticleSystem:setSpinVariation") love FullscreenType FullscreenType ============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This enum is not supported in earlier versions. Types of fullscreen modes. Constants --------- desktop Sometimes known as [borderless fullscreen windowed](http://pcgamingwiki.com/wiki/Borderless_fullscreen_windowed) mode. A borderless screen-sized window is created which sits on top of all desktop UI elements. The window is automatically resized to match the dimensions of the desktop, and its size cannot be changed. This constant has been renamed from **normal** exclusive Available since 0.10.0 Standard exclusive-fullscreen mode. Changes the display mode (actual resolution) of the monitor. This constant has been renamed to **exclusive** normal Removed in 0.10.0 Standard exclusive-fullscreen mode. Changes the display mode (actual resolution) of the monitor. Notes ----- In exclusive fullscreen mode, if a window size is used which does not match one of the monitor's supported display modes, the window will be resized to the next largest display mode. Exclusive fullscreen mode is sometimes avoided by users because it can cause issues in some window managers and with multi-monitor setups. In OS X it prevents switching to a different program until fullscreen mode is exited. The "desktop" fullscreen mode generally avoids these issues. See Also -------- * [love.window](love.window "love.window") * [love.window.setMode](love.window.setmode "love.window.setMode") * [love.window.setFullscreen](love.window.setfullscreen "love.window.setFullscreen") * [love.resize](love.resize "love.resize") * [Config Files](love.conf "Config Files") love love.window.isMaximized love.window.isMaximized ======================= **Available since LÖVE [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2")** This function is not supported in earlier versions. Gets whether the Window is currently [maximized](love.window.maximize "love.window.maximize"). The window can be maximized if it is not fullscreen and is resizable, and either the user has pressed the window's Maximize button or [love.window.maximize](love.window.maximize "love.window.maximize") has been called. Function -------- ### Synopsis ``` maximized = love.window.isMaximized( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") maximized` True if the window is currently maximized in windowed mode, false otherwise. See Also -------- * [love.window](love.window "love.window") * [love.window.maximize](love.window.maximize "love.window.maximize") love love.filesystem.setSymlinksEnabled love.filesystem.setSymlinksEnabled ================================== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Sets whether love.filesystem follows symbolic links. It is enabled by default in version [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0") and newer, and disabled by default in [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2"). Function -------- ### Synopsis ``` love.filesystem.setSymlinksEnabled( enable ) ``` ### Arguments `[boolean](boolean "boolean") enable` Whether love.filesystem should follow symbolic links. ### Returns Nothing. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [love.filesystem.areSymlinksEnabled](love.filesystem.aresymlinksenabled "love.filesystem.areSymlinksEnabled") * [love.filesystem.isSymlink](love.filesystem.issymlink "love.filesystem.isSymlink") love BezierCurve:removeControlPoint BezierCurve:removeControlPoint ============================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Removes the specified control point. Function -------- ### Synopsis ``` BezierCurve:removeControlPoint( index ) ``` ### Arguments `[number](number "number") index` The index of the control point to remove. ### Returns Nothing. See Also -------- * [BezierCurve](beziercurve "BezierCurve") * [BezierCurve:getDegree](beziercurve-getdegree "BezierCurve:getDegree") * [BezierCurve:setControlPoint](beziercurve-setcontrolpoint "BezierCurve:setControlPoint") * [BezierCurve:getControlPoint](beziercurve-getcontrolpoint "BezierCurve:getControlPoint") * [BezierCurve:insertControlPoint](beziercurve-insertcontrolpoint "BezierCurve:insertControlPoint") * [love.math](love.math "love.math") love love.graphics.getPointStyle love.graphics.getPointStyle =========================== **Removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in that and later versions. Gets the current [point](love.graphics.point "love.graphics.point") style. Function -------- ### Synopsis ``` style = love.graphics.getPointStyle( ) ``` ### Arguments None. ### Returns `[PointStyle](pointstyle "PointStyle") style` The current point style. Examples -------- Toggle between [point styles](pointstyle "PointStyle") with the help of [love.graphics.setPointStyle](love.graphics.setpointstyle "love.graphics.setPointStyle"). ``` if love.graphics.getPointStyle() == "rough" then love.graphics.setPointStyle("smooth") else love.graphics.setPointStyle("rough") end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.point](love.graphics.point "love.graphics.point") * [love.graphics.setPointStyle](love.graphics.setpointstyle "love.graphics.setPointStyle") love love.graphics.setStencilTest love.graphics.setStencilTest ============================ **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** Together with [love.graphics.stencil](love.graphics.stencil "love.graphics.stencil"), it has replaced [love.graphics.setStencil](love.graphics.setstencil "love.graphics.setStencil"). 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](love.graphics.stencil "love.graphics.stencil"). Starting with version [11.0](https://love2d.org/wiki/11.0 "11.0"), a stencil buffer must be set or requested in [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas") when using stencils with a Canvas. `love.graphics.setCanvas{canvas, stencil=true}` is an easy way to use an automatically provided temporary stencil buffer in that case. Function -------- ### Synopsis ``` love.graphics.setStencilTest( comparemode, comparevalue ) ``` ### Arguments `[CompareMode](comparemode "CompareMode") comparemode` The type of comparison to make for each pixel. `[number](number "number") comparevalue` The value to use when comparing with the stencil value of each pixel. Must be between 0 and 255. ### Returns Nothing. Function -------- Disables stencil testing. ### Synopsis ``` love.graphics.setStencilTest( ) ``` ### Arguments None. ### Returns Nothing. Examples -------- ### Drawing circles masked by a rectangle ``` local function myStencilFunction() love.graphics.rectangle("fill", 225, 200, 350, 300) end   function love.draw() -- draw a rectangle as a stencil. Each pixel touched by the rectangle will have its stencil value set to 1. The rest will be 0. love.graphics.stencil(myStencilFunction, "replace", 1)   -- Only allow rendering on pixels whose stencil value is greater than 0. love.graphics.setStencilTest("greater", 0)   love.graphics.setColor(1, 0, 0, 0.45) love.graphics.circle("fill", 300, 300, 150, 50)   love.graphics.setColor(0, 255, 0, 0.45) love.graphics.circle("fill", 500, 300, 150, 50)   love.graphics.setColor(0, 0, 255, 0.45) love.graphics.circle("fill", 400, 400, 150, 50)   love.graphics.setStencilTest() end ``` ### Drawing a circle with a hole ``` local function myStencilFunction() -- Draw a small circle as a stencil. This will be the hole. love.graphics.circle("fill", 400, 300, 50) end   function love.draw() -- Each pixel touched by the circle will have its stencil value set to 1. The rest will be 0. love.graphics.stencil(myStencilFunction, "replace", 1)   -- Configure the stencil test to only allow rendering on pixels whose stencil value is equal to 0. -- This will end up being every pixel *except* ones that were touched by the circle drawn as a stencil. love.graphics.setStencilTest("equal", 0) love.graphics.circle("fill", 400, 300, 150) love.graphics.setStencilTest() end ``` ### Drawing two masked triangles with different colors ``` local function myStencilFunction() love.graphics.circle("fill", 400, 300, 60, 25) end   function love.draw() -- Each pixel touched by the circle will have its stencil value set to 1. The rest will be 0. love.graphics.stencil(myStencilFunction, "replace", 1)   -- Only allow rendering on pixels whose stencil value is greater than 0. love.graphics.setStencilTest("greater", 0) love.graphics.setColor(0.6, 0, 0.5) love.graphics.polygon("fill", 400, 200, 486, 350, 314, 350)   -- Now only allow rendering on pixels whose stencil value is equal to 0. love.graphics.setStencilTest("equal", 0) love.graphics.setColor(0.55, 0.85, 0.5) love.graphics.polygon("fill", 400, 200, 486, 350, 314, 350)   love.graphics.setStencilTest() end ``` The [love.graphics.stencil](love.graphics.stencil "love.graphics.stencil") wiki page includes more examples. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getStencilTest](love.graphics.getstenciltest "love.graphics.getStencilTest") * [love.graphics.stencil](love.graphics.stencil "love.graphics.stencil") love love.graphics.getBlendMode love.graphics.getBlendMode ========================== **Available since LÖVE [0.2.0](https://love2d.org/wiki/0.2.0 "0.2.0")** This function is not supported in earlier versions. Gets the [blending mode](blendmode "BlendMode"). Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. ### Synopsis ``` mode, alphamode = love.graphics.getBlendMode( ) ``` ### Arguments None. ### Returns `[BlendMode](blendmode "BlendMode") mode` The current blend mode. `[BlendAlphaMode](blendalphamode "BlendAlphaMode") alphamode` The current blend alpha mode – it determines how the alpha of drawn objects affects blending. Function -------- **Removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in that and later versions. ### Synopsis ``` mode = love.graphics.getBlendMode( ) ``` ### Arguments None. ### Returns `[BlendMode](blendmode "BlendMode") mode` The current blend mode. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setBlendMode](love.graphics.setblendmode "love.graphics.setBlendMode") * [BlendMode](blendmode "BlendMode") love Contact:isEnabled Contact:isEnabled ================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Returns whether the contact is enabled. The collision will be ignored if a contact gets disabled in the preSolve callback. Function -------- ### Synopsis ``` enabled = Contact:isEnabled( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") enabled` True if enabled, false otherwise. See Also -------- * [Contact](contact "Contact") * [Contact:setEnabled](contact-setenabled "Contact:setEnabled")
programming_docs
love love.keyboard.getKeyFromScancode love.keyboard.getKeyFromScancode ================================ **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Gets the key corresponding to the given hardware scancode. Unlike [key constants](keyconstant "KeyConstant"), [Scancodes](scancode "Scancode") are keyboard layout-independent. For example the scancode "w" will be generated if the key in the same place as the "w" key on an American keyboard is pressed, no matter what the key is labelled or what the user's operating system settings are. Scancodes are useful for creating default controls that have the same physical locations on on all systems. Function -------- ### Synopsis ``` key = love.keyboard.getKeyFromScancode( scancode ) ``` ### Arguments `[Scancode](scancode "Scancode") scancode` The scancode to get the key from. ### Returns `[KeyConstant](keyconstant "KeyConstant") key` The key corresponding to the given scancode, or "unknown" if the scancode doesn't map to a [KeyConstant](keyconstant "KeyConstant") on the current system. See Also -------- * [love.keyboard](love.keyboard "love.keyboard") * [love.keyboard.getScancodeFromKey](love.keyboard.getscancodefromkey "love.keyboard.getScancodeFromKey") * [love.keyboard.isScancodeDown](love.keyboard.isscancodedown "love.keyboard.isScancodeDown") * [love.keypressed](love.keypressed "love.keypressed") * [love.keyreleased](love.keyreleased "love.keyreleased") love enet.host:flush enet.host:flush =============== Sends any queued packets. This is only required to send packets earlier than the next call to [host:service](enet.host-service "enet.host:service"), or if [host:service](enet.host-service "enet.host:service") will not be called again. Function -------- ### Synopsis ``` host:flush() ``` ### Arguments None. ### Returns Nothing. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.host:service](enet.host-service "enet.host:service") * [enet.host](enet.host "enet.host") love love.audio.newQueueableSource love.audio.newQueueableSource ============================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Creates a new Source usable for real-time generated sound playback with [Source:queue](source-queue "Source:queue"). This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- ### Synopsis ``` source = love.audio.newQueueableSource( samplerate, bitdepth, channels, buffercount ) ``` ### Arguments `[number](number "number") samplerate` Number of samples per second when playing. `[number](number "number") bitdepth` Bits per sample (8 or 16). `[number](number "number") channels` 1 for mono or 2 for stereo. `[number](number "number") buffercount (0)` The number of buffers that can be queued up at any given time with [Source:queue](source-queue "Source:queue"). Cannot be greater than 64. A sensible default (~8) is chosen if no value is specified. ### Returns `[Source](source "Source") source` The new Source usable with [Source:queue](source-queue "Source:queue"). Notes ----- The sample rate, bit depth, and channel count of any [SoundData](sounddata "SoundData") used with [Source:queue](source-queue "Source:queue") must match the parameters given to this constructor. See Also -------- * [love.audio](love.audio "love.audio") * [Source](source "Source") * [Source:queue](source-queue "Source:queue") * [SourceType](sourcetype "SourceType") love RevoluteJoint:setLowerLimit RevoluteJoint:setLowerLimit =========================== Sets the lower limit. Function -------- ### Synopsis ``` RevoluteJoint:setLowerLimit( lower ) ``` ### Arguments `[number](number "number") lower` The lower limit, in radians. ### Returns Nothing. See Also -------- * [RevoluteJoint](revolutejoint "RevoluteJoint") love Body:isAwake Body:isAwake ============ **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the sleep status of the body. Function -------- ### Synopsis ``` status = Body:isAwake( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") status` True if the body is awake or false if not. See Also -------- * [Body](body "Body") love love.graphics.intersectScissor love.graphics.intersectScissor ============================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Sets the [scissor](love.graphics.setscissor "love.graphics.setScissor") 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](love.graphics.setscissor "love.graphics.setScissor"). The scissor limits the drawing area to a specified rectangle. This affects all graphics calls, including [love.graphics.clear](love.graphics.clear "love.graphics.clear"). The dimensions of the scissor is unaffected by graphical transformations (translate, scale, ...). Function -------- ### Synopsis ``` love.graphics.intersectScissor( x, y, width, height ) ``` ### Arguments `[number](number "number") x` The x-coordinate of the upper left corner of the rectangle to intersect with the existing scissor rectangle. `[number](number "number") y` The y-coordinate of the upper left corner of the rectangle to intersect with the existing scissor rectangle. `[number](number "number") width` The width of the rectangle to intersect with the existing scissor rectangle. `[number](number "number") height` The height of the rectangle to intersect with the existing scissor rectangle. ### Returns Nothing. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setScissor](love.graphics.setscissor "love.graphics.setScissor") * [love.graphics.getScissor](love.graphics.getscissor "love.graphics.getScissor") * [love.graphics.push](love.graphics.push "love.graphics.push") * [love.graphics.pop](love.graphics.pop "love.graphics.pop") love SpriteBatch:setTexture SpriteBatch:setTexture ====================== **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. Sets the texture ([Image](image "Image") or [Canvas](canvas "Canvas")) used for the sprites in the batch, when drawing. Function -------- ### Synopsis ``` SpriteBatch:setTexture( texture ) ``` ### Arguments `[Texture](texture "Texture") texture` The new Image or Canvas to use for the sprites in the batch. ### Returns Nothing. See Also -------- * [SpriteBatch](spritebatch "SpriteBatch") * [SpriteBatch:getTexture](spritebatch-gettexture "SpriteBatch:getTexture") love Joint:getType Joint:getType ============= Gets a string representing the type. Function -------- ### Synopsis ``` type = Joint:getType( ) ``` ### Arguments None. ### Returns `[JointType](jointtype "JointType") type` A string with the name of the Joint type. See Also -------- * [Joint](joint "Joint") love love.audio.setEffect love.audio.setEffect ==================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Defines an effect that can be applied to a [Source](source "Source"). Not all system supports audio effects. Use [love.audio.isEffectsSupported](love.audio.iseffectssupported "love.audio.isEffectsSupported") to check. Function -------- ### Synopsis ``` love.audio.setEffect(name, settings) ``` ### Arguments `[string](string "string") name` The name of the effect. `[table](table "table") settings` The settings to use for this effect, with the following fields: `[EffectType](effecttype "EffectType") type` The type of effect to use. `[number](number "number") volume` The volume of the effect. `[number](number "number") ...` Effect-specific settings. See [EffectType](effecttype "EffectType") for available effects and their corresponding settings. ### Returns `[boolean](boolean "boolean") success` Whether the effect was successfully created. Function -------- ### Synopsis ``` love.audio.setEffect(name, enabled) ``` ### Arguments `[string](string "string") name` The name of the effect. `[boolean](boolean "boolean") enabled (true)` If false and the given effect name was previously set, disables the effect. ### Returns `[boolean](boolean "boolean") success` Whether the effect was successfully disabled. Examples -------- ### Playing music with added reverb ``` love.audio.setEffect('myEffect', {type = 'reverb'}) local source = love.audio.newSource('music.ogg', 'stream') source:setEffect('myEffect') source:play() ``` ### Playing music with distortion ``` love.audio.setEffect('myEffect', { type = 'distortion', gain = .5, edge = .25, }) local source = love.audio.newSource('music.ogg', 'stream') source:setEffect('myEffect') source:play() ``` See Also -------- * [love.audio](love.audio "love.audio") * [love.audio.isEffectsSupported](love.audio.iseffectssupported "love.audio.isEffectsSupported") * [Source:setEffect](source-seteffect "Source:setEffect") love SoundData:getChannels SoundData:getChannels ===================== | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | This function has been renamed to [SoundData:getChannelCount](sounddata-getchannelcount "SoundData:getChannelCount"). | Returns the number of channels in the stream. Function -------- ### Synopsis ``` channels = SoundData:getChannels( ) ``` ### Arguments None. ### Returns `[number](number "number") channels` 1 for mono, 2 for stereo. See Also -------- * [SoundData](sounddata "SoundData") love MouseJoint:getMaxForce MouseJoint:getMaxForce ====================== Gets the highest allowed force. Function -------- ### Synopsis ``` f = MouseJoint:getMaxForce( ) ``` ### Arguments None. ### Returns `[number](number "number") f` The max allowed force. See Also -------- * [MouseJoint](mousejoint "MouseJoint") love VertexWinding VertexWinding ============= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This enum is not supported in earlier versions. How Mesh geometry vertices are ordered. Constants --------- cw Clockwise ccw Counter-clockwise See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getFrontFaceWinding](love.graphics.getfrontfacewinding "love.graphics.getFrontFaceWinding") love ParticleSystem:setEmitterLifetime ParticleSystem:setEmitterLifetime ================================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [ParticleSystem:setLifetime](particlesystem-setlifetime "ParticleSystem:setLifetime"). Sets how long the particle system should emit particles (if -1 then it emits particles forever). Function -------- ### Synopsis ``` ParticleSystem:setEmitterLifetime( life ) ``` ### Arguments `[number](number "number") life` The lifetime of the emitter (in seconds). ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love Joystick:getButtonCount Joystick:getButtonCount ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been moved from [love.joystick.getNumButtons](love.joystick.getnumbuttons "love.joystick.getNumButtons"). Gets the number of buttons on the joystick. Function -------- ### Synopsis ``` buttons = Joystick:getButtonCount( ) ``` ### Arguments None. ### Returns `[number](number "number") buttons` The number of buttons available. See Also -------- * [Joystick](joystick "Joystick") * [Joystick:isDown](joystick-isdown "Joystick:isDown") love love.graphics.getMaxPointSize love.graphics.getMaxPointSize ============================= **Removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** Use [love.graphics.getSystemLimits](love.graphics.getsystemlimits "love.graphics.getSystemLimits") instead. Gets the max supported [point](love.graphics.point "love.graphics.point") size. Function -------- ### Synopsis ``` size = love.graphics.getMaxPointSize( ) ``` ### Arguments None. ### Returns `[number](number "number") size` The max supported point size. Examples -------- Draws a [point](love.graphics.point "love.graphics.point") at the maximum supported size. ``` function love.draw() local max = love.graphics.getMaxPointSize(); love.graphics.setPointSize(max); love.graphics.point(100, 100); end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.point](love.graphics.point "love.graphics.point") * [love.graphics.getPointSize](love.graphics.getpointsize "love.graphics.getPointSize") * [love.graphics.setPointSize](love.graphics.setpointsize "love.graphics.setPointSize") love Video:tell Video:tell ========== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets the current playback position of the Video. Function -------- ### Synopsis ``` seconds = Video:tell( ) ``` ### Arguments None. ### Returns `[number](number "number") seconds` The time in seconds since the beginning of the Video. See Also -------- * [Video](video "Video") * [Video:rewind](video-rewind "Video:rewind") * [Video:seek](video-seek "Video:seek") love Contact Contact ======= Contacts are objects created to manage collisions in worlds. Functions --------- | | | | | | --- | --- | --- | --- | | [Contact:getChildren](contact-getchildren "Contact:getChildren") | Gets the child indices of the shapes of the two colliding fixtures. | 0.9.0 | | | [Contact:getFixtures](contact-getfixtures "Contact:getFixtures") | Gets the two [Fixtures](fixture "Fixture") that hold the shapes that are in contact. | 0.9.2 | | | [Contact:getFriction](contact-getfriction "Contact:getFriction") | Get the friction between two shapes that are in contact. | | | | [Contact:getNormal](contact-getnormal "Contact:getNormal") | Get the normal vector between two shapes that are in contact. | | | | [Contact:getPosition](contact-getposition "Contact:getPosition") | Get the location of the contact point between two shapes. | | 0.8.0 | | [Contact:getPositions](contact-getpositions "Contact:getPositions") | Returns the contact points of the two colliding fixtures. | 0.8.0 | | | [Contact:getRestitution](contact-getrestitution "Contact:getRestitution") | Get the restitution between two shapes that are in contact. | | | | [Contact:getSeparation](contact-getseparation "Contact:getSeparation") | Get the separation between two shapes that are in contact. | | 0.8.0 | | [Contact:getVelocity](contact-getvelocity "Contact:getVelocity") | Get the linear impact velocity of a contact. | | 0.8.0 | | [Contact:isEnabled](contact-isenabled "Contact:isEnabled") | Returns whether the contact is enabled. | 0.8.0 | | | [Contact:isTouching](contact-istouching "Contact:isTouching") | Returns whether the two colliding fixtures are touching each other. | 0.8.0 | | | [Contact:resetFriction](contact-resetfriction "Contact:resetFriction") | Resets the contact friction to the mixture value of both fixtures. | 0.8.0 | | | [Contact:resetRestitution](contact-resetrestitution "Contact:resetRestitution") | Resets the contact restitution to the mixture value of both fixtures. | 0.8.0 | | | [Contact:setEnabled](contact-setenabled "Contact:setEnabled") | Enables or disables the contact. | 0.8.0 | | | [Contact:setFriction](contact-setfriction "Contact:setFriction") | Sets the contact friction. | 0.8.0 | | | [Contact:setRestitution](contact-setrestitution "Contact:setRestitution") | Sets the contact restitution. | 0.8.0 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Supertypes ---------- * [Object](object "Object") See Also -------- * [World:setCallbacks](world-setcallbacks "World:setCallbacks") * [World:getContacts](world-getcontacts "World:getContacts") * [love.physics](love.physics "love.physics") love Body:applyAngularImpulse Body:applyAngularImpulse ======================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Applies an angular impulse to a body. This makes a single, instantaneous addition to the body momentum. A body with with a larger mass will react less. The reaction does **not** depend on the timestep, and is equivalent to applying a force continuously for 1 second. Impulses are best used to give a single push to a body. For a continuous push to a body it is better to use [Body:applyForce](body-applyforce "Body:applyForce"). Function -------- ### Synopsis ``` Body:applyAngularImpulse( impulse ) ``` ### Arguments `[number](number "number") impulse` The impulse in kilogram-square meter per second. ### Returns Nothing. See Also -------- * [Body](body "Body") * [Body:applyLinearImpulse](body-applylinearimpulse "Body:applyLinearImpulse") * [Body:applyTorque](body-applytorque "Body:applyTorque") * [Body:getAngle](body-getangle "Body:getAngle") * [Body:getAngularVelocity](body-getangularvelocity "Body:getAngularVelocity") * [Body:getInertia](body-getinertia "Body:getInertia") love Decoder:getSampleRate Decoder:getSampleRate ===================== Returns the sample rate of the Decoder. Function -------- ### Synopsis ``` rate = Decoder:getSampleRate( ) ``` ### Arguments None. ### Returns `[number](number "number") rate` Number of samples per second. See Also -------- * [Decoder](decoder "Decoder") love (File):isOpen (File):isOpen ============= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets whether the file is open. Function -------- ### Synopsis ``` open = File:isOpen( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") open` True if the file is currently open, false otherwise. See Also -------- * [File](file "File") * [File:open]((file)-open "(File):open") love ChainShape:setPreviousVertex ChainShape:setPreviousVertex ============================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [ChainShape:setPrevVertex](chainshape-setprevvertex "ChainShape:setPrevVertex"). Sets a vertex that establishes a connection to the previous shape. This can help prevent unwanted collisions when a flat shape slides along the edge and moves over to the new shape. Function -------- ### Synopsis ``` ChainShape:setPreviousVertex( x, y ) ``` ### Arguments `[number](number "number") x` The x-component of the vertex. `[number](number "number") y` The y-component of the vertex. ### Returns Nothing. See Also -------- * [ChainShape](chainshape "ChainShape") * [ChainShape:setNextVertex](chainshape-setnextvertex "ChainShape:setNextVertex") love love.window.isDisplaySleepEnabled love.window.isDisplaySleepEnabled ================================= **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets whether the display is allowed to sleep while the program is running. Display sleep is disabled by default. Some types of input (e.g. joystick button presses) might not prevent the display from sleeping, if display sleep is allowed. Function -------- ### Synopsis ``` enabled = love.window.isDisplaySleepEnabled( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") enabled` True if system display sleep is enabled / allowed, false otherwise. See Also -------- * [love.window](love.window "love.window") * [love.window.setDisplaySleepEnabled](love.window.setdisplaysleepenabled "love.window.setDisplaySleepEnabled")
programming_docs
love love.data.pack love.data.pack ============== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Packs (serializes) simple Lua values. This function behaves the same as Lua 5.3's [string.pack](https://www.lua.org/manual/5.3/manual.html#pdf-string.pack). Function -------- ### Synopsis ``` data = love.data.pack( container, format, v1, ... ) ``` ### Arguments `[ContainerType](containertype "ContainerType") container` What type to return the encoded data as. `[string](string "string") format` A string determining how the values are packed. Follows the rules of [Lua 5.3's string.pack format strings](https://www.lua.org/manual/5.3/manual.html#6.4.2). `[value](value "value") v1` The first value (number, boolean, or string) to serialize. `[value](value "value") ...` Additional values to serialize. ### Returns `[value](value "value") data` [Data](data "Data")/[string](string "string") which contains the serialized data. Notes ----- Packing integers with values greater than 2^53 is not supported, as Lua 5.1 cannot represent those values in its number type. See Also -------- * [love.data](love.data "love.data") * [love.data.unpack](love.data.unpack "love.data.unpack") * [love.data.getPackedSize](love.data.getpackedsize "love.data.getPackedSize") love love.joystick love.joystick ============= **Available since LÖVE [0.5.0](https://love2d.org/wiki/0.5.0 "0.5.0")** This module is not supported in earlier versions. Provides an interface to connected joysticks. Types ----- | | | | | | --- | --- | --- | --- | | [Joystick](joystick "Joystick") | Represents a physical joystick. | 0.9.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [love.joystick.close](love.joystick.close "love.joystick.close") | Closes a joystick. | 0.5.0 | 0.9.0 | | [love.joystick.getAxes](love.joystick.getaxes "love.joystick.getAxes") | Returns the position of each axis. | 0.5.0 | 0.9.0 | | [love.joystick.getAxis](love.joystick.getaxis "love.joystick.getAxis") | Returns the direction of the axis. | 0.5.0 | 0.9.0 | | [love.joystick.getBall](love.joystick.getball "love.joystick.getBall") | Returns the change in ball position. | 0.5.0 | 0.9.0 | | [love.joystick.getGamepadMappingString](love.joystick.getgamepadmappingstring "love.joystick.getGamepadMappingString") | Gets the full gamepad mapping string of the Joysticks which have the given GUID, or nil if the GUID isn't recognized as a [gamepad](joystick-isgamepad "Joystick:isGamepad"). | 11.3 | | | [love.joystick.getHat](love.joystick.gethat "love.joystick.getHat") | Returns the direction of a hat. | 0.5.0 | 0.9.0 | | [love.joystick.getJoystickCount](love.joystick.getjoystickcount "love.joystick.getJoystickCount") | Gets the number of connected joysticks. | 0.9.0 | | | [love.joystick.getJoysticks](love.joystick.getjoysticks "love.joystick.getJoysticks") | Gets a list of connected Joysticks. | 0.9.0 | | | [love.joystick.getName](love.joystick.getname "love.joystick.getName") | Returns the name of a joystick. | 0.5.0 | 0.9.0 | | [love.joystick.getNumAxes](love.joystick.getnumaxes "love.joystick.getNumAxes") | Returns the number of axes on the joystick. | 0.5.0 | 0.9.0 | | [love.joystick.getNumBalls](love.joystick.getnumballs "love.joystick.getNumBalls") | Returns the number of balls on the joystick. | 0.5.0 | 0.9.0 | | [love.joystick.getNumButtons](love.joystick.getnumbuttons "love.joystick.getNumButtons") | Returns the number of buttons on the joystick. | 0.5.0 | 0.9.0 | | [love.joystick.getNumHats](love.joystick.getnumhats "love.joystick.getNumHats") | Returns the number of hats on the joystick. | 0.5.0 | 0.9.0 | | [love.joystick.getNumJoysticks](love.joystick.getnumjoysticks "love.joystick.getNumJoysticks") | Returns how many joysticks are available. | 0.5.0 | 0.9.0 | | [love.joystick.isDown](love.joystick.isdown "love.joystick.isDown") | Checks if a button on a joystick is pressed. | 0.5.0 | 0.9.0 | | [love.joystick.isOpen](love.joystick.isopen "love.joystick.isOpen") | Checks if the joystick is open. | 0.5.0 | 0.9.0 | | [love.joystick.loadGamepadMappings](love.joystick.loadgamepadmappings "love.joystick.loadGamepadMappings") | Loads a gamepad mappings string or file created with [love.joystick.saveGamepadMappings](love.joystick.savegamepadmappings "love.joystick.saveGamepadMappings"). | 0.9.2 | | | [love.joystick.open](love.joystick.open "love.joystick.open") | Opens up a joystick to be used. | 0.5.0 | 0.9.0 | | [love.joystick.saveGamepadMappings](love.joystick.savegamepadmappings "love.joystick.saveGamepadMappings") | Saves the virtual gamepad mappings of all recently-used [Joysticks](joystick "Joystick") that are [recognized](joystick-isgamepad "Joystick:isGamepad") as gamepads. | 0.9.2 | | | [love.joystick.setGamepadMapping](love.joystick.setgamepadmapping "love.joystick.setGamepadMapping") | Binds a virtual gamepad input to a button, axis or hat. | 0.9.2 | | Enums ----- | | | | | | --- | --- | --- | --- | | [GamepadAxis](gamepadaxis "GamepadAxis") | Virtual gamepad axes. | 0.9.0 | | | [GamepadButton](gamepadbutton "GamepadButton") | Virtual gamepad buttons. | 0.9.0 | | | [JoystickHat](joystickhat "JoystickHat") | Joystick hat positions. | 0.5.0 | | | [JoystickInputType](joystickinputtype "JoystickInputType") | Types of Joystick inputs. | 0.9.0 | | See Also -------- * [love](love "love") * [love.gamepadpressed](love.gamepadpressed "love.gamepadpressed") * [love.gamepadreleased](love.gamepadreleased "love.gamepadreleased") * [love.joystickpressed](love.joystickpressed "love.joystickpressed") * [love.joystickreleased](love.joystickreleased "love.joystickreleased") * [love.joystickadded](love.joystickadded "love.joystickadded") * [love.joystickremoved](love.joystickremoved "love.joystickremoved") love require require ======= Opens and executes Lua modules. Use periods to seperate folders. If the module is a lua file, don't use the .lua extension in the string passed to `require`. ``` require("foo") require("subfolder.bar") ``` LÖVE adds two loaders (before the Lua loaders) that search for modules in the [game and save directory](love.filesystem "love.filesystem"). These loaders are not affected by Lua's `package.path`. The paths can be altered with [love.filesystem.setRequirePath](love.filesystem.setrequirepath "love.filesystem.setRequirePath") for Lua modules and [love.filesystem.setCRequirePath](love.filesystem.setcrequirepath "love.filesystem.setCRequirePath") for C modules, the latter only work on files located at [save directory](love.filesystem.getsavedirectory "love.filesystem.getSaveDirectory"). Notes ----- It's strongly recommended to use period as directory separator! Forward slashes *accidently* work, hence its usage is discouraged! See Also -------- * [require on the Lua manual.](https://www.lua.org/manual/5.1/manual.html#pdf-require) * [Programming in Lua.](https://www.lua.org/pil/8.1.html) love RevoluteJoint:getLowerLimit RevoluteJoint:getLowerLimit =========================== Gets the lower limit. Function -------- ### Synopsis ``` lower = RevoluteJoint:getLowerLimit( ) ``` ### Arguments None. ### Returns `[number](number "number") lower` The lower limit, in radians. See Also -------- * [RevoluteJoint](revolutejoint "RevoluteJoint") love love.graphics.reset love.graphics.reset =================== Resets the current graphics settings. Calling reset makes the current drawing color white, the current background color black, disables any active [Canvas](canvas "Canvas") or [Shader](shader "Shader"), and removes any scissor settings. It sets the [BlendMode](blendmode "BlendMode") to alpha, enables all [color component masks](love.graphics.setcolormask "love.graphics.setColorMask"), disables [wireframe mode](love.graphics.setwireframe "love.graphics.setWireframe") and resets the current graphics transformation to the [origin](love.graphics.origin "love.graphics.origin"). It also sets both the point and line drawing modes to smooth and their sizes to 1.0. Function -------- ### Synopsis ``` love.graphics.reset( ) ``` ### Arguments None ### Returns Nothing Notes ----- This function, like any other function that change graphics state, only affects the current stack. Calling [love.graphics.pop](love.graphics.pop "love.graphics.pop") will restore the previous transformation stack or the whole graphics settings, depending on how [love.graphics.push](love.graphics.push "love.graphics.push") was called. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setBackgroundColor](love.graphics.setbackgroundcolor "love.graphics.setBackgroundColor") * [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor") * [love.graphics.setLineStyle](love.graphics.setlinestyle "love.graphics.setLineStyle") * [love.graphics.setPointStyle](love.graphics.setpointstyle "love.graphics.setPointStyle") * [love.graphics.origin](love.graphics.origin "love.graphics.origin") love love.joystickreleased love.joystickreleased ===================== Called when a joystick button is released. Function -------- **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.joystickreleased( joystick, button ) ``` ### Arguments `[Joystick](joystick "Joystick") joystick` The joystick object. `[number](number "number") button` The button number. ### Returns Nothing. Function -------- **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in that and later versions. ### Synopsis ``` love.joystickreleased( joystick, button ) ``` ### Arguments `[number](number "number") joystick` The joystick number. `[number](number "number") button` The button number. ### Returns Nothing. See Also -------- * [love](love "love") * [love.joystickpressed](love.joystickpressed "love.joystickpressed") love Source:getChannelCount Source:getChannelCount ====================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** It has been renamed from [Source:getChannels](source-getchannels "Source:getChannels"). Gets the number of channels in the Source. Only 1-channel (mono) Sources can use directional and positional effects. Function -------- ### Synopsis ``` channels = Source:getChannelCount( ) ``` ### Arguments None. ### Returns `[number](number "number") channels` 1 for mono, 2 for stereo. See Also -------- * [Source](source "Source") love Fixture:setMask Fixture:setMask =============== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Fixture:setMask works in **NOT**.Categories selected will **NOT** collide with this fixture. If you want to work as Box2d works with Mask use instead [Fixture:setFilterData](fixture-setfilterdata "Fixture:setFilterData") Sets the category mask of the fixture. There can be up to 16 categories represented as a number from 1 to 16. This fixture will **NOT** collide with the fixtures that are in the selected categories if the other fixture also has a category of this fixture selected. Function -------- ### Synopsis ``` Fixture:setMask( mask1, mask2, ... ) ``` ### Arguments `[number](number "number") mask1` The first category. `[number](number "number") mask2` The second category. ### Returns Nothing. See Also -------- * [Fixture](fixture "Fixture") * [Fixture:getMask](fixture-getmask "Fixture:getMask") love ParticleSystem:getEmissionArea ParticleSystem:getEmissionArea ============================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** It has been renamed from [ParticleSystem:getAreaSpread](particlesystem-getareaspread "ParticleSystem:getAreaSpread"). Gets the area-based spawn parameters for the particles. Function -------- ### Synopsis ``` distribution, dx, dy, angle, directionRelativeToCenter = ParticleSystem:getEmissionArea( ) ``` ### Arguments None. ### Returns `[AreaSpreadDistribution](areaspreaddistribution "AreaSpreadDistribution") distribution` The type of distribution for new particles. `[number](number "number") dx` The maximum spawn distance from the emitter along the x-axis for uniform distribution, or the standard deviation along the x-axis for normal distribution. `[number](number "number") dy` The maximum spawn distance from the emitter along the y-axis for uniform distribution, or the standard deviation along the y-axis for normal distribution. `[number](number "number") angle` The angle in radians of the emission area. `[boolean](boolean "boolean") directionRelativeToCenter` True if newly spawned particles will be oriented relative to the center of the emission area, false otherwise. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setEmissionArea](particlesystem-setemissionarea "ParticleSystem:setEmissionArea") love CircleShape CircleShape =========== Circle extends Shape and adds a radius and a local position. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.physics.newCircleShape](love.physics.newcircleshape "love.physics.newCircleShape") | Creates a new **CircleShape**. | | | Functions --------- | | | | | | --- | --- | --- | --- | | [CircleShape:getLocalCenter](circleshape-getlocalcenter "CircleShape:getLocalCenter") | Get the center of the circle in local coordinates. | | 0.8.0 | | [CircleShape:getPoint](circleshape-getpoint "CircleShape:getPoint") | Gets the center point of the circle shape. | 0.9.1 | | | [CircleShape:getRadius](circleshape-getradius "CircleShape:getRadius") | Gets the radius of the circle shape. | | | | [CircleShape:getWorldCenter](circleshape-getworldcenter "CircleShape:getWorldCenter") | Get the center of the circle in world coordinates. | | 0.8.0 | | [CircleShape:setPoint](circleshape-setpoint "CircleShape:setPoint") | Sets the center point of the circle shape. | 0.9.1 | | | [CircleShape:setRadius](circleshape-setradius "CircleShape:setRadius") | Sets the radius of the circle. | 0.8.0 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | | [Shape:computeAABB](shape-computeaabb "Shape:computeAABB") | Returns the points of the bounding box for the transformed shape. | 0.8.0 | | | [Shape:computeMass](shape-computemass "Shape:computeMass") | Computes the mass properties for the shape. | 0.8.0 | | | [Shape:destroy](shape-destroy "Shape:destroy") | Explicitly destroys the Shape. | | 0.8.0 | | [Shape:getBody](shape-getbody "Shape:getBody") | Get the body the shape is attached to. | 0.7.0 | 0.8.0 | | [Shape:getBoundingBox](shape-getboundingbox "Shape:getBoundingBox") | Gets the bounding box of the shape. | | 0.8.0 | | [Shape:getCategory](shape-getcategory "Shape:getCategory") | Gets the categories this shape is a member of. | | 0.8.0 | | [Shape:getCategoryBits](shape-getcategorybits "Shape:getCategoryBits") | Gets the categories as a 16-bit integer. | | 0.8.0 | | [Shape:getChildCount](shape-getchildcount "Shape:getChildCount") | Returns the number of children the shape has. | 0.8.0 | | | [Shape:getData](shape-getdata "Shape:getData") | Get the data set with setData. | | 0.8.0 | | [Shape:getDensity](shape-getdensity "Shape:getDensity") | Gets the density of the Shape. | | 0.8.0 | | [Shape:getFilterData](shape-getfilterdata "Shape:getFilterData") | Gets the filter data of the Shape. | | 0.8.0 | | [Shape:getFriction](shape-getfriction "Shape:getFriction") | Gets the friction of this shape. | | 0.8.0 | | [Shape:getMask](shape-getmask "Shape:getMask") | Gets which categories this shape should **NOT** collide with. | | 0.8.0 | | [Shape:getRadius](shape-getradius "Shape:getRadius") | Gets the radius of the shape. | | | | [Shape:getRestitution](shape-getrestitution "Shape:getRestitution") | Gets the restitution of this shape. | | 0.8.0 | | [Shape:getType](shape-gettype "Shape:getType") | Gets a string representing the Shape. | | | | [Shape:isSensor](shape-issensor "Shape:isSensor") | Checks whether a Shape is a sensor or not. | | 0.8.0 | | [Shape:rayCast](shape-raycast "Shape:rayCast") | Casts a ray against the shape. | 0.8.0 | | | [Shape:setCategory](shape-setcategory "Shape:setCategory") | Sets the categories this shape is a member of. | | 0.8.0 | | [Shape:setData](shape-setdata "Shape:setData") | Set data to be passed to the collision callback. | | 0.8.0 | | [Shape:setDensity](shape-setdensity "Shape:setDensity") | Sets the density of a Shape. | | 0.8.0 | | [Shape:setFilterData](shape-setfilterdata "Shape:setFilterData") | Sets the filter data for a Shape. | | 0.8.0 | | [Shape:setFriction](shape-setfriction "Shape:setFriction") | Sets the friction of the shape. | | 0.8.0 | | [Shape:setMask](shape-setmask "Shape:setMask") | Sets which categories this shape should **NOT** collide with. | | 0.8.0 | | [Shape:setRestitution](shape-setrestitution "Shape:setRestitution") | Sets the restitution of the shape. | | 0.8.0 | | [Shape:setSensor](shape-setsensor "Shape:setSensor") | Sets whether this shape should act as a sensor. | | 0.8.0 | | [Shape:testPoint](shape-testpoint "Shape:testPoint") | Checks whether a point lies inside the shape. | | | | [Shape:testSegment](shape-testsegment "Shape:testSegment") | Checks whether a line segment intersects a shape. | | 0.8.0 | Supertypes ---------- * [Shape](shape "Shape") * [Object](object "Object") See Also -------- * [love.physics](love.physics "love.physics") love PrismaticJoint:isLimitsEnabled PrismaticJoint:isLimitsEnabled ============================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in that and later versions. Checks whether limits are enabled. Function -------- ### Synopsis ``` enabled = PrismaticJoint:isLimitsEnabled( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") enabled` True if enabled, false otherwise. See Also -------- * [PrismaticJoint](prismaticjoint "PrismaticJoint") love World:getJointList World:getJointList ================== | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | This function has been renamed to [World:getJoints](world-getjoints "World:getJoints"). | **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns a table with all joints. Function -------- ### Synopsis ``` joints = World:getJointList( ) ``` ### Arguments None. ### Returns `[table](table "table") joints` A [sequence](sequence "sequence") with all joints. See Also -------- * [World](world "World") love love.graphics.getTextureTypes love.graphics.getTextureTypes ============================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the available [texture types](texturetype "TextureType"), and whether each is supported. Function -------- ### Synopsis ``` texturetypes = love.graphics.getTextureTypes( ) ``` ### Arguments None. ### Returns `[table](table "table") texturetypes` A table containing [TextureTypes](texturetype "TextureType") as keys, and a boolean indicating whether the type is supported as values. Not all systems support all types. Examples -------- ### Display the texture types on screen and whether they're supported ``` textypes = love.graphics.getTextureTypes()   function love.draw() local y = 0 for name, supported in pairs(textypes) do local str = string.format("Supports texture type '%s': %s", name, tostring(supported)) love.graphics.print(str, 10, y) y = y + 20 end end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [TextureType](texturetype "TextureType") * [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") * [love.graphics.newImage](love.graphics.newimage "love.graphics.newImage") * [love.graphics.newArrayImage](love.graphics.newarrayimage "love.graphics.newArrayImage") * [love.graphics.newCubeImage](love.graphics.newcubeimage "love.graphics.newCubeImage") * [love.graphics.newVolumeImage](love.graphics.newvolumeimage "love.graphics.newVolumeImage")
programming_docs
love Canvas:getMSAA Canvas:getMSAA ============== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** It has been renamed from [Canvas:getFSAA](canvas-getfsaa "Canvas:getFSAA"). Gets the number of multisample antialiasing (MSAA) samples used when drawing to the Canvas. This may be different than the number used as an argument to [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") if the system running LÖVE doesn't support that number. Function -------- ### Synopsis ``` samples = Canvas:getMSAA( ) ``` ### Arguments None. ### Returns `[number](number "number") samples` The number of multisample antialiasing samples used by the canvas when drawing to it. See Also -------- * [Canvas](canvas "Canvas") * [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") * [love.graphics.getSystemLimit](love.graphics.getsystemlimit "love.graphics.getSystemLimit") love PrismaticJoint PrismaticJoint ============== Restricts relative motion between Bodies to one shared axis. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.physics.newPrismaticJoint](love.physics.newprismaticjoint "love.physics.newPrismaticJoint") | Creates a **PrismaticJoint** between two bodies. | | | Functions --------- | | | | | | --- | --- | --- | --- | | [Joint:destroy](joint-destroy "Joint:destroy") | Explicitly destroys the Joint. | | | | [Joint:getAnchors](joint-getanchors "Joint:getAnchors") | Get the anchor points of the joint. | | | | [Joint:getBodies](joint-getbodies "Joint:getBodies") | Gets the [bodies](body "Body") that the Joint is attached to. | 0.9.2 | | | [Joint:getCollideConnected](joint-getcollideconnected "Joint:getCollideConnected") | Gets whether the connected Bodies collide. | | | | [Joint:getReactionForce](joint-getreactionforce "Joint:getReactionForce") | Returns the reaction force on the second body. | | | | [Joint:getReactionTorque](joint-getreactiontorque "Joint:getReactionTorque") | Returns the reaction torque on the second body. | | | | [Joint:getType](joint-gettype "Joint:getType") | Gets a string representing the type. | | | | [Joint:getUserData](joint-getuserdata "Joint:getUserData") | Returns the Lua value associated with this Joint. | 0.9.2 | | | [Joint:isDestroyed](joint-isdestroyed "Joint:isDestroyed") | Gets whether the Joint is destroyed. | 0.9.2 | | | [Joint:setCollideConnected](joint-setcollideconnected "Joint:setCollideConnected") | Sets whether the connected Bodies should collide with each other. | | 0.8.0 | | [Joint:setUserData](joint-setuserdata "Joint:setUserData") | Associates a Lua value with the Joint. | 0.9.2 | | | [PrismaticJoint:areLimitsEnabled](prismaticjoint-arelimitsenabled "PrismaticJoint:areLimitsEnabled") | Checks whether the limits are enabled. | 11.0 | | | [PrismaticJoint:enableLimit](prismaticjoint-enablelimit "PrismaticJoint:enableLimit") | Enables or disables the limits of the joint. | 0.8.0 | 0.9.0 | | [PrismaticJoint:enableMotor](prismaticjoint-enablemotor "PrismaticJoint:enableMotor") | Starts or stops the joint motor. | 0.8.0 | 0.9.0 | | [PrismaticJoint:getAxis](prismaticjoint-getaxis "PrismaticJoint:getAxis") | Gets the world-space axis vector of the Prismatic Joint. | 0.10.2 | | | [PrismaticJoint:getJointSpeed](prismaticjoint-getjointspeed "PrismaticJoint:getJointSpeed") | Get the current joint angle speed. | | | | [PrismaticJoint:getJointTranslation](prismaticjoint-getjointtranslation "PrismaticJoint:getJointTranslation") | Get the current joint translation. | | | | [PrismaticJoint:getLimits](prismaticjoint-getlimits "PrismaticJoint:getLimits") | Gets the joint limits. | | | | [PrismaticJoint:getLowerLimit](prismaticjoint-getlowerlimit "PrismaticJoint:getLowerLimit") | Gets the lower limit. | | | | [PrismaticJoint:getMaxMotorForce](prismaticjoint-getmaxmotorforce "PrismaticJoint:getMaxMotorForce") | Gets the maximum motor force. | | | | [PrismaticJoint:getMotorForce](prismaticjoint-getmotorforce "PrismaticJoint:getMotorForce") | Returns the current motor force. | | | | [PrismaticJoint:getMotorSpeed](prismaticjoint-getmotorspeed "PrismaticJoint:getMotorSpeed") | Gets the motor speed. | | | | [PrismaticJoint:getUpperLimit](prismaticjoint-getupperlimit "PrismaticJoint:getUpperLimit") | Gets the upper limit. | | | | [PrismaticJoint:hasLimitsEnabled](prismaticjoint-haslimitsenabled "PrismaticJoint:hasLimitsEnabled") | Checks whether the limits are enabled. | 0.9.0 | | | [PrismaticJoint:isLimitEnabled](prismaticjoint-islimitenabled "PrismaticJoint:isLimitEnabled") | Checks whether the limits are enabled. | 0.8.0 | 0.9.0 | | [PrismaticJoint:isLimitsEnabled](prismaticjoint-islimitsenabled "PrismaticJoint:isLimitsEnabled") | Checks whether limits are enabled. | | 0.8.0 | | [PrismaticJoint:isMotorEnabled](prismaticjoint-ismotorenabled "PrismaticJoint:isMotorEnabled") | Checks whether the motor is enabled. | | | | [PrismaticJoint:setLimits](prismaticjoint-setlimits "PrismaticJoint:setLimits") | Sets the limits. | | | | [PrismaticJoint:setLimitsEnabled](prismaticjoint-setlimitsenabled "PrismaticJoint:setLimitsEnabled") | Enables/disables the joint limit. | 0.9.0 | 0.8.0 | | [PrismaticJoint:setLowerLimit](prismaticjoint-setlowerlimit "PrismaticJoint:setLowerLimit") | Sets the lower limit. | | | | [PrismaticJoint:setMaxMotorForce](prismaticjoint-setmaxmotorforce "PrismaticJoint:setMaxMotorForce") | Set the maximum motor force. | | | | [PrismaticJoint:setMotorEnabled](prismaticjoint-setmotorenabled "PrismaticJoint:setMotorEnabled") | Enables/disables the joint motor. | 0.9.0 | 0.8.0 | | [PrismaticJoint:setMotorSpeed](prismaticjoint-setmotorspeed "PrismaticJoint:setMotorSpeed") | Sets the motor speed. | | | | [PrismaticJoint:setUpperLimit](prismaticjoint-setupperlimit "PrismaticJoint:setUpperLimit") | Sets the upper limit. | | | Supertypes ---------- * [Joint](joint "Joint") * [Object](object "Object") See Also -------- * [love.physics](love.physics "love.physics") love love.physics.newWorld love.physics.newWorld ===================== Creates a new World. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in earlier versions. ### Synopsis ``` world = love.physics.newWorld( xg, yg, sleep ) ``` ### Arguments `[number](number "number") xg (0)` The x component of gravity. `[number](number "number") yg (0)` The y component of gravity. `[boolean](boolean "boolean") sleep (true)` Whether the bodies in this world are allowed to sleep. ### Returns `[World](world "World") world` A brave new World. Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. This function creates a new World with the given size, no gravity and sleeping turned on. ### Synopsis ``` world = love.physics.newWorld( x1, y1, x2, y2 ) ``` ### Arguments `[number](number "number") x1` The smallest x position in the world. `[number](number "number") y1` The smallest y position in the world. `[number](number "number") x2` The largest x position in the world. `[number](number "number") y2` The largest y position in the world. ### Returns `[World](world "World") world` A World object. Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. ### Synopsis ``` world = love.physics.newWorld( x1, y1, x2, y2, xg, yg, sleep ) ``` ### Arguments `[number](number "number") x1` The smallest x position in the world. `[number](number "number") y1` The smallest y position in the world. `[number](number "number") x2` The largest x position in the world. `[number](number "number") y2` The largest y position in the world. `[number](number "number") xg` The x component of gravity. `[number](number "number") yg` The y component of gravity. `[boolean](boolean "boolean") sleep (true)` Whether sleep is possible in the world. ### Returns `[World](world "World") world` A brave new World. See Also -------- * [love.physics](love.physics "love.physics") * [World](world "World") love ParticleSystem:getLinearDamping ParticleSystem:getLinearDamping =============================== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Gets the amount of linear damping (constant deceleration) for particles. Function -------- ### Synopsis ``` min, max = ParticleSystem:getLinearDamping( ) ``` ### Arguments None. ### Returns `[number](number "number") min` The minimum amount of linear damping applied to particles. `[number](number "number") max` The maximum amount of linear damping applied to particles. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setLinearDamping](particlesystem-setlineardamping "ParticleSystem:setLinearDamping") love World World ===== A world is an object that contains all bodies and joints. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.physics.newWorld](love.physics.newworld "love.physics.newWorld") | Creates a new World. | | | Functions --------- | | | | | | --- | --- | --- | --- | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | | [World:destroy](world-destroy "World:destroy") | Destroys the world. | 0.8.0 | | | [World:getAllowSleeping](world-getallowsleeping "World:getAllowSleeping") | Returns the sleep behaviour of the world. | 0.8.0 | 0.9.0 | | [World:getBodies](world-getbodies "World:getBodies") | Returns a table with all bodies. | 11.0 | | | [World:getBodyCount](world-getbodycount "World:getBodyCount") | Returns the number of bodies in the world. | | | | [World:getBodyList](world-getbodylist "World:getBodyList") | Returns a table with all bodies. | 0.8.0 | 11.0 | | [World:getCallbacks](world-getcallbacks "World:getCallbacks") | Returns functions for the callbacks during the world update. | | | | [World:getContactCount](world-getcontactcount "World:getContactCount") | Returns the number of contacts in the world. | 0.8.0 | | | [World:getContactFilter](world-getcontactfilter "World:getContactFilter") | Returns the function for collision filtering. | 0.8.0 | | | [World:getContactList](world-getcontactlist "World:getContactList") | Returns a table with all contacts. | 0.8.0 | 11.0 | | [World:getContacts](world-getcontacts "World:getContacts") | Returns a table with all [Contacts](contact "Contact"). | 11.0 | | | [World:getGravity](world-getgravity "World:getGravity") | Get the gravity of the world. | | | | [World:getJointCount](world-getjointcount "World:getJointCount") | Returns the number of joints in the world. | | | | [World:getJointList](world-getjointlist "World:getJointList") | Returns a table with all joints. | 0.8.0 | 11.0 | | [World:getJoints](world-getjoints "World:getJoints") | Returns a table with all joints. | 11.0 | | | [World:isAllowSleep](world-isallowsleep "World:isAllowSleep") | Get the sleep behaviour of the world. | | 0.8.0 | | [World:isDestroyed](world-isdestroyed "World:isDestroyed") | Gets whether the World is destroyed. | 0.9.2 | | | [World:isLocked](world-islocked "World:isLocked") | Returns if the world is updating its state. | 0.8.0 | | | [World:isSleepingAllowed](world-issleepingallowed "World:isSleepingAllowed") | Gets the sleep behaviour of the world. | 0.9.0 | | | [World:queryBoundingBox](world-queryboundingbox "World:queryBoundingBox") | Calls a function for each fixture inside the specified area. | 0.8.0 | | | [World:rayCast](world-raycast "World:rayCast") | Casts a ray and calls a function with the fixtures that intersect it. | 0.8.0 | | | [World:setAllowSleep](world-setallowsleep "World:setAllowSleep") | Set the sleep behaviour of the world. | | 0.8.0 | | [World:setAllowSleeping](world-setallowsleeping "World:setAllowSleeping") | Sets the sleep behaviour of the world. | 0.8.0 | 0.9.0 | | [World:setCallbacks](world-setcallbacks "World:setCallbacks") | Sets functions to be called when shapes collide. | 0.8.0 | | | [World:setContactFilter](world-setcontactfilter "World:setContactFilter") | Sets a function for collision filtering. | 0.8.0 | | | [World:setGravity](world-setgravity "World:setGravity") | Set the gravity of the world. | | | | [World:setMeter](world-setmeter "World:setMeter") | Set the scale of the world. | | 0.8.0 | | [World:setSleepingAllowed](world-setsleepingallowed "World:setSleepingAllowed") | Sets the sleep behaviour of the world. | 0.9.0 | | | [World:translateOrigin](world-translateorigin "World:translateOrigin") | Translates the World's origin. | 0.9.0 | | | [World:update](world-update "World:update") | Update the state of the world. | | | Supertypes ---------- * [Object](object "Object") See Also -------- * [love.physics](love.physics "love.physics") love MessageBoxType MessageBoxType ============== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This enum is not supported in earlier versions. Types of [message box](love.window.showmessagebox "love.window.showMessageBox") dialogs. Different types may have slightly different looks. Constants --------- info Informational dialog. warning Warning dialog. error Error dialog. See Also -------- * [love.window](love.window "love.window") * [love.window.showMessageBox](love.window.showmessagebox "love.window.showMessageBox") love enet.peer:send enet.peer:send ============== Queues a packet to be sent to the [peer](enet.peer "enet.peer"). Function -------- ### Synopsis ``` peer:send(data, channel, flag) ``` ### Arguments `[string](string "string") data` The contents of the packet, it must be a [string](string "string"). `[number](number "number") channel` The channel to send the packet on. Optional. Defaults to 0. `[string](string "string") flag` flag is one of "reliable", "unsequenced", or "unreliable". Reliable packets are guaranteed to arrive, and arrive in the order in which they are sent. Unreliable packets arrive in the order in which they are sent, but they aren't guaranteed to arrive. Unsequenced packets are neither guaranteed to arrive, nor do they have any guarantee on the order they arrive. Optional. Defaults to reliable. ### Returns Nothing. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.peer](enet.peer "enet.peer") love BezierCurve:translate BezierCurve:translate ===================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Move the Bézier curve by an offset. Function -------- ### Synopsis ``` BezierCurve:translate(dx, dy) ``` ### Arguments `[number](number "number") dx` Offset along the x axis. `[number](number "number") dy` Offset along the y axis. ### Returns Nothing. See Also -------- * [BezierCurve:rotate](beziercurve-rotate "BezierCurve:rotate") * [BezierCurve:scale](beziercurve-scale "BezierCurve:scale") * [BezierCurve](beziercurve "BezierCurve") * [love.math](love.math "love.math") love RandomGenerator:getSeed RandomGenerator:getSeed ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the seed of the random number generator object. The seed is split into two numbers due to Lua's use of [doubles](https://en.wikipedia.org/wiki/Double-precision_floating-point_format) for all number values - doubles can't accurately represent integer values above 2^53, but the seed value is an integer number in the range of [0, 2^64 - 1]. Function -------- ### Synopsis ``` low, high = RandomGenerator:getSeed( ) ``` ### Arguments None. ### Returns `[number](number "number") low` Integer number representing the lower 32 bits of the RandomGenerator's 64 bit seed value. `[number](number "number") high` Integer number representing the higher 32 bits of the RandomGenerator's 64 bit seed value. See Also -------- * [RandomGenerator](randomgenerator "RandomGenerator") * [RandomGenerator:setSeed](randomgenerator-setseed "RandomGenerator:setSeed") * [love.math](love.math "love.math") love MouseJoint:setDampingRatio MouseJoint:setDampingRatio ========================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Sets a new damping ratio. Function -------- ### Synopsis ``` MouseJoint:setDampingRatio( ratio ) ``` ### Arguments `[number](number "number") ratio` The new damping ratio. ### Returns Nothing. See Also -------- * [MouseJoint](mousejoint "MouseJoint") * [MouseJoint:getDampingRatio](mousejoint-getdampingratio "MouseJoint:getDampingRatio") love CircleShape:setPoint CircleShape:setPoint ==================== **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. Sets the location of the center of the circle shape. Function -------- ### Synopsis ``` CircleShape:setPoint( x, y ) ``` ### Arguments `[number](number "number") x` The x-component of the new center point of the circle. `[number](number "number") y` The y-component of the new center point of the circle. ### Returns Nothing. See Also -------- * [CircleShape](circleshape "CircleShape") * [CircleShape:getPoint](circleshape-getpoint "CircleShape:getPoint") love Shader Shader ====== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This type is not supported in earlier versions. A Shader is used for advanced hardware-accelerated pixel or vertex manipulation. These effects are written in a language based on GLSL (OpenGL Shading Language) with a few things simplified for easier coding. Potential uses for shaders include HDR/bloom, motion blur, grayscale/invert/sepia/any kind of color effect, reflection/refraction, distortions, bump mapping, and much more! Here is a collection of basic shaders and good starting point to learn: <https://github.com/vrld/moonshine> Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.graphics.newShader](love.graphics.newshader "love.graphics.newShader") | Creates a new **Shader**. | 0.9.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | | [Shader:getExternVariable](shader-getexternvariable "Shader:getExternVariable") | Gets information about an 'extern' ('uniform') variable in the Shader. | 0.9.2 | 11.0 | | [Shader:getWarnings](shader-getwarnings "Shader:getWarnings") | Gets warning and error messages (if any). | 0.9.0 | | | [Shader:hasUniform](shader-hasuniform "Shader:hasUniform") | Gets whether a uniform / extern variable exists in the Shader. | 11.0 | | | [Shader:send](shader-send "Shader:send") | Sends one or more values to the shader. | 0.9.0 | | | [Shader:sendColor](shader-sendcolor "Shader:sendColor") | Sends one or more colors to the shader. | 0.10.0 | | Supertypes ---------- * [Object](object "Object") See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setShader](love.graphics.setshader "love.graphics.setShader") * [Shader Variables](shader_variables "Shader Variables")
programming_docs
love EdgeShape:getNextVertex EdgeShape:getNextVertex ======================= **Available since LÖVE [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2")** This function is not supported in earlier versions. Gets the vertex that establishes a connection to the next shape. Setting next and previous EdgeShape vertices can help prevent unwanted collisions when a flat shape slides along the edge and moves over to the new shape. Function -------- ### Synopsis ``` x, y = EdgeShape:getNextVertex( ) ``` ### Arguments None. ### Returns `[number](number "number") x (nil)` The x-component of the vertex, or nil if [EdgeShape:setNextVertex](edgeshape-setnextvertex "EdgeShape:setNextVertex") hasn't been called. `[number](number "number") y (nil)` The y-component of the vertex, or nil if [EdgeShape:setNextVertex](edgeshape-setnextvertex "EdgeShape:setNextVertex") hasn't been called. See Also -------- * [EdgeShape](edgeshape "EdgeShape") * [EdgeShape:setNextVertex](edgeshape-setnextvertex "EdgeShape:setNextVertex") * [EdgeShape:getPreviousVertex](edgeshape-getpreviousvertex "EdgeShape:getPreviousVertex") love love.timer.step love.timer.step =============== Measures the time between two frames. Calling this changes the return value of [love.timer.getDelta](love.timer.getdelta "love.timer.getDelta"). Function -------- ### Synopsis ``` dt = love.timer.step( ) ``` ### Arguments None. ### Returns `[number](number "number") dt` Available since 11.0 The time passed (in seconds). See Also -------- * [love.timer](love.timer "love.timer") * [love.run](love.run "love.run") love Decoder Decoder ======= An object which can gradually decode a sound file. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.sound.newDecoder](love.sound.newdecoder "love.sound.newDecoder") | Attempts to find a decoder for the encoded sound data in the specified file. | | | Functions --------- | | | | | | --- | --- | --- | --- | | [Decoder:clone](decoder-clone "Decoder:clone") | Create new copy of existing decoder. | 11.3 | | | [Decoder:decode](decoder-decode "Decoder:decode") | Decodes a chunk of audio data to a SoundData. | 11.0 | | | [Decoder:getBitDepth](decoder-getbitdepth "Decoder:getBitDepth") | Returns the number of bits per sample. | 0.9.0 | | | [Decoder:getBits](decoder-getbits "Decoder:getBits") | Returns the number of bits per sample. | | 0.9.0 | | [Decoder:getChannelCount](decoder-getchannelcount "Decoder:getChannelCount") | Returns the number of channels in the stream. | 11.0 | | | [Decoder:getChannels](decoder-getchannels "Decoder:getChannels") | Returns the number of channels in the stream. | | 11.0 | | [Decoder:getDuration](decoder-getduration "Decoder:getDuration") | Gets the duration of the sound file. | 0.10.0 | | | [Decoder:getSampleRate](decoder-getsamplerate "Decoder:getSampleRate") | Returns the sample rate of the Decoder. | | | | [Decoder:seek](decoder-seek "Decoder:seek") | Sets the currently playing position of the Decoder. | 11.0 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Supertypes ---------- * [Object](object "Object") See Also -------- * [love.sound](love.sound "love.sound") love Shape:setCategory Shape:setCategory ================= **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** Use [Fixture:setCategory](fixture-setcategory "Fixture:setCategory") instead. Sets the categories this shape is a member of. Sets the categories of this shape by specifying numbers from 1-16 as parameters. Categories can be used to prevent certain shapes from colliding. Function -------- ### Synopsis ``` Shape:setCategory( ... ) ``` ### Arguments `[numbers](https://love2d.org/w/index.php?title=numbers&action=edit&redlink=1 "numbers (page does not exist)") ...` Numbers from 1-16 ### Returns Nothing. See Also -------- * [Shape](shape "Shape") love love.graphics.newScreenshot love.graphics.newScreenshot =========================== **Removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** It has been replaced by [love.graphics.captureScreenshot](love.graphics.capturescreenshot "love.graphics.captureScreenshot"). Creates a screenshot and returns the image data. This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- ### Synopsis ``` screenshot = love.graphics.newScreenshot( ) ``` ### Arguments None. ### Returns `[ImageData](imagedata "ImageData") screenshot` The image data of the screenshot. Function -------- **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in earlier versions. ### Synopsis ``` screenshot = love.graphics.newScreenshot( copyAlpha ) ``` ### Arguments `[boolean](boolean "boolean") copyAlpha (false)` Whether to include the screen's alpha channel in the ImageData. If false, the screenshot will be fully opaque. ### Returns `[ImageData](imagedata "ImageData") screenshot` The image data of the screenshot. Examples -------- Create a new screenshot and write it to the save directory. ``` function love.load() love.filesystem.setIdentity('screenshot_example'); end   function love.keypressed() local screenshot = love.graphics.newScreenshot(); screenshot:encode('png', os.time() .. '.png'); end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [ImageData](imagedata "ImageData") * [ImageData:encode](imagedata-encode "ImageData:encode") love love.system.getProcessorCount love.system.getProcessorCount ============================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the amount of logical processor in the system. Function -------- ### Synopsis ``` processorCount = love.system.getProcessorCount( ) ``` ### Arguments None. ### Returns `[number](number "number") processorCount` Amount of logical processors. Notes ----- The number includes the threads reported if technologies such as Intel's [Hyper-threading](https://en.wikipedia.org/wiki/Hyper-threading) are enabled. For example, on a 4-core CPU with Hyper-threading, this function will return 8. See Also -------- * [love.system](love.system "love.system") * [love.thread.newThread](love.thread.newthread "love.thread.newThread") love love.wheelmoved love.wheelmoved =============== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Callback function triggered when the mouse wheel is moved. Function -------- ### Synopsis ``` love.wheelmoved( x, y ) ``` ### Arguments `[number](number "number") x` Amount of horizontal mouse wheel movement. Positive values indicate movement to the right. `[number](number "number") y` Amount of vertical mouse wheel movement. Positive values indicate upward movement. ### Returns Nothing. Examples -------- ``` local text = ""   function love.wheelmoved(x, y) if y > 0 then text = "Mouse wheel moved up" elseif y < 0 then text = "Mouse wheel moved down" end end   function love.draw() love.graphics.print(text, 10, 10) end ``` ### Smooth scrolling ``` function love.load() posx, posy = love.graphics.getWidth() * 0.5, love.graphics.getHeight() * 0.5 velx, vely = 0, 0 -- The scroll velocity end   function love.draw() love.graphics.rectangle( 'line', posx, posy, 50, 50 ) end   function love.update( dt ) posx = posx + velx * dt posy = posy + vely * dt   -- Gradually reduce the velocity to create smooth scrolling effect. velx = velx - velx * math.min( dt * 10, 1 ) vely = vely - vely * math.min( dt * 10, 1 ) end   function love.wheelmoved( dx, dy ) velx = velx + dx * 20 vely = vely + dy * 20 end ``` See Also -------- * [love](love "love") love cdata cdata ===== A C data object. See [http://luajit.org/ext\_ffi\_api.html](https://luajit.org/ext_ffi_api.html) for more information. Other Language -------------- love PrismaticJoint:setLowerLimit PrismaticJoint:setLowerLimit ============================ Sets the lower limit. Function -------- ### Synopsis ``` PrismaticJoint:setLowerLimit( lower ) ``` ### Arguments `[number](number "number") lower` The lower limit, usually in meters. ### Returns Nothing. See Also -------- * [PrismaticJoint](prismaticjoint "PrismaticJoint") love enet.host:total received data enet.host:total received data ============================= Returns the number of bytes that were received by the given host. Function -------- ### Synopsis ``` host:total_received_data() ``` ### Arguments None. ### Returns `[number](number "number") bytes` The total number of bytes received. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.host](enet.host "enet.host") * [enet.host:total\_sent\_data](enet.host-total_sent_data "enet.host:total sent data") love Video Video ===== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This type is not supported in earlier versions. A drawable video. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.graphics.newVideo](love.graphics.newvideo "love.graphics.newVideo") | Creates a new **Video**. | 0.10.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | | [Video:getDimensions](video-getdimensions "Video:getDimensions") | Gets the width and height of the Video. | 0.10.0 | | | [Video:getFilter](video-getfilter "Video:getFilter") | Gets the scaling filters used when drawing the Video. | 0.10.0 | | | [Video:getHeight](video-getheight "Video:getHeight") | Gets the height of the Video. | 0.10.0 | | | [Video:getSource](video-getsource "Video:getSource") | Gets the audio [Source](source "Source") used for playing back the video's audio. | 0.10.0 | | | [Video:getStream](video-getstream "Video:getStream") | Gets the [VideoStream](videostream "VideoStream") object used for decoding and controlling the video. | 0.10.0 | | | [Video:getWidth](video-getwidth "Video:getWidth") | Gets the width of the Video. | 0.10.0 | | | [Video:isPlaying](video-isplaying "Video:isPlaying") | Gets whether the Video is currently playing. | 0.10.0 | | | [Video:pause](video-pause "Video:pause") | Pauses the Video. | 0.10.0 | | | [Video:play](video-play "Video:play") | Starts playing the Video. | 0.10.0 | | | [Video:rewind](video-rewind "Video:rewind") | Rewinds the Video to the beginning. | 0.10.0 | | | [Video:seek](video-seek "Video:seek") | Sets the current playback position of the Video. | 0.10.0 | | | [Video:setFilter](video-setfilter "Video:setFilter") | Sets the scaling filters used when drawing the Video. | 0.10.0 | | | [Video:setSource](video-setsource "Video:setSource") | Sets the audio [Source](source "Source") used for playing back the video's audio. | 0.10.0 | | | [Video:tell](video-tell "Video:tell") | Gets the current playback position of the Video. | 0.10.0 | | Supertypes ---------- * [Drawable](drawable "Drawable") * [Object](object "Object") See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.draw](love.graphics.draw "love.graphics.draw") * [VideoStream](videostream "VideoStream") love SoundData:getBitDepth SoundData:getBitDepth ===================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [SoundData:getBits](sounddata-getbits "SoundData:getBits"). Returns the number of bits per sample. Function -------- ### Synopsis ``` bitdepth = SoundData:getBitDepth( ) ``` ### Arguments None. ### Returns `[number](number "number") bitdepth` Either 8, or 16. See Also -------- * [SoundData](sounddata "SoundData") love Source:isStatic Source:isStatic =============== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** It has been replaced by [Source:getType](source-gettype "Source:getType"). Returns whether the Source is static. Function -------- ### Synopsis ``` static = Source:isStatic( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") static` True if the Source is static, false otherwise. See Also -------- * [Source](source "Source") * [SourceType](sourcetype "SourceType") love Shape:getBoundingBox Shape:getBoundingBox ==================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in that and later versions. Gets the bounding box of the shape. This function can be used in a nested fashion with [love.graphics.polygon](love.graphics.polygon "love.graphics.polygon"). Function -------- ### Synopsis A bounding box is the smallest rectangle that encapsulates the entire polygon. ``` x1, y1, x2, y2, x3, y3, x4, y4 = Shape:getBoundingBox( ) ``` Vertexes are returned starting from the bottom-left in a clockwise fashion (bottom-left, top-left, top-right, bottom-right). ### Arguments None. ### Returns `[number](number "number") x1` The x-component of the first vertex, bottom-left. `[number](number "number") y1` The y-component of the first vertex, bottom-left. `[number](number "number") x2` The x-component of the second vertex, top-left. `[number](number "number") y2` The y-component of the second vertex, top-left. `[number](number "number") x3` The x-component of the third vertex, top-right. `[number](number "number") y3` The y-component of the third vertex, top-right. `[number](number "number") x4` The x-component of the fourth vertex, bottom-right. `[number](number "number") y4` The y-component of the fourth vertex, bottom-right. Example ------- And here's the source code if you want to try/test/see it yourself. ``` function love.load()   world = love.physics.newWorld(650, 650) world:setGravity(0,700) world:setMeter(64)   body = love.physics.newBody(world, 650/2, 650/2, 0, 0) shape = love.physics.newRectangleShape(body, 0, 0, 300, 300, 0)     love.graphics.setFont(18) love.graphics.setBackgroundColor(255, 255, 255, 255) love.graphics.setMode(650, 650, false, true, 0)   end   function love.draw()   X1, Y1, X2, Y2, X3, Y3, X4, Y4 = shape:getBoundingBox()   love.graphics.setColor(0,0,0,255)   love.graphics.print("X1, Y1", X1, Y1) love.graphics.print("X2, Y2", X2, Y2) love.graphics.print("X3, Y3", X3, Y3) love.graphics.print("X4, Y4", X4, Y4)   end ``` See Also -------- * [Shape](shape "Shape") love ParticleSystem:setQuads ParticleSystem:setQuads ======================= **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Sets a series of [Quads](quad "Quad") to use for the particle sprites. Particles will choose a Quad from the list based on the particle's current lifetime, allowing for the use of animated sprite sheets with ParticleSystems. Function -------- ### Synopsis ``` ParticleSystem:setQuads( quad1, quad2, ... ) ``` ### Arguments `[Quad](quad "Quad") quad1` The first Quad to use. `[Quad](quad "Quad") quad2` The second Quad to use. ### Returns Nothing. Function -------- ### Synopsis ``` ParticleSystem:setQuads( quads ) ``` ### Arguments `[table](table "table") quads` A table containing the Quads to use. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:getQuads](particlesystem-getquads "ParticleSystem:getQuads") love Font:setFilter Font:setFilter ============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Sets the filter mode for a font. Function -------- ### Synopsis ``` Font:setFilter( min, mag, anisotropy ) ``` ### Arguments `[FilterMode](filtermode "FilterMode") min` How to scale a font down. `[FilterMode](filtermode "FilterMode") mag` How to scale a font up. `[number](number "number") anisotropy (1)` Maximum amount of anisotropic filtering used. ### Returns Nothing. See Also -------- * [Font](font "Font") * [FilterMode](filtermode "FilterMode") love love.thread love.thread =========== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This module is not supported in earlier versions. Allows you to work with threads. Threads are separate Lua environments, running in parallel to the main code. As their code runs separately, they can be used to compute complex operations without adversely affecting the frame rate of the main thread. However, as they are separate environments, they cannot access the variables and functions of the main thread, and communication between threads is limited. All LÖVE objects (userdata) are shared among threads so you'll only have to send their references across threads. You may run into concurrency issues if you manipulate an object on multiple threads at the same time. When a [Thread](thread "Thread") is started, it only loads [love.data](love.data "love.data"), [love.filesystem](love.filesystem "love.filesystem"), and love.thread module. Every other module has to be loaded with [require](require "require"). The [love.graphics](love.graphics "love.graphics"), [love.window](love.window "love.window"), [love.joystick](love.joystick "love.joystick"), [love.keyboard](love.keyboard "love.keyboard"), [love.mouse](love.mouse "love.mouse"), and [love.touch](love.touch "love.touch") modules have several restrictions and therefore can only be used in the main thread. Unless you define the [love.threaderror](love.threaderror "love.threaderror") callback or call [Thread:getError](thread-geterror "Thread:getError") you won't see any errors your thread code throws. In Android, you have to make sure all threads are terminated before [quitting/restarting](love.event.quit "love.event.quit"), otherwise LOVE will fail to start again! Types ----- | | | | | | --- | --- | --- | --- | | [Channel](channel "Channel") | An object which can be used to send and receive data between different threads. | 0.9.0 | | | [Thread](thread "Thread") | A Thread represents a thread. | 0.7.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [love.thread.getChannel](love.thread.getchannel "love.thread.getChannel") | Creates or retrieves a named thread channel. | 0.9.0 | | | [love.thread.getThread](love.thread.getthread "love.thread.getThread") | Look for a thread and get its object. | 0.7.0 | 0.9.0 | | [love.thread.getThreads](love.thread.getthreads "love.thread.getThreads") | Get all threads. | 0.7.0 | 0.9.0 | | [love.thread.newChannel](love.thread.newchannel "love.thread.newChannel") | Creates a new unnamed thread channel. | 0.9.0 | | | [love.thread.newThread](love.thread.newthread "love.thread.newThread") | Creates a new Thread from a filename, string or [FileData](filedata "FileData") object containing Lua code. | 0.7.0 | | Examples -------- A simple example showing the general usage of a thread and using channels for communication. ``` -- This is the code that's going to run on the our thread. It should be moved -- to its own dedicated Lua file, but for simplicity's sake we'll create it -- here. local threadCode = [[ -- Receive values sent via thread:start local min, max = ...   for i = min, max do -- The Channel is used to handle communication between our main thread and -- this thread. On each iteration of the loop will push a message to it which -- we can then pop / receive in the main thread. love.thread.getChannel( 'info' ):push( i ) end ]]   local thread -- Our thread object. local timer -- A timer used to animate our circle.   function love.load() thread = love.thread.newThread( threadCode ) thread:start( 99, 1000 ) end   function love.update( dt ) timer = timer and timer + dt or 0   -- Make sure no errors occured. local error = thread:getError() assert( not error, error ) end   function love.draw() -- Get the info channel and pop the next message from it. local info = love.thread.getChannel( 'info' ):pop() if info then love.graphics.print( info, 10, 10 ) end   -- We smoothly animate a circle to show that the thread isn't blocking our main thread. love.graphics.circle( 'line', 100 + math.sin( timer ) * 20, 100 + math.cos( timer ) * 20, 20 ) end ``` See Also -------- * [love](love "love")
programming_docs
love love.touch.getTouches love.touch.getTouches ===================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets a list of all active touch-presses. Function -------- ### Synopsis ``` touches = love.touch.getTouches( ) ``` ### Arguments None. ### Returns `[table](table "table") touches` A list of active touch-press id values, which can be used with [love.touch.getPosition](love.touch.getposition "love.touch.getPosition"). Notes ----- The id values are the same as those used as arguments to [love.touchpressed](love.touchpressed "love.touchpressed"), [love.touchmoved](love.touchmoved "love.touchmoved"), and [love.touchreleased](love.touchreleased "love.touchreleased"). The id value of a specific touch-press is only guaranteed to be unique for the duration of that touch-press. As soon as [love.touchreleased](love.touchreleased "love.touchreleased") is called using that id, it may be reused for a new touch-press via [love.touchpressed](love.touchpressed "love.touchpressed"). See Also -------- * [love.touch](love.touch "love.touch") * [love.touch.getPosition](love.touch.getposition "love.touch.getPosition") * [love.touchpressed](love.touchpressed "love.touchpressed") * [love.touchreleased](love.touchreleased "love.touchreleased") love ParticleSystem:setPosition ParticleSystem:setPosition ========================== Sets the position of the emitter. Function -------- ### Synopsis ``` ParticleSystem:setPosition( x, y ) ``` ### Arguments `[number](number "number") x` Position along x-axis. `[number](number "number") y` Position along y-axis. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love JoystickConstant JoystickConstant ================ **Available since LÖVE [0.5.0](https://love2d.org/wiki/0.5.0 "0.5.0")** This enum is not supported in earlier versions. Joystick hat positions. Constants --------- c Centered d Down l Left ld Left+Down lu Left+Up r Right rd Right+Down ru Right+Up u Up See Also -------- * [love.joystick](love.joystick "love.joystick") * [Joystick](joystick "Joystick") love CompressedImageFormat CompressedImageFormat ===================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This enum is not supported in earlier versions. | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | It has been superseded by [PixelFormat](pixelformat "PixelFormat").. | Compressed image data formats. [Here](http://renderingpipeline.com/2012/07/texture-compression/) and [here](http://www.reedbeta.com/blog/2012/02/12/understanding-bcn-texture-compression-formats/) are a couple overviews of many of the formats. Unlike traditional PNG or jpeg, these formats stay compressed in RAM and in the graphics card's VRAM. This is good for saving memory space as well as improving performance, since the graphics card will be able to keep more of the image's pixels in its fast-access cache when drawing it. In LÖVE versions prior to [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0"), these constants are all lower-case. Constants --------- DXT1 The DXT1 format. RGB data at 4 bits per pixel (compared to 32 bits for [ImageData](imagedata "ImageData") and regular [Images](image "Image").) Suitable for fully opaque images on desktop systems. DXT3 The DXT3 format. RGBA data at 8 bits per pixel. Smooth variations in opacity do not mix well with this format. DXT5 The DXT5 format. RGBA data at 8 bits per pixel. Recommended for images with varying opacity on desktop systems. BC4 The BC4 format (also known as 3Dc+ or ATI1.) Stores just the red channel, at 4 bits per pixel. BC4s The signed variant of the BC4 format. Same as above but pixel values in the texture are in the range of [-1, 1] instead of [0, 1] in shaders. BC5 The BC5 format (also known as 3Dc or ATI2.) Stores red and green channels at 8 bits per pixel. BC5s The signed variant of the BC5 format. BC6h Available since 0.9.2 The BC6H format. Stores [half-precision](https://en.wikipedia.org/wiki/Half-precision_floating-point_format) floating-point RGB data in the range of [0, 65504] at 8 bits per pixel. Suitable for HDR images on desktop systems. BC6hs Available since 0.9.2 The signed variant of the BC6H format. Stores RGB data in the range of [-65504, +65504]. BC7 Available since 0.9.2 The BC7 format (also known as BPTC.) Stores RGB or RGBA data at 8 bits per pixel. ETC1 Available since 0.10.0 The ETC1 format. RGB data at 4 bits per pixel. Suitable for fully opaque images on older Android devices. ETC2rgb Available since 0.10.0 The RGB variant of the ETC2 format. RGB data at 4 bits per pixel. Suitable for fully opaque images on newer mobile devices. ETC2rgba Available since 0.10.0 The RGBA variant of the ETC2 format. RGBA data at 8 bits per pixel. Recommended for images with varying opacity on newer mobile devices. ETC2rgba1 Available since 0.10.0 The RGBA variant of the ETC2 format where pixels are either fully transparent or fully opaque. RGBA data at 4 bits per pixel. EACr Available since 0.10.0 The single-channel variant of the EAC format. Stores just the red channel, at 4 bits per pixel. EACrs Available since 0.10.0 The signed single-channel variant of the EAC format. Same as above but pixel values in the texture are in the range of [-1, 1] instead of [0, 1] in shaders. EACrg Available since 0.10.0 The two-channel variant of the EAC format. Stores red and green channels at 8 bits per pixel. EACrgs Available since 0.10.0 The signed two-channel variant of the EAC format. PVR1rgb2 Available since 0.10.0 The 2 bit per pixel RGB variant of the PVRTC1 format. Stores RGB data at 2 bits per pixel. Textures compressed with PVRTC1 formats must be square and power-of-two sized. PVR1rgb4 Available since 0.10.0 The 4 bit per pixel RGB variant of the PVRTC1 format. Stores RGB data at 4 bits per pixel. PVR1rgba2 Available since 0.10.0 The 2 bit per pixel RGBA variant of the PVRTC1 format. PVR1rgba4 Available since 0.10.0 The 4 bit per pixel RGBA variant of the PVRTC1 format. ASTC4x4 Available since 0.10.0 The 4x4 pixels per block variant of the ASTC format. RGBA data at 8 bits per pixel. ASTC5x4 Available since 0.10.0 The 5x4 pixels per block variant of the ASTC format. RGBA data at 6.4 bits per pixel. ASTC5x5 Available since 0.10.0 The 5x5 pixels per block variant of the ASTC format. RGBA data at 5.12 bits per pixel. ASTC6x5 Available since 0.10.0 The 6x5 pixels per block variant of the ASTC format. RGBA data at 4.27 bits per pixel. ASTC6x6 Available since 0.10.0 The 6x6 pixels per block variant of the ASTC format. RGBA data at 3.56 bits per pixel. ASTC8x5 Available since 0.10.0 The 8x5 pixels per block variant of the ASTC format. RGBA data at 3.2 bits per pixel. ASTC8x6 Available since 0.10.0 The 8x6 pixels per block variant of the ASTC format. RGBA data at 2.67 bits per pixel. ASTC8x8 Available since 0.10.0 The 8x8 pixels per block variant of the ASTC format. RGBA data at 2 bits per pixel. ASTC10x5 Available since 0.10.0 The 10x5 pixels per block variant of the ASTC format. RGBA data at 2.56 bits per pixel. ASTC10x6 Available since 0.10.0 The 10x6 pixels per block variant of the ASTC format. RGBA data at 2.13 bits per pixel. ASTC10x8 Available since 0.10.0 The 10x8 pixels per block variant of the ASTC format. RGBA data at 1.6 bits per pixel. ASTC10x10 Available since 0.10.0 The 10x10 pixels per block variant of the ASTC format. RGBA data at 1.28 bits per pixel. ASTC12x10 Available since 0.10.0 The 12x10 pixels per block variant of the ASTC format. RGBA data at 1.07 bits per pixel. ASTC12x12 Available since 0.10.0 The 12x12 pixels per block variant of the ASTC format. RGBA data at 0.89 bits per pixel. Notes ----- Not all formats are supported in love.graphics [Images](image "Image") on all systems, although the DXT formats have close to 100% support on desktop operating systems. The BC4 and BC5 formats are supported on systems with DirectX 10 / OpenGL 3-capable desktop hardware and drivers. The BC6H and BC7 formats are only supported on desktop systems with DirectX 11 / OpenGL 4-capable hardware and very recent drivers. macOS does not support BC6H or BC7 at all currently. ETC1 is supported by Android devices, as well as newer (OpenGL ES 3-capable) iOS devices. The PVR1 formats are supported by iOS devices, as well as Android devices with PowerVR GPUs. The ETC2 and EAC formats are supported by newer (OpenGL ES 3-capable) iOS and Android devices. ASTC is only supported by very new mobile devices (e.g. the iPhone 6), and the latest Skylake (and newer) integrated Intel GPUs. It has a variety of variants to allow for picking the most compressed possible one that doesn't have any noticeable compression artifacts, for a given texture. Use [love.graphics.getCompressedImageFormats](love.graphics.getcompressedimageformats "love.graphics.getCompressedImageFormats") to check for support: ``` local supportedformats = love.graphics.getCompressedImageFormats()   if not supportedformats["DXT5"] then -- Can't load CompressedImageData with the DXT5 format into images! -- On some Linux systems with Mesa drivers, the user will need to install a "libtxc-dxtn" package because the DXT (aka S3TC) formats used to be patented. -- Support for DXT formats on all other desktop drivers is pretty much guaranteed. end   if not supportedformats["BC5"] then -- Can't load CompressedImageData with the BC5 format into images! -- The user likely doesn't have a video card capable of using that format. end ``` See Also -------- * [love.image](love.image "love.image") * [CompressedImageData](compressedimagedata "CompressedImageData") * [CompressedImageData:getFormat](compressedimagedata-getformat "CompressedImageData:getFormat") * [love.graphics.getCompressedImageFormats](love.graphics.getcompressedimageformats "love.graphics.getCompressedImageFormats") love love.focus love.focus ========== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This callback is not supported in earlier versions. Callback function triggered when window receives or loses focus. Function -------- ### Synopsis ``` love.focus( focus ) ``` ### Arguments `[boolean](boolean "boolean") focus` True if the window gains focus, false if it loses focus. ### Returns Nothing. Example ------- ``` function love.load() text = "FOCUSED" end   function love.draw() love.graphics.print(text,0,0) end   function love.focus(f) if f then print("Window is focused.") text = "FOCUSED" else print("Window is not focused.") text = "UNFOCUSED" end end ``` See Also -------- * [love](love "love") love EdgeShape:setNextVertex EdgeShape:setNextVertex ======================= **Available since LÖVE [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2")** This function is not supported in earlier versions. Sets a vertex that establishes a connection to the next shape. This can help prevent unwanted collisions when a flat shape slides along the edge and moves over to the new shape. Function -------- ### Synopsis ``` EdgeShape:setNextVertex( x, y ) ``` ### Arguments `[number](number "number") x` The x-component of the vertex. `[number](number "number") y` The y-component of the vertex. ### Returns Nothing. See Also -------- * [EdgeShape](edgeshape "EdgeShape") * [EdgeShape:getNextVertex](edgeshape-getnextvertex "EdgeShape:getNextVertex") * [EdgeShape:setPreviousVertex](edgeshape-setpreviousvertex "EdgeShape:setPreviousVertex") love love.filesystem.getIdentity love.filesystem.getIdentity =========================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the write directory name for your game. Note that this only returns the name of the folder to store your files in, not the full path. Function -------- ### Synopsis ``` name = love.filesystem.getIdentity( ) ``` ### Arguments None. ### Returns `[string](string "string") name` The identity that is used as write directory. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [love.filesystem.setIdentity](love.filesystem.setidentity "love.filesystem.setIdentity") love Texture:getDimensions Texture:getDimensions ===================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the width and height of the Texture. Function -------- ### Synopsis ``` width, height = Texture:getDimensions( ) ``` ### Arguments None. ### Returns `[number](number "number") width` The width of the Texture, in pixels. `[number](number "number") height` The height of the Texture, in pixels. See Also -------- * [Texture](texture "Texture") * [Texture:getWidth](texture-getwidth "Texture:getWidth") * [Texture:getHeight](texture-getheight "Texture:getHeight") love Joystick:getDeviceInfo Joystick:getDeviceInfo ====================== **Available since LÖVE [11.3](https://love2d.org/wiki/11.3 "11.3")** This function is not supported in earlier versions. Gets the USB vendor ID, product ID, and product version numbers of joystick which consistent across operating systems. Can be used to show different icons, etc. for different gamepads. This function returns 0 for all the values if LÖVE is compiled with SDL 2.0.5 or earlier. Function -------- ### Synopsis ``` vendorID, productID, productVersion = Joystick:getDeviceInfo( ) ``` ### Arguments None. ### Returns `[number](number "number") vendorID` The USB vendor ID of the joystick. `[number](number "number") productID` The USB product ID of the joystick. `[number](number "number") productVersion` The product version of the joystick. Notes ----- Some Linux distribution may not ship with SDL 2.0.6 or later, in which case this function will returns 0 for all the three values. See Also -------- * [Joystick](joystick "Joystick") love VideoStream:play VideoStream:play ================ **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Plays video stream. Function -------- ### Synopsis ``` VideoStream:play( ) ``` ### Arguments None. ### Returns None. See Also -------- * [VideoStream](videostream "VideoStream") * [VideoStream:pause](videostream-pause "VideoStream:pause") * [VideoStream:isPlaying](videostream-isplaying "VideoStream:isPlaying") love RevoluteJoint:setLimits RevoluteJoint:setLimits ======================= Sets the limits. Function -------- ### Synopsis ``` RevoluteJoint:setLimits( lower, upper ) ``` ### Arguments `[number](number "number") lower` The lower limit, in radians. `[number](number "number") upper` The upper limit, in radians. ### Returns Nothing. See Also -------- * [RevoluteJoint](revolutejoint "RevoluteJoint") love Body:setMass Body:setMass ============ Sets a new body mass. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in earlier versions. ### Synopsis ``` body:setMass( mass ) ``` ### Arguments `[number](number "number") mass` The mass, in kilograms. ### Returns Nothing. Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. Sets the mass properties directly. If you're not sure what all this stuff means, you can use [Body:setMassFromShapes](body-setmassfromshapes "Body:setMassFromShapes") after adding shapes instead. The first two parameters will be the local coordinates of the Body's [center of mass](https://en.wikipedia.org/wiki/Center_of_mass). The third parameter is the mass, in kilograms. The last parameter is the [rotational inertia](https://en.wikipedia.org/wiki/Moment_of_inertia). ### Synopsis ``` body:setMass( x, y, m, i ) ``` ### Arguments `[number](number "number") x` The x-component of the center of mass in local coordinates. `[number](number "number") y` The y-component of the center of mass in local coordinates. `[number](number "number") m` The mass, in kilograms. `[number](number "number") i` The rotational inertia, in kilograms per squared meter. ### Returns Nothing. See Also -------- * [Body](body "Body") love Thread:isRunning Thread:isRunning ================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Returns whether the thread is currently running. Threads which are not running can be (re)started with [Thread:start](thread-start "Thread:start"). Function -------- ### Synopsis ``` running = Thread:isRunning( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") value` True if the thread is running, false otherwise. See Also -------- * [Thread](thread "Thread") * [Thread:start](thread-start "Thread:start") love PrismaticJoint:getLowerLimit PrismaticJoint:getLowerLimit ============================ Gets the lower limit. Function -------- ### Synopsis ``` lower = PrismaticJoint:getLowerLimit( ) ``` ### Arguments None. ### Returns `[number](number "number") lower` The lower limit, usually in meters. See Also -------- * [PrismaticJoint](prismaticjoint "PrismaticJoint") love love.mouse.isCursorSupported love.mouse.isCursorSupported ============================ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** It has been renamed from [love.mouse.hasCursor](love.mouse.hascursor "love.mouse.hasCursor"). Gets whether cursor functionality is supported. If it isn't supported, calling [love.mouse.newCursor](love.mouse.newcursor "love.mouse.newCursor") and [love.mouse.getSystemCursor](love.mouse.getsystemcursor "love.mouse.getSystemCursor") will cause an error. Mobile devices do not support cursors. Function -------- ### Synopsis ``` supported = love.mouse.isCursorSupported( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") supported` Whether the system has cursor functionality. See Also -------- * [love.mouse](love.mouse "love.mouse") love enet.host:peer count enet.host:peer count ==================== Returns the number of [peers](enet.peer "enet.peer") that are allocated for the given [host](enet.host "enet.host"). This represents the maximum number of possible connections. Function -------- ### Synopsis ``` host:peer_count() ``` ### Arguments None. ### Returns `[number](number "number") limit` The maximum number of peers allowed. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.host](enet.host "enet.host") * [enet.peer](enet.peer "enet.peer") love Object:release Object:release ============== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Destroys the object's Lua reference. The object will be completely deleted if it's not referenced by any other LÖVE object or thread. This method can be used to immediately clean up resources without waiting for Lua's garbage collector. After this method has been called, attempting to call any other method on the object or using the object as an argument in another LÖVE API will cause an error. Function -------- ### Synopsis ``` success = Object:release( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") success` True if the object was released by this call, false if it had been previously released. See Also -------- * [Object](object "Object")
programming_docs
love love.graphics.isWireframe love.graphics.isWireframe ========================= **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. Gets whether wireframe mode is used when drawing. Function -------- ### Synopsis ``` wireframe = love.graphics.isWireframe( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") wireframe` True if wireframe lines are used when drawing, false if it's not. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setWireframe](love.graphics.setwireframe "love.graphics.setWireframe") love Body:getAllowSleeping Body:getAllowSleeping ===================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0") and removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier or later versions. Return whether a body is allowed to sleep. A sleeping body is much more efficient to simulate than when awake. Function -------- ### Synopsis ``` status = Body:getAllowSleeping( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") status` True when the body is allowed to sleep. See Also -------- * [Body](body "Body") love love.joystick.getAxis love.joystick.getAxis ===================== **Available since LÖVE [0.5.0](https://love2d.org/wiki/0.5.0 "0.5.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been moved to [Joystick:getAxis](joystick-getaxis "Joystick:getAxis"). Returns the direction of the axis. Function -------- ### Synopsis ``` direction = love.joystick.getAxis( joystick, axis ) ``` ### Arguments `[number](number "number") joystick` The joystick to be checked `[number](number "number") axis` The axis to be checked ### Returns `[number](number "number") direction` Current value of the axis See Also -------- * [love.joystick](love.joystick "love.joystick") love love.window.getWidth love.window.getWidth ==================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** Use [love.graphics.getWidth](love.graphics.getwidth "love.graphics.getWidth") or [love.window.getMode](love.window.getmode "love.window.getMode") instead. Gets the width of the window. Function -------- ### Synopsis ``` width = love.window.getWidth( ) ``` ### Arguments None. ### Returns `[number](number "number") width` The width of the window. See Also -------- * [love.window](love.window "love.window") * [love.window.getHeight](love.window.getheight "love.window.getHeight") * [love.window.getDimensions](love.window.getdimensions "love.window.getDimensions") * [love.window.setMode](love.window.setmode "love.window.setMode") love Transform:setTransformation Transform:setTransformation =========================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Resets the Transform to the specified transformation parameters. Function -------- ### Synopsis ``` transform = Transform:setTransformation( x, y, angle, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[number](number "number") x` The position of the Transform on the x-axis. `[number](number "number") y` The position of the Transform on the y-axis. `[number](number "number") angle (0)` The orientation of the Transform in radians. `[number](number "number") sx (1)` Scale factor on the x-axis. `[number](number "number") sy (sx)` Scale factor on the y-axis. `[number](number "number") ox (0)` Origin offset on the x-axis. `[number](number "number") oy (0)` Origin offset on the y-axis. `[number](number "number") kx (0)` Shearing / skew factor on the x-axis. `[number](number "number") ky (0)` Shearing / skew factor on the y-axis. ### Returns `[Transform](transform "Transform") transform` The Transform object the method was called on. Allows easily chaining Transform methods. See Also -------- * [Transform](transform "Transform") * [love.math.newTransform](love.math.newtransform "love.math.newTransform") love love.graphics.newFont love.graphics.newFont ===================== Creates a new [Font](font "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](data "Data") object instead. This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- Create a new BMFont or TrueType font. ### Synopsis ``` font = love.graphics.newFont( filename ) ``` ### Arguments `[string](string "string") filename` The filepath to the BMFont or TrueType font file. ### Returns `[Font](font "Font") font` A Font object which can be used to draw text on screen. ### Notes If the file is a TrueType font, it will be size 12. Use the variant below to create a TrueType font with a custom size. Function -------- Create a new TrueType font. ### Synopsis ``` font = love.graphics.newFont( filename, size, hinting, dpiscale ) ``` ### Arguments `[string](string "string") filename` The filepath to the TrueType font file. `[number](number "number") size` The size of the font in pixels. `[HintingMode](hintingmode "HintingMode") hinting ("normal")` Available since 0.10.0 True Type hinting mode. `[number](number "number") dpiscale ([love.graphics.getDPIScale](love.graphics.getdpiscale "love.graphics.getDPIScale")())` Available since 11.0 The [DPI scale factor](font-getdpiscale "Font:getDPIScale") of the font. ### Returns `[Font](font "Font") font` A Font object which can be used to draw text on screen. Function -------- Create a new BMFont. ### Synopsis ``` font = love.graphics.newFont( filename, imagefilename ) ``` ### Arguments `[string](string "string") filename` The filepath to the BMFont file. `[string](string "string") imagefilename` The filepath to the BMFont's image file. If this argument is omitted, the path specified inside the BMFont file will be used. ### Returns `[Font](font "Font") font` A Font object which can be used to draw text on screen. Function -------- Create a new instance of the default font (Vera Sans) with a custom size. ### Synopsis ``` font = love.graphics.newFont( size, hinting, dpiscale ) ``` ### Arguments `[number](number "number") size (12)` The size of the font in pixels. `[HintingMode](hintingmode "HintingMode") hinting ("normal")` Available since 0.10.0 True Type hinting mode. `[number](number "number") dpiscale ([love.graphics.getDPIScale](love.graphics.getdpiscale "love.graphics.getDPIScale")())` Available since 11.0 The [DPI scale factor](font-getdpiscale "Font:getDPIScale") of the font. ### Returns `[Font](font "Font") font` A Font object which can be used to draw text on screen. Examples -------- ### Use newFont to draw a custom styled text ``` -- Create a ttf file font with a custom size of 20 pixels. mainFont = love.graphics.newFont("anyfont.ttf", 20)   function love.draw() -- Setting the font so that it is used when drawning the string. love.graphics.setFont(mainFont)   -- Draws "Hello world!" at position x: 100, y: 200 with the custom font applied. love.graphics.print("Hello world!", 100, 200) end ``` See Also -------- * [Font](font "Font") * [love.graphics](love.graphics "love.graphics") * [love.graphics.setFont](love.graphics.setfont "love.graphics.setFont") * [love.graphics.setNewFont](love.graphics.setnewfont "love.graphics.setNewFont") * [love.graphics.newImageFont](love.graphics.newimagefont "love.graphics.newImageFont") love SpriteBatch:flush SpriteBatch:flush ================= **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Immediately sends all new and modified sprite data in the batch to the graphics card. Normally it isn't necessary to call this method as love.graphics.draw(spritebatch, ...) will do it automatically if needed, but explicitly using **SpriteBatch:flush** gives more control over when the work happens. If this method is used, it generally shouldn't be called more than once (at most) between love.graphics.draw(spritebatch, ...) calls. Function -------- ### Synopsis ``` SpriteBatch:flush( ) ``` ### Arguments None. ### Returns Nothing. Examples -------- ### Initialize a static spritebatch with sprites and immediately send the data to the graphics card ``` function love.load() image = love.graphics.newImage("tile.png") spritebatch = love.graphics.newSpriteBatch(image, 20 * 20, "static")   for y = 1, 20 do for x = 1, 20 do spritebatch:add((x - 1) * 64, (y - 1) * 64) end end   -- If we call SpriteBatch:flush now then it won't be called internally when the SpriteBatch is drawn for the first time. -- In other words, we're choosing to do the work in love.load instead of the first love.draw. spritebatch:flush() end   function love.draw() love.graphics.draw(spritebatch, 0, 0) end ``` See Also -------- * [SpriteBatch](spritebatch "SpriteBatch") love Fixture:testPoint Fixture:testPoint ================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Checks if a point is inside the shape of the fixture. Function -------- ### Synopsis ``` isInside = Fixture:testPoint( x, y ) ``` ### Arguments `[number](number "number") x` The x position of the point. `[number](number "number") y` The y position of the point. ### Returns `[boolean](boolean "boolean") isInside` True if the point is inside or false if it is outside. See Also -------- * [Fixture](fixture "Fixture") love (Image):getFlags (Image):getFlags ================ **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets the flags used when the image was [created](love.graphics.newimage "love.graphics.newImage"). Function -------- ### Synopsis ``` flags = Image:getFlags( ) ``` ### Arguments None. ### Returns `[table](table "table") flags` A table with [ImageFlag](imageflag "ImageFlag") keys. See Also -------- * [Image](image "Image") * [love.graphics.newImage](love.graphics.newimage "love.graphics.newImage") love love.graphics.polygon love.graphics.polygon ===================== **Available since LÖVE [0.4.0](https://love2d.org/wiki/0.4.0 "0.4.0")** This function is not supported in earlier versions. 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. When in **fill** mode, the polygon must be [convex](https://en.wikipedia.org/wiki/Convex_polygon) and [simple](https://en.wikipedia.org/wiki/Simple_polygon) or rendering artifacts may occur. [love.math.triangulate](love.math.triangulate "love.math.triangulate") and [love.math.isConvex](love.math.isconvex "love.math.isConvex") can be used in [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")+. Function -------- ### Synopsis ``` love.graphics.polygon( mode, ... ) ``` ### Arguments `[DrawMode](drawmode "DrawMode") mode` How to draw the polygon. `[number](number "number") ...` The vertices of the polygon. ### Returns Nothing. Function -------- ### Synopsis ``` love.graphics.polygon( mode, vertices ) ``` ### Arguments `[DrawMode](drawmode "DrawMode") mode` How to draw the polygon. `[table](table "table") vertices` The vertices of the polygon as a table. ### Returns Nothing. Examples -------- ### Two ways of drawing the same triangle Triangle drawn using love.graphics.polygon This example shows how to give the coordinates explicitly and how to pass a table argument. ``` -- giving the coordinates directly love.graphics.polygon('fill', 100, 100, 200, 100, 150, 200)   -- defining a table with the coordinates -- this table could be built incrementally too local vertices = {100, 100, 200, 100, 150, 200}   -- passing the table to the function as a second argument love.graphics.polygon('fill', vertices) ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.math.triangulate](love.math.triangulate "love.math.triangulate") * [love.math.isConvex](love.math.isconvex "love.math.isConvex") love Decoder:getChannelCount Decoder:getChannelCount ======================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** It has been renamed from [Decoder:getChannels](decoder-getchannels "Decoder:getChannels"). Returns the number of channels in the stream. Function -------- ### Synopsis ``` channels = Decoder:getChannelCount( ) ``` ### Arguments None. ### Returns `[number](number "number") channels` 1 for mono, 2 for stereo. See Also -------- * [Decoder](decoder "Decoder") love ParticleSystem:getSpread ParticleSystem:getSpread ======================== Gets the amount of directional spread of the particle emitter (in radians). Function -------- ### Synopsis ``` spread = ParticleSystem:getSpread( ) ``` ### Arguments None. ### Returns `[number](number "number") spread` The spread of the emitter (radians). See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love Thread:receive Thread:receive ============== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0") and removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been renamed to [Thread:get](thread-get "Thread:get"). Receive a message from a thread. Returns nil when a message is not in the message box. Function -------- ### Synopsis ``` value = Thread:receive(name) ``` ### Arguments `[string](string "string") name` The name of the message. ### Returns `[Variant](variant "Variant") value` The contents of the message or nil when no message in message box. See Also -------- * [Thread](thread "Thread") love Body:setAwake Body:setAwake ============= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Wakes the body up or puts it to sleep. Function -------- ### Synopsis ``` Body:setAwake( awake ) ``` ### Arguments `[boolean](boolean "boolean") awake` The body sleep status. ### Returns Nothing. See Also -------- * [Body](body "Body") * [Body:isAwake](body-isawake "Body:isAwake") love love.joystick.open love.joystick.open ================== **Available since LÖVE [0.5.0](https://love2d.org/wiki/0.5.0 "0.5.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier or later versions. Opens up a joystick to be used, i.e. makes it ready to use. By default joysticks that are available at the start of your game will be opened. Unlike conventional Lua indexes, joysticks begin counting from 0 in LÖVE [0.7.2](https://love2d.org/wiki/0.7.2 "0.7.2") and below. To to open the first joystick, you would use love.joystick.open(0). This is not the case in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and later. Function -------- ### Synopsis ``` open = love.joystick.open( joystick ) ``` ### Arguments `[number](number "number") joystick` The joystick to be opened ### Returns `[boolean](boolean "boolean") open` True if the joystick has been successfully opened or false on failure. See Also -------- * [love.joystick](love.joystick "love.joystick") love ParticleSystem:getX ParticleSystem:getX =================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** Use [ParticleSystem:getPosition](particlesystem-getposition "ParticleSystem:getPosition"). Gets the x-coordinate of the particle emitter's position. Function -------- ### Synopsis ``` x = ParticleSystem:getX( ) ``` ### Arguments None. ### Returns `[number](number "number") x` Position along x-axis. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love love.graphics.getMode love.graphics.getMode ===================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** Moved to the [love.window](love.window "love.window") module as [love.window.getMode](love.window.getmode "love.window.getMode"). Returns the current display mode. Function -------- ### Synopsis ``` width, height, fullscreen, vsync, fsaa = love.graphics.getMode( ) ``` ### Arguments None. ### Returns `[number](number "number") width` Display width. `[number](number "number") height` Display height. `[boolean](boolean "boolean") fullscreen` Fullscreen (true) or windowed (false). `[boolean](boolean "boolean") vsync` True if vertical sync is enabled or false if disabled. `[number](number "number") fsaa` The number of FSAA samples. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setMode](love.graphics.setmode "love.graphics.setMode") love love.graphics.setColorMask love.graphics.setColorMask ========================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. 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. Function -------- Enables color masking for the specified color components. ### Synopsis ``` love.graphics.setColorMask( red, green, blue, alpha ) ``` ### Arguments `[boolean](boolean "boolean") red` Render red component. `[boolean](boolean "boolean") green` Render green component. `[boolean](boolean "boolean") blue` Render blue component. `[boolean](boolean "boolean") alpha` Render alpha component. ### Returns Nothing. Function -------- Disables color masking. ### Synopsis ``` love.graphics.setColorMask( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getColorMask](love.graphics.getcolormask "love.graphics.getColorMask") love Body Body ==== Bodies are objects with velocity and position. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.physics.newBody](love.physics.newbody "love.physics.newBody") | Creates a new body. | | | Functions --------- | | | | | | --- | --- | --- | --- | | [Body:applyAngularImpulse](body-applyangularimpulse "Body:applyAngularImpulse") | Applies an angular impulse to a body. | 0.8.0 | | | [Body:applyForce](body-applyforce "Body:applyForce") | Apply force to a Body. | | | | [Body:applyImpulse](body-applyimpulse "Body:applyImpulse") | Applies an impulse to a body. | | 0.8.0 | | [Body:applyLinearImpulse](body-applylinearimpulse "Body:applyLinearImpulse") | Applies an impulse to a body. | 0.8.0 | | | [Body:applyTorque](body-applytorque "Body:applyTorque") | Apply torque to a body. | | | | [Body:destroy](body-destroy "Body:destroy") | Explicitly destroys the Body. | | | | [Body:getAllowSleeping](body-getallowsleeping "Body:getAllowSleeping") | Return whether a body is allowed to sleep. | 0.7.0 | 0.8.0 | | [Body:getAngle](body-getangle "Body:getAngle") | Get the angle of the body. | | | | [Body:getAngularDamping](body-getangulardamping "Body:getAngularDamping") | Gets the Angular damping of the Body. | | | | [Body:getAngularVelocity](body-getangularvelocity "Body:getAngularVelocity") | Get the angular velocity of the Body. | | | | [Body:getContactList](body-getcontactlist "Body:getContactList") | Gets a list of all [Contacts](contact "Contact") attached to the Body. | 0.9.2 | 11.0 | | [Body:getContacts](body-getcontacts "Body:getContacts") | Gets a list of all [Contacts](contact "Contact") attached to the Body. | 11.0 | | | [Body:getFixtureList](body-getfixturelist "Body:getFixtureList") | Returns a table with all fixtures. | 0.8.0 | 11.0 | | [Body:getFixtures](body-getfixtures "Body:getFixtures") | Returns a table with all fixtures. | 11.0 | | | [Body:getGravityScale](body-getgravityscale "Body:getGravityScale") | Returns the gravity scale factor. | 0.8.0 | | | [Body:getInertia](body-getinertia "Body:getInertia") | Gets the rotational inertia of the body. | | | | [Body:getJointList](body-getjointlist "Body:getJointList") | Returns a table containing the Joints attached to this Body. | 0.9.2 | 11.0 | | [Body:getJoints](body-getjoints "Body:getJoints") | Returns a table containing the [Joints](joint "Joint") attached to this Body. | 11.0 | | | [Body:getLinearDamping](body-getlineardamping "Body:getLinearDamping") | Gets the linear damping of the Body. | | | | [Body:getLinearVelocity](body-getlinearvelocity "Body:getLinearVelocity") | Gets the linear velocity of the Body from its center of mass. | | | | [Body:getLinearVelocityFromLocalPoint](body-getlinearvelocityfromlocalpoint "Body:getLinearVelocityFromLocalPoint") | Get the linear velocity of a point on the body. | | | | [Body:getLinearVelocityFromWorldPoint](body-getlinearvelocityfromworldpoint "Body:getLinearVelocityFromWorldPoint") | Get the linear velocity of a point on the body. | | | | [Body:getLocalCenter](body-getlocalcenter "Body:getLocalCenter") | Get the center of mass position in local coordinates. | | | | [Body:getLocalPoint](body-getlocalpoint "Body:getLocalPoint") | Transform a point from world coordinates to local coordinates. | | | | [Body:getLocalVector](body-getlocalvector "Body:getLocalVector") | Transform a vector from world coordinates to local coordinates. | | | | [Body:getMass](body-getmass "Body:getMass") | Get the mass of the body. | | | | [Body:getMassData](body-getmassdata "Body:getMassData") | Returns the mass, its center, and the rotational inertia. | 0.8.0 | | | [Body:getPosition](body-getposition "Body:getPosition") | Get the position of the body. | | | | [Body:getType](body-gettype "Body:getType") | Returns the type of the body. | 0.8.0 | | | [Body:getUserData](body-getuserdata "Body:getUserData") | Returns the Lua value associated with this Body. | 0.9.1 | | | [Body:getWorld](body-getworld "Body:getWorld") | Gets the [World](world "World") the body lives in. | 0.9.2 | | | [Body:getWorldCenter](body-getworldcenter "Body:getWorldCenter") | Get the center of mass position in world coordinates. | | | | [Body:getWorldPoint](body-getworldpoint "Body:getWorldPoint") | Transform a point from local coordinates to world coordinates. | | | | [Body:getWorldPoints](body-getworldpoints "Body:getWorldPoints") | Transforms multiple points from local coordinates to world coordinates. | 0.8.0 | | | [Body:getWorldVector](body-getworldvector "Body:getWorldVector") | Transform a vector from local coordinates to world coordinates. | | | | [Body:getX](body-getx "Body:getX") | Get the x position of the body in world coordinates. | | | | [Body:getY](body-gety "Body:getY") | Get the y position of the body in world coordinates. | | | | [Body:isActive](body-isactive "Body:isActive") | Returns whether the body is actively used in the simulation. | 0.8.0 | | | [Body:isAwake](body-isawake "Body:isAwake") | Returns the sleep status of the body. | 0.8.0 | | | [Body:isBullet](body-isbullet "Body:isBullet") | Get the bullet status of a body. | | | | [Body:isDestroyed](body-isdestroyed "Body:isDestroyed") | Gets whether the Body is destroyed. | 0.9.2 | | | [Body:isDynamic](body-isdynamic "Body:isDynamic") | Get the dynamic status of the body. | | 0.8.0 | | [Body:isFixedRotation](body-isfixedrotation "Body:isFixedRotation") | Returns whether the body rotation is locked. | 0.8.0 | | | [Body:isFrozen](body-isfrozen "Body:isFrozen") | Get the frozen status of the body. | | 0.8.0 | | [Body:isSleeping](body-issleeping "Body:isSleeping") | Get the sleeping status of a body. | | 0.8.0 | | [Body:isSleepingAllowed](body-issleepingallowed "Body:isSleepingAllowed") | Returns the sleeping behaviour of the body. | 0.8.0 | | | [Body:isStatic](body-isstatic "Body:isStatic") | Get the static status of the body. | | 0.8.0 | | [Body:isTouching](body-istouching "Body:isTouching") | Gets whether the Body is touching the given other Body. | 11.0 | | | [Body:putToSleep](body-puttosleep "Body:putToSleep") | Put the body to sleep. | | 0.8.0 | | [Body:resetMassData](body-resetmassdata "Body:resetMassData") | Resets the mass of the body. | 0.8.0 | | | [Body:setActive](body-setactive "Body:setActive") | Sets whether the body is active in the world. | 0.8.0 | | | [Body:setAllowSleeping](body-setallowsleeping "Body:setAllowSleeping") | Set the sleep behaviour of a body. | | 0.8.0 | | [Body:setAngle](body-setangle "Body:setAngle") | Set the angle of the body. | | | | [Body:setAngularDamping](body-setangulardamping "Body:setAngularDamping") | Sets the angular damping of a Body | | | | [Body:setAngularVelocity](body-setangularvelocity "Body:setAngularVelocity") | Sets the angular velocity of a Body. | | | | [Body:setAwake](body-setawake "Body:setAwake") | Wakes the body up or puts it to sleep. | 0.8.0 | | | [Body:setBullet](body-setbullet "Body:setBullet") | Set the bullet status of a body. | | | | [Body:setFixedRotation](body-setfixedrotation "Body:setFixedRotation") | Set whether a body has fixed rotation. | | | | [Body:setGravityScale](body-setgravityscale "Body:setGravityScale") | Sets a new gravity scale factor for the body. | 0.8.0 | | | [Body:setInertia](body-setinertia "Body:setInertia") | Set the inertia of a body. | | | | [Body:setLinearDamping](body-setlineardamping "Body:setLinearDamping") | Sets the linear damping of a Body. | | | | [Body:setLinearVelocity](body-setlinearvelocity "Body:setLinearVelocity") | Sets a new linear velocity for the Body. | | | | [Body:setMass](body-setmass "Body:setMass") | Sets the mass properties directly. | | | | [Body:setMassData](body-setmassdata "Body:setMassData") | Overrides the calculated mass data. | 0.8.0 | | | [Body:setMassFromShapes](body-setmassfromshapes "Body:setMassFromShapes") | Sets mass properties from attatched shapes. | | 0.8.0 | | [Body:setPosition](body-setposition "Body:setPosition") | Set the position of the body. | | | | [Body:setSleepingAllowed](body-setsleepingallowed "Body:setSleepingAllowed") | Sets the sleeping behaviour of the body. | 0.8.0 | | | [Body:setType](body-settype "Body:setType") | Sets a new body type. | 0.8.0 | | | [Body:setUserData](body-setuserdata "Body:setUserData") | Associates a Lua value with the Body. | 0.9.1 | | | [Body:setX](body-setx "Body:setX") | Set the x position of the body. | | | | [Body:setY](body-sety "Body:setY") | Set the y position of the body. | | | | [Body:wakeUp](body-wakeup "Body:wakeUp") | Wake up a sleeping body. | | 0.8.0 | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Enums ----- | | | | | | --- | --- | --- | --- | | [BodyType](bodytype "BodyType") | The types of a **Body**. | | | Supertypes ---------- * [Object](object "Object") See Also -------- * [love.physics](love.physics "love.physics")
programming_docs
love ParticleSystem:setRotation ParticleSystem:setRotation ========================== Sets the rotation of the image upon particle creation (in radians). Function -------- ### Synopsis ``` ParticleSystem:setRotation( min, max ) ``` ### Arguments `[number](number "number") min` The minimum initial angle (radians). `[number](number "number") max (min)` The maximum initial angle (radians). ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love SoundData:getChannelCount SoundData:getChannelCount ========================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** It has been renamed from [SoundData:getChannels](sounddata-getchannels "SoundData:getChannels"). Returns the number of channels in the SoundData. Function -------- ### Synopsis ``` channels = SoundData:getChannelCount( ) ``` ### Arguments None. ### Returns `[number](number "number") channels` 1 for mono, 2 for stereo. See Also -------- * [SoundData](sounddata "SoundData") love GlyphData:getFormat GlyphData:getFormat =================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets glyph pixel format. Function -------- ### Synopsis ``` format = GlyphData:getFormat() ``` ### Arguments None. ### Returns `[PixelFormat](pixelformat "PixelFormat") format` Glyph pixel format. See Also -------- * [GlyphData](glyphdata "GlyphData") * [PixelFormat](pixelformat "PixelFormat") love BodyType BodyType ======== The types of a [Body](body "Body"). Constants --------- static Static bodies do not move. dynamic Dynamic bodies collide with all bodies. kinematic Kinematic bodies only collide with dynamic bodies. See Also -------- * [Body](body "Body") * [love.physics](love.physics "love.physics") love Joystick:getName Joystick:getName ================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been moved from [love.joystick.getName](love.joystick.getname "love.joystick.getName"). Gets the name of the joystick. Function -------- ### Synopsis ``` name = Joystick:getName( ) ``` ### Arguments None. ### Returns `[string](string "string") name` The name of the joystick. See Also -------- * [Joystick](joystick "Joystick") love Text:clear Text:clear ========== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Clears the contents of the Text object. Function -------- ### Synopsis ``` Text:clear( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Text](text "Text") love love.graphics.setDepthMode love.graphics.setDepthMode ========================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Configures depth testing and writing to the depth buffer. This is low-level functionality designed for use with custom [vertex shaders](love.graphics.newshader "love.graphics.newShader") and [Meshes](mesh "Mesh") with custom vertex attributes. No higher level APIs are provided to set the depth of 2D graphics such as shapes, lines, and Images. Depth testing and depth writes will have no effect unless the depth field is set to true in a table passed to [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas"), or a custom Canvas with a depth [PixelFormat](pixelformat "PixelFormat") is set in the depthstencil field in a table passed to [setCanvas](love.graphics.setcanvas "love.graphics.setCanvas"). Writing to the depth buffer is generally incompatible with rendering alpha-blended sprites / images. By default depth is determined by geometry (vertices) instead of texture alpha values, the depth buffer only stores a single depth value per pixel, and alpha blending **requires** back-to-front rendering for blending to be correct. Function -------- ### Synopsis ``` love.graphics.setDepthMode( comparemode, write ) ``` ### Arguments `[CompareMode](comparemode "CompareMode") comparemode` Depth comparison mode used for depth testing. `[boolean](boolean "boolean") write` Whether to write update / write values to the depth buffer when rendering. ### Returns Nothing. Function -------- Disables depth testing and depth writes. ### Synopsis ``` love.graphics.setDepthMode( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getDepthMode](love.graphics.getdepthmode "love.graphics.getDepthMode") * [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas") * [love.graphics.clear](love.graphics.clear "love.graphics.clear") * [PixelFormat](pixelformat "PixelFormat") * [Mesh](mesh "Mesh") love Font:getBaseline Font:getBaseline ================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the baseline of the Font. Most scripts share the notion of a baseline: an imaginary horizontal line on which characters rest. In some scripts, parts of glyphs lie below the baseline. Function -------- ### Synopsis ``` baseline = Font:getBaseline( ) ``` ### Arguments None. ### Returns `[number](number "number") baseline` The baseline of the Font in pixels. See Also -------- * [Font](font "Font") * [Font:getAscent](font-getascent "Font:getAscent") * [Font:getDescent](font-getdescent "Font:getDescent") love MotorJoint MotorJoint ========== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This type is not supported in earlier versions. Controls the relative motion between two [Bodies](body "Body"). Position and rotation offsets can be specified, as well as the maximum motor force and torque that will be applied to reach the target offsets. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.physics.newMotorJoint](love.physics.newmotorjoint "love.physics.newMotorJoint") | Creates a joint between two bodies which controls the relative motion between them. | 0.9.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Joint:destroy](joint-destroy "Joint:destroy") | Explicitly destroys the Joint. | | | | [Joint:getAnchors](joint-getanchors "Joint:getAnchors") | Get the anchor points of the joint. | | | | [Joint:getBodies](joint-getbodies "Joint:getBodies") | Gets the [bodies](body "Body") that the Joint is attached to. | 0.9.2 | | | [Joint:getCollideConnected](joint-getcollideconnected "Joint:getCollideConnected") | Gets whether the connected Bodies collide. | | | | [Joint:getReactionForce](joint-getreactionforce "Joint:getReactionForce") | Returns the reaction force on the second body. | | | | [Joint:getReactionTorque](joint-getreactiontorque "Joint:getReactionTorque") | Returns the reaction torque on the second body. | | | | [Joint:getType](joint-gettype "Joint:getType") | Gets a string representing the type. | | | | [Joint:getUserData](joint-getuserdata "Joint:getUserData") | Returns the Lua value associated with this Joint. | 0.9.2 | | | [Joint:isDestroyed](joint-isdestroyed "Joint:isDestroyed") | Gets whether the Joint is destroyed. | 0.9.2 | | | [Joint:setCollideConnected](joint-setcollideconnected "Joint:setCollideConnected") | Sets whether the connected Bodies should collide with each other. | | 0.8.0 | | [Joint:setUserData](joint-setuserdata "Joint:setUserData") | Associates a Lua value with the Joint. | 0.9.2 | | | [MotorJoint:getAngularOffset](motorjoint-getangularoffset "MotorJoint:getAngularOffset") | Gets the target angular offset between the two Bodies the Joint is attached to. | 0.9.0 | | | [MotorJoint:getLinearOffset](motorjoint-getlinearoffset "MotorJoint:getLinearOffset") | Gets the target linear offset between the two Bodies the Joint is attached to. | 0.9.0 | | | [MotorJoint:setAngularOffset](motorjoint-setangularoffset "MotorJoint:setAngularOffset") | Sets the target angular offset between the two Bodies the Joint is attached to. | 0.9.0 | | | [MotorJoint:setLinearOffset](motorjoint-setlinearoffset "MotorJoint:setLinearOffset") | Sets the target linear offset between the two Bodies the Joint is attached to. | 0.9.0 | | Supertypes ---------- * [Joint](joint "Joint") * [Object](object "Object") See Also -------- * [love.physics](love.physics "love.physics") love Fixture:getBody Fixture:getBody =============== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the body to which the fixture is attached. Function -------- ### Synopsis ``` body = Fixture:getBody( ) ``` ### Arguments None. ### Returns `[Body](body "Body") body` The parent body. See Also -------- * [Fixture](fixture "Fixture") love love.graphics.getPixelWidth love.graphics.getPixelWidth =========================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the width in pixels of the window. The graphics coordinate system and [love.graphics.getWidth](love.graphics.getwidth "love.graphics.getWidth") use units scaled by the screen's [DPI scale factor](love.graphics.getdpiscale "love.graphics.getDPIScale"), 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](shader "Shader"), for example). Function -------- ### Synopsis ``` pixelwidth = love.graphics.getPixelWidth( ) ``` ### Arguments None. ### Returns `[number](number "number") pixelwidth` The width of the window in pixels. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getPixelHeight](love.graphics.getpixelheight "love.graphics.getPixelHeight") * [love.graphics.getPixelDimensions](love.graphics.getpixeldimensions "love.graphics.getPixelDimensions") love Texture:getPixelHeight Texture:getPixelHeight ====================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This method is not supported in earlier versions. Gets the height in pixels of the Texture. [Texture:getHeight](texture-getheight "Texture:getHeight") gets the height of the texture in units scaled by the texture's [DPI scale factor](texture-getdpiscale "Texture:getDPIScale"), rather than pixels. Use getHeight for calculations related to drawing the texture (calculating an origin offset, for example), and getPixelHeight only when dealing specifically with pixels, for example when using [Canvas:newImageData](canvas-newimagedata "Canvas:newImageData"). Function -------- ### Synopsis ``` pixelheight = Texture:getPixelHeight( ) ``` ### Arguments None. ### Returns `[number](number "number") pixelheight` The height of the Texture, in pixels. See Also -------- * [Texture](texture "Texture") * [Texture:getDPIScale](texture-getdpiscale "Texture:getDPIScale") * [Texture:getPixelWidth](texture-getpixelwidth "Texture:getPixelWidth") * [Texture:getPixelDimensions](texture-getpixeldimensions "Texture:getPixelDimensions") love PrismaticJoint:hasLimitsEnabled PrismaticJoint:hasLimitsEnabled =============================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | This function has been renamed to [PrismaticJoint:areLimitsEnabled](prismaticjoint-arelimitsenabled "PrismaticJoint:areLimitsEnabled"). | Checks whether the limits are enabled. Function -------- ### Synopsis ``` enabled = PrismaticJoint:hasLimitsEnabled( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") enabled` True if enabled, false otherwise. See Also -------- * [PrismaticJoint](prismaticjoint "PrismaticJoint") love love.audio.resume love.audio.resume ================= **Removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** Use [love.audio.play](love.audio.play "love.audio.play") instead. Resumes all audio. Function -------- ### Synopsis ``` love.audio.resume( ) ``` ### Arguments None. ### Returns Nothing. Function -------- ### Synopsis ``` love.audio.resume( source ) ``` ### Arguments `[Source](source "Source") source` The source on which to resume the playback. ### Returns Nothing. See Also -------- * [love.audio](love.audio "love.audio") love love.window.maximize love.window.maximize ==================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Makes the window as large as possible. This function has no effect if the window isn't [resizable](love.window.setmode "love.window.setMode"), since it essentially programmatically presses the window's "maximize" button. Function -------- ### Synopsis ``` love.window.maximize( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [love.window](love.window "love.window") love love.touch love.touch ========== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This module is not supported in earlier versions. Provides an interface to touch-screen presses. Functions --------- | | | | | | --- | --- | --- | --- | | [love.touch.getPosition](love.touch.getposition "love.touch.getPosition") | Gets the current position of the specified touch-press. | 0.10.0 | | | [love.touch.getPressure](love.touch.getpressure "love.touch.getPressure") | Gets the current pressure of the specified touch-press. | 0.10.0 | | | [love.touch.getTouches](love.touch.gettouches "love.touch.getTouches") | Gets a list of all active touch-presses. | 0.10.0 | | See Also -------- * [love](love "love") * [love.touchpressed](love.touchpressed "love.touchpressed") * [love.touchreleased](love.touchreleased "love.touchreleased") * [love.touchmoved](love.touchmoved "love.touchmoved") love ParticleSystem:getParticleLifetime ParticleSystem:getParticleLifetime ================================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the lifetime of the particles. Function -------- ### Synopsis ``` min, max = ParticleSystem:getParticleLifetime( ) ``` ### Arguments Nothing. ### Returns `[number](number "number") min` The minimum life of the particles (in seconds). `[number](number "number") max` The maximum life of the particles (in seconds). See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setParticleLifetime](particlesystem-setparticlelifetime "ParticleSystem:setParticleLifetime") love love.graphics.setPointSize love.graphics.setPointSize ========================== Sets the [point](love.graphics.points "love.graphics.points") size. The sizes of points are not affected by [love.graphics.scale](love.graphics.scale "love.graphics.scale") – they're always in pixels, or since [11.0](https://love2d.org/wiki/11.0 "11.0"), in [DPI-scaled units](love.graphics.getdpiscale "love.graphics.getDPIScale"). Function -------- ### Synopsis ``` love.graphics.setPointSize( size ) ``` ### Arguments `[number](number "number") size` The new point size. ### Returns Nothing. Examples -------- Increase the point size by 1, by using [love.graphics.getPointSize](love.graphics.getpointsize "love.graphics.getPointSize"). ``` function love.draw() local s = love.graphics.getPointSize() + 1 love.graphics.setPointSize(s) love.graphics.points(100, 100) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.points](love.graphics.points "love.graphics.points") * [love.graphics.setPointStyle](love.graphics.setpointstyle "love.graphics.setPointStyle") * [love.graphics.getPointSize](love.graphics.getpointsize "love.graphics.getPointSize") love CircleShape:getWorldCenter CircleShape:getWorldCenter ========================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in that and later versions. Get the center of the circle in world coordinates. Function -------- ### Synopsis ``` wx, wy = CircleShape:getWorldCenter( ) ``` ### Arguments None. ### Returns `[number](number "number") wx` The x position of the circle in world coordinates. `[number](number "number") wy` The y position of the circle in world coordinates. See Also -------- * [CircleShape](circleshape "CircleShape") Others Languages ---------------- love World:update World:update ============ Update the state of the world. Function -------- ### Synopsis ``` World:update( dt, velocityiterations, positioniterations ) ``` ### Arguments `[number](number "number") dt` The time (in seconds) to advance the physics simulation. `[number](number "number") velocityiterations (8)` Available since 11.0 The maximum number of steps used to determine the new velocities when resolving a collision. `[number](number "number") positioniterations (3)` Available since 11.0 The maximum number of steps used to determine the new positions when resolving a collision. ### Returns Nothing. See Also -------- * [World](world "World") love love.audio.setVelocity love.audio.setVelocity ====================== Sets the velocity of the listener. Function -------- ### Synopsis ``` love.audio.setVelocity( x, y, z ) ``` ### Arguments `[number](number "number") x` The X velocity of the listener. `[number](number "number") y` The Y velocity of the listener. `[number](number "number") z` The Z velocity of the listener. ### Returns Nothing. See Also -------- * [love.audio](love.audio "love.audio") love (Image):isCompressed (Image):isCompressed ==================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets whether the Image was created from [CompressedData](compresseddata "CompressedData"). Compressed images take up less space in VRAM, and drawing a compressed image will generally be more efficient than drawing one created from raw pixel data. Function -------- ### Synopsis ``` compressed = Image:isCompressed( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") compressed` Whether the Image is stored as a compressed texture on the GPU. See Also -------- * [Image](image "Image") love love.event.push love.event.push =============== **Available since LÖVE [0.6.0](https://love2d.org/wiki/0.6.0 "0.6.0")** This function is not supported in earlier versions. Adds an event to the event queue. See [Variant](variant "Variant") for the list of supported types for the arguments. From [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0") onwards, you may pass an arbitrary amount of arguments with this function, though the default callbacks don't ever use more than six. Function -------- ### Synopsis ``` love.event.push( n, a, b, c, d, e, f, ... ) ``` ### Arguments `[Event](event "Event") n` The name of the event. `[Variant](variant "Variant") a (nil)` First event argument. `[Variant](variant "Variant") b (nil)` Second event argument. `[Variant](variant "Variant") c (nil)` Third event argument. `[Variant](variant "Variant") d (nil)` Available since 0.8.0 Fourth event argument. `[Variant](variant "Variant") e (nil)` Available since 0.10.0 Fifth event argument. `[Variant](variant "Variant") f (nil)` Available since 0.10.0 Sixth event argument. `[Variant](variant "Variant") ... (nil)` Available since 0.10.0 Further event arguments may follow. ### Returns Nothing. Examples -------- ``` function love.keypressed(k) if k == 'escape' then love.event.push('quit') -- Quit the game. end end ``` ``` function love.keypressed(k) if k == 'escape' then love.event.push('q') -- Quit the game. end end ``` See Also -------- * [love.event](love.event "love.event")
programming_docs
love Canvas:getFSAA Canvas:getFSAA ============== **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. **Removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** It has been renamed to [Canvas:getMSAA](canvas-getmsaa "Canvas:getMSAA"). Gets the number of antialiasing samples used when drawing to the Canvas. This may be different than the number used as an argument to [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") if the system running LÖVE doesn't support that number. Function -------- ### Synopsis ``` samples = Canvas:getFSAA( ) ``` ### Arguments None. ### Returns `[number](number "number") samples` The number of antialiasing samples used by the canvas when drawing to it. See Also -------- * [Canvas](canvas "Canvas") * [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") * [love.graphics.getSystemLimit](love.graphics.getsystemlimit "love.graphics.getSystemLimit") love JoystickHat JoystickHat =========== **Available since LÖVE [0.5.0](https://love2d.org/wiki/0.5.0 "0.5.0")** This enum is not supported in earlier versions. Joystick hat positions. Constants --------- c Centered d Down l Left ld Left+Down lu Left+Up r Right rd Right+Down ru Right+Up u Up See Also -------- * [love.joystick](love.joystick "love.joystick") * [Joystick](joystick "Joystick") love BezierCurve:render BezierCurve:render ================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Get a list of coordinates to be used with [love.graphics.line](love.graphics.line "love.graphics.line"). This function samples the Bézier curve using recursive subdivision. You can control the recursion depth using the depth parameter. If you are just interested to know the position on the curve given a parameter, use [BezierCurve:evaluate](beziercurve-evaluate "BezierCurve:evaluate"). Function -------- ### Synopsis ``` coordinates = BezierCurve:render(depth) ``` ### Arguments `[number](number "number") depth (5)` Number of recursive subdivision steps. ### Returns `[table](table "table") coordinates` List of x,y-coordinate pairs of points on the curve. Example ------- ### Draw a bezier curve ``` curve = love.math.newBezierCurve({25,25,75,50,125,25}) function love.draw() love.graphics.line(curve:render()) end ``` See Also -------- * [BezierCurve](beziercurve "BezierCurve") * [BezierCurve:renderSegment](beziercurve-rendersegment "BezierCurve:renderSegment") * [BezierCurve:evaluate](beziercurve-evaluate "BezierCurve:evaluate") * [love.math](love.math "love.math") love Mesh:getVertexAttribute Mesh:getVertexAttribute ======================= **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets the properties of a specific attribute within a vertex in the Mesh. Meshes without a custom vertex format specified in [love.graphics.newMesh](love.graphics.newmesh "love.graphics.newMesh") have position as their first attribute, texture coordinates as their second attribute, and color as their third attribute. Function -------- ### Synopsis ``` value1, value2, ... = Mesh:getVertexAttribute( vertexindex, attributeindex ) ``` ### Arguments `[number](number "number") vertexindex` The index of the the vertex you want to retrieve the attribute for (one-based). `[number](number "number") attributeindex` The index of the attribute within the vertex to be retrieved (one-based). ### Returns `[number](number "number") value1` The value of the first component of the attribute. `[number](number "number") value2` The value of the second component of the attribute. `[number](number "number") ...` Any additional vertex attribute components. See Also -------- * [Mesh](mesh "Mesh") * [Mesh:setVertexAttribute](mesh-setvertexattribute "Mesh:setVertexAttribute") * [Mesh:getVertexCount](mesh-getvertexcount "Mesh:getVertexCount") * [Mesh:getVertexFormat](mesh-getvertexformat "Mesh:getVertexFormat") * [Mesh:getVertex](mesh-getvertex "Mesh:getVertex") love love.graphics.isGammaCorrect love.graphics.isGammaCorrect ============================ **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets whether gamma-correct rendering is supported and enabled. It can be enabled by setting `t.gammacorrect = true` in [love.conf](love.conf "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. Function -------- ### Synopsis ``` gammacorrect = love.graphics.isGammaCorrect( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") gammacorrect` True if gamma-correct rendering is supported and was enabled in [love.conf](love.conf "love.conf"), false otherwise. Notes ----- When gamma-correct rendering is enabled, many functions and objects perform automatic color conversion between sRGB and linear RGB in order for [blending](blendmode "BlendMode") and [shader math](shader "Shader") to be mathematically correct (which they aren't if it's not enabled.) * The colors passed into [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor"), [love.graphics.clear](love.graphics.clear "love.graphics.clear"), and [Shader:sendColor](shader-sendcolor "Shader:sendColor") will automatically be [converted](love.math.gammatolinear "love.math.gammaToLinear") from sRGB to linear RGB. * The colors set in [SpriteBatches](spritebatch "SpriteBatch"), [text with per-character colors](love.graphics.print "love.graphics.print"), [ParticleSystems](particlesystem "ParticleSystem"), [points with per-point colors](love.graphics.points "love.graphics.points"), standard [Meshes](mesh "Mesh"), and [custom Meshes](love.graphics.newmesh "love.graphics.newMesh") which use the "VertexColor" attribute name will automatically be converted from sRGB to linear RGB when those objects are drawn. * [Images](image "Image") will have their colors automatically converted from sRGB to linear RGB when drawing them (and when getting their pixels in a [Shader](shader "Shader")), unless the flag `linear = true` is set when [creating the Image](love.graphics.newimage "love.graphics.newImage"). * Everything drawn to the screen will be blended in linear RGB and then the result will be converted to sRGB for display. * [Canvases](canvas "Canvas") which use the "normal" or "srgb" [CanvasFormat](canvasformat "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](mesh "Mesh") with custom vertex attributes is used and one of the attributes is meant to be used as a color in a [Shader](shader "Shader"), and the attribute isn't named "VertexColor". * If a [Shader](shader "Shader") is used which has uniform / extern variables or other variables that are meant to be used as colors, and [Shader:sendColor](shader-sendcolor "Shader:sendColor") isn't used. In both cases, [love.math.gammaToLinear](love.math.gammatolinear "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](http://http.developer.nvidia.com/GPUGems3/gpugems3_ch24.html), [here](http://filmicgames.com/archives/299), and [here](http://renderwonk.com/blog/index.php/archive/adventures-with-gamma-correct-rendering/). See Also -------- * [love.graphics](love.graphics "love.graphics") * [Config Files](love.conf "Config Files") * [love.math.gammaToLinear](love.math.gammatolinear "love.math.gammaToLinear") * [love.math.linearToGamma](love.math.lineartogamma "love.math.linearToGamma") * [Shader:sendColor](shader-sendcolor "Shader:sendColor") love love.graphics.getHeight love.graphics.getHeight ======================= **Available since LÖVE [0.2.1](https://love2d.org/wiki/0.2.1 "0.2.1")** This function is not supported in earlier versions. Gets the height in pixels of the window. Function -------- ### Synopsis ``` height = love.graphics.getHeight( ) ``` ### Arguments None. ### Returns `[number](number "number") height` The height of the window. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getWidth](love.graphics.getwidth "love.graphics.getWidth") * [love.graphics.getDimensions](love.graphics.getdimensions "love.graphics.getDimensions") love Joystick:getGUID Joystick:getGUID ================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets a stable GUID unique to the type of the physical joystick which does not change over time. For example, all Sony Dualshock 3 controllers in OS X have the same GUID. The value is platform-dependent. Function -------- ### Synopsis ``` guid = Joystick:getGUID( ) ``` ### Arguments None. ### Returns `[string](string "string") guid` The Joystick type's OS-dependent unique identifier. See Also -------- * [Joystick](joystick "Joystick") * [Joystick:getID](joystick-getid "Joystick:getID") * [love.joystick.setGamepadMapping](love.joystick.setgamepadmapping "love.joystick.setGamepadMapping") love love.audio.getSourceCount love.audio.getSourceCount ========================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [love.audio.getNumSources](love.audio.getnumsources "love.audio.getNumSources"). | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | It has been renamed to [love.audio.getActiveSourceCount](love.audio.getactivesourcecount "love.audio.getActiveSourceCount"). | Gets the current number of simultaneously playing sources. Function -------- ### Synopsis ``` numSources = love.audio.getSourceCount( ) ``` ### Arguments None. ### Returns `[number](number "number") numSources` The current number of simultaneously playing sources. See Also -------- * [love.audio](love.audio "love.audio") love enet.host:get peer enet.host:get peer ================== Returns the connected [peer](enet.peer "enet.peer") at the specified index (starting at 1). ENet stores all [peers](enet.peer "enet.peer") in an array of the corresponding [host](enet.host "enet.host") and re-uses unused peers for new connections. You can query the state of a peer using [peer:state()](enet.peer-state "enet.peer:state"). Function -------- ### Synopsis ``` host:get_peer(index) ``` ### Arguments `[number](number "number") index` The index of the desired [peer](enet.peer "enet.peer"). ### Returns `[enet.peer](enet.peer "enet.peer") peer` The desired [peer](enet.peer "enet.peer") structure. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.host](enet.host "enet.host") * [enet.peer](enet.peer "enet.peer") love love.window.setMode love.window.setMode =================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** Moved from [love.graphics.setMode](love.graphics.setmode "love.graphics.setMode"). Sets the display mode and properties of the window. If width or height is 0, setMode will use the width and height of the desktop. Changing the display mode may have side effects: for example, [canvases](canvas "Canvas") will be cleared and values sent to shaders with [Shader:send](shader-send "Shader:send") will be erased. Make sure to save the contents of [canvases](canvas "Canvas") beforehand or re-draw to them afterward if you need to. Function -------- ### Synopsis ``` success = love.window.setMode( width, height, flags ) ``` ### Arguments `[number](number "number") width` Display width. `[number](number "number") height` Display height. `[table](table "table") flags` The flags table with the options: `[boolean](boolean "boolean") fullscreen (false)` Fullscreen (true), or windowed (false). `[FullscreenType](fullscreentype "FullscreenType") fullscreentype ("desktop")` The type of fullscreen to use. This defaults to "normal" in [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0") through [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2") and to "desktop" in [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0") and older. `[number](number "number") vsync (1)` Enables or disables vertical synchronisation ('vsync'): **1** to enable vsync, **0** to disable it, and **-1** to use adaptive vsync (where supported). Prior to [11.0](https://love2d.org/wiki/11.0 "11.0") this was a boolean flag, rather than a number. `[number](number "number") msaa (0)` The number of antialiasing samples. `[boolean](boolean "boolean") stencil (true)` Whether a stencil buffer should be allocated. If true, the stencil buffer will have 8 bits. `[number](number "number") depth (0)` The number of bits in the depth buffer. `[boolean](boolean "boolean") resizable (false)` True if the window should be resizable in windowed mode, false otherwise. `[boolean](boolean "boolean") borderless (false)` True if the window should be borderless in windowed mode, false otherwise. `[boolean](boolean "boolean") centered (true)` True if the window should be centered in windowed mode, false otherwise. `[number](number "number") display (1)` The index of the display to show the window in, if multiple monitors are available. `[number](number "number") minwidth (1)` The minimum width of the window, if it's resizable. Cannot be less than 1. `[number](number "number") minheight (1)` The minimum height of the window, if it's resizable. Cannot be less than 1. `[boolean](boolean "boolean") highdpi (false)` Available since 0.9.1 True if [high-dpi mode](love.window.getdpiscale "love.window.getDPIScale") should be used on Retina displays in macOS and iOS. Does nothing on non-Retina displays. This is always enabled on Android. `[number](number "number") x (nil)` Available since 0.9.2 The x-coordinate of the window's position in the specified display. `[number](number "number") y (nil)` Available since 0.9.2 The y-coordinate of the window's position in the specified display. `[boolean](boolean "boolean") usedpiscale (true)` Available since 11.3 Disables LOVE's automatic DPI scaling on high-DPI displays when false. This only has an effect when the `highdpi` flag is set to true, since the OS (rather than LOVE) takes care of everything otherwise. `[boolean](boolean "boolean") srgb (false)` Available since 0.9.1 and removed in LÖVE 0.10.0 Removed in [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0") (set t.gammacorrect in [conf.lua](love.conf "conf.lua") instead). True if sRGB gamma correction should be applied when drawing to the screen. ### Returns `[boolean](boolean "boolean") success` True if successful, false otherwise. Notes ----- [love.conf](love.conf#window "love.conf") may have more extensive documentation on the behavior of each window flag. * If fullscreen is enabled and the width or height is not supported (see [love.window.getFullscreenModes](love.window.getfullscreenmodes "love.window.getFullscreenModes")), the window may be resized to the closest available resolution and a [resize](love.resize "love.resize") event will be triggered. * If the fullscreen type is "desktop", then the window will be automatically resized to the desktop resolution. * If the width and height is bigger than or equal to the desktop dimensions (this includes setting both to 0) and fullscreen is set to false, it will appear "visually" fullscreen, but it's not true fullscreen and [love.window.getFullscreen](love.window.getfullscreen "love.window.getFullscreen") will return false in this case. This also applies to [love.window.updateMode](love.window.updatemode "love.window.updateMode") as well. * If you have disabled the window in [conf.lua](love.conf "Config Files") (i.e. `t.window = false`) and use this function to manually create the window, then you must not call any other [love.graphics](love.graphics "love.graphics").\* function before this one. Doing so will result in undefined behavior and/or crashes because OpenGL cannot function properly without a window. * In Android, the aspect ratio deducted from the width and the height is used to determine whetever the game run in landscape or portrait. * Transparent backgrounds are currently not supported. Examples -------- ### Make the window resizable with vsync disabled and a minimum width and height set. ``` function love.load() love.window.setMode(800, 600, {resizable=true, vsync=false, minwidth=400, minheight=300}) end ``` See Also -------- * [love.window](love.window "love.window") * [love.window.getMode](love.window.getmode "love.window.getMode") * [love.window.getFullscreenModes](love.window.getfullscreenmodes "love.window.getFullscreenModes") * [love.resize](love.resize "love.resize") love Source:resume Source:resume ============= **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0") and removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** Use [Source:play](source-play "Source:play") instead. Resumes a paused Source. Function -------- ### Synopsis ``` Source:resume() ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Source](source "Source") love PrismaticJoint:setMotorSpeed PrismaticJoint:setMotorSpeed ============================ Sets the motor speed. Function -------- ### Synopsis ``` PrismaticJoint:setMotorSpeed( s ) ``` ### Arguments `[number](number "number") s` The motor speed, usually in meters per second. ### Returns Nothing. See Also -------- * [PrismaticJoint](prismaticjoint "PrismaticJoint") love WeldJoint WeldJoint ========= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This type is not supported in earlier versions. A WeldJoint essentially glues two bodies together. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.physics.newWeldJoint](love.physics.newweldjoint "love.physics.newWeldJoint") | A **WeldJoint** essentially glues two bodies together. | 0.8.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Joint:destroy](joint-destroy "Joint:destroy") | Explicitly destroys the Joint. | | | | [Joint:getAnchors](joint-getanchors "Joint:getAnchors") | Get the anchor points of the joint. | | | | [Joint:getBodies](joint-getbodies "Joint:getBodies") | Gets the [bodies](body "Body") that the Joint is attached to. | 0.9.2 | | | [Joint:getCollideConnected](joint-getcollideconnected "Joint:getCollideConnected") | Gets whether the connected Bodies collide. | | | | [Joint:getReactionForce](joint-getreactionforce "Joint:getReactionForce") | Returns the reaction force on the second body. | | | | [Joint:getReactionTorque](joint-getreactiontorque "Joint:getReactionTorque") | Returns the reaction torque on the second body. | | | | [Joint:getType](joint-gettype "Joint:getType") | Gets a string representing the type. | | | | [Joint:getUserData](joint-getuserdata "Joint:getUserData") | Returns the Lua value associated with this Joint. | 0.9.2 | | | [Joint:isDestroyed](joint-isdestroyed "Joint:isDestroyed") | Gets whether the Joint is destroyed. | 0.9.2 | | | [Joint:setCollideConnected](joint-setcollideconnected "Joint:setCollideConnected") | Sets whether the connected Bodies should collide with each other. | | 0.8.0 | | [Joint:setUserData](joint-setuserdata "Joint:setUserData") | Associates a Lua value with the Joint. | 0.9.2 | | | [WeldJoint:getDampingRatio](weldjoint-getdampingratio "WeldJoint:getDampingRatio") | Returns the damping ratio of the joint. | 0.8.0 | | | [WeldJoint:getFrequency](weldjoint-getfrequency "WeldJoint:getFrequency") | Returns the frequency. | 0.8.0 | | | [WeldJoint:setDampingRatio](weldjoint-setdampingratio "WeldJoint:setDampingRatio") | Sets a new damping ratio. | 0.8.0 | | | [WeldJoint:setFrequency](weldjoint-setfrequency "WeldJoint:setFrequency") | Sets a new frequency. | 0.8.0 | | Supertypes ---------- * [Joint](joint "Joint") * [Object](object "Object") See Also -------- * [love.physics](love.physics "love.physics")
programming_docs
love Object:type Object:type =========== Gets the type of the object as a string. Function -------- ### Synopsis ``` type = Object:type() ``` ### Arguments None. ### Returns `[string](string "string") type` The type as a string. Examples -------- ### Printing the type of an object ``` image = love.graphics.newImage("test.png") print(image:type()) -- outputs: Image source = love.audio.newSource("test.ogg") print(source:type()) -- outputs: Source ``` See Also -------- * [Object](object "Object") love love.physics.newPrismaticJoint love.physics.newPrismaticJoint ============================== Creates a [PrismaticJoint](prismaticjoint "PrismaticJoint") between two bodies. A prismatic joint constrains two bodies to move relatively to each other on a specified axis. It does not allow for relative rotation. Its definition and operation are similar to a [revolute](revolutejoint "RevoluteJoint") joint, but with translation and force substituted for angle and torque. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in earlier versions. ### Synopsis ``` joint = love.physics.newPrismaticJoint( body1, body2, x, y, ax, ay, collideConnected ) ``` ### Arguments `[Body](body "Body") body1` The first body to connect with a prismatic joint. `[Body](body "Body") body2` The second body to connect with a prismatic joint. `[number](number "number") x` The x coordinate of the anchor point. `[number](number "number") y` The y coordinate of the anchor point. `[number](number "number") ax` The x coordinate of the axis vector. `[number](number "number") ay` The y coordinate of the axis vector. `[boolean](boolean "boolean") collideConnected (false)` Specifies whether the two bodies should collide with each other. ### Returns `[PrismaticJoint](prismaticjoint "PrismaticJoint") joint` The new prismatic joint. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in earlier versions. ### Synopsis ``` joint = love.physics.newPrismaticJoint( body1, body2, x1, y1, x2, y2, ax, ay, collideConnected ) ``` ### Arguments `[Body](body "Body") body1` The first body to connect with a prismatic joint. `[Body](body "Body") body2` The second body to connect with a prismatic joint. `[number](number "number") x1` The x coordinate of the first anchor point. `[number](number "number") y1` The y coordinate of the first anchor point. `[number](number "number") x2` The x coordinate of the second anchor point. `[number](number "number") y2` The y coordinate of the second anchor point. `[number](number "number") ax` The x coordinate of the axis unit vector. `[number](number "number") ay` The y coordinate of the axis unit vector. `[boolean](boolean "boolean") collideConnected (false)` Specifies whether the two bodies should collide with each other. ### Returns `[PrismaticJoint](prismaticjoint "PrismaticJoint") joint` The new prismatic joint. Function -------- **Available since LÖVE [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2")** This variant is not supported in earlier versions. ### Synopsis ``` joint = love.physics.newPrismaticJoint( body1, body2, x1, y1, x2, y2, ax, ay, collideConnected, referenceAngle ) ``` ### Arguments `[Body](body "Body") body1` The first body to connect with a prismatic joint. `[Body](body "Body") body2` The second body to connect with a prismatic joint. `[number](number "number") x1` The x coordinate of the first anchor point. `[number](number "number") y1` The y coordinate of the first anchor point. `[number](number "number") x2` The x coordinate of the second anchor point. `[number](number "number") y2` The y coordinate of the second anchor point. `[number](number "number") ax` The x coordinate of the axis unit vector. `[number](number "number") ay` The y coordinate of the axis unit vector. `[boolean](boolean "boolean") collideConnected (false)` Specifies whether the two bodies should collide with each other. `[number](number "number") referenceAngle (0)` The reference angle between body1 and body2, in radians. ### Returns `[PrismaticJoint](prismaticjoint "PrismaticJoint") joint` The new prismatic joint. Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. ### Synopsis ``` joint = love.physics.newPrismaticJoint( body1, body2, x, y, ax, ay ) ``` ### Arguments `[Body](body "Body") body1` The first body to connect with a prismatic joint. `[Body](body "Body") body2` The second body to connect with a prismatic joint. `[number](number "number") x` The x coordinate of the anchor point. `[number](number "number") y` The y coordinate of the anchor point. `[number](number "number") ax` The x coordinate of the axis unit vector. `[number](number "number") ay` The y coordinate of the axis unit vector. ### Returns `[PrismaticJoint](prismaticjoint "PrismaticJoint") joint` The new prismatic joint. See Also -------- * [love.physics](love.physics "love.physics") * [PrismaticJoint](prismaticjoint "PrismaticJoint") * [Joint](joint "Joint") love love.graphics.setBlendMode love.graphics.setBlendMode ========================== **Available since LÖVE [0.2.0](https://love2d.org/wiki/0.2.0 "0.2.0")** This function is not supported in earlier versions. Sets the [blending mode](blendmode "BlendMode"). Function -------- ### Synopsis ``` love.graphics.setBlendMode( mode ) ``` ### Arguments `[BlendMode](blendmode "BlendMode") mode` The blend mode to use. ### Returns Nothing. Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.setBlendMode( mode, alphamode ) ``` ### Arguments `[BlendMode](blendmode "BlendMode") mode` The blend mode to use. `[BlendAlphaMode](blendalphamode "BlendAlphaMode") alphamode ("alphamultiply")` What to do with the alpha of drawn objects when blending. ### Returns Nothing. ### Notes The default "alphamultiply" alpha mode should normally be preferred except when drawing content with pre-multiplied alpha. If content is drawn to a [Canvas](canvas "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. Example ------- ``` function love.load() love.graphics.setBackgroundColor(54/255, 172/255, 248/255) end   function love.draw() love.graphics.setBlendMode("alpha") --Default blend mode love.graphics.setColor(230/255, 44/255, 123/255) love.graphics.rectangle("fill", 50, 50, 100, 100)   love.graphics.setColor(12/255, 100/255, 230/255) love.graphics.setBlendMode("multiply") love.graphics.rectangle("fill", 75, 75, 125, 125) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getBlendMode](love.graphics.getblendmode "love.graphics.getBlendMode") * [BlendMode](blendmode "BlendMode") love Source:setAttenuationDistances Source:setAttenuationDistances ============================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [Source:setDistance](source-setdistance "Source:setDistance"). Sets the reference and maximum attenuation distances of the Source. The parameters, combined with the current [DistanceModel](distancemodel "DistanceModel"), affect how the Source's volume attenuates based on distance. Distance attenuation is only applicable to Sources based on mono (rather than stereo) audio. Function -------- ### Synopsis ``` Source:setAttenuationDistances( ref, max ) ``` ### Arguments `[number](number "number") ref` The new reference attenuation distance. If the current [DistanceModel](distancemodel "DistanceModel") is clamped, this is the minimum attenuation distance. `[number](number "number") max` The new maximum attenuation distance. ### Returns Nothing. See Also -------- * [Source](source "Source") * [Source:getAttenuationDistances](source-getattenuationdistances "Source:getAttenuationDistances") * [love.audio.setDistanceModel](love.audio.setdistancemodel "love.audio.setDistanceModel") love Source:tell Source:tell =========== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Gets the currently playing position of the Source. Function -------- ### Synopsis ``` position = Source:tell( unit ) ``` ### Arguments `[TimeUnit](timeunit "TimeUnit") unit ("seconds")` The type of unit for the return value. ### Returns `[number](number "number") position` The currently playing position of the [Source](source "Source"). See Also -------- * [Source:seek](source-seek "Source:seek") * [Source:getDuration](source-getduration "Source:getDuration") * [Source](source "Source") love love.physics.newCircleShape love.physics.newCircleShape =========================== Creates a new [CircleShape](circleshape "CircleShape"). Making changes to a [World](world "World") is not allowed inside of the [beginContact](https://love2d.org/w/index.php?title=beginContact&action=edit&redlink=1 "beginContact (page does not exist)"), [endContact](https://love2d.org/w/index.php?title=endContact&action=edit&redlink=1 "endContact (page does not exist)"), [preSolve](https://love2d.org/w/index.php?title=preSolve&action=edit&redlink=1 "preSolve (page does not exist)"), and [postSolve](https://love2d.org/w/index.php?title=postSolve&action=edit&redlink=1 "postSolve (page does not exist)") callback functions, as BOX2D locks the world during these callbacks. **Script Example Missing** ***love.physics.newCircleShape** needs a script example, help out by writing one.* Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** These variants are not supported in earlier versions. ### Synopsis ``` shape = love.physics.newCircleShape( radius ) ``` ### Arguments `[number](number "number") radius` The radius of the circle. ### Returns `[CircleShape](circleshape "CircleShape") shape` The new shape. Function -------- ### Synopsis ``` shape = love.physics.newCircleShape( x, y, radius ) ``` ### Arguments `[number](number "number") x` The x position of the circle. `[number](number "number") y` The y position of the circle. `[number](number "number") radius` The radius of the circle. ### Returns `[CircleShape](circleshape "CircleShape") shape` The new shape. Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. ### Synopsis ``` shape = love.physics.newCircleShape( body, x, y, radius ) ``` ### Arguments `[Body](body "Body") body` The body to attach the shape to. `[number](number "number") x` The x offset of the circle. `[number](number "number") y` The y offset of the circle. `[number](number "number") radius` The radius of the circle. ### Returns `[CircleShape](circleshape "CircleShape") shape` A new CircleShape. See Also -------- * [love.physics](love.physics "love.physics") * [CircleShape](circleshape "CircleShape") * [Shape](shape "Shape") love SpriteBatch:getCount SpriteBatch:getCount ==================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the number of sprites currently in the SpriteBatch. Function -------- ### Synopsis ``` count = SpriteBatch:getCount( ) ``` ### Arguments None. ### Returns `[number](number "number") count` The number of sprites currently in the batch. See Also -------- * [SpriteBatch](spritebatch "SpriteBatch") * [SpriteBatch:getBufferSize](spritebatch-getbuffersize "SpriteBatch:getBufferSize") love love.audio.getMaxSceneEffects love.audio.getMaxSceneEffects ============================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the maximum number of active effects supported by the system. Function -------- ### Synopsis ``` maximum = love.audio.getMaxSceneEffects( ) ``` ### Arguments None. ### Returns `[number](number "number") maximum` The maximum number of active effects. See Also -------- * [love.audio](love.audio "love.audio") * [love.audio.getMaxSourceEffects](love.audio.getmaxsourceeffects "love.audio.getMaxSourceEffects") * [love.audio.isEffectsSupported](love.audio.iseffectssupported "love.audio.isEffectsSupported") * [love.audio.setEffect](love.audio.seteffect "love.audio.setEffect") love Transform:transformPoint Transform:transformPoint ======================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Applies the Transform object's transformation to the given 2D position. This effectively converts the given position from global coordinates into the local coordinate space of the Transform. Function -------- ### Synopsis ``` localX, localY = Transform:transformPoint( globalX, globalY ) ``` ### Arguments `[number](number "number") globalX` The x component of the position in global coordinates. `[number](number "number") globalY` The y component of the position in global coordinates. ### Returns `[number](number "number") localX` The x component of the position with the transform applied. `[number](number "number") localY` The y component of the position with the transform applied. See Also -------- * [Transform](transform "Transform") * [Transform:inverseTransformPoint](transform-inversetransformpoint "Transform:inverseTransformPoint") love Body:getAngularVelocity Body:getAngularVelocity ======================= Get the angular velocity of the Body. The angular velocity is the *rate of change of angle over time*. It is changed in [World:update](world-update "World:update") by applying torques, off centre forces/impulses, and angular damping. It can be set directly with [Body:setAngularVelocity](body-setangularvelocity "Body:setAngularVelocity"). If you need the *rate of change of position over time*, use [Body:getLinearVelocity](body-getlinearvelocity "Body:getLinearVelocity"). Function -------- ### Synopsis ``` w = Body:getAngularVelocity( ) ``` ### Arguments None. ### Returns `[number](number "number") w` The angular velocity in radians/second. See Also -------- * [Body](body "Body") love love.window.toPixels love.window.toPixels ==================== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Converts a number from density-independent units to pixels. 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](love.window.setmode "love.window.setMode") enabled, the window may take up the same physical size as an 800x600 window, but the area inside the window uses 1600x1200 pixels. `love.window.toPixels(800)` would return `1600` in that case. This is used to convert coordinates from the size users are expecting them to display at onscreen to pixels. [love.window.fromPixels](love.window.frompixels "love.window.fromPixels") does the opposite. 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. Most LÖVE functions return values and expect arguments in terms of pixels rather than density-independent units. Function -------- ### Synopsis ``` pixelvalue = love.window.toPixels( value ) ``` ### Arguments `[number](number "number") value` A number in density-independent units to convert to pixels. ### Returns `[number](number "number") pixelvalue` The converted number, in pixels. Function -------- ### Synopsis ``` px, py = love.window.toPixels( x, y ) ``` ### Arguments `[number](number "number") x` The x-axis value of a coordinate in density-independent units to convert to pixels. `[number](number "number") y` The y-axis value of a coordinate in density-independent units to convert to pixels. ### Returns `[number](number "number") px` The converted x-axis value of the coordinate, in pixels. `[number](number "number") py` The converted y-axis value of the coordinate, in pixels. Notes ----- The units of [love.graphics.getWidth](love.graphics.getwidth "love.graphics.getWidth"), [love.graphics.getHeight](love.graphics.getheight "love.graphics.getHeight"), [love.mouse.getPosition](love.mouse.getposition "love.mouse.getPosition"), mouse events, [love.touch.getPosition](love.touch.getposition "love.touch.getPosition"), and touch events are always in terms of pixels. See Also -------- * [love.window](love.window "love.window") * [love.window.fromPixels](love.window.frompixels "love.window.fromPixels") * [love.window.getDPIScale](love.window.getdpiscale "love.window.getDPIScale") * [love.window.setMode](love.window.setmode "love.window.setMode") * [Config Files](love.conf "Config Files") love PrismaticJoint:getMotorSpeed PrismaticJoint:getMotorSpeed ============================ Gets the motor speed. Function -------- ### Synopsis ``` s = PrismaticJoint:getMotorSpeed( ) ``` ### Arguments None. ### Returns `[number](number "number") s` The motor speed, usually in meters per second. See Also -------- * [PrismaticJoint](prismaticjoint "PrismaticJoint") love Body:getWorld Body:getWorld ============= **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This method is not supported in earlier versions. Gets the [World](world "World") the body lives in. Function -------- ### Synopsis ``` world = Body:getWorld( ) ``` ### Arguments None. ### Returns `[World](world "World") world` The world the body lives in. See Also -------- * [Body](body "Body") * [World](world "World") love ByteData ByteData ======== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This type is not supported in earlier versions. Data object containing arbitrary bytes in an contiguous memory. There are currently no LÖVE functions provided for manipulating the contents of a ByteData, but [Data:getFFIPointer](data-getffipointer "Data:getFFIPointer") can be used with LuaJIT's FFI to access and write to the contents directly. Used primarily for creating [ImageData](imagedata "ImageData"), [Image](image "Image"), also [love.filesystem.mount](love.filesystem.mount "love.filesystem.mount") etc. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.data.newByteData](love.data.newbytedata "love.data.newByteData") | Creates a new Data object containing arbitrary bytes. | 11.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Data:clone](data-clone "Data:clone") | Creates a new copy of the Data object. | 11.0 | | | [Data:getFFIPointer](data-getffipointer "Data:getFFIPointer") | Gets an FFI pointer to the Data. | 11.3 | | | [Data:getPointer](data-getpointer "Data:getPointer") | Gets a pointer to the Data. | | | | [Data:getSize](data-getsize "Data:getSize") | Gets the [Data](data "Data")'s size in bytes. | | | | [Data:getString](data-getstring "Data:getString") | Gets the full Data as a string. | 0.9.0 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Supertypes ---------- * [Object](object "Object") * [Data](data "Data") See Also -------- * [love.data](love.data "love.data")
programming_docs
love Video:pause Video:pause =========== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Pauses the Video. Function -------- ### Synopsis ``` Video:pause( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Video](video "Video") * [Video:play](video-play "Video:play") * [Video:isPlaying](video-isplaying "Video:isPlaying") love love.graphics.origin love.graphics.origin ==================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Resets the current coordinate transformation. This function is always used to reverse any previous calls to [love.graphics.rotate](love.graphics.rotate "love.graphics.rotate"), [love.graphics.scale](love.graphics.scale "love.graphics.scale"), [love.graphics.shear](love.graphics.shear "love.graphics.shear") or [love.graphics.translate](love.graphics.translate "love.graphics.translate"). It returns the current transformation state to its defaults. Function -------- ### Synopsis ``` love.graphics.origin() ``` ### Arguments None ### Returns Nothing. Example ------- ``` local image = love.graphics.newImage("path_to_your_image") function love.draw() love.graphics.push() -- stores the coordinate system love.graphics.scale(0.5, 0.5) -- reduce everything by 50% in both X and Y coordinates love.graphics.draw(image, 0, 0) -- you can see a scaled image that you loaded on the left top of the screen. love.graphics.print("Scaled text", 50, 50) -- print half-sized text at 25x25 love.graphics.draw(image, 0, 0) love.graphics.push() love.graphics.origin() -- Rest the state to the defaults. love.graphics.draw(image, 0, 0) -- Draw the image on screen as if nothing was scaled. love.graphics.pop() -- return to our scaled coordinate state. love.graphics.print("Scaled text", 100, 100) -- print half-sized text at 50x50 love.graphics.pop() -- return to the previous stored coordinated love.graphics.print("Normal text", 50, 50) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.pop](love.graphics.pop "love.graphics.pop") * [love.graphics.push](love.graphics.push "love.graphics.push") * [love.graphics.rotate](love.graphics.rotate "love.graphics.rotate") * [love.graphics.scale](love.graphics.scale "love.graphics.scale") * [love.graphics.shear](love.graphics.shear "love.graphics.shear") * [love.graphics.translate](love.graphics.translate "love.graphics.translate") love RevoluteJoint:areLimitsEnabled RevoluteJoint:areLimitsEnabled ============================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** It has been renamed from [RevoluteJoint:hasLimitsEnabled](revolutejoint-haslimitsenabled "RevoluteJoint:hasLimitsEnabled"). Checks whether limits are enabled. Function -------- ### Synopsis ``` enabled = RevoluteJoint:areLimitsEnabled( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") enabled` True if enabled, false otherwise. See Also -------- * [RevoluteJoint](revolutejoint "RevoluteJoint") love love.system.getPowerInfo love.system.getPowerInfo ======================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets information about the system's power supply. Function -------- ### Synopsis ``` state, percent, seconds = love.system.getPowerInfo( ) ``` ### Arguments None. ### Returns `[PowerState](powerstate "PowerState") state` The basic state of the power supply. `[number](number "number") percent (nil)` Percentage of battery life left, between 0 and 100. nil if the value can't be determined or there's no battery. `[number](number "number") seconds (nil)` Seconds of battery life left. nil if the value can't be determined or there's no battery. Examples -------- Print to console battery state, percent battery remaining, and seconds of battery life remaining. Note that percent and seconds remaining will be nil if no battery is present. ``` function love.load() print(love.system.getPowerInfo()) end ``` See Also -------- * [love.system](love.system "love.system") * [PowerState](powerstate "PowerState") love love.audio.getActiveEffects love.audio.getActiveEffects =========================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets a list of the names of the currently enabled effects. Function -------- ### Synopsis ``` effects = love.audio.getActiveEffects() ``` ### Arguments None. ### Returns `[table](table "table") effects` The list of the names of the currently enabled effects. See Also -------- * [love.audio](love.audio "love.audio") * [love.audio.setEffect](love.audio.seteffect "love.audio.setEffect") love Source:getType Source:getType ============== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** It has replaced [Source:isStatic](source-isstatic "Source:isStatic"). Gets the type of the Source. Function -------- ### Synopsis ``` sourcetype = Source:getType( ) ``` ### Arguments None. ### Returns `[SourceType](sourcetype "SourceType") sourcetype` The type of the source. See Also -------- * [Source](source "Source") * [love.audio.newSource](love.audio.newsource "love.audio.newSource") * [SourceType](sourcetype "SourceType") love love.graphics.getModes love.graphics.getModes ====================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** Moved to the [love.window](love.window "love.window") module as [love.window.getFullscreenModes](love.window.getfullscreenmodes "love.window.getFullscreenModes"). Gets a list of supported fullscreen modes. Function -------- ### Synopsis ``` modes = love.graphics.getModes( ) ``` ### Arguments None. ### Returns `[table](table "table") modes` A table of width/height pairs. (Note that this may not be in order.) Examples -------- ### Format of the returned table ``` modes = love.graphics.getModes()   -- modes = { -- { width = 320, height = 240 }, -- { width = 640, height = 480 }, -- { width = 800, height = 600 }, -- { width = 1024, height = 768 }, -- ... -- } ``` ### Sort table to ensure it is in order ``` modes = love.graphics.getModes() table.sort(modes, function(a, b) return a.width*a.height < b.width*b.height end) -- sort from smallest to largest ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.checkMode](love.graphics.checkmode "love.graphics.checkMode") * [love.graphics.setMode](love.graphics.setmode "love.graphics.setMode") love Text:getWidth Text:getWidth ============= **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets the width of the text in pixels. Function -------- ### Synopsis ``` width = Text:getWidth( ) ``` ### Arguments None. ### Returns `[number](number "number") width` The width of the text. If multiple sub-strings have been added with [Text:add](text-add "Text:add"), the width of the last sub-string is returned. Function -------- Gets the width of a specific sub-string that was previously added to the Text object. ### Synopsis ``` width = Text:getWidth( index ) ``` ### Arguments `[number](number "number") index` An index number returned by [Text:add](text-add "Text:add") or [Text:addf](text-addf "Text:addf"). ### Returns `[number](number "number") width` The width of the sub-string (before scaling and other transformations). See Also -------- * [Text](text "Text") * [Text:getHeight](text-getheight "Text:getHeight") * [Text:set](text-set "Text:set") * [Text:setf](text-setf "Text:setf") * [Text:add](text-add "Text:add") * [Text:addf](text-addf "Text:addf") love Body:getAngle Body:getAngle ============= Get the angle of the body. The angle is measured in [radians](https://en.wikipedia.org/wiki/Radian). If you need to transform it to degrees, use [math.deg](https://www.lua.org/manual/5.1/manual.html#pdf-math.deg). A value of 0 radians will mean "looking to the right". Although radians increase counter-clockwise, the y axis points down so it becomes *clockwise* from our point of view. Function -------- ### Synopsis ``` angle = Body:getAngle( ) ``` ### Arguments None. ### Returns `[number](number "number") angle` The angle in radians. See Also -------- * [Body](body "Body") * [Body:setAngle](body-setangle "Body:setAngle") * [Body:getAngularVelocity](body-getangularvelocity "Body:getAngularVelocity") love Source:isRelative Source:isRelative ================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets whether the Source's position, velocity, direction, and cone angles are relative to the listener. Function -------- ### Synopsis ``` relative = Source:isRelative( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") relative` True if the position, velocity, direction and cone angles are relative to the listener, false if they're absolute. See Also -------- * [Source](source "Source") * [Source:setRelative](source-setrelative "Source:setRelative") love love.keyboard.hasScreenKeyboard love.keyboard.hasScreenKeyboard =============================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets whether screen keyboard is supported. Function -------- ### Synopsis ``` supported = love.keyboard.hasScreenKeyboard( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") supported` Whether screen keyboard is supported. See Also -------- * [love.keyboard](love.keyboard "love.keyboard") love RecordingDevice:getName RecordingDevice:getName ======================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the name of the recording device. Function -------- ### Synopsis ``` name = RecordingDevice:getName( ) ``` ### Arguments None. ### Returns `[string](string "string") name` The name of the device. See Also -------- * [RecordingDevice](recordingdevice "RecordingDevice") love ImageFontFormat ImageFontFormat =============== The imagefont file is an image file in a format that LÖVE can load. It can contain transparent pixels, so a PNG file is preferable, and it also needs to contain spacer color that will separate the different font glyphs. The *upper left pixel* of the image file is always taken to be the spacer color. All columns that have this color as their uppermost pixel are interpreted as separators of font glyphs. The areas between these separators are interpreted as the actual font glyphs. It is possible to have more areas in the image than are required for the font in the [love.graphics.newImageFont](love.graphics.newimagefont "love.graphics.newImageFont")() call. The extra areas are ignored. In versions prior to [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0") the width of the separator area after a particular font glyph sets the amount of space that goes after the glyph. As of [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0"), it is possible to add negative spacing for all characters by using the 3-parameter version of [love.graphics.newImageFont](love.graphics.newimagefont "love.graphics.newImageFont") and giving a negative number as the third parameter. See Also -------- * [Tutorial:Fonts and Text](https://love2d.org/wiki/Tutorial:Fonts_and_Text "Tutorial:Fonts and Text") love ParticleSystem:getOffsetX ParticleSystem:getOffsetX ========================= **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been moved to [ParticleSystem:getOffset](particlesystem-getoffset "ParticleSystem:getOffset"). Get the x coordinate of the particle rotation offset. Function -------- ### Synopsis ``` xOffset = ParticleSystem:getOffsetX( ) ``` ### Arguments None. ### Returns `[number](number "number") xOffset` The x coordinate of the rotation offset. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:getOffsetY](particlesystem-getoffsety "ParticleSystem:getOffsetY") * [ParticleSystem:setOffset](particlesystem-setoffset "ParticleSystem:setOffset") love love.graphics.setBackgroundColor love.graphics.setBackgroundColor ================================ Sets the background color. In versions prior to [11.0](https://love2d.org/wiki/11.0 "11.0"), color component values were within the range of 0 to 255 instead of 0 to 1. Function -------- ### Synopsis ``` love.graphics.setBackgroundColor( red, green, blue, alpha ) ``` ### Arguments `[number](number "number") red` The red component (0-1). `[number](number "number") green` The green component (0-1). `[number](number "number") blue` The blue component (0-1). `[number](number "number") alpha (1)` Available since 0.8.0 The alpha component (0-1). ### Returns Nothing. ### Example ``` function love.draw() -- Set Background Color to #731b87 (115, 27, 135) with an alpha of 50% -- Note: Remember that Love uses 0-1 and not 0-255 red = 115/255 green = 27/255 blue = 135/255 alpha = 50/100 love.graphics.setBackgroundColor( red, green, blue, alpha) end ``` Function -------- **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.setBackgroundColor( rgb ) ``` ### Arguments `[table](table "table") rgb` A numerical indexed table with the red, green and blue values as [numbers](number "number"). ### Returns Nothing. ### Example ``` function love.draw() -- Set Background Color to #1b8724 (27, 135, 36) -- Note: Remember that Love uses 0-1 and not 0-255 red = 27/255 green = 135/255 blue = 36/255 color = { red, green, blue} love.graphics.setBackgroundColor( color) end ``` Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.setBackgroundColor( rgba ) ``` ### Arguments `[table](table "table") rgba` A numerical indexed table with the red, green, blue and alpha values as [numbers](number "number"). ### Returns Nothing. ### Example ``` function love.draw() -- Set Background Color to #731b87 (115, 27, 135) with an alpha of 50% -- Note: Remember that Love uses 0-1 and not 0-255 red = 115/255 green = 27/255 blue = 135/255 alpha = 50/100 color = { red, green, blue, alpha} love.graphics.setBackgroundColor( color) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.clear](love.graphics.clear "love.graphics.clear") * [love.graphics.getBackgroundColor](love.graphics.getbackgroundcolor "love.graphics.getBackgroundColor") love love.window.getPosition love.window.getPosition ======================= **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Gets the position of the window on the screen. The window position is in the coordinate space of the display it is currently in. Function -------- ### Synopsis ``` x, y, display = love.window.getPosition( ) ``` ### Arguments None. ### Returns `[number](number "number") x` The x-coordinate of the window's position. `[number](number "number") y` The y-coordinate of the window's position. `[number](number "number") display` The index of the display that the window is in. See Also -------- * [love.window](love.window "love.window") * [love.window.setPosition](love.window.setposition "love.window.setPosition") love Body:getLocalVector Body:getLocalVector =================== Transform a vector from world coordinates to local coordinates. Function -------- ### Synopsis ``` localX, localY = Body:getLocalVector( worldX, worldY ) ``` ### Arguments `[number](number "number") worldX` The vector x component in world coordinates. `[number](number "number") worldY` The vector y component in world coordinates. ### Returns `[number](number "number") localX` The vector x component in local coordinates. `[number](number "number") localY` The vector y component in local coordinates. See Also -------- * [Body](body "Body") love love.system.vibrate love.system.vibrate =================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Causes the device to vibrate, if possible. Currently this will only work on Android and iOS devices that have a built-in vibration motor. Function -------- ### Synopsis ``` love.system.vibrate( seconds ) ``` ### Arguments `[number](number "number") seconds (0.5)` The duration to vibrate for. If called on an iOS device, it will always vibrate for 0.5 seconds due to limitations in the iOS system APIs. ### Returns Nothing. See Also -------- * [love.system](love.system "love.system") love RevoluteJoint:getJointSpeed RevoluteJoint:getJointSpeed =========================== Get the current joint angle speed. Function -------- ### Synopsis ``` s = RevoluteJoint:getJointSpeed( ) ``` ### Arguments None. ### Returns `[number](number "number") s` Joint angle speed in radians/second. See Also -------- * [RevoluteJoint](revolutejoint "RevoluteJoint") love ParticleSystem:setRadialAcceleration ParticleSystem:setRadialAcceleration ==================================== Set the radial acceleration (away from the emitter). Function -------- ### Synopsis ``` ParticleSystem:setRadialAcceleration( min, max ) ``` ### Arguments `[number](number "number") min` The minimum acceleration. `[number](number "number") max (min)` The maximum acceleration. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:getRadialAcceleration](particlesystem-getradialacceleration "ParticleSystem:getRadialAcceleration") love love.graphics.setColorMode love.graphics.setColorMode ========================== **Available since LÖVE [0.2.0](https://love2d.org/wiki/0.2.0 "0.2.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier or later versions. Sets the color mode (which controls how images are affected by the current color). Function -------- ### Synopsis ``` love.graphics.setColorMode( mode ) ``` ### Arguments `[ColorMode](colormode "ColorMode") mode` The color mode to use. ### Returns Nothing. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getColorMode](love.graphics.getcolormode "love.graphics.getColorMode") love love.joystick.saveGamepadMappings love.joystick.saveGamepadMappings ================================= **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Saves the virtual gamepad mappings of all [Joysticks](joystick "Joystick") that are [recognized](joystick-isgamepad "Joystick:isGamepad") as gamepads and have either been recently used or their gamepad bindings have been modified. The mappings are stored as a string for use with [love.joystick.loadGamepadMappings](love.joystick.loadgamepadmappings "love.joystick.loadGamepadMappings"). Function -------- Saves the gamepad mappings of all relevant joysticks to a file. ### Synopsis ``` mappings = love.joystick.saveGamepadMappings( filename ) ``` ### Arguments `[string](string "string") filename` The filename to save the mappings string to. ### Returns `[string](string "string") mappings` The mappings string that was written to the file. Function -------- Returns the mappings string without writing to a file. ### Synopsis ``` mappings = love.joystick.saveGamepadMappings( ) ``` ### Arguments None. ### Returns `[string](string "string") mappings` The mappings string. See Also -------- * [love.joystick](love.joystick "love.joystick") * [love.joystick.loadGamepadMappings](love.joystick.loadgamepadmappings "love.joystick.loadGamepadMappings") * [love.joystick.setGamepadMapping](love.joystick.setgamepadmapping "love.joystick.setGamepadMapping") * [Joystick:getGamepadMapping](joystick-getgamepadmapping "Joystick:getGamepadMapping") * [Joystick:isGamepad](joystick-isgamepad "Joystick:isGamepad")
programming_docs
love Body:getLocalCenter Body:getLocalCenter =================== Get the center of mass position in local coordinates. Use [Body:getWorldCenter](body-getworldcenter "Body:getWorldCenter") to get the center of mass in world coordinates. Function -------- ### Synopsis ``` x, y = Body:getLocalCenter( ) ``` ### Arguments None. ### Returns `[number](number "number") x` The x coordinate of the center of mass. `[number](number "number") y` The y coordinate of the center of mass. See Also -------- * [Body](body "Body") love RevoluteJoint RevoluteJoint ============= Allow two Bodies to revolve around a shared point. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.physics.newRevoluteJoint](love.physics.newrevolutejoint "love.physics.newRevoluteJoint") | Creates a pivot joint between two bodies. | | | Functions --------- | | | | | | --- | --- | --- | --- | | [Joint:destroy](joint-destroy "Joint:destroy") | Explicitly destroys the Joint. | | | | [Joint:getAnchors](joint-getanchors "Joint:getAnchors") | Get the anchor points of the joint. | | | | [Joint:getBodies](joint-getbodies "Joint:getBodies") | Gets the [bodies](body "Body") that the Joint is attached to. | 0.9.2 | | | [Joint:getCollideConnected](joint-getcollideconnected "Joint:getCollideConnected") | Gets whether the connected Bodies collide. | | | | [Joint:getReactionForce](joint-getreactionforce "Joint:getReactionForce") | Returns the reaction force on the second body. | | | | [Joint:getReactionTorque](joint-getreactiontorque "Joint:getReactionTorque") | Returns the reaction torque on the second body. | | | | [Joint:getType](joint-gettype "Joint:getType") | Gets a string representing the type. | | | | [Joint:getUserData](joint-getuserdata "Joint:getUserData") | Returns the Lua value associated with this Joint. | 0.9.2 | | | [Joint:isDestroyed](joint-isdestroyed "Joint:isDestroyed") | Gets whether the Joint is destroyed. | 0.9.2 | | | [Joint:setCollideConnected](joint-setcollideconnected "Joint:setCollideConnected") | Sets whether the connected Bodies should collide with each other. | | 0.8.0 | | [Joint:setUserData](joint-setuserdata "Joint:setUserData") | Associates a Lua value with the Joint. | 0.9.2 | | | [RevoluteJoint:areLimitsEnabled](revolutejoint-arelimitsenabled "RevoluteJoint:areLimitsEnabled") | Checks whether limits are enabled. | 11.0 | | | [RevoluteJoint:enableLimit](revolutejoint-enablelimit "RevoluteJoint:enableLimit") | Enables or disables the joint limits. | 0.8.0 | 0.9.0 | | [RevoluteJoint:enableMotor](revolutejoint-enablemotor "RevoluteJoint:enableMotor") | Starts or stops the joint motor. | 0.8.0 | 0.9.0 | | [RevoluteJoint:getJointAngle](revolutejoint-getjointangle "RevoluteJoint:getJointAngle") | Get the current joint angle. | | | | [RevoluteJoint:getJointSpeed](revolutejoint-getjointspeed "RevoluteJoint:getJointSpeed") | Get the current joint angle speed. | | | | [RevoluteJoint:getLimits](revolutejoint-getlimits "RevoluteJoint:getLimits") | Gets the joint limits. | | | | [RevoluteJoint:getLowerLimit](revolutejoint-getlowerlimit "RevoluteJoint:getLowerLimit") | Gets the lower limit. | | | | [RevoluteJoint:getMaxMotorTorque](revolutejoint-getmaxmotortorque "RevoluteJoint:getMaxMotorTorque") | Gets the maximum motor force. | | | | [RevoluteJoint:getMotorSpeed](revolutejoint-getmotorspeed "RevoluteJoint:getMotorSpeed") | Gets the motor speed. | | | | [RevoluteJoint:getMotorTorque](revolutejoint-getmotortorque "RevoluteJoint:getMotorTorque") | Get the current motor force. | | | | [RevoluteJoint:getUpperLimit](revolutejoint-getupperlimit "RevoluteJoint:getUpperLimit") | Gets the upper limit. | | | | [RevoluteJoint:hasLimitsEnabled](revolutejoint-haslimitsenabled "RevoluteJoint:hasLimitsEnabled") | Checks whether limits are enabled. | 0.9.0 | | | [RevoluteJoint:isLimitsEnabled](revolutejoint-islimitsenabled "RevoluteJoint:isLimitsEnabled") | Checks whether limits are enabled. | | 0.9.0 | | [RevoluteJoint:isMotorEnabled](revolutejoint-ismotorenabled "RevoluteJoint:isMotorEnabled") | Checks whether the motor is enabled. | | | | [RevoluteJoint:setLimits](revolutejoint-setlimits "RevoluteJoint:setLimits") | Sets the limits. | | | | [RevoluteJoint:setLimitsEnabled](revolutejoint-setlimitsenabled "RevoluteJoint:setLimitsEnabled") | Enables/disables the joint limit. | 0.9.0 | | | [RevoluteJoint:setLowerLimit](revolutejoint-setlowerlimit "RevoluteJoint:setLowerLimit") | Sets the lower limit. | | | | [RevoluteJoint:setMaxMotorTorque](revolutejoint-setmaxmotortorque "RevoluteJoint:setMaxMotorTorque") | Set the maximum motor force. | | | | [RevoluteJoint:setMotorEnabled](revolutejoint-setmotorenabled "RevoluteJoint:setMotorEnabled") | Enables/disables the joint motor. | 0.9.0 | | | [RevoluteJoint:setMotorSpeed](revolutejoint-setmotorspeed "RevoluteJoint:setMotorSpeed") | Sets the motor speed. | | | Supertypes ---------- * [Joint](joint "Joint") * [Object](object "Object") See Also -------- * [love.physics](love.physics "love.physics") love HintingMode HintingMode =========== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This enum is not supported in earlier versions. True Type hinting mode. Constants --------- normal Default hinting. Should be preferred for typical antialiased fonts. light Results in fuzzier text but can sometimes preserve the original glyph shapes of the text better than normal hinting. mono Results in aliased / unsmoothed text with either full opacity or completely transparent pixels. Should be used when antialiasing is not desired for the font. none Disables hinting for the font. Results in fuzzier text. See Also -------- * [love.font](love.font "love.font") * [love.font.newRasterizer](love.font.newrasterizer "love.font.newRasterizer") * [love.font.newTrueTypeRasterizer](love.font.newtruetyperasterizer "love.font.newTrueTypeRasterizer") * [love.graphics.newFont](love.graphics.newfont "love.graphics.newFont") love love.touchmoved love.touchmoved =============== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Callback function triggered when a touch press moves inside the touch screen. Function -------- ### Synopsis ``` love.touchmoved( id, x, y, dx, dy, pressure ) ``` ### Arguments `[light userdata](light_userdata "light userdata") id` The identifier for the touch press. `[number](number "number") x` The x-axis position of the touch inside the window, in pixels. `[number](number "number") y` The y-axis position of the touch inside the window, in pixels. `[number](number "number") dx` The x-axis movement of the touch inside the window, in pixels. `[number](number "number") dy` The y-axis movement of the touch inside the window, in pixels. `[number](number "number") pressure` The amount of pressure being applied. Most touch screens aren't pressure sensitive, in which case the pressure will be 1. ### Returns Nothing. Notes ----- The identifier is only guaranteed to be unique for the specific touch press until [love.touchreleased](love.touchreleased "love.touchreleased") is called with that identifier, at which point it may be reused for new touch presses. The unofficial Android and iOS ports of LÖVE 0.9.2 reported touch positions as normalized values in the range of [0, 1], whereas this API reports positions in pixels. See Also -------- * [love](love "love") * [love.touchpressed](love.touchpressed "love.touchpressed") * [love.touchreleased](love.touchreleased "love.touchreleased") * [love.touch](love.touch "love.touch") love love.graphics.newArrayImage love.graphics.newArrayImage =========================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Creates a new [array](texturetype "TextureType") [Image](image "Image"). Not all system supports array image. Use [love.graphics.getTextureTypes](love.graphics.gettexturetypes "love.graphics.getTextureTypes") to check! This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! 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](love.graphics.drawlayer "love.graphics.drawLayer") / [SpriteBatch:addLayer](spritebatch-addlayer "SpriteBatch:addLayer"), or with the [Quad](quad "Quad") variant of [love.graphics.draw](love.graphics.draw "love.graphics.draw") and [Quad:setLayer](https://love2d.org/w/index.php?title=Quad:setLayer&action=edit&redlink=1 "Quad:setLayer (page does not exist)"), 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. Function -------- Creates an array Image given a different image file for each slice of the resulting array image object. ### Synopsis ``` image = love.graphics.newArrayImage( slices, settings ) ``` ### Arguments `[table](table "table") slices` A table containing filepaths to images (or [File](file "File"), [FileData](filedata "FileData"), [ImageData](imagedata "ImageData"), or [CompressedImageData](compressedimagedata "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. `[table](table "table") settings (nil)` Optional table of settings to configure the array image, containing the following fields: `[boolean](boolean "boolean") mipmaps (false)` True to make the image use mipmaps, false to disable them. Mipmaps will be automatically generated if the image isn't a [compressed texture](pixelformat "PixelFormat") format. `[boolean](boolean "boolean") linear (false)` True to treat the image's pixels as linear instead of sRGB, when [gamma correct rendering](love.graphics.isgammacorrect "love.graphics.isGammaCorrect") is enabled. Most images are authored as sRGB. `[number](number "number") dpiscale (1)` The DPI scale to use when drawing the array image and calling [getWidth](texture-getwidth "Texture:getWidth")/[getHeight](texture-getheight "Texture:getHeight"). ### Returns `[Image](image "Image") image` An Array Image object. Notes ----- Illustration of how an array image works: [[1]](http://codeflow.org/entries/2010/dec/09/minecraft-like-rendering-experiments-in-opengl-4/illustrations/textures.jpg) 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 [Shader](shader "Shader"), the [void effect()](love.graphics.newshader "love.graphics.newShader") variant must be used in the pixel shader, and MainTex must be declared as an ArrayImage or sampler2DArray like so: `uniform ArrayImage MainTex;`. Examples -------- ### Draw multiple layers of an Array Image ``` function love.load() local sprites = {"sprite1.png", "sprite2.png"} image = love.graphics.newArrayImage(sprites) end   function love.draw() love.graphics.drawLayer(image, 1, 50, 50) love.graphics.drawLayer(image, 2, 250, 50) end ``` ### Use a custom shader with love.graphics.drawLayer ``` shader = love.graphics.newShader[[ uniform ArrayImage MainTex;   void effect() { // Texel uses a third component of the texture coordinate for the layer index, when an Array Texture is passed in. // love sets up the texture coordinates to contain the layer index specified in love.graphics.drawLayer, when // rendering the Array Texture. love_PixelColor = Texel(MainTex, VaryingTexCoord.xyz) * VaryingColor; } ]]   function love.load() local sprites = {"sprite1.png", "sprite2.png"} image = love.graphics.newArrayImage(sprites) end   function love.draw() love.graphics.setShader(shader) love.graphics.drawLayer(image, 1, 50, 50) love.graphics.drawLayer(image, 2, 250, 50) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [Image](image "Image") * [TextureType](texturetype "TextureType") love PrismaticJoint:getJointTranslation PrismaticJoint:getJointTranslation ================================== Get the current joint translation. Function -------- ### Synopsis ``` t = PrismaticJoint:getJointTranslation( ) ``` ### Arguments None. ### Returns `[number](number "number") t` Joint translation, usually in meters.. See Also -------- * [PrismaticJoint](prismaticjoint "PrismaticJoint") love Fixture:isDestroyed Fixture:isDestroyed =================== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Gets whether the Fixture is destroyed. Destroyed fixtures cannot be used. Function -------- ### Synopsis ``` destroyed = Fixture:isDestroyed( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") destroyed` Whether the Fixture is destroyed. See Also -------- * [Fixture](fixture "Fixture") * [Fixture:destroy](fixture-destroy "Fixture:destroy") love PixelFormat PixelFormat =========== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This enum replaces [CanvasFormat](canvasformat "CanvasFormat") and [CompressedImageFormat](compressedimageformat "CompressedImageFormat"). Pixel formats for [Textures](texture "Texture"), [ImageData](imagedata "ImageData"), and [CompressedImageData](compressedimagedata "CompressedImageData"). Normal color formats -------------------- ### Constants | Name | Components | Bits per pixel | Range | Usable with [Canvases](canvas "Canvas") | Usable with [ImageData](imagedata "ImageData") | Note(s) | | --- | --- | --- | --- | --- | --- | --- | | normal | 4 | 32 | [0, 1] | Yes | | Alias for `rgba8`, or `srgba8` if [gamma-correct rendering](love.graphics.isgammacorrect "love.graphics.isGammaCorrect") is enabled. | | r8 | 1 | 8 | [0, 1] | Yes | 11.3 | | | rg8 | 2 | 16 | [0, 1] | Yes | 11.3 | | | rgba8 | 4 | 32 | [0, 1] | Yes | Yes | | | srgba8 | 4 | 32 | [0, 1] | Yes | | [gamma-correct](love.graphics.isgammacorrect "love.graphics.isGammaCorrect") version of rgba8. | | r16 | 1 | 16 | [0, 1] | | 11.3 | | | rg16 | 2 | 32 | [0, 1] | | 11.3 | | | rgba16 | 4 | 64 | [0, 1] | | Yes | | | r16f | 1 | 16 | [-65504, +65504]\* | Yes | 11.3 | | | rg16f | 2 | 32 | [-65504, +65504]\* | Yes | 11.3 | | | rgba16f | 4 | 64 | [-65504, +65504]\* | Yes | Yes | | | r32f | 1 | 32 | [-3.4028235e38, 3.4028235e38]\* | Yes | 11.3 | | | rg32f | 2 | 64 | [-3.4028235e38, 3.4028235e38]\* | Yes | 11.3 | | | rgba32f | 4 | 128 | [-3.4028235e38, 3.4028235e38]\* | Yes | Yes | | | rgba4 | 4 | 16 | [0, 1] | Yes | 11.3 | | | rgb5a1 | 4 | 16 | [0, 1] | Yes | 11.3 | | | rgb565 | 3 | 16 | [0, 1] | Yes | 11.3 | | | rgb10a2 | 4 | 32 | [0, 1] | Yes | 11.3 | | | rg11b10f | 3 | 32 | [0, 65024]\*\* | Yes | 11.3 | | \* -infinity and +infinity are also valid values. \*\* +infinity is also a valid value. Depth / stencil formats ----------------------- All depth and stencil pixel formats are only usable in [Canvases](canvas "Canvas"). They are [non-readable](texture-isreadable "Texture:isReadable") by default, and Canvases with a depth/stencil format created with the [readable flag](love.graphics.newcanvas "love.graphics.newCanvas") can only access the depth values of their pixels in shaders (stencil values are not readable no matter what). ### Constants | Name | Bits per pixel | Has depth | Has stencil | Note(s) | | --- | --- | --- | --- | --- | | stencil8 | 8 | | Yes | | | depth16 | 16 | Yes | | | | depth24 | 24 | Yes | | | | depth32f | 32 | Yes | | | | depth24stencil8 | 32 | Yes | Yes | | | depth32fstencil8 | 40 | Yes | Yes | | Compressed formats ------------------ All compressed pixel formats are only usable in [Images](image "Image") via [CompressedImageData](compressedimagedata "CompressedImageData") (compressed textures). Unlike regular color formats, these stay compressed in RAM and VRAM. This is good for saving memory space as well as improving performance, since the graphics card will be able to keep more of the image's pixels in its fast-access cache when drawing it. ### Constants (desktop GPUs) | Name | Components | Bits per pixel | Range | Note(s) | | --- | --- | --- | --- | --- | | DXT1 | 3 | 4 | [0, 1] | Suitable for fully opaque images on desktop systems. | | DXT3 | 4 | 8 | [0, 1] | Smooth variations in opacity do not mix well with this format. DXT1 or DXT5 is generally better in every situation. | | DXT5 | 4 | 8 | [0, 1] | Recommended for images with varying opacity on desktop systems. | | BC4 | 1 | 4 | [0, 1] | Also known as 3Dc+ or ATI1. Stores just the red channel. | | BC4s | 1 | 4 | [-1, 1] | Less precision than BC4 but allows negative numbers. | | BC5 | 2 | 8 | [0, 1] | Also known as 3Dc or ATI2. Often used for normal maps on desktop systems. | | BC5s | 2 | 8 | [-1, 1] | Less precision than BC5 but allows negative numbers. Often used for normal maps on desktop systems. | | BC6h | 3 | 8 | [0, +infinity] | Stores [half-precision](https://en.wikipedia.org/wiki/Half-precision_floating-point_format) floating point RGB data. Suitable for HDR images on desktop systems. | | BC6hs | 3 | 8 | [-infinity, +infinity] | Less precision than BC6h but allows negative numbers. | | BC7 | 4 | 8 | [0, 1] | Very good at representing opaque or transparent images, but requires a DX11 / OpenGL 4-capable GPU. | ### Constants (mobile GPUs) | Name | Components | Bits per pixel | Range | Note(s) | | --- | --- | --- | --- | --- | | ETC1 | 3 | 4 | [0, 1] | Suitable for fully opaque images on older Android devices. | | ETC2rgb | 3 | 4 | [0, 1] | Suitable for fully opaque images on newer mobile devices | | ETC2rgba | 4 | 8 | [0, 1] | Recommended for images with varying opacity on newer mobile devices. | | ETC2rgba1 | 4 | 4 | [0, 1] | RGBA variant of the ETC2 format where pixels are either fully transparent or fully opaque. | | EACr | 1 | 4 | [0, 1] | Stores just the red channel. | | EACrs | 1 | 4 | [-1, 1] | Less precision than EACr but allows negative numbers. | | EACrg | 2 | 8 | [0, 1] | Stores red and green channels. | | EACrgs | 2 | 8 | [-1, 1] | Less precision than EACrg but allows negative numbers. | | PVR1rgb2 | 3 | 2 | [0, 1] | Images using this format must be square and power-of-two sized. | | PVR1rgb4 | 3 | 4 | [0, 1] | Images using this format must be square and power-of-two sized. | | PVR1rgba2 | 4 | 2 | [0, 1] | Images using this format must be square and power-of-two sized. | | PVR1rgba4 | 4 | 4 | [0, 1] | Images using this format must be square and power-of-two sized. | | ASTC4x4 | 4 | 8 | [0, 1] | | | ASTC5x4 | 4 | 6.4 | [0, 1] | | | ASTC5x5 | 4 | 5.12 | [0, 1] | | | ASTC6x5 | 4 | 4.27 | [0, 1] | | | ASTC6x6 | 4 | 3.56 | [0, 1] | | | ASTC8x5 | 4 | 3.2 | [0, 1] | | | ASTC8x6 | 4 | 2.67 | [0, 1] | | | ASTC8x8 | 4 | 2 | [0, 1] | | | ASTC10x5 | 4 | 2.56 | [0, 1] | | | ASTC10x6 | 4 | 2.13 | [0, 1] | | | ASTC10x8 | 4 | 1.6 | [0, 1] | | | ASTC10x10 | 4 | 1.28 | [0, 1] | | | ASTC12x10 | 4 | 1.07 | [0, 1] | | | ASTC12x12 | 4 | 0.89 | [0, 1] | | Notes ----- Not all formats are supported in love.graphics [Images](image "Image") and [Canvases](canvas "Canvas") on all systems, although the DXT compressed image formats have close to 100% support on desktop operating systems. The BC4 and BC5 formats are supported on systems with DirectX 10 / OpenGL 3-capable desktop hardware and drivers. The BC6H and BC7 formats are only supported on desktop systems with DirectX 11 / OpenGL 4-capable hardware and very recent drivers. macOS does not support BC6H or BC7 at all currently. ETC1 is supported by *most* Android devices, as well as the iPhone 5s and newer. The ETC2 and EAC formats are supported by the iPhone 5s and newer, all OpenGL ES 3-capable Android devices, and OpenGL 4.3-capable desktop GPUs. The PVR1 formats are supported by all iOS devices, as well as the small number of Android devices which have PowerVR GPUs. ASTC is supported by new mobile devices (e.g. the iPhone 6 and newer), Android devices which have Adreno 4xx (and later) GPUs, and Skylake (and newer) integrated Intel GPUs. It has a variety of variants to allow for picking the most compressed possible one that doesn't have any noticeable compression artifacts, for a given texture. Use [love.graphics.getCanvasFormats](love.graphics.getcanvasformats "love.graphics.getCanvasFormats") and [love.graphics.getImageFormats](love.graphics.getimageformats "love.graphics.getImageFormats") to check for Canvas and Image support, respectively: ``` local supportedformats = love.graphics.getImageFormats()   if not supportedformats["DXT5"] then -- Can't load CompressedImageData with the DXT5 format into images! -- On some Linux systems with Mesa drivers, the user will need to install a "libtxc-dxtn" package because the DXT (aka S3TC) formats used to be patented. -- Support for DXT formats on all other desktop drivers is pretty much guaranteed. end   if not supportedformats["BC5"] then -- Can't load CompressedImageData with the BC5 format into images! -- The user likely doesn't have a video card capable of using that format. end ``` See Also -------- * [love.image](love.image "love.image") * [love.graphics](love.graphics "love.graphics") * [love.font](love.font "love.font") * [love.image.newImageData](love.image.newimagedata "love.image.newImageData") * [love.graphics.getImageFormats](love.graphics.getimageformats "love.graphics.getImageFormats") * [love.graphics.getCanvasFormats](love.graphics.getcanvasformats "love.graphics.getCanvasFormats") * [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") * [Texture:getFormat](texture-getformat "Texture:getFormat") * [ImageData:getFormat](imagedata-getformat "ImageData:getFormat") * [CompressedImageData:getFormat](compressedimagedata-getformat "CompressedImageData:getFormat") * [GlyphData:getFormat](glyphdata-getformat "GlyphData:getFormat")
programming_docs
love love.timer.getAverageDelta love.timer.getAverageDelta ========================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Returns the average delta time (seconds per frame) over the last second. Function -------- ### Synopsis ``` delta = love.timer.getAverageDelta( ) ``` ### Arguments None. ### Returns `[number](number "number") delta` The average delta time over the last second. Examples -------- Display text at the top left of the screen showing the average time taken to [update](love.update "love.update") and [draw](love.draw "love.draw") each frame. ``` function love.draw() local delta = love.timer.getAverageDelta() -- Display the frame time in milliseconds for convenience. -- A lower frame time means more frames per second. love.graphics.print(string.format("Average frame time: %.3f ms", 1000 * delta), 10, 10) end ``` See Also -------- * [love.timer](love.timer "love.timer") * [love.timer.getDelta](love.timer.getdelta "love.timer.getDelta") * [love.timer.getFPS](love.timer.getfps "love.timer.getFPS") love Video:seek Video:seek ========== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Sets the current playback position of the Video. Function -------- ### Synopsis ``` Video:seek( offset ) ``` ### Arguments `[number](number "number") offset` The time in seconds since the beginning of the Video. ### Returns Nothing. See Also -------- * [Video](video "Video") * [Video:rewind](video-rewind "Video:rewind") * [Video:tell](video-tell "Video:tell") love love.physics.newFrictionJoint love.physics.newFrictionJoint ============================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Create a friction joint between two bodies. A [FrictionJoint](frictionjoint "FrictionJoint") applies friction to a body. Function -------- ### Synopsis ``` joint = love.physics.newFrictionJoint( body1, body2, x, y, collideConnected ) ``` ### Arguments `[Body](body "Body") body1` The first body to attach to the joint. `[Body](body "Body") body2` The second body to attach to the joint. `[number](number "number") x` The x position of the anchor point. `[number](number "number") y` The y position of the anchor point. `[boolean](boolean "boolean") collideConnected (false)` Specifies whether the two bodies should collide with each other. ### Returns `[FrictionJoint](frictionjoint "FrictionJoint") joint` The new FrictionJoint. Function -------- ### Synopsis ``` joint = love.physics.newFrictionJoint( body1, body2, x1, y1, x2, y2, collideConnected ) ``` ### Arguments `[Body](body "Body") body1` The first body to attach to the joint. `[Body](body "Body") body2` The second body to attach to the joint. `[number](number "number") x1` The x position of the first anchor point. `[number](number "number") y1` The y position of the first anchor point. `[number](number "number") x2` The x position of the second anchor point. `[number](number "number") y2` The y position of the second anchor point. `[boolean](boolean "boolean") collideConnected (false)` Specifies whether the two bodies should collide with each other. ### Returns `[FrictionJoint](frictionjoint "FrictionJoint") joint` The new FrictionJoint. See Also -------- * [love.physics](love.physics "love.physics") * [FrictionJoint](frictionjoint "FrictionJoint") * [Joint](joint "Joint") love Source:setDirection Source:setDirection =================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Sets the direction vector of the Source. A zero vector makes the source non-directional. Function -------- ### Synopsis ``` Source:setDirection( x, y, z ) ``` ### Arguments `[number](number "number") x` The X part of the direction vector. `[number](number "number") y` The Y part of the direction vector. `[number](number "number") z` The Z part of the direction vector. ### Returns Nothing. See Also -------- * [Source](source "Source") love Texture:getMipmapFilter Texture:getMipmapFilter ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the mipmap filter mode for a Texture. Prior to 11.0 this method only worked on Images. Function -------- ### Synopsis ``` mode, sharpness = Texture:getMipmapFilter( ) ``` ### Arguments None. ### Returns `[FilterMode](filtermode "FilterMode") mode` The filter mode used in between mipmap levels. [nil](nil "nil") if mipmap filtering is not enabled. `[number](number "number") sharpness` Value used to determine whether the image should use more or less detailed mipmap levels than normal when drawing. See Also -------- * [Texture](texture "Texture") * [Texture:setMipmapFilter](texture-setmipmapfilter "Texture:setMipmapFilter") love love.graphics.newSpriteBatch love.graphics.newSpriteBatch ============================ Creates a new [SpriteBatch](spritebatch "SpriteBatch") object. This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- ### Synopsis ``` spriteBatch = love.graphics.newSpriteBatch( image, maxsprites ) ``` ### Arguments `[Image](image "Image") image` The Image to use for the sprites. `[number](number "number") maxsprites (1000)` The maximum number of sprites that the SpriteBatch can contain at any given time. Since version [11.0](https://love2d.org/wiki/11.0 "11.0"), additional sprites added past this number will automatically grow the spritebatch. ### Returns `[SpriteBatch](spritebatch "SpriteBatch") spriteBatch` The new SpriteBatch. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in earlier versions. ### Synopsis ``` spriteBatch = love.graphics.newSpriteBatch( image, maxsprites, usage ) ``` ### Arguments `[Image](image "Image") image` The Image to use for the sprites. `[number](number "number") maxsprites (1000)` The maximum number of sprites that the SpriteBatch can contain at any given time. Since version [11.0](https://love2d.org/wiki/11.0 "11.0"), additional sprites added past this number will automatically grow the spritebatch. `[SpriteBatchUsage](spritebatchusage "SpriteBatchUsage") usage ("dynamic")` The expected usage of the SpriteBatch. The specified usage mode affects the SpriteBatch's memory usage and performance. ### Returns `[SpriteBatch](spritebatch "SpriteBatch") spriteBatch` The new SpriteBatch. Function -------- **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This variant is not supported in earlier versions. ### Synopsis ``` spriteBatch = love.graphics.newSpriteBatch( texture, maxsprites, usage ) ``` ### Arguments `[Texture](texture "Texture") texture` The [Image](image "Image") or [Canvas](canvas "Canvas") to use for the sprites. `[number](number "number") maxsprites (1000)` The maximum number of sprites that the SpriteBatch can contain at any given time. Since version [11.0](https://love2d.org/wiki/11.0 "11.0"), additional sprites added past this number will automatically grow the spritebatch. `[SpriteBatchUsage](spritebatchusage "SpriteBatchUsage") usage ("dynamic")` The expected usage of the SpriteBatch. The specified usage mode affects the SpriteBatch's memory usage and performance. ### Returns `[SpriteBatch](spritebatch "SpriteBatch") spriteBatch` The new SpriteBatch. See Also -------- * [love.graphics](love.graphics "love.graphics") * [SpriteBatch](spritebatch "SpriteBatch") love CompressedFormat CompressedFormat ================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This enum is not supported in earlier versions. | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | It has been superseded by [PixelFormat](pixelformat "PixelFormat").. | Compressed image data formats. [Here](http://renderingpipeline.com/2012/07/texture-compression/) and [here](http://www.reedbeta.com/blog/2012/02/12/understanding-bcn-texture-compression-formats/) are a couple overviews of many of the formats. Unlike traditional PNG or jpeg, these formats stay compressed in RAM and in the graphics card's VRAM. This is good for saving memory space as well as improving performance, since the graphics card will be able to keep more of the image's pixels in its fast-access cache when drawing it. In LÖVE versions prior to [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0"), these constants are all lower-case. Constants --------- DXT1 The DXT1 format. RGB data at 4 bits per pixel (compared to 32 bits for [ImageData](imagedata "ImageData") and regular [Images](image "Image").) Suitable for fully opaque images on desktop systems. DXT3 The DXT3 format. RGBA data at 8 bits per pixel. Smooth variations in opacity do not mix well with this format. DXT5 The DXT5 format. RGBA data at 8 bits per pixel. Recommended for images with varying opacity on desktop systems. BC4 The BC4 format (also known as 3Dc+ or ATI1.) Stores just the red channel, at 4 bits per pixel. BC4s The signed variant of the BC4 format. Same as above but pixel values in the texture are in the range of [-1, 1] instead of [0, 1] in shaders. BC5 The BC5 format (also known as 3Dc or ATI2.) Stores red and green channels at 8 bits per pixel. BC5s The signed variant of the BC5 format. BC6h Available since 0.9.2 The BC6H format. Stores [half-precision](https://en.wikipedia.org/wiki/Half-precision_floating-point_format) floating-point RGB data in the range of [0, 65504] at 8 bits per pixel. Suitable for HDR images on desktop systems. BC6hs Available since 0.9.2 The signed variant of the BC6H format. Stores RGB data in the range of [-65504, +65504]. BC7 Available since 0.9.2 The BC7 format (also known as BPTC.) Stores RGB or RGBA data at 8 bits per pixel. ETC1 Available since 0.10.0 The ETC1 format. RGB data at 4 bits per pixel. Suitable for fully opaque images on older Android devices. ETC2rgb Available since 0.10.0 The RGB variant of the ETC2 format. RGB data at 4 bits per pixel. Suitable for fully opaque images on newer mobile devices. ETC2rgba Available since 0.10.0 The RGBA variant of the ETC2 format. RGBA data at 8 bits per pixel. Recommended for images with varying opacity on newer mobile devices. ETC2rgba1 Available since 0.10.0 The RGBA variant of the ETC2 format where pixels are either fully transparent or fully opaque. RGBA data at 4 bits per pixel. EACr Available since 0.10.0 The single-channel variant of the EAC format. Stores just the red channel, at 4 bits per pixel. EACrs Available since 0.10.0 The signed single-channel variant of the EAC format. Same as above but pixel values in the texture are in the range of [-1, 1] instead of [0, 1] in shaders. EACrg Available since 0.10.0 The two-channel variant of the EAC format. Stores red and green channels at 8 bits per pixel. EACrgs Available since 0.10.0 The signed two-channel variant of the EAC format. PVR1rgb2 Available since 0.10.0 The 2 bit per pixel RGB variant of the PVRTC1 format. Stores RGB data at 2 bits per pixel. Textures compressed with PVRTC1 formats must be square and power-of-two sized. PVR1rgb4 Available since 0.10.0 The 4 bit per pixel RGB variant of the PVRTC1 format. Stores RGB data at 4 bits per pixel. PVR1rgba2 Available since 0.10.0 The 2 bit per pixel RGBA variant of the PVRTC1 format. PVR1rgba4 Available since 0.10.0 The 4 bit per pixel RGBA variant of the PVRTC1 format. ASTC4x4 Available since 0.10.0 The 4x4 pixels per block variant of the ASTC format. RGBA data at 8 bits per pixel. ASTC5x4 Available since 0.10.0 The 5x4 pixels per block variant of the ASTC format. RGBA data at 6.4 bits per pixel. ASTC5x5 Available since 0.10.0 The 5x5 pixels per block variant of the ASTC format. RGBA data at 5.12 bits per pixel. ASTC6x5 Available since 0.10.0 The 6x5 pixels per block variant of the ASTC format. RGBA data at 4.27 bits per pixel. ASTC6x6 Available since 0.10.0 The 6x6 pixels per block variant of the ASTC format. RGBA data at 3.56 bits per pixel. ASTC8x5 Available since 0.10.0 The 8x5 pixels per block variant of the ASTC format. RGBA data at 3.2 bits per pixel. ASTC8x6 Available since 0.10.0 The 8x6 pixels per block variant of the ASTC format. RGBA data at 2.67 bits per pixel. ASTC8x8 Available since 0.10.0 The 8x8 pixels per block variant of the ASTC format. RGBA data at 2 bits per pixel. ASTC10x5 Available since 0.10.0 The 10x5 pixels per block variant of the ASTC format. RGBA data at 2.56 bits per pixel. ASTC10x6 Available since 0.10.0 The 10x6 pixels per block variant of the ASTC format. RGBA data at 2.13 bits per pixel. ASTC10x8 Available since 0.10.0 The 10x8 pixels per block variant of the ASTC format. RGBA data at 1.6 bits per pixel. ASTC10x10 Available since 0.10.0 The 10x10 pixels per block variant of the ASTC format. RGBA data at 1.28 bits per pixel. ASTC12x10 Available since 0.10.0 The 12x10 pixels per block variant of the ASTC format. RGBA data at 1.07 bits per pixel. ASTC12x12 Available since 0.10.0 The 12x12 pixels per block variant of the ASTC format. RGBA data at 0.89 bits per pixel. Notes ----- Not all formats are supported in love.graphics [Images](image "Image") on all systems, although the DXT formats have close to 100% support on desktop operating systems. The BC4 and BC5 formats are supported on systems with DirectX 10 / OpenGL 3-capable desktop hardware and drivers. The BC6H and BC7 formats are only supported on desktop systems with DirectX 11 / OpenGL 4-capable hardware and very recent drivers. macOS does not support BC6H or BC7 at all currently. ETC1 is supported by Android devices, as well as newer (OpenGL ES 3-capable) iOS devices. The PVR1 formats are supported by iOS devices, as well as Android devices with PowerVR GPUs. The ETC2 and EAC formats are supported by newer (OpenGL ES 3-capable) iOS and Android devices. ASTC is only supported by very new mobile devices (e.g. the iPhone 6), and the latest Skylake (and newer) integrated Intel GPUs. It has a variety of variants to allow for picking the most compressed possible one that doesn't have any noticeable compression artifacts, for a given texture. Use [love.graphics.getCompressedImageFormats](love.graphics.getcompressedimageformats "love.graphics.getCompressedImageFormats") to check for support: ``` local supportedformats = love.graphics.getCompressedImageFormats()   if not supportedformats["DXT5"] then -- Can't load CompressedImageData with the DXT5 format into images! -- On some Linux systems with Mesa drivers, the user will need to install a "libtxc-dxtn" package because the DXT (aka S3TC) formats used to be patented. -- Support for DXT formats on all other desktop drivers is pretty much guaranteed. end   if not supportedformats["BC5"] then -- Can't load CompressedImageData with the BC5 format into images! -- The user likely doesn't have a video card capable of using that format. end ``` See Also -------- * [love.image](love.image "love.image") * [CompressedImageData](compressedimagedata "CompressedImageData") * [CompressedImageData:getFormat](compressedimagedata-getformat "CompressedImageData:getFormat") * [love.graphics.getCompressedImageFormats](love.graphics.getcompressedimageformats "love.graphics.getCompressedImageFormats") love Fixture:getMask Fixture:getMask =============== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns which categories this fixture should **NOT** collide with. Function -------- ### Synopsis ``` mask1, mask2, ... = Fixture:getMask( ) ``` ### Arguments None. ### Returns `[number](number "number") mask1` The first category selected by the mask. `[number](number "number") mask2` The second category selected by the mask. See Also -------- * [Fixture](fixture "Fixture") * [Fixture:setMask](fixture-setmask "Fixture:setMask") love PrismaticJoint:setMaxMotorForce PrismaticJoint:setMaxMotorForce =============================== Set the maximum motor force. Function -------- ### Synopsis ``` PrismaticJoint:setMaxMotorForce( f ) ``` ### Arguments `[number](number "number") f` The maximum motor force, usually in N. ### Returns Nothing. See Also -------- * [PrismaticJoint](prismaticjoint "PrismaticJoint") love Source:queue Source:queue ============ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Queues SoundData for playback in a [queueable Source](love.audio.newqueueablesource "love.audio.newQueueableSource"). This method requires the Source to be created via [love.audio.newQueueableSource](love.audio.newqueueablesource "love.audio.newQueueableSource"). Function -------- ### Synopsis ``` success = Source:queue( soundData, length ) ``` ### Arguments `[SoundData](sounddata "SoundData") soundData` The data to queue. The SoundData's sample rate, bit depth, and channel count must match the Source's. `[number](number "number") length ([sounddata:getSize()](data-getsize "Data:getSize"))` Length in bytes to queue. ### Returns `[boolean](boolean "boolean") success` True if the data was successfully queued for playback, false if there were no [available buffers](source-getfreebuffercount "Source:getFreeBufferCount") to use for queueing. Function -------- ### Synopsis ``` success = Source:queue( soundData, offset, length ) ``` ### Arguments `[SoundData](sounddata "SoundData") soundData` The data to queue. The SoundData's sample rate, bit depth, and channel count must match the Source's. `[number](number "number") offset` Starting position in bytes to queue. `[number](number "number") length` Length in bytes to queue starting from specified offset. ### Returns `[boolean](boolean "boolean") success` True if the data was successfully queued for playback, false if there were no [available buffers](source-getfreebuffercount "Source:getFreeBufferCount") to use for queueing. Notes ----- To convert sample unit to bytes, multiply the sample unit by `SoundData:getBitDepth() * SoundData:getChannelCount() / 8`. See Also -------- * [Source](source "Source") * [love.audio.newQueueableSource](love.audio.newqueueablesource "love.audio.newQueueableSource") * [SourceType](sourcetype "SourceType") love love.math.noise love.math.noise =============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Generates a Simplex or Perlin noise value in 1-4 dimensions. The return value will always be the same, given the same arguments. [Simplex noise](https://en.wikipedia.org/wiki/Simplex_noise) is closely related to [Perlin noise](https://en.wikipedia.org/wiki/Perlin_noise). It is widely used for procedural content generation. There are many [webpages](http://libnoise.sourceforge.net/noisegen/) which discuss Perlin and Simplex noise in detail. The return value might be constant if only integer arguments are used. Avoid solely passing in integers, to get varying return values. Function -------- Generates Simplex noise from 1 dimension. ### Synopsis ``` value = love.math.noise( x ) ``` ### Arguments `[number](number "number") x` The number used to generate the noise value. ### Returns `[number](number "number") value` The noise value in the range of [0, 1]. Function -------- Generates Simplex noise from 2 dimensions. ### Synopsis ``` value = love.math.noise( x, y ) ``` ### Arguments `[number](number "number") x` The first value of the 2-dimensional vector used to generate the noise value. `[number](number "number") y` The second value of the 2-dimensional vector used to generate the noise value. ### Returns `[number](number "number") value` The noise value in the range of [0, 1]. Function -------- Generates Perlin noise (Simplex noise in version [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2") and older) from 3 dimensions. ### Synopsis ``` value = love.math.noise( x, y, z ) ``` ### Arguments `[number](number "number") x` The first value of the 3-dimensional vector used to generate the noise value. `[number](number "number") y` The second value of the 3-dimensional vector used to generate the noise value. `[number](number "number") z` The third value of the 3-dimensional vector used to generate the noise value. ### Returns `[number](number "number") value` The noise value in the range of [0, 1]. Function -------- Generates Perlin noise (Simplex noise in version [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2") and older) from 4 dimensions. ### Synopsis ``` value = love.math.noise( x, y, z, w ) ``` ### Arguments `[number](number "number") x` The first value of the 4-dimensional vector used to generate the noise value. `[number](number "number") y` The second value of the 4-dimensional vector used to generate the noise value. `[number](number "number") z` The third value of the 4-dimensional vector used to generate the noise value. `[number](number "number") w` The fourth value of the 4-dimensional vector used to generate the noise value. ### Returns `[number](number "number") value` The noise value in the range of [0, 1]. Examples -------- Fills a two-dimensional grid with simplex noise each time a key is pressed. ``` local grid = {}   function love.draw() for x = 1, #grid do for y = 1, #grid[x] do local f = 1 * grid[x][y] love.graphics.setColor( f, f, f, 1 ) love.graphics.rectangle( 'fill', x * 8, y * 8, 7, 7 ) love.graphics.setColor( 1, 1, 1, 1 ) end end end   -- Fill each pixel in our grid with simplex noise. local function noise() for x = 1, 60 do for y = 1, 60 do grid[x] = grid[x] or {} grid[x][y] = love.math.noise( x + love.math.random(), y + love.math.random() ) end end end   function love.keypressed() noise() end ``` See Also -------- * [love.math](love.math "love.math")
programming_docs
love love.graphics.print love.graphics.print =================== Draws text on screen. If no [Font](font "Font") is set, one will be created and set (once) if needed. As of LOVE [0.7.1](https://love2d.org/wiki/0.7.1 "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](love.graphics.printf "love.graphics.printf") both support UTF-8 encoding. You'll also need a proper [Font](font "Font") for special characters. In versions prior to [11.0](https://love2d.org/wiki/11.0 "11.0"), color and byte component values were within the range of 0 to 255 instead of 0 to 1. Text may appear blurry if it's rendered at non-integer pixel locations. Function -------- ### Synopsis ``` love.graphics.print( text, x, y, r, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[string](string "string") text` The text to draw. `[number](number "number") x (0)` The position to draw the object (x-axis). `[number](number "number") y (0)` The position to draw the object (y-axis). `[number](number "number") r (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Available since 0.8.0 Shearing factor (x-axis). `[number](number "number") ky (0)` Available since 0.8.0 Shearing factor (y-axis). ### Returns Nothing. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.print( text, font, x, y, r, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[string](string "string") text` The text to draw. `[Font](font "Font") font` The Font object to use. `[number](number "number") x (0)` The position of the text on the x-axis. `[number](number "number") y (0)` The position of the text on the y-axis. `[number](number "number") angle (0)` The orientation of the text in radians. `[number](number "number") sx (1)` Scale factor on the x-axis. `[number](number "number") sy (sx)` Scale factor on the y-axis. `[number](number "number") ox (0)` Origin offset on the x-axis. `[number](number "number") oy (0)` Origin offset on the y-axis. `[number](number "number") kx (0)` Shearing / skew factor on the x-axis. `[number](number "number") ky (0)` Shearing / skew factor on the y-axis. ### Returns Nothing. Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.print( coloredtext, x, y, angle, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[table](table "table") coloredtext` A table containing colors and strings to add to the object, in the form of `{color1, string1, color2, string2, ...}`. `[table](table "table") 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}`. `[string](string "string") string1` A string of text which has a color specified by the previous color. `[table](table "table") 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}`. `[string](string "string") string2` A string of text which has a color specified by the previous color. `[tables and strings](https://love2d.org/w/index.php?title=tables_and_strings&action=edit&redlink=1 "tables and strings (page does not exist)") ...` Additional colors and strings. `[number](number "number") x (0)` The position of the text on the x-axis. `[number](number "number") y (0)` The position of the text on the y-axis. `[number](number "number") angle (0)` The orientation of the text in radians. `[number](number "number") sx (1)` Scale factor on the x-axis. `[number](number "number") sy (sx)` Scale factor on the y-axis. `[number](number "number") ox (0)` Origin offset on the x-axis. `[number](number "number") oy (0)` Origin offset on the y-axis. `[number](number "number") kx (0)` Shearing / skew factor on the x-axis. `[number](number "number") ky (0)` Shearing / skew factor on the y-axis. ### Returns Nothing. ### Notes The color set by [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor") will be combined (multiplied) with the colors of the text. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.print( coloredtext, font, x, y, angle, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[table](table "table") coloredtext` A table containing colors and strings to add to the object, in the form of `{color1, string1, color2, string2, ...}`. `[table](table "table") 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}`. `[string](string "string") string1` A string of text which has a color specified by the previous color. `[table](table "table") 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}`. `[string](string "string") string2` A string of text which has a color specified by the previous color. `[tables and strings](https://love2d.org/w/index.php?title=tables_and_strings&action=edit&redlink=1 "tables and strings (page does not exist)") ...` Additional colors and strings. `[Font](font "Font") font` The Font object to use. `[number](number "number") x (0)` The position of the text on the x-axis. `[number](number "number") y (0)` The position of the text on the y-axis. `[number](number "number") angle (0)` The orientation of the text in radians. `[number](number "number") sx (1)` Scale factor on the x-axis. `[number](number "number") sy (sx)` Scale factor on the y-axis. `[number](number "number") ox (0)` Origin offset on the x-axis. `[number](number "number") oy (0)` Origin offset on the y-axis. `[number](number "number") kx (0)` Shearing / skew factor on the x-axis. `[number](number "number") ky (0)` Shearing / skew factor on the y-axis. ### Returns Nothing. ### Notes The color set by [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor") will be combined (multiplied) with the colors of the text. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.print( text, transform ) ``` ### Arguments `[string](string "string") text` The text to draw. `[Transform](transform "Transform") transform` Transformation object. ### Returns Nothing. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.print( text, font, transform ) ``` ### Arguments `[string](string "string") text` The text to draw. `[Font](font "Font") font` The Font object to use. `[Transform](transform "Transform") transform` Transformation object. ### Returns Nothing. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.print( coloredtext, transform ) ``` ### Arguments `[table](table "table") coloredtext` A table containing colors and strings to add to the object, in the form of `{color1, string1, color2, string2, ...}`. `[table](table "table") 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}`. `[string](string "string") string1` A string of text which has a color specified by the previous color. `[table](table "table") 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}`. `[string](string "string") string2` A string of text which has a color specified by the previous color. `[tables and strings](https://love2d.org/w/index.php?title=tables_and_strings&action=edit&redlink=1 "tables and strings (page does not exist)") ...` Additional colors and strings. `[Transform](transform "Transform") transform` Transformation object. ### Returns Nothing. ### Notes The color set by [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor") will be combined (multiplied) with the colors of the text. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.print( coloredtext, font, transform ) ``` ### Arguments `[table](table "table") coloredtext` A table containing colors and strings to add to the object, in the form of `{color1, string1, color2, string2, ...}`. `[table](table "table") 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}`. `[string](string "string") string1` A string of text which has a color specified by the previous color. `[table](table "table") 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}`. `[string](string "string") string2` A string of text which has a color specified by the previous color. `[tables and strings](https://love2d.org/w/index.php?title=tables_and_strings&action=edit&redlink=1 "tables and strings (page does not exist)") ...` Additional colors and strings. `[Font](font "Font") font` The Font object to use. `[Transform](transform "Transform") transform` Transformation object. ### Returns Nothing. ### Notes The color set by [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor") will be combined (multiplied) with the colors of the text. Examples -------- ### A lame example ``` function love.draw() love.graphics.setColor(0, 1, 0, 1) love.graphics.print("This is a pretty lame example.", 10, 200) love.graphics.setColor(1, 0, 0, 1) love.graphics.print("This lame example is twice as big.", 10, 250, 0, 2, 2) love.graphics.setColor(0, 0, 1, 1) love.graphics.print("This example is lamely vertical.", 300, 30, math.pi/2) end ``` Notes ----- In version 0.8.0 and older, love.graphics.print stops at the first '\0' (null) character. This can bite you if you are appending keystrokes to form your string, as some of those are multi-byte unicode characters which will likely contain null bytes. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.printf](love.graphics.printf "love.graphics.printf") love love.filesystem.areSymlinksEnabled love.filesystem.areSymlinksEnabled ================================== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Gets whether love.filesystem follows symbolic links. Function -------- ### Synopsis ``` enabled = love.filesystem.areSymlinksEnabled( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") enable` Whether love.filesystem follows symbolic links. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [love.filesystem.setSymlinksEnabled](love.filesystem.setsymlinksenabled "love.filesystem.setSymlinksEnabled") * [love.filesystem.isSymlink](love.filesystem.issymlink "love.filesystem.isSymlink") love PrismaticJoint:getLimits PrismaticJoint:getLimits ======================== Gets the joint limits. Function -------- ### Synopsis ``` lower, upper = PrismaticJoint:getLimits( ) ``` ### Arguments None. ### Returns `[number](number "number") lower` The lower limit, usually in meters. `[number](number "number") upper` The upper limit, usually in meters. See Also -------- * [PrismaticJoint](prismaticjoint "PrismaticJoint") love love.graphics.pop love.graphics.pop ================= Pops the current coordinate transformation from the transformation stack. This function is always used to reverse a previous [push](love.graphics.push "love.graphics.push") operation. It returns the current transformation state to what it was before the last preceding push. Function -------- ### Synopsis ``` love.graphics.pop() ``` ### Arguments None ### Returns Nothing. Examples -------- Draw two lines of text, one scaled and one normal, using [love.graphics.scale](love.graphics.scale "love.graphics.scale"). We use **love.graphics.pop** to return to normal render scale, after having used [love.graphics.push](love.graphics.push "love.graphics.push"). ``` function love.draw() love.graphics.push() -- stores the coordinate system love.graphics.scale(0.5, 0.5) -- reduce everything by 50% in both X and Y coordinates love.graphics.print("Scaled text", 50, 50) -- print half-sized text at 25x25 love.graphics.pop() -- return to stored coordinated love.graphics.print("Normal text", 50, 50) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.push](love.graphics.push "love.graphics.push") * [love.graphics.translate](love.graphics.translate "love.graphics.translate") * [love.graphics.rotate](love.graphics.rotate "love.graphics.rotate") * [love.graphics.scale](love.graphics.scale "love.graphics.scale") * [love.graphics.shear](love.graphics.shear "love.graphics.shear") * [love.graphics.origin](love.graphics.origin "love.graphics.origin") love love.image.newCompressedData love.image.newCompressedData ============================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Create a new [CompressedImageData](compressedimagedata "CompressedImageData") object from a compressed image file. LÖVE supports several compressed texture formats, enumerated in the [CompressedImageFormat](compressedimageformat "CompressedImageFormat") page. This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- ### Synopsis ``` compressedImageData = love.image.newCompressedData( filename ) ``` ### Arguments `[string](string "string") filename` The filename of the compressed image file. ### Returns `[CompressedImageData](compressedimagedata "CompressedImageData") compressedImageData` The new CompressedImageData object. Function -------- ### Synopsis ``` compressedImageData = love.image.newCompressedData( fileData ) ``` ### Arguments `[FileData](filedata "FileData") fileData` A FileData containing a compressed image. ### Returns `[CompressedImageData](compressedimagedata "CompressedImageData") compressedImageData` The new CompressedImageData object. See Also -------- * [love.image](love.image "love.image") * [love.image.isCompressed](love.image.iscompressed "love.image.isCompressed") * [love.graphics.newImage](love.graphics.newimage "love.graphics.newImage") * [CompressedImageData](compressedimagedata "CompressedImageData") love Joystick:getGamepadMappingString Joystick:getGamepadMappingString ================================ **Available since LÖVE [11.3](https://love2d.org/wiki/11.3 "11.3")** This function is not supported in earlier versions. Gets the full gamepad mapping string of this Joystick, or nil if it's not recognized as a [gamepad](joystick-isgamepad "Joystick:isGamepad"). The mapping string contains binding information used to map the Joystick's buttons an axes to the standard [gamepad layout](joystick-isgamepad "Joystick:isGamepad"), and can be used later with [love.joystick.loadGamepadMappings](love.joystick.loadgamepadmappings "love.joystick.loadGamepadMappings"). Function -------- ### Synopsis ``` mappingstring = Joystick:getGamepadMappingString( ) ``` ### Arguments None. ### Returns `[string](string "string") mappingstring (nil)` A string containing the Joystick's gamepad mappings, or nil if the Joystick is not recognized as a gamepad. See Also -------- * [Joystick](joystick "Joystick") * [Joystick:isGamepad](joystick-isgamepad "Joystick:isGamepad") * [love.joystick.loadGamepadMappings](love.joystick.loadgamepadmappings "love.joystick.loadGamepadMappings") * [love.joystick.saveGamepadMappings](love.joystick.savegamepadmappings "love.joystick.saveGamepadMappings") * [love.joystick.setGamepadMapping](love.joystick.setgamepadmapping "love.joystick.setGamepadMapping") * [Joystick:getGamepadMapping](joystick-getgamepadmapping "Joystick:getGamepadMapping") love Source:getDistance Source:getDistance ================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [Source:getAttenuationDistances](source-getattenuationdistances "Source:getAttenuationDistances"). Returns the reference and maximum distance of the source. There's a bug in [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") preventing this function from working Function -------- ### Synopsis ``` ref, max = Source:getDistance( ) ``` ### Arguments None. ### Returns `[number](number "number") ref` The reference distance. `[number](number "number") max` The maximum distance. See Also -------- * [Source](source "Source") love Decoder:seek Decoder:seek ============ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Sets the currently playing position of the Decoder. Function -------- ### Synopsis ``` Decoder:seek( offset ) ``` ### Arguments `[number](number "number") offset` The position to seek to, in seconds. ### Returns Nothing. See Also -------- * [Decoder](decoder "Decoder") * [Source:seek](source-seek "Source:seek") love love.graphics.setScissor love.graphics.setScissor ======================== **Available since LÖVE [0.4.0](https://love2d.org/wiki/0.4.0 "0.4.0")** This function is not supported in earlier versions. Sets or disables scissor. The scissor limits the drawing area to a specified rectangle. This affects all graphics calls, including [love.graphics.clear](love.graphics.clear "love.graphics.clear"). The dimensions of the scissor is unaffected by graphical transformations (translate, scale, ...). Function -------- Limits the drawing area to a specified rectangle. ### Synopsis ``` love.graphics.setScissor( x, y, width, height ) ``` ### Arguments `[number](number "number") x` x coordinate of upper left corner. `[number](number "number") y` y coordinate of upper left corner. `[number](number "number") width` width of clipping rectangle. `[number](number "number") height` height of clipping rectangle. ### Returns Nothing. Function -------- Disables scissor. ### Synopsis ``` love.graphics.setScissor( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getScissor](love.graphics.getscissor "love.graphics.getScissor") * [love.graphics.intersectScissor](love.graphics.intersectscissor "love.graphics.intersectScissor")
programming_docs
love Shape:destroy Shape:destroy ============= **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in that and later versions. Explicitly destroys the Shape. When you don't have time to wait for garbage collection, this function may be used to free the object immediately, but note that an error will occur if you attempt to use the object after calling this function. Note that Box2D doesn't allow destroying or creating shapes during collision callbacks. Function -------- ### Synopsis ``` Shape:destroy( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Shape](shape "Shape") love Joystick:getAxes Joystick:getAxes ================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been moved from [love.joystick.getAxes](love.joystick.getaxes "love.joystick.getAxes"). Gets the direction of each axis. Function -------- ### Synopsis ``` axisDir1, axisDir2, ..., axisDirN = Joystick:getAxes( ) ``` ### Arguments None. ### Returns `[number](number "number") axisDir1` Direction of axis1. `[number](number "number") axisDir2` Direction of axis2. `[number](number "number") axisDirN` Direction of axisN. See Also -------- * [Joystick](joystick "Joystick") * [Joystick:getAxis](joystick-getaxis "Joystick:getAxis") * [Joystick:getAxisCount](joystick-getaxiscount "Joystick:getAxisCount") love DistanceModel DistanceModel ============= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This enum is not supported in earlier versions. The different distance models. Extended information can be found in the chapter "3.4. Attenuation By Distance" of the [OpenAL 1.1 specification](https://www.openal.org/documentation/openal-1.1-specification.pdf). Constants --------- none Sources do not get attenuated. inverse Inverse distance attenuation. inverseclamped Inverse distance attenuation. Gain is clamped. In version [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2") and older this is named **inverse clamped**. linear Linear attenuation. linearclamped Linear attenuation. Gain is clamped. In version [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2") and older this is named **linear clamped**. exponent Exponential attenuation. exponentclamped Exponential attenuation. Gain is clamped. In version [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2") and older this is named **exponent clamped**. See Also -------- * [love.audio](love.audio "love.audio") * [love.audio.setDistanceModel](love.audio.setdistancemodel "love.audio.setDistanceModel") * [love.audio.getDistanceModel](love.audio.getdistancemodel "love.audio.getDistanceModel") love Body:setSleepingAllowed Body:setSleepingAllowed ======================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Sets the sleeping behaviour of the body. Should sleeping be allowed, a body at rest will automatically sleep. A sleeping body is not simulated unless it collided with an awake body. Be wary that one can end up with a situation like a floating sleeping body if the floor was removed. Function -------- ### Synopsis ``` Body:setSleepingAllowed( allowed ) ``` ### Arguments `[boolean](boolean "boolean") allowed` True if the body is allowed to sleep or false if not. ### Returns Nothing. See Also -------- * [Body](body "Body") * [Body:isSleepingAllowed](body-issleepingallowed "Body:isSleepingAllowed") love love.draw love.draw ========= Callback function used to draw on the screen every frame. Function -------- ### Synopsis ``` love.draw( ) ``` ### Arguments None. ### Returns Nothing. Examples -------- Draw an image that was loaded in [love.load](love.load "love.load") (putting [love.graphics.newImage](love.graphics.newimage "love.graphics.newImage") in love.draw would cause the image to be reloaded every frame, which would cause issues). ``` function love.load() hamster = love.graphics.newImage("hamster.png") x = 50 y = 50 end function love.draw() love.graphics.draw(hamster, x, y) end ``` See Also -------- * [love](love "love") love love.graphics.setLineJoin love.graphics.setLineJoin ========================= Sets the line join style. See [LineJoin](linejoin "LineJoin") for the possible options. Function -------- ### Synopsis ``` love.graphics.setLineJoin( join ) ``` ### Arguments `[LineJoin](linejoin "LineJoin") join` The LineJoin to use. ### Returns Nothing. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getLineJoin](love.graphics.getlinejoin "love.graphics.getLineJoin") love Body:setPosition Body:setPosition ================ Set the position of the body. Note that this may not be the center of mass of the body. This function cannot wake up the body. Function -------- ### Synopsis ``` Body:setPosition( x, y ) ``` ### Arguments `[number](number "number") x` The x position. `[number](number "number") y` The y position. ### Returns Nothing. See Also -------- * [Body](body "Body") love World:isAllowSleep World:isAllowSleep ================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in that and later versions. Get the sleep behaviour of the world. A sleeping body is much more efficient to simulate than when awake. If sleeping is allowed, any body that has come to rest will sleep. Function -------- ### Synopsis ``` permission = World:isAllowSleep( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") permission` Permission for any body to sleep. See Also -------- * [World](world "World") love love.math.random love.math.random ================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Generates a pseudo-random number in a platform independent manner. This function is seeded at startup, so you generally don't need to seed it yourself. Function -------- Get uniformly distributed pseudo-random real number within [0, 1]. ### Synopsis ``` number = love.math.random( ) ``` ### Arguments None. ### Returns `[number](number "number") number` The pseudo-random number. Function -------- Get a uniformly distributed pseudo-random **integer** within [1, max]. ### Synopsis ``` number = love.math.random( max ) ``` ### Arguments `[number](number "number") max` The maximum possible value it should return. ### Returns `[number](number "number") number` The pseudo-random integer number. Function -------- Get uniformly distributed pseudo-random **integer** within [min, max]. ### Synopsis ``` number = love.math.random( min, max ) ``` ### Arguments `[number](number "number") min` The minimum possible value it should return. `[number](number "number") max` The maximum possible value it should return. ### Returns `[number](number "number") number` The pseudo-random integer number. Examples -------- Generates a number between 1 and 100 (both inclusive). ``` function love.load() randomNumber = love.math.random(1, 100) end ``` Notes ----- When using the 2nd and 3rd variant, numbers passed will be rounded, thus, `love.math.random(0, 76.767)` may return 77 See Also -------- * [love.math](love.math "love.math") * [love.math.setRandomSeed](love.math.setrandomseed "love.math.setRandomSeed") * [love.math.randomNormal](love.math.randomnormal "love.math.randomNormal") * [love.math.newRandomGenerator](love.math.newrandomgenerator "love.math.newRandomGenerator") love table table ===== From the Lua 5.1 [reference manual §2.2](https://www.lua.org/manual/5.1/manual.html#2.2): The type table implements associative arrays, that is, arrays that can be indexed not only with [numbers](number "number"), but with any value (except [nil](nil "nil")). Tables can be heterogeneous; that is, they can contain values of all types (except [nil](nil "nil")). Tables are the sole data structuring mechanism in Lua; they can be used to represent ordinary arrays, symbol tables, sets, records, graphs, trees, etc. To represent records, Lua uses the field name as an index. The language supports this representation by providing a.name as syntactic sugar for a["name"]. There are several convenient ways to create tables in Lua (see [§2.5.7](https://www.lua.org/manual/5.1/manual.html#2.5.7)). love EdgeShape EdgeShape ========= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This shape is not supported in earlier versions. A EdgeShape is a line segment. They can be used to create the boundaries of your terrain. The shape does not have volume and can only collide with [PolygonShape](polygonshape "PolygonShape") and [CircleShape](circleshape "CircleShape"). Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.physics.newEdgeShape](love.physics.newedgeshape "love.physics.newEdgeShape") | Creates a new **EdgeShape**. | 0.8.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [EdgeShape:getNextVertex](edgeshape-getnextvertex "EdgeShape:getNextVertex") | Gets the vertex that establishes a connection to the next shape. | 0.10.2 | | | [EdgeShape:getPoints](edgeshape-getpoints "EdgeShape:getPoints") | Returns the local coordinates of the edge points. | 0.8.0 | | | [EdgeShape:getPreviousVertex](edgeshape-getpreviousvertex "EdgeShape:getPreviousVertex") | Gets the vertex that establishes a connection to the previous shape. | 0.10.2 | | | [EdgeShape:setNextVertex](edgeshape-setnextvertex "EdgeShape:setNextVertex") | Sets a vertex that establishes a connection to the next shape. | 0.10.2 | | | [EdgeShape:setPreviousVertex](edgeshape-setpreviousvertex "EdgeShape:setPreviousVertex") | Sets a vertex that establishes a connection to the previous shape. | 0.10.2 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | | [Shape:computeAABB](shape-computeaabb "Shape:computeAABB") | Returns the points of the bounding box for the transformed shape. | 0.8.0 | | | [Shape:computeMass](shape-computemass "Shape:computeMass") | Computes the mass properties for the shape. | 0.8.0 | | | [Shape:destroy](shape-destroy "Shape:destroy") | Explicitly destroys the Shape. | | 0.8.0 | | [Shape:getBody](shape-getbody "Shape:getBody") | Get the body the shape is attached to. | 0.7.0 | 0.8.0 | | [Shape:getBoundingBox](shape-getboundingbox "Shape:getBoundingBox") | Gets the bounding box of the shape. | | 0.8.0 | | [Shape:getCategory](shape-getcategory "Shape:getCategory") | Gets the categories this shape is a member of. | | 0.8.0 | | [Shape:getCategoryBits](shape-getcategorybits "Shape:getCategoryBits") | Gets the categories as a 16-bit integer. | | 0.8.0 | | [Shape:getChildCount](shape-getchildcount "Shape:getChildCount") | Returns the number of children the shape has. | 0.8.0 | | | [Shape:getData](shape-getdata "Shape:getData") | Get the data set with setData. | | 0.8.0 | | [Shape:getDensity](shape-getdensity "Shape:getDensity") | Gets the density of the Shape. | | 0.8.0 | | [Shape:getFilterData](shape-getfilterdata "Shape:getFilterData") | Gets the filter data of the Shape. | | 0.8.0 | | [Shape:getFriction](shape-getfriction "Shape:getFriction") | Gets the friction of this shape. | | 0.8.0 | | [Shape:getMask](shape-getmask "Shape:getMask") | Gets which categories this shape should **NOT** collide with. | | 0.8.0 | | [Shape:getRadius](shape-getradius "Shape:getRadius") | Gets the radius of the shape. | | | | [Shape:getRestitution](shape-getrestitution "Shape:getRestitution") | Gets the restitution of this shape. | | 0.8.0 | | [Shape:getType](shape-gettype "Shape:getType") | Gets a string representing the Shape. | | | | [Shape:isSensor](shape-issensor "Shape:isSensor") | Checks whether a Shape is a sensor or not. | | 0.8.0 | | [Shape:rayCast](shape-raycast "Shape:rayCast") | Casts a ray against the shape. | 0.8.0 | | | [Shape:setCategory](shape-setcategory "Shape:setCategory") | Sets the categories this shape is a member of. | | 0.8.0 | | [Shape:setData](shape-setdata "Shape:setData") | Set data to be passed to the collision callback. | | 0.8.0 | | [Shape:setDensity](shape-setdensity "Shape:setDensity") | Sets the density of a Shape. | | 0.8.0 | | [Shape:setFilterData](shape-setfilterdata "Shape:setFilterData") | Sets the filter data for a Shape. | | 0.8.0 | | [Shape:setFriction](shape-setfriction "Shape:setFriction") | Sets the friction of the shape. | | 0.8.0 | | [Shape:setMask](shape-setmask "Shape:setMask") | Sets which categories this shape should **NOT** collide with. | | 0.8.0 | | [Shape:setRestitution](shape-setrestitution "Shape:setRestitution") | Sets the restitution of the shape. | | 0.8.0 | | [Shape:setSensor](shape-setsensor "Shape:setSensor") | Sets whether this shape should act as a sensor. | | 0.8.0 | | [Shape:testPoint](shape-testpoint "Shape:testPoint") | Checks whether a point lies inside the shape. | | | | [Shape:testSegment](shape-testsegment "Shape:testSegment") | Checks whether a line segment intersects a shape. | | 0.8.0 | Supertypes ---------- * [Shape](shape "Shape") * [Object](object "Object") See Also -------- * [love.physics](love.physics "love.physics") love love.video.newVideoStream love.video.newVideoStream ========================= **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Creates a new [VideoStream](videostream "VideoStream"). Currently only Ogg Theora video files are supported. VideoStreams can't draw videos, see [love.graphics.newVideo](love.graphics.newvideo "love.graphics.newVideo") for that. This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- ### Synopsis ``` videostream = love.video.newVideoStream( filename ) ``` ### Arguments `[string](string "string") filename` The file path to the Ogg Theora video file. ### Returns `[VideoStream](videostream "VideoStream") videostream` A new VideoStream. Function -------- ### Synopsis ``` videostream = love.video.newVideoStream( file ) ``` ### Arguments `[File](file "File") file` The [File](file "File") object containing the Ogg Theora video. ### Returns `[VideoStream](videostream "VideoStream") videostream` A new VideoStream. See Also -------- * [love.video](love.video "love.video") * [VideoStream](videostream "VideoStream") * [Video](video "Video") love Body:getInertia Body:getInertia =============== Gets the rotational inertia of the body. The rotational inertia is how hard is it to make the body spin. Function -------- ### Synopsis ``` inertia = Body:getInertia( ) ``` ### Arguments None. ### Returns `[number](number "number") inertia` The rotational inertial of the body. See Also -------- * [Body](body "Body") * [Body:setInertia](body-setinertia "Body:setInertia") * [Body:getMassData](body-getmassdata "Body:getMassData") love love.mouse.setPosition love.mouse.setPosition ====================== Sets the current position of the mouse. Non-integer values are floored. Function -------- ### Synopsis ``` love.mouse.setPosition( x, y ) ``` ### Arguments `[number](number "number") x` The new position of the mouse along the x-axis. `[number](number "number") y` The new position of the mouse along the y-axis. ### Returns Nothing. Examples -------- Snap the mouse to the horizontal center of the screen while maintaining the coordinate along the y-axis by using [love.mouse.getY](love.mouse.gety "love.mouse.getY"). ``` function love.keypressed( ) love.mouse.setPosition( love.graphics.getWidth() * 0.5, love.mouse.getY() ) end ``` See Also -------- * [love.mouse](love.mouse "love.mouse") * [love.mouse.getPosition](love.mouse.getposition "love.mouse.getPosition") * [love.mouse.getX](love.mouse.getx "love.mouse.getX") * [love.mouse.getY](love.mouse.gety "love.mouse.getY") love FileType FileType ======== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This enum is not supported in earlier versions. The type of a file. Constants --------- file Regular file. directory Directory. symlink Symbolic link. other Something completely different like a device. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [love.filesystem.getInfo](love.filesystem.getinfo "love.filesystem.getInfo") love love.filesystem.lines love.filesystem.lines ===================== Iterate over the lines in a file. Function -------- ### Synopsis ``` iterator = love.filesystem.lines( name ) ``` ### Arguments `[string](string "string") name` The name (and path) of the file ### Returns `[function](function "function") iterator` A function that iterates over all the lines in the file ### Example ``` local highscores = {} for line in love.filesystem.lines("highscores.lst") do table.insert(highscores, line) end ``` See Also -------- * [love.filesystem](love.filesystem "love.filesystem") love love.graphics.setCanvas love.graphics.setCanvas ======================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been renamed from [love.graphics.setRenderTarget](love.graphics.setrendertarget "love.graphics.setRenderTarget"). Captures drawing operations to a [Canvas](canvas "Canvas"). Function -------- Sets the render target to a specified [Canvas](canvas "Canvas"). All drawing operations until the next *love.graphics.setCanvas* call will be redirected to the [Canvas](canvas "Canvas") and not shown on the screen. When using a [stencil](love.graphics.stencil "love.graphics.stencil") or [depth testing](love.graphics.setdepthmode "love.graphics.setDepthMode") with an active Canvas, the stencil buffer or depth buffer must be explicitly enabled in setCanvas via the variants below. Note that no canvas should be active when *[love.graphics.present](love.graphics.present "love.graphics.present")* is called. *love.graphics.present* is called at the end of [love.draw](love.draw "love.draw") in the default [love.run](love.run "love.run"), hence if you activate a canvas using this function, you normally need to deactivate it at some point before *love.draw* finishes. ### Synopsis ``` love.graphics.setCanvas( canvas, mipmap ) ``` ### Arguments `[Canvas](canvas "Canvas") canvas` The new target. `[number](number "number") mipmap (1)` Available since 11.0 The mipmap level to render to, for Canvases with [mipmaps](texture-getmipmapcount "Texture:getMipmapCount"). ### Returns Nothing. Function -------- Resets the render target to the screen, i.e. re-enables drawing to the screen. ### Synopsis ``` love.graphics.setCanvas( ) ``` ### Arguments None. ### Returns Nothing. Function -------- **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in earlier versions. Sets the render target to multiple simultaneous [2D](texturetype "TextureType") [Canvases](canvas "Canvas"). All drawing operations until the next *love.graphics.setCanvas* call will be redirected to the specified canvases and not shown on the screen. ### Synopsis ``` love.graphics.setCanvas( canvas1, canvas2, ... ) ``` ### Arguments `[Canvas](canvas "Canvas") canvas1` The first render target. `[Canvas](canvas "Canvas") canvas2` The second render target. `[Canvas](canvas "Canvas") ...` More canvases. ### Returns Nothing. ### Notes Normally all drawing operations will draw only to the first canvas passed to the function, but that can be changed if a [pixel shader](shader "Shader") is used with the [`void effect` function](love.graphics.newshader#Pixel_Shader_Function "love.graphics.newShader") instead of the regular `vec4 effect`. All canvas arguments must have the same widths and heights and the same [texture type](texturemode "TextureMode"). Not all computers which support Canvases will support multiple render targets. If [love.graphics.isSupported("multicanvas")](love.graphics.issupported "love.graphics.isSupported") returns true, at least 4 simultaneously active canvases are supported. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. Sets the render target to the specified [layer/slice](texturetype "TextureType") and [mipmap level](texture-getmipmapcount "Texture:getMipmapCount") of the given non-2D [Canvas](canvas "Canvas"). All drawing operations until the next *love.graphics.setCanvas* call will be redirected to the [Canvas](canvas "Canvas") and not shown on the screen. ### Synopsis ``` love.graphics.setCanvas( canvas, slice, mipmap ) ``` ### Arguments `[Canvas](canvas "Canvas") canvas` The new render target. `[number](number "number") slice` For cubemaps this is the cube face index to render to (between 1 and 6). For Array textures this is the [array layer](texture-getlayercount "Texture:getLayerCount"). For volume textures this is the depth slice. 2D canvases should use a value of 1. `[number](number "number") mipmap (1)` The mipmap level to render to, for Canvases with [mipmaps](texture-getmipmapcount "Texture:getMipmapCount"). ### Returns Nothing. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. Sets the active render target(s) and active stencil and depth buffers based on the specified setup information. All drawing operations until the next *love.graphics.setCanvas* call will be redirected to the specified [Canvases](canvas "Canvas") and not shown on the screen. ### Synopsis ``` love.graphics.setCanvas( setup ) ``` ### Arguments `[table](table "table") setup` 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. `[RenderTargetSetup](https://love2d.org/w/index.php?title=RenderTargetSetup&action=edit&redlink=1 "RenderTargetSetup (page does not exist)") [1]` The Canvas to render to. `[RenderTargetSetup](https://love2d.org/w/index.php?title=RenderTargetSetup&action=edit&redlink=1 "RenderTargetSetup (page does not exist)") [2] (nil)` An additional Canvas to render to, if multiple simultaneous render targets are wanted. `[RenderTargetSetup](https://love2d.org/w/index.php?title=RenderTargetSetup&action=edit&redlink=1 "RenderTargetSetup (page does not exist)") ...` Additional Canvases to render to, if multiple simultaneous render targets are wanted. `[boolean](boolean "boolean") stencil (false)` Whether an internally managed stencil buffer should be used, if the `depthstencil` field isn't set. `[boolean](boolean "boolean") depth (false)` Whether an internally managed depth buffer should be used, if the `depthstencil` field isn't set. `[RenderTargetSetup](https://love2d.org/w/index.php?title=RenderTargetSetup&action=edit&redlink=1 "RenderTargetSetup (page does not exist)") depthstencil (nil)` An optional custom depth/stencil [formatted](pixelformat "PixelFormat") Canvas to use for the depth and/or stencil buffer. ### Returns Nothing. ### Notes The `RenderTargetSetup` parameters can either be a [Canvas](canvas "Canvas") object, or a table in the following format: `{canvas, mipmap=#, layer=#, face=#}` `[Canvas](canvas "Canvas") [1]` The Canvas to use for this active render target. `[number](number "number") mipmap (1)` The mipmap level to render to, for Canvases with [mipmaps](texture-getmipmapcount "Texture:getMipmapCount"). `[number](number "number") layer (1)` Only used for [Volume and Array](texturetype "TextureType")-type Canvases. For Array textures this is the [array layer](texture-getlayercount "Texture:getLayerCount") to render to. For volume textures this is the depth slice. `[number](number "number") face (1)` Only used for [Cubemap](texturetype "TextureType")-type Canvases. The cube face index to render to (between 1 and 6) Examples -------- ### Drawing to a canvas ``` function love.load() -- create canvas canvas = love.graphics.newCanvas()   -- direct drawing operations to the canvas love.graphics.setCanvas(canvas)   -- draw colored square to canvas love.graphics.setColor(0.8, 0.9, 0.4) love.graphics.rectangle("fill", 0, 0, 100, 100)   -- re-enable drawing to the main screen love.graphics.setCanvas() end   function love.draw() -- draw scaled canvas to screen love.graphics.setColor(1, 1, 1) love.graphics.draw(canvas, 200, 100, 0, 0.5, 0.5) end ``` ### Advanced setup with the table variant of love.graphics.setCanvas ``` -- Allow love.graphics.stencil calls when drawing to the given Canvas. love.graphics.setCanvas({canvas, stencil=true})   -- Use multiple simultaneous render targets when drawing to several canvases of the Array Texture type, -- and use a custom depth buffer as well. canvas1 = love.graphics.newCanvas(128, 128, 4, {type="array"}) canvas2 = love.graphics.newCanvas(128, 128, 8, {type="array"}) depthcanvas = love.graphics.newCanvas(128, 128, {format="depth24", readable=true})   love.graphics.setCanvas({ {canvas1, layer = 3}, {canvas2, layer = 1}, depthstencil = depthcanvas, }) ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getCanvas](love.graphics.getcanvas "love.graphics.getCanvas") * [Canvas](canvas "Canvas") * [Canvas:renderTo](canvas-renderto "Canvas:renderTo")
programming_docs
love Mesh:setTexture Mesh:setTexture =============== **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1") (bug) [Textures](texture "Texture") are not released from memory automatically when nil-ing meshes. Call Mesh:setTexture() to manually clear. Sets the texture ([Image](image "Image") or [Canvas](canvas "Canvas")) used when drawing the Mesh. Function -------- ### Synopsis ``` Mesh:setTexture( texture ) ``` ### Arguments `[Texture](texture "Texture") texture` The Image or Canvas to texture the Mesh with when drawing. ### Returns Nothing. Function -------- ### Synopsis ``` Mesh:setTexture( ) ``` ### Arguments None. ### Returns Nothing. ### Notes Disables any texture from being used when drawing the Mesh. Untextured meshes have a white color by default. See Also -------- * [Mesh](mesh "Mesh") * [Mesh:getTexture](mesh-gettexture "Mesh:getTexture") love Shader:send Shader:send =========== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [PixelEffect:send](pixeleffect-send "PixelEffect:send"). Sends one or more values to a special (*uniform*) variable inside the shader. Uniform variables have to be marked using the *uniform* or *extern* keyword, e.g. ``` uniform float time; // "float" is the typical number type used in GLSL shaders. uniform float vars[2]; uniform vec2 light_pos; uniform vec4 colors[4]; ``` The corresponding send calls would be ``` shader:send("time", t) shader:send("vars",a,b) shader:send("light_pos", {light_x, light_y}) shader:send("colors", {r1, g1, b1, a1}, {r2, g2, b2, a2}, {r3, g3, b3, a3}, {r4, g4, b4, a4}) ``` Uniform / extern variables are read-only in the shader code and remain constant until modified by a Shader:send call. Uniform variables can be accessed in both the Vertex and Pixel components of a shader, as long as the variable is declared in each. There is a bug in version [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2") which causes Shader:send to ignore the last argument when sending arrays. A simple workaround is to add an extra dummy argument when sending multiple values to a uniform array. Function -------- ### Synopsis ``` Shader:send( name, number, ... ) ``` ### Arguments `[string](string "string") name` Name of the number to send to the shader. `[number](number "number") number` Number to send to store in the uniform variable. `[number](number "number") ...` Additional numbers to send if the uniform variable is an array. ### Returns Nothing. ### Notes Because all numbers in Lua are floating point, in versions prior to [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2") you must use the function [Shader:sendInt](https://love2d.org/w/index.php?title=Shader:sendInt&action=edit&redlink=1 "Shader:sendInt (page does not exist)") to send values to `uniform int` variables in the shader's code. Function -------- ### Synopsis ``` Shader:send( name, vector, ... ) ``` ### Arguments `[string](string "string") name` Name of the vector to send to the shader. `[table](table "table") vector` Numbers to send to the uniform variable as a vector. The number of elements in the table determines the type of the vector (e.g. two numbers -> vec2). At least two and at most four numbers can be used. `[table](table "table") ...` Additional vectors to send if the uniform variable is an array. All vectors need to be of the same size (e.g. only vec3's). ### Returns Nothing. Function -------- ### Synopsis ``` Shader:send( name, matrix, ... ) ``` ### Arguments `[string](string "string") name` Name of the matrix to send to the shader. `[table](table "table") matrix` 2x2, 3x3, or 4x4 matrix to send to the uniform variable. Using table form: `{{a,b,c,d}, {e,f,g,h}, ... }` or (since version [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2")) `{a,b,c,d, e,f,g,h, ...}`. The order in 0.10.2 is column-major; starting in [11.0](https://love2d.org/wiki/11.0 "11.0") it's row-major instead. `[table](table "table") ...` Additional matrices of the same type as *matrix* to store in a uniform array. ### Returns Nothing. Function -------- ### Synopsis ``` Shader:send( name, texture ) ``` ### Arguments `[string](string "string") name` Name of the [Texture](texture "Texture") to send to the shader. `[Texture](texture "Texture") texture` Texture ([Image](image "Image") or [Canvas](canvas "Canvas")) to send to the uniform variable. ### Returns Nothing. Function -------- ### Synopsis ``` Shader:send( name, boolean, ... ) ``` ### Arguments `[string](string "string") name` Name of the boolean to send to the shader. `[boolean](boolean "boolean") boolean` Boolean to send to store in the uniform variable. `[boolean](boolean "boolean") ...` Additional booleans to send if the uniform variable is an array. ### Returns Nothing. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` Shader:send( name, matrixlayout, matrix, ... ) ``` ### Arguments `[string](string "string") name` Name of the matrix to send to the shader. `[MatrixLayout](matrixlayout "MatrixLayout") matrixlayout` The layout (row- or column-major) of the matrix. `[table](table "table") matrix` 2x2, 3x3, or 4x4 matrix to send to the uniform variable. Using table form: `{{a,b,c,d}, {e,f,g,h}, ... }` or `{a,b,c,d, e,f,g,h, ...}`. `[table](table "table") ...` Additional matrices of the same type as *matrix* to store in a uniform array. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. Sends uniform values to the Shader sourced from the contents of a [Data](data "Data") object. This directly copies the bytes of the data. ### Synopsis ``` Shader:send( name, data, offset, size ) ``` ### Arguments `[string](string "string") name` Name of the uniform to send to the shader. `[Data](data "Data") data` Data object containing the values to send. `[number](number "number") offset (0)` Offset in bytes from the start of the Data object. `[number](number "number") size (all)` Size in bytes of the data to send. If nil, as many bytes as the specified uniform uses will be copied. ### Returns Nothing. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. Sends uniform matrices to the Shader sourced from the contents of a [Data](data "Data") object. This directly copies the bytes of the data. ### Synopsis ``` Shader:send( name, data, matrixlayout, offset, size ) ``` ### Arguments `[string](string "string") name` Name of the uniform matrix to send to the shader. `[Data](data "Data") data` Data object containing the values to send. `[MatrixLayout](matrixlayout "MatrixLayout") matrixlayout` The layout (row- or column-major) of the matrix in memory. `[number](number "number") offset (0)` Offset in bytes from the start of the Data object. `[number](number "number") size (all)` Size in bytes of the data to send. If nil, as many bytes as the specified uniform uses will be copied. ### Returns Nothing. See Also -------- * [Shader](shader "Shader") love Transform:inverseTransformPoint Transform:inverseTransformPoint =============================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Applies the reverse of the Transform object's transformation to the given 2D position. This effectively converts the given position from the local coordinate space of the Transform into global coordinates. One use of this method can be to convert a screen-space mouse position into global world coordinates, if the given Transform has transformations applied that are used for a camera system in-game. Function -------- ### Synopsis ``` globalX, globalY = Transform:inverseTransformPoint( localX, localY ) ``` ### Arguments `[number](number "number") localX` The x component of the position with the transform applied. `[number](number "number") localY` The y component of the position with the transform applied. ### Returns `[number](number "number") globalX` The x component of the position in global coordinates. `[number](number "number") globalY` The y component of the position in global coordinates. See Also -------- * [Transform](transform "Transform") * [Transform:transformPoint](transform-transformpoint "Transform:transformPoint") love DistanceJoint:getFrequency DistanceJoint:getFrequency ========================== Gets the response speed. Function -------- ### Synopsis ``` Hz = DistanceJoint:getFrequency( ) ``` ### Arguments None. ### Returns `[number](number "number") Hz` The response speed. See Also -------- * [DistanceJoint](distancejoint "DistanceJoint") love love.graphics.setCaption love.graphics.setCaption ======================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** Moved to the [love.window](love.window "love.window") module as [love.window.setTitle](love.window.settitle "love.window.setTitle"). Sets the window caption. Function -------- ### Synopsis ``` love.graphics.setCaption( caption ) ``` ### Arguments `[string](string "string") caption` The new window caption. ### Returns Nothing. See Also -------- * [love.graphics](love.graphics "love.graphics") love love.graphics.checkMode love.graphics.checkMode ======================= **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in that and later versions. Checks if a display mode is supported. Function -------- ### Synopsis ``` supported = love.graphics.checkMode( width, height, fullscreen ) ``` ### Arguments `[number](number "number") width` The display width. `[number](number "number") height` The display height. `[boolean](boolean "boolean") fullscreen (false)` True to check for fullscreen, false for windowed. ### Returns `[boolean](boolean "boolean") supported` True if supported, false if not. See Also -------- * [love.graphics](love.graphics "love.graphics") love BlendAlphaMode BlendAlphaMode ============== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This enum is not supported in earlier versions. Different ways alpha affects color blending. See [BlendMode](blendmode "BlendMode") and the [BlendMode Formulas](blendmode_formulas "BlendMode Formulas") for additional notes. Constants --------- alphamultiply The RGB values of what's drawn are multiplied by the alpha values of those colors during blending. This is the default alpha mode. premultiplied The RGB values of what's drawn are **not** multiplied by the alpha values of those colors during blending. For most blend modes to work correctly with this alpha mode, the colors of a drawn object need to have had their RGB values multiplied by their alpha values at some point previously ("premultiplied alpha"). Notes ----- The "premultiplied" constant should generally be used when drawing a [Canvas](canvas "Canvas") to the screen, because the RGB values of the Canvas' texture had previously been multiplied by its alpha values when drawing content to the Canvas itself. The "alphamultiply" constant does not affect the "multiply" [BlendMode](blendmode "BlendMode"). Similarly, the "screen" [BlendMode](blendmode "BlendMode")'s math is only correct if the "premultiplied" alpha mode is used and the alpha of drawn objects has already been multiplied with its RGB values previously (possibly inside a shader). Several articles have been written about *premultiplied alpha* and when to use it: * <http://www.realtimerendering.com/blog/gpus-prefer-premultiplication/> * <https://developer.nvidia.com/content/alpha-blending-pre-or-not-pre> * [http://blogs.msdn.com/b/shawnhar/archive/2009/11/06/premultiplied-alpha.aspx](https://blogs.msdn.com/b/shawnhar/archive/2009/11/06/premultiplied-alpha.aspx) * [http://blogs.msdn.com/b/shawnhar/archive/2009/11/07/premultiplied-alpha-and-image-composition.aspx](https://blogs.msdn.com/b/shawnhar/archive/2009/11/07/premultiplied-alpha-and-image-composition.aspx) See Also -------- * [love.graphics](love.graphics "love.graphics") * [BlendMode](blendmode "BlendMode") * [BlendMode Formulas](blendmode_formulas "BlendMode Formulas") * [love.graphics.setBlendMode](love.graphics.setblendmode "love.graphics.setBlendMode") * [love.graphics.getBlendMode](love.graphics.getblendmode "love.graphics.getBlendMode") love love.lowmemory love.lowmemory ============== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This callback is not supported in earlier versions. Callback function triggered when the system is running out of memory on mobile devices. Mobile operating systems may forcefully kill the game if it uses too much memory, so any non-critical resource should be removed if possible (by setting all variables referencing the resources to **nil**), when this event is triggered. Sounds and images in particular tend to use the most memory. Function -------- ### Synopsis ``` love.lowmemory( ) ``` ### Arguments None. ### Returns Nothing. Examples -------- Clear unused data and collect the garbage when memory is low. ``` local cachetable = {} for i = 0, math.pi * 2, math.pi / 1000 do cachetable[i] = math.sin(i) end   function love.lowmemory() cachetable = {} collectgarbage() end ``` See Also -------- * [love](love "love") love ChainShape:getPoint ChainShape:getPoint =================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Returns a point of the shape. Function -------- ### Synopsis ``` x, y = ChainShape:getPoint( index ) ``` ### Arguments `[number](number "number") index` The index of the point to return. ### Returns `[number](number "number") x` The x-coordinate of the point. `[number](number "number") y` The y-coordinate of the point. See Also -------- * [ChainShape](chainshape "ChainShape") love love.mouse.isGrabbed love.mouse.isGrabbed ==================== Checks if the mouse is grabbed. Function -------- ### Synopsis ``` grabbed = love.mouse.isGrabbed( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") grabbed` True if the cursor is grabbed, false if it is not. Examples -------- Toggles whether the mouse is grabbed by pressing tab, using [love.mouse.setGrabbed](love.mouse.setgrabbed "love.mouse.setGrabbed"). ``` function love.keypressed(key) if key == "tab" then local state = not love.mouse.isGrabbed() -- the opposite of whatever it currently is love.mouse.setGrabbed(state) --Use love.mouse.setGrab(state) for 0.8.0 or lower end end ``` See Also -------- * [love.mouse](love.mouse "love.mouse") * [love.mouse.setGrabbed](love.mouse.setgrabbed "love.mouse.setGrabbed") love Font:getHeight Font:getHeight ============== Gets the height of the Font. The height of the font is the size including any spacing; the height which it will need. Function -------- ### Synopsis ``` height = Font:getHeight( ) ``` ### Arguments None. ### Returns `[number](number "number") height` The height of the Font in pixels. See Also -------- * [Font](font "Font") love love.keyboard.getScancodeFromKey love.keyboard.getScancodeFromKey ================================ **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Gets the hardware scancode corresponding to the given key. Unlike [key constants](keyconstant "KeyConstant"), Scancodes are keyboard layout-independent. For example the scancode "w" will be generated if the key in the same place as the "w" key on an American keyboard is pressed, no matter what the key is labelled or what the user's operating system settings are. Scancodes are useful for creating default controls that have the same physical locations on on all systems. Function -------- ### Synopsis ``` scancode = love.keyboard.getScancodeFromKey( key ) ``` ### Arguments `[KeyConstant](keyconstant "KeyConstant") key` The key to get the scancode from. ### Returns `[Scancode](scancode "Scancode") scancode` The scancode corresponding to the given key, or "unknown" if the given key has no known physical representation on the current system. See Also -------- * [love.keyboard](love.keyboard "love.keyboard") * [love.keyboard.getKeyFromScancode](love.keyboard.getkeyfromscancode "love.keyboard.getKeyFromScancode") * [love.keyboard.isScancodeDown](love.keyboard.isscancodedown "love.keyboard.isScancodeDown") * [love.keypressed](love.keypressed "love.keypressed") * [love.keyreleased](love.keyreleased "love.keyreleased") love Decoder:decode Decoder:decode ============== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Decodes the audio and returns a [SoundData](sounddata "SoundData") object containing the decoded audio data. Function -------- ### Synopsis ``` soundData = Decoder:decode( ) ``` ### Arguments None. ### Returns `[SoundData](sounddata "SoundData") soundData` Decoded audio data. See Also -------- * [Decoder](decoder "Decoder") * [SoundData](sounddata "SoundData") * [Source:queue](source-queue "Source:queue") love love.keyboard.hasKeyRepeat love.keyboard.hasKeyRepeat ========================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets whether key repeat is enabled. Function -------- ### Synopsis ``` enabled = love.keyboard.hasKeyRepeat( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") enabled` Whether key repeat is enabled. See Also -------- * [love.keyboard](love.keyboard "love.keyboard") * [love.keyboard.setKeyRepeat](love.keyboard.setkeyrepeat "love.keyboard.setKeyRepeat") * [love.keypressed](love.keypressed "love.keypressed") love BlendMode BlendMode ========= **Available since LÖVE [0.2.0](https://love2d.org/wiki/0.2.0 "0.2.0")** This enum is not supported in earlier versions. Different ways to do color blending. See [BlendAlphaMode](blendalphamode "BlendAlphaMode") and the [BlendMode Formulas](blendmode_formulas "BlendMode Formulas") for additional notes. Constants --------- alpha Alpha blending (normal). The alpha of what's drawn determines its opacity. replace Available since 0.9.0 The colors of what's drawn completely replace what was on the screen, with no additional blending. The [BlendAlphaMode](blendalphamode "BlendAlphaMode") specified in [love.graphics.setBlendMode](love.graphics.setblendmode "love.graphics.setBlendMode") still affects what happens. screen Available since 0.9.1 'Screen' blending. add Available since 0.10.0 The pixel colors of what's drawn are added to the pixel colors already on the screen. The alpha of the screen is not modified. subtract Available since 0.10.0 The pixel colors of what's drawn are subtracted from the pixel colors already on the screen. The alpha of the screen is not modified. multiply Available since 0.10.0 The pixel colors of what's drawn are multiplied with the pixel colors already on the screen (darkening them). The alpha of drawn objects is multiplied with the alpha of the screen rather than determining how much the colors on the screen are affected, even when the "alphamultiply" [BlendAlphaMode](blendalphamode "BlendAlphaMode") is used. lighten Available since 0.10.1 The pixel colors of what's drawn are compared to the existing pixel colors, and the larger of the two values for each color component is used. Only works when the "premultiplied" [BlendAlphaMode](blendalphamode "BlendAlphaMode") is used in [love.graphics.setBlendMode](love.graphics.setblendmode "love.graphics.setBlendMode"). darken Available since 0.10.1 The pixel colors of what's drawn are compared to the existing pixel colors, and the smaller of the two values for each color component is used. Only works when the "premultiplied" [BlendAlphaMode](blendalphamode "BlendAlphaMode") is used in [love.graphics.setBlendMode](love.graphics.setblendmode "love.graphics.setBlendMode"). additive Removed in 0.10.0 Additive blend mode. subtractive Available since 0.7.0 and removed in LÖVE 0.10.0 Subtractive blend mode. multiplicative Available since 0.7.0 and removed in LÖVE 0.10.0 Multiply blend mode. premultiplied Available since 0.8.0 and removed in LÖVE 0.10.0 Premultiplied alpha blend mode. See Also -------- * [love.graphics](love.graphics "love.graphics") * [BlendMode Formulas](blendmode_formulas "BlendMode Formulas") * [love.graphics.setBlendMode](love.graphics.setblendmode "love.graphics.setBlendMode") * [love.graphics.getBlendMode](love.graphics.getblendmode "love.graphics.getBlendMode") * [BlendAlphaMode](blendalphamode "BlendAlphaMode")
programming_docs
love CompressedDataFormat CompressedDataFormat ==================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This enum is not supported in earlier versions. Compressed data formats. Constants --------- lz4 The LZ4 compression format. Compresses and decompresses very quickly, but the compression ratio is not the best. LZ4-HC is used when compression level 9 is specified. Some benchmarks are available [here](https://github.com/Cyan4973/lz4#user-content-benchmarks). zlib The zlib format is DEFLATE-compressed data with a small bit of header data. Compresses relatively slowly and decompresses moderately quickly, and has a decent compression ratio. gzip The gzip format is DEFLATE-compressed data with a slightly larger header than zlib. Since it uses DEFLATE it has the same compression characteristics as the zlib format. deflate Available since 11.0 Raw DEFLATE-compressed data (no header). See Also -------- * [love.data](love.data "love.data") * [love.data.compress](love.data.compress "love.data.compress") * [love.math.compress](love.math.compress "love.math.compress") (deprecated since 11.0) * [CompressedData](compresseddata "CompressedData") * [CompressedData:getFormat](compresseddata-getformat "CompressedData:getFormat") love PrismaticJoint:areLimitsEnabled PrismaticJoint:areLimitsEnabled =============================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** It has been renamed from [PrismaticJoint:hasLimitsEnabled](prismaticjoint-haslimitsenabled "PrismaticJoint:hasLimitsEnabled"). Checks whether the limits are enabled. Function -------- ### Synopsis ``` enabled = PrismaticJoint:areLimitsEnabled( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") enabled` True if enabled, false otherwise. See Also -------- * [PrismaticJoint](prismaticjoint "PrismaticJoint") love Texture:setMipmapFilter Texture:setMipmapFilter ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Sets the mipmap filter mode for a Texture. Prior to [11.0](https://love2d.org/wiki/11.0 "11.0") this method only worked on [Images](image "Image"). [Mipmapping](https://en.wikipedia.org/wiki/Mipmap) is useful when drawing a texture at a reduced scale. It can improve performance and reduce aliasing issues. In [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0") and newer, the texture must be [created](love.graphics.newimage "love.graphics.newImage") with the `mipmaps` flag enabled for the mipmap filter to have any effect. In versions prior to [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0") it's best to call this method directly after creating the image with [love.graphics.newImage](love.graphics.newimage "love.graphics.newImage"), to avoid bugs in certain graphics drivers. Due to hardware restrictions and driver bugs, in versions prior to [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0") images that weren't loaded from a [CompressedData](compresseddata "CompressedData") must have power-of-two dimensions (64x64, 512x256, etc.) to use mipmaps. Function -------- ### Synopsis ``` Texture:setMipmapFilter( filtermode, sharpness ) ``` ### Arguments `[FilterMode](filtermode "FilterMode") filtermode` The filter mode to use in between mipmap levels. "nearest" will often give better performance. `[number](number "number") sharpness (0)` A positive sharpness value makes the texture use a more detailed mipmap level when drawing, at the expense of performance. A negative value does the reverse. ### Returns Nothing. ### Notes On mobile devices (Android and iOS), the sharpness parameter is not supported and will do nothing. You can use a custom [Shader](shader "Shader") instead, and specify the mipmap sharpness in the optional third parameter to the `Texel` function in the shader (a *negative* value makes the texture use a more detailed mipmap level.) In versions prior to [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0"), calling this function automatically creates mipmaps for the Image if none exist yet. If the image is [compressed]((image)-iscompressed "(Image):isCompressed") and its [CompressedData](compresseddata "CompressedData") has mipmap data included, it will use that. Function -------- Disables mipmap filtering. ### Synopsis ``` Texture:setMipmapFilter( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Texture](texture "Texture") * [Texture:getMipmapFilter](texture-getmipmapfilter "Texture:getMipmapFilter") * [love.graphics.newImage](love.graphics.newimage "love.graphics.newImage") * [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") * [MipmapMode](mipmapmode "MipmapMode") love SpriteBatch:attachAttribute SpriteBatch:attachAttribute =========================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Attaches a per-vertex attribute from a [Mesh](mesh "Mesh") onto this SpriteBatch, for use when drawing. This can be combined with a [Shader](shader "Shader") to augment a SpriteBatch with per-vertex or additional per-sprite information instead of just having per-sprite colors. Each sprite in a SpriteBatch has 4 vertices in the following order: top-left, bottom-left, top-right, bottom-right. The index returned by [SpriteBatch:add](spritebatch-add "SpriteBatch:add") (and used by [SpriteBatch:set](spritebatch-set "SpriteBatch:set")) can used to determine the first vertex of a specific sprite with the formula `1 + 4 * ( id - 1 )`. Function -------- ### Synopsis ``` SpriteBatch:attachAttribute( name, mesh ) ``` ### Arguments `[string](string "string") name` The name of the vertex attribute to attach. `[Mesh](mesh "Mesh") mesh` The Mesh to get the vertex attribute from. ### Returns Nothing. Notes ----- If a [Mesh](mesh "Mesh") wasn't [created](love.graphics.newmesh "love.graphics.newMesh") with a custom vertex format, it will have 3 vertex attributes named `VertexPosition`, `VertexTexCoord`, and `VertexColor`. If vertex attributes with those names are attached to the SpriteBatch, it will override the SpriteBatch's sprite positions, texture coordinates, and sprite colors, respectively. Custom named attributes can be accessed in a [vertex shader](shader "Shader") by declaring them as `attribute vec4 MyCustomAttributeName;` at the top-level of the vertex shader code. The name must match what was specified in the Mesh's vertex format and in the `name` argument of **SpriteBatch:attachAttribute**. A Mesh must have at least 4 \* [SpriteBatch:getBufferSize](spritebatch-getbuffersize "SpriteBatch:getBufferSize") vertices in order to be attachable to a SpriteBatch. See Also -------- * [SpriteBatch](spritebatch "SpriteBatch") * [Mesh](mesh "Mesh") * [Mesh:getVertexFormat](mesh-getvertexformat "Mesh:getVertexFormat") * [love.graphics.draw](love.graphics.draw "love.graphics.draw") love love.window.getDPIScale love.window.getDPIScale ======================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function replaces [love.window.getPixelScale](love.window.getpixelscale "love.window.getPixelScale"). Gets the DPI scale factor associated with the window. 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](love.window.setmode "love.window.setMode") enabled, the window may take up the same physical size as an 800x600 window, but the area inside the window uses 1600x1200 pixels. `love.window.getDPIScale()` would return `2.0` in that case. The [love.window.fromPixels](love.window.frompixels "love.window.fromPixels") and [love.window.toPixels](love.window.topixels "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. Function -------- ### Synopsis ``` scale = love.window.getDPIScale( ) ``` ### Arguments None. ### Returns `[number](number "number") scale` The pixel scale factor associated with the window. Notes ----- The units of [love.graphics.getWidth](love.graphics.getwidth "love.graphics.getWidth"), [love.graphics.getHeight](love.graphics.getheight "love.graphics.getHeight"), [love.mouse.getPosition](love.mouse.getposition "love.mouse.getPosition"), mouse events, [love.touch.getPosition](love.touch.getposition "love.touch.getPosition"), and touch events are always in DPI-scaled units in LOVE [11.0](https://love2d.org/wiki/11.0 "11.0")+, unless the `usedpiscale` flag is set to false in [love.window.setMode](love.window.setmode "love.window.setMode") or [love.conf](love.conf "love.conf"). See Also -------- * [love.window](love.window "love.window") * [love.window.toPixels](love.window.topixels "love.window.toPixels") * [love.window.fromPixels](love.window.frompixels "love.window.fromPixels") * [love.window.setMode](love.window.setmode "love.window.setMode") * [Config Files](love.conf "Config Files") love FileData:getFilename FileData:getFilename ==================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Gets the filename of the FileData. Function -------- ### Synopsis ``` name = FileData:getFilename( ) ``` ### Arguments None. ### Returns `[string](string "string") name` The name of the file the FileData represents. See Also -------- * [FileData](filedata "FileData") love ImageData:getString ImageData:getString =================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been moved to [Data:getString](data-getstring "Data:getString"). Gets the full ImageData as a string. Function -------- ### Synopsis ``` pixels = ImageData:getString( ) ``` ### Arguments None. ### Returns `[string](string "string") pixels` The raw data. See Also -------- * [ImageData](imagedata "ImageData") love Framebuffer:getWrap Framebuffer:getWrap =================== **Available since LÖVE [0.7.2](https://love2d.org/wiki/0.7.2 "0.7.2")** This function is not supported in earlier versions. **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been renamed to [Canvas:getWrap](canvas-getwrap "Canvas:getWrap"). Gets the wrapping properties of a Framebuffer. This functions returns the currently set horizontal and vertical [wrapping modes](wrapmode "WrapMode") for the framebuffer. Function -------- ### Synopsis ``` horiz, vert = Framebuffer:getWrap( ) ``` ### Arguments None ### Returns `[WrapMode](wrapmode "WrapMode") horiz` Horizontal wrapping mode of the Framebuffer. `[WrapMode](wrapmode "WrapMode") vert` Vertical wrapping mode of the Framebuffer. See Also -------- * [Framebuffer](framebuffer "Framebuffer") * [WrapMode](wrapmode "WrapMode") love love.filesystem.getSize love.filesystem.getSize ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | This function is deprecated and is replaced by [love.filesystem.getInfo](love.filesystem.getinfo "love.filesystem.getInfo"). | Gets the size in bytes of a file. Function -------- ### Synopsis ``` size, errormsg = love.filesystem.getSize( filename ) ``` ### Arguments `[string](string "string") filename` The path and name to a file. ### Returns `[number](number "number") size` The size in bytes of the file, or nil on failure. `[string](string "string") errormsg (nil)` The error message on failure. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") love Source:getCone Source:getCone ============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the Source's directional volume cones. Together with [Source:setDirection](source-setdirection "Source:setDirection"), the cone angles allow for the Source's volume to vary depending on its direction. Function -------- ### Synopsis ``` innerAngle, outerAngle, outerVolume = Source:getCone( ) ``` ### Arguments None. ### Returns `[number](number "number") innerAngle` The inner angle from the Source's direction, in radians. The Source will play at normal volume if the listener is inside the cone defined by this angle. `[number](number "number") outerAngle` The outer angle from the Source's direction, in radians. The Source will play at a volume between the normal and outer volumes, if the listener is in between the cones defined by the inner and outer angles. `[number](number "number") outerVolume` The Source's volume when the listener is outside both the inner and outer cone angles. See Also -------- * [Source](source "Source") * [Source:setCone](source-setcone "Source:setCone") * [Source:setDirection](source-setdirection "Source:setDirection") love Decoder:clone Decoder:clone ============= **Available since LÖVE [11.3](https://love2d.org/wiki/11.3 "11.3")** This function is not supported in earlier versions. Creates a new copy of current decoder. The new decoder will start decoding from the beginning of the audio stream. Function -------- ### Synopsis ``` decoder = Decoder:clone( ) ``` ### Arguments None. ### Returns `[Decoder](decoder "Decoder") decoder` New copy of the decoder. See Also -------- * [Decoder](decoder "Decoder") love Source:getActiveEffects Source:getActiveEffects ======================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets a list of the [Source's](source "Source") active [effect](effecttype "EffectType") names. Function -------- ### Synopsis ``` effects = Source:getActiveEffects() ``` ### Arguments None. ### Returns `[table](table "table") effects` A list of the source's active effect names. See Also -------- * [Source](source "Source") * [Source:setEffect](source-seteffect "Source:setEffect") * [love.audio.setEffect](love.audio.seteffect "love.audio.setEffect") love SpriteBatch:lock SpriteBatch:lock ================ This has been changed to [SpriteBatch:bind](spritebatch-bind "SpriteBatch:bind") love Source:setPosition Source:setPosition ================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Sets the position of the Source. Please note that this only works for mono (i.e. non-stereo) sound files! Function -------- ### Synopsis ``` Source:setPosition( x, y, z ) ``` ### Arguments `[number](number "number") x` The X position of the Source. `[number](number "number") y` The Y position of the Source. `[number](number "number") z` The Z position of the Source. ### Returns Nothing. See Also -------- * [Source](source "Source") * [love.audio.setPosition](love.audio.setposition "love.audio.setPosition") love ChainShape:setPrevVertex ChainShape:setPrevVertex ======================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [ChainShape:setPreviousVertex](chainshape-setpreviousvertex "ChainShape:setPreviousVertex"). Sets a vertex that establishes a connection to the previous shape. This can help prevent unwanted collisions when a flat shape slides along the edge and moves over to the new shape. Function -------- ### Synopsis ``` ChainShape:setPrevVertex( x, y ) ``` ### Arguments `[number](number "number") x` The x-component of the vertex. `[number](number "number") y` The y-component of the vertex. ### Returns Nothing. See Also -------- * [ChainShape](chainshape "ChainShape") * [ChainShape:setNextVertex](chainshape-setnextvertex "ChainShape:setNextVertex") love Body:getWorldPoint Body:getWorldPoint ================== Transform a point from local coordinates to world coordinates. Function -------- ### Synopsis ``` worldX, worldY = Body:getWorldPoint( localX, localY ) ``` ### Arguments `[number](number "number") localX` The x position in local coordinates. `[number](number "number") localY` The y position in local coordinates. ### Returns `[number](number "number") worldX` The x position in world coordinates. `[number](number "number") worldY` The y position in world coordinates. See Also -------- * [Body](body "Body") love ParticleSystem:getOffsetY ParticleSystem:getOffsetY ========================= **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been moved to [ParticleSystem:getOffset](particlesystem-getoffset "ParticleSystem:getOffset"). Get the y coordinate of the particle rotation offset. Function -------- ### Synopsis ``` yOffset = ParticleSystem:getOffsetY( ) ``` ### Arguments None. ### Returns `[number](number "number") yOffset` The y coordinate of the rotation offset. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:getOffsetX](particlesystem-getoffsetx "ParticleSystem:getOffsetX") * [ParticleSystem:setOffset](particlesystem-setoffset "ParticleSystem:setOffset") love CompressedData:getFormat CompressedData:getFormat ======================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets the compression format of the CompressedData. Function -------- ### Synopsis ``` format = CompressedData:getFormat( ) ``` ### Arguments None. ### Returns `[CompressedDataFormat](compresseddataformat "CompressedDataFormat") format` The format of the CompressedData. See Also -------- * [CompressedData](compresseddata "CompressedData") love BezierCurve:getDerivative BezierCurve:getDerivative ========================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Get the derivative of the Bézier curve. This function can be used to rotate sprites moving along a curve in the direction of the movement and compute the direction perpendicular to the curve at some parameter t. Function -------- ### Synopsis ``` derivative = BezierCurve:getDerivative() ``` ### Arguments None. ### Returns `[BezierCurve](beziercurve "BezierCurve") derivative` The derivative curve. Example ------- ### Position a sprite along a Bézier-curve. ``` curve = love.math.newBezierCurve({25,25,75,50,125,25}) derivative = curve:getDerivative() sprite = love.graphics.newImage('sprite.png') -- to demonstrate orientation; assuming the sprite's front is upwards.   local t = 0.0 -- range: [0,1] function love.update(dt) t = (t + dt / 10) % 1.0 end   function love.draw() local ex,ey = curve:evaluate(t) local dx,dy = derivative:evaluate(t) -- If the sprite were facing to the right, the +math.pi/2 part would not be needed. love.graphics.draw(sprite, ex, ey, math.atan2(dy,dx)+math.pi/2, 1, 1, sprite:getWidth()/2, sprite:getHeight()/2) end ``` See Also -------- * [BezierCurve](beziercurve "BezierCurve") * [love.math](love.math "love.math") love love.keyreleased love.keyreleased ================ Callback function triggered when a keyboard key is released. Function -------- ### Synopsis ``` love.keyreleased( key, scancode ) ``` ### Arguments `[KeyConstant](keyconstant "KeyConstant") key` Character of the released key. `[Scancode](scancode "Scancode") scancode` Available since 0.10.0 The scancode representing the released key. ### Returns Nothing. ### Notes [Scancodes](scancode "Scancode") are keyboard layout-independent, so the scancode "w" will be used if the key in the same place as the "w" key on an [American keyboard](https://en.wikipedia.org/wiki/British_and_American_keyboards#/media/File:KB_United_States-NoAltGr.svg) is released, no matter what the key is labelled or what the user's operating system settings are. Examples -------- Exit the game when the player releases the Escape key, using [love.event.quit](love.event.quit "love.event.quit"). ``` function love.keyreleased(key) if key == "escape" then love.event.quit() end end ``` See Also -------- * [love](love "love") * [love.keypressed](love.keypressed "love.keypressed") * [love.keyboard.isDown](love.keyboard.isdown "love.keyboard.isDown")
programming_docs
love ChainShape ChainShape ========== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This shape is not supported in earlier versions. A ChainShape consists of multiple line segments. It can be used to create the boundaries of your terrain. The shape does not have volume and can only collide with [PolygonShape](polygonshape "PolygonShape") and [CircleShape](circleshape "CircleShape"). Unlike the [PolygonShape](polygonshape "PolygonShape"), the ChainShape does not have a vertices limit or has to form a convex shape, but self intersections are not supported. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.physics.newChainShape](love.physics.newchainshape "love.physics.newChainShape") | Creates a new **ChainShape**. | 0.8.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [ChainShape:getChildEdge](chainshape-getchildedge "ChainShape:getChildEdge") | Returns a child of the shape as an EdgeShape. | 0.8.0 | | | [ChainShape:getNextVertex](chainshape-getnextvertex "ChainShape:getNextVertex") | Gets the vertex that establishes a connection to the next shape. | 0.10.2 | | | [ChainShape:getPoint](chainshape-getpoint "ChainShape:getPoint") | Returns a point of the shape. | 0.8.0 | | | [ChainShape:getPoints](chainshape-getpoints "ChainShape:getPoints") | Returns all points of the shape. | 0.8.0 | | | [ChainShape:getPreviousVertex](chainshape-getpreviousvertex "ChainShape:getPreviousVertex") | Gets the vertex that establishes a connection to the previous shape. | 0.10.2 | | | [ChainShape:getVertexCount](chainshape-getvertexcount "ChainShape:getVertexCount") | Returns the number of vertices the shape has. | 0.8.0 | | | [ChainShape:setNextVertex](chainshape-setnextvertex "ChainShape:setNextVertex") | Sets a vertex that establishes a connection to the next shape. | 0.8.0 | | | [ChainShape:setPrevVertex](chainshape-setprevvertex "ChainShape:setPrevVertex") | Sets a vertex that establishes a connection to the previous shape. | 0.8.0 | 0.9.0 | | [ChainShape:setPreviousVertex](chainshape-setpreviousvertex "ChainShape:setPreviousVertex") | Sets a vertex that establishes a connection to the previous shape. | 0.9.0 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | | [Shape:computeAABB](shape-computeaabb "Shape:computeAABB") | Returns the points of the bounding box for the transformed shape. | 0.8.0 | | | [Shape:computeMass](shape-computemass "Shape:computeMass") | Computes the mass properties for the shape. | 0.8.0 | | | [Shape:destroy](shape-destroy "Shape:destroy") | Explicitly destroys the Shape. | | 0.8.0 | | [Shape:getBody](shape-getbody "Shape:getBody") | Get the body the shape is attached to. | 0.7.0 | 0.8.0 | | [Shape:getBoundingBox](shape-getboundingbox "Shape:getBoundingBox") | Gets the bounding box of the shape. | | 0.8.0 | | [Shape:getCategory](shape-getcategory "Shape:getCategory") | Gets the categories this shape is a member of. | | 0.8.0 | | [Shape:getCategoryBits](shape-getcategorybits "Shape:getCategoryBits") | Gets the categories as a 16-bit integer. | | 0.8.0 | | [Shape:getChildCount](shape-getchildcount "Shape:getChildCount") | Returns the number of children the shape has. | 0.8.0 | | | [Shape:getData](shape-getdata "Shape:getData") | Get the data set with setData. | | 0.8.0 | | [Shape:getDensity](shape-getdensity "Shape:getDensity") | Gets the density of the Shape. | | 0.8.0 | | [Shape:getFilterData](shape-getfilterdata "Shape:getFilterData") | Gets the filter data of the Shape. | | 0.8.0 | | [Shape:getFriction](shape-getfriction "Shape:getFriction") | Gets the friction of this shape. | | 0.8.0 | | [Shape:getMask](shape-getmask "Shape:getMask") | Gets which categories this shape should **NOT** collide with. | | 0.8.0 | | [Shape:getRadius](shape-getradius "Shape:getRadius") | Gets the radius of the shape. | | | | [Shape:getRestitution](shape-getrestitution "Shape:getRestitution") | Gets the restitution of this shape. | | 0.8.0 | | [Shape:getType](shape-gettype "Shape:getType") | Gets a string representing the Shape. | | | | [Shape:isSensor](shape-issensor "Shape:isSensor") | Checks whether a Shape is a sensor or not. | | 0.8.0 | | [Shape:rayCast](shape-raycast "Shape:rayCast") | Casts a ray against the shape. | 0.8.0 | | | [Shape:setCategory](shape-setcategory "Shape:setCategory") | Sets the categories this shape is a member of. | | 0.8.0 | | [Shape:setData](shape-setdata "Shape:setData") | Set data to be passed to the collision callback. | | 0.8.0 | | [Shape:setDensity](shape-setdensity "Shape:setDensity") | Sets the density of a Shape. | | 0.8.0 | | [Shape:setFilterData](shape-setfilterdata "Shape:setFilterData") | Sets the filter data for a Shape. | | 0.8.0 | | [Shape:setFriction](shape-setfriction "Shape:setFriction") | Sets the friction of the shape. | | 0.8.0 | | [Shape:setMask](shape-setmask "Shape:setMask") | Sets which categories this shape should **NOT** collide with. | | 0.8.0 | | [Shape:setRestitution](shape-setrestitution "Shape:setRestitution") | Sets the restitution of the shape. | | 0.8.0 | | [Shape:setSensor](shape-setsensor "Shape:setSensor") | Sets whether this shape should act as a sensor. | | 0.8.0 | | [Shape:testPoint](shape-testpoint "Shape:testPoint") | Checks whether a point lies inside the shape. | | | | [Shape:testSegment](shape-testsegment "Shape:testSegment") | Checks whether a line segment intersects a shape. | | 0.8.0 | Supertypes ---------- * [Shape](shape "Shape") * [Object](object "Object") See Also -------- * [love.physics](love.physics "love.physics") love SoundData:getSample SoundData:getSample =================== Gets the value of the sample-point at the specified position. For stereo SoundData objects, the data from the left and right channels are interleaved in that order. Function -------- ### Synopsis ``` sample = SoundData:getSample( i ) ``` ### Arguments `[number](number "number") i` An integer value specifying the position of the sample (starting at 0). ### Returns `[number](number "number") sample` The normalized samplepoint (range -1.0 to 1.0). Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. Gets the value of a sample using an explicit sample index instead of interleaving them in the sample position parameter. ### Synopsis ``` sample = SoundData:getSample( i, channel ) ``` ### Arguments `[number](number "number") i` An integer value specifying the position of the sample (starting at 0). `[number](number "number") channel` The index of the channel to get within the given sample. ### Returns `[number](number "number") sample` The normalized samplepoint (range -1.0 to 1.0). See Also -------- * [SoundData](sounddata "SoundData") * [SoundData:setSample](sounddata-setsample "SoundData:setSample") * [SoundData:getSampleCount](sounddata-getsamplecount "SoundData:getSampleCount") love SpriteBatch:unlock SpriteBatch:unlock ================== This has been changed to [SpriteBatch:unbind](spritebatch-unbind "SpriteBatch:unbind") love Fixture:getGroupIndex Fixture:getGroupIndex ===================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the group the fixture belongs to. Fixtures with the same group will always collide if the group is positive or never collide if it's negative. The group zero means no group. The groups range from -32768 to 32767. Function -------- ### Synopsis ``` group = Fixture:getGroupIndex( ) ``` ### Arguments None. ### Returns `[number](number "number") group` The group of the fixture. See Also -------- * [Fixture](fixture "Fixture") * [Fixture:setGroupIndex](fixture-setgroupindex "Fixture:setGroupIndex") love enet.peer:disconnect now enet.peer:disconnect now ======================== Force immediate disconnection from [peer](enet.peer "enet.peer"). Foreign [peer](enet.peer "enet.peer") not guaranteed to receive disconnect notification. Function -------- ### Synopsis ``` peer:disconnect_now(data) ``` ### Arguments `[number](number "number") data` Optional integer value to be associated with the disconnect. ### Returns Nothing. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.peer](enet.peer "enet.peer") love Quad:getTextureDimensions Quad:getTextureDimensions ========================= **Available since LÖVE [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2")** This function is not supported in earlier versions. Gets reference texture dimensions initially specified in [love.graphics.newQuad](love.graphics.newquad "love.graphics.newQuad"). Function -------- ### Synopsis ``` sw, sh = Quad:getTextureDimensions( ) ``` ### Arguments None. ### Returns `[number](number "number") sw` The Texture width used by the Quad. `[number](number "number") sh` The Texture height used by the Quad. See Also -------- * [Quad](quad "Quad") * [Quad:getViewport](quad-getviewport "Quad:getViewport") love Joint:getBodies Joint:getBodies =============== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Gets the [bodies](body "Body") that the Joint is attached to. Function -------- ### Synopsis ``` bodyA, bodyB = Joint:getBodies( ) ``` ### Arguments None. ### Returns `[Body](body "Body") bodyA (nil)` The first Body. `[Body](body "Body") bodyB (nil)` The second Body. See Also -------- * [Joint](joint "Joint") * [Body](body "Body") love Texture:getWidth Texture:getWidth ================ Gets the width of the Texture. Function -------- ### Synopsis ``` width = Texture:getWidth( ) ``` ### Arguments None. ### Returns `[number](number "number") width` The width of the Texture, in pixels. See Also -------- * [Texture](texture "Texture") * [Texture:getHeight](texture-getheight "Texture:getHeight") * [Texture:getDimensions](texture-getdimensions "Texture:getDimensions") love love.timer.sleep love.timer.sleep ================ **Available since LÖVE [0.2.1](https://love2d.org/wiki/0.2.1 "0.2.1")** This function is not supported in earlier versions. Pauses the current thread for the specified amount of time. This function causes the entire thread to pause for the duration of the sleep. Graphics will not draw, input events will not trigger, code will not run, and the window will be unresponsive if you use this as "wait()" in the main thread. Use [love.update](love.update "love.update") or a [Timer library](love.timer "love.timer") for that instead. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.timer.sleep( s ) ``` ### Arguments `[number](number "number") s` Seconds to sleep for. ### Returns Nothing. Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. ### Synopsis ``` love.timer.sleep( ms ) ``` ### Arguments `[number](number "number") ms` Milliseconds to sleep for. ### Returns Nothing. Examples -------- ### Use sleep to cap FPS at 30 ``` function love.update(dt) if dt < 1/30 then love.timer.sleep(1/30 - dt) end end ``` ### More sophisticated way to cap 30 FPS This takes into account the time spent updating and drawing each frame. ``` function love.load() min_dt = 1/30 next_time = love.timer.getTime() end   function love.update(dt) next_time = next_time + min_dt   -- rest of function here end   function love.draw() -- rest of function here   local cur_time = love.timer.getTime() if next_time <= cur_time then next_time = cur_time return end love.timer.sleep(next_time - cur_time) end ``` See Also -------- * [love.timer](love.timer "love.timer") love love.joystick.getNumButtons love.joystick.getNumButtons =========================== **Available since LÖVE [0.5.0](https://love2d.org/wiki/0.5.0 "0.5.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [Joystick:getButtonCount](joystick-getbuttoncount "Joystick:getButtonCount"). Returns the number of buttons on the joystick. Function -------- ### Synopsis ``` buttons = love.joystick.getNumButtons( joystick ) ``` ### Arguments `[number](number "number") joystick` The joystick to be checked ### Returns `[number](number "number") buttons` The number of buttons available See Also -------- * [love.joystick](love.joystick "love.joystick") love Text:add Text:add ======== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Adds additional colored text to the Text object at the specified position. Text may appear blurry if it's rendered at non-integer pixel locations. Function -------- ### Synopsis ``` index = Text:add( textstring, x, y, angle, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[string](string "string") textstring` The text to add to the object. `[number](number "number") x (0)` The position of the new text on the x-axis. `[number](number "number") y (0)` The position of the new text on the y-axis. `[number](number "number") angle (0)` The orientation of the new text in radians. `[number](number "number") sx (1)` Scale factor on the x-axis. `[number](number "number") sy (sx)` Scale factor on the y-axis. `[number](number "number") ox (0)` Origin offset on the x-axis. `[number](number "number") oy (0)` Origin offset on the y-axis. `[number](number "number") kx (0)` Shearing / skew factor on the x-axis. `[number](number "number") ky (0)` Shearing / skew factor on the y-axis. ### Returns `[number](number "number") index` An index number that can be used with [Text:getWidth](text-getwidth "Text:getWidth") or [Text:getHeight](text-getheight "Text:getHeight"). Function -------- ### Synopsis ``` index = Text:add( coloredtext, x, y, angle, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[table](table "table") coloredtext` A table containing colors and strings to add to the object, in the form of `{color1, string1, color2, string2, ...}`. `[table](table "table") 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}`. `[string](string "string") string1` A string of text which has a color specified by the previous color. `[table](table "table") 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}`. `[string](string "string") string2` A string of text which has a color specified by the previous color. `[tables and strings](https://love2d.org/w/index.php?title=tables_and_strings&action=edit&redlink=1 "tables and strings (page does not exist)") ...` Additional colors and strings. `[number](number "number") x (0)` The position of the new text on the x-axis. `[number](number "number") y (0)` The position of the new text on the y-axis. `[number](number "number") angle (0)` The orientation of the new text in radians. `[number](number "number") sx (1)` Scale factor on the x-axis. `[number](number "number") sy (sx)` Scale factor on the y-axis. `[number](number "number") ox (0)` Origin offset on the x-axis. `[number](number "number") oy (0)` Origin offset on the y-axis. `[number](number "number") kx (0)` Shearing / skew factor on the x-axis. `[number](number "number") ky (0)` Shearing / skew factor on the y-axis. ### Returns `[number](number "number") index` An index number that can be used with [Text:getWidth](text-getwidth "Text:getWidth") or [Text:getHeight](text-getheight "Text:getHeight"). ### Notes The color set by [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor") will be combined (multiplied) with the colors of the text, when drawing the Text object. See Also -------- * [Text](text "Text") * [Text:addf](text-addf "Text:addf") * [Text:set](text-set "Text:set") * [Text:setf](text-setf "Text:setf") * [Text:clear](text-clear "Text:clear") love Shape:getCategoryBits Shape:getCategoryBits ===================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** Use [Fixture:getCategory](fixture-getcategory "Fixture:getCategory") instead. Gets the categories as a 16-bit integer. A set bit indicates membership of that category. Function -------- ### Synopsis ``` An = Shape:getCategoryBits( ) ``` ### Arguments None. ### Returns `[number](number "number") An` Integer value representing the categories. See Also -------- * [Shape](shape "Shape") love love.filesystem.getUserDirectory love.filesystem.getUserDirectory ================================ Returns the path of the user's directory Function -------- ### Synopsis ``` path = love.filesystem.getUserDirectory( ) ``` ### Arguments None. ### Returns `[string](string "string") path` The path of the user's directory See Also -------- * [love.filesystem](love.filesystem "love.filesystem") love love.math.getRandomSeed love.math.getRandomSeed ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the seed of the random number generator. The seed is split into two numbers due to Lua's use of [doubles](https://en.wikipedia.org/wiki/Double-precision_floating-point_format) for all number values - doubles can't accurately represent integer values above 2^53, but the seed can be an integer value up to 2^64. Function -------- ### Synopsis ``` low, high = love.math.getRandomSeed( ) ``` ### Arguments None. ### Returns `[number](number "number") low` Integer number representing the lower 32 bits of the random number generator's 64 bit seed value. `[number](number "number") high` Integer number representing the higher 32 bits of the random number generator's 64 bit seed value. See Also -------- * [love.math](love.math "love.math") * [love.math.setRandomSeed](love.math.setrandomseed "love.math.setRandomSeed") love love.physics.newRectangleShape love.physics.newRectangleShape ============================== Shorthand for creating rectangular [PolygonShapes](polygonshape "PolygonShape"). By default, the local origin is located at the **center** of the rectangle as opposed to the top left for graphics. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** These variants are not supported in earlier versions. ### Synopsis ``` shape = love.physics.newRectangleShape( width, height ) ``` ### Arguments `[number](number "number") width` The width of the rectangle. `[number](number "number") height` The height of the rectangle. ### Returns `[PolygonShape](polygonshape "PolygonShape") shape` A new PolygonShape. Function -------- ### Synopsis ``` shape = love.physics.newRectangleShape( x, y, width, height, angle ) ``` ### Arguments `[number](number "number") x` The offset along the x-axis. `[number](number "number") y` The offset along the y-axis. `[number](number "number") width` The width of the rectangle. `[number](number "number") height` The height of the rectangle. `[number](number "number") angle (0)` The initial angle of the rectangle. ### Returns `[PolygonShape](polygonshape "PolygonShape") shape` A new PolygonShape. Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. ### Synopsis ``` s = love.physics.newRectangleShape( body, x, y, width, height, angle ) ``` ### Arguments `[Body](body "Body") body` The Body to attach the Shape to. `[number](number "number") x` The offset along the x-axis. `[number](number "number") y` The offset along the y-axis. `[number](number "number") width` The width of the rectangle. `[number](number "number") height` The height of the rectangle. `[number](number "number") angle (0)` The initial angle of the rectangle. ### Returns `[PolygonShape](polygonshape "PolygonShape") s` A new PolygonShape. See Also -------- * [love.physics](love.physics "love.physics") * [PolygonShape](polygonshape "PolygonShape") * [Shape](shape "Shape")
programming_docs
love Joystick:isGamepadDown Joystick:isGamepadDown ====================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Checks if a virtual gamepad button on the Joystick is pressed. If the Joystick is not recognized as a [Gamepad](joystick-isgamepad "Joystick:isGamepad") or isn't connected, then this function will always return false. Function -------- ### Synopsis ``` anyDown = Joystick:isGamepadDown( button1, button2, button3, ... ) ``` ### Arguments `[GamepadButton](gamepadbutton "GamepadButton") buttonN` The gamepad button to check. ### Returns `[boolean](boolean "boolean") anyDown` True if any supplied button is down, false if not. See Also -------- * [Joystick](joystick "Joystick") * [Joystick:isGamepad](joystick-isgamepad "Joystick:isGamepad") * [Joystick:getGamepadAxis](joystick-getgamepadaxis "Joystick:getGamepadAxis") * [Joystick:isConnected](joystick-isconnected "Joystick:isConnected") * [love.gamepadpressed](love.gamepadpressed "love.gamepadpressed") * [love.gamepadreleased](love.gamepadreleased "love.gamepadreleased") love love.graphics.newCubeImage love.graphics.newCubeImage ========================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Creates a new [cubemap](texturetype "TextureType") [Image](image "Image"). This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Cubemap images have 6 faces (sides) which represent a cube. They can't be rendered directly, they can only be used in [Shader](shader "Shader") code (and sent to the shader via [Shader:send](shader-send "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 ``` Function -------- Creates a cubemap Image given a single image file containing multiple cube faces. ### Synopsis ``` image = love.graphics.newCubeImage( filename, settings ) ``` ### Arguments `[string](string "string") filename` The filepath to a cubemap image file (or a [File](file "File"), [FileData](filedata "FileData"), or [ImageData](imagedata "ImageData")). `[table](table "table") settings (nil)` Optional table of settings to configure the cubemap image, containing the following fields: `[boolean](boolean "boolean") mipmaps (false)` True to make the image use mipmaps, false to disable them. Mipmaps will be automatically generated if the image isn't a [compressed texture](pixelformat "PixelFormat") format. `[boolean](boolean "boolean") linear (false)` True to treat the image's pixels as linear instead of sRGB, when [gamma correct rendering](love.graphics.isgammacorrect "love.graphics.isGammaCorrect") is enabled. Most images are authored as sRGB. ### Returns `[Image](image "Image") image` An cubemap Image object. Function -------- Creates a cubemap Image given a different image file for each cube face. ### Synopsis ``` image = love.graphics.newCubeImage( faces, settings ) ``` ### Arguments `[table](table "table") faces` A table containing 6 filepaths to images (or [File](file "File"), [FileData](filedata "FileData"), [ImageData](imagedata "ImageData"), or [CompressedImageData](compressedimagedata "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. `[table](table "table") settings (nil)` Optional table of settings to configure the cubemap image, containing the following fields: `[boolean](boolean "boolean") mipmaps (false)` True to make the image use mipmaps, false to disable them. Mipmaps will be automatically generated if the image isn't a [compressed texture](pixelformat "PixelFormat") format. `[boolean](boolean "boolean") linear (false)` True to treat the image's pixels as linear instead of sRGB, when [gamma correct rendering](love.graphics.isgammacorrect "love.graphics.isGammaCorrect") is enabled. Most images are authored as sRGB. ### Returns `[Image](image "Image") image` An cubemap Image object. See Also -------- * [love.graphics](love.graphics "love.graphics") * [Image](image "Image") * [TextureType](texturetype "TextureType") love love.window.getDimensions love.window.getDimensions ========================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** Use [love.graphics.getDimensions](love.graphics.getdimensions "love.graphics.getDimensions") or [love.window.getMode](love.window.getmode "love.window.getMode") instead. Gets the width and height of the window. Function -------- ### Synopsis ``` width, height = love.window.getDimensions( ) ``` ### Arguments None. ### Returns `[number](number "number") width` The width of the window. `[number](number "number") height` The height of the window. See Also -------- * [love.window](love.window "love.window") * [love.window.getWidth](love.window.getwidth "love.window.getWidth") * [love.window.getHeight](love.window.getheight "love.window.getHeight") * [love.window.setMode](love.window.setmode "love.window.setMode") love love.data.compress love.data.compress ================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** Deprecates [love.math.compress](love.math.compress "love.math.compress"). Compresses a string or data using a specific compression algorithm. This function, depending on the compression format and level, can be slow if called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). Some benchmarks are available [here](https://github.com/Cyan4973/lz4#user-content-benchmarks). Function -------- ### Synopsis ``` compressedData = love.data.compress( container, format, rawstring, level ) ``` ### Arguments `[ContainerType](containertype "ContainerType") container` What type to return the compressed data as. `[CompressedDataFormat](compresseddataformat "CompressedDataFormat") format` The format to use when compressing the string. `[string](string "string") rawstring` The raw (un-compressed) string to compress. `[number](number "number") level (-1)` The level of compression to use, between 0 and 9. -1 indicates the default level. The meaning of this argument depends on the compression format being used. ### Returns `[value](value "value") compressedData` [CompressedData](compresseddata "CompressedData")/[string](string "string") which contains the compressed version of rawstring. Function -------- ### Synopsis ``` compressedData = love.data.compress( container, format, data, level ) ``` ### Arguments `[ContainerType](containertype "ContainerType") container` What type to return the compressed data as. `[CompressedDataFormat](compresseddataformat "CompressedDataFormat") format` The format to use when compressing the data. `[Data](data "Data") data` A Data object containing the raw (un-compressed) data to compress. `[number](number "number") level (-1)` The level of compression to use, between 0 and 9. -1 indicates the default level. The meaning of this argument depends on the compression format being used. ### Returns `[value](value "value") compressedData` [CompressedData](compresseddata "CompressedData")/[string](string "string") which contains the compressed version of data. See Also -------- * [love.data](love.data "love.data") * [love.data.decompress](love.data.decompress "love.data.decompress") * [CompressedData](compresseddata "CompressedData") love love.mouse.setGrabbed love.mouse.setGrabbed ===================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [love.mouse.setGrab](love.mouse.setgrab "love.mouse.setGrab"). Grabs the mouse and confines it to the window. Function -------- ### Synopsis ``` love.mouse.setGrabbed( grab ) ``` ### Arguments `[boolean](boolean "boolean") grab` True to confine the mouse, false to let it leave the window. ### Returns Nothing. Examples -------- Toggles whether the mouse is grabbed by pressing tab, with the help of [love.mouse.isGrabbed](love.mouse.isgrabbed "love.mouse.isGrabbed"). ``` function love.keypressed(key) if key == "tab" then local state = not love.mouse.isGrabbed() -- the opposite of whatever it currently is love.mouse.setGrabbed(state) end end ``` See Also -------- * [love.mouse](love.mouse "love.mouse") * [love.mouse.isGrabbed](love.mouse.isgrabbed "love.mouse.isGrabbed") love Contact:getPosition Contact:getPosition =================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in that and later versions. Get the location of the contact point between two shapes. Function -------- ### Synopsis ``` cx, cy = Contact:getPosition( ) ``` ### Arguments None. ### Returns `[number](number "number") cx` The x coordinate of the contact point. `[number](number "number") cy` The y coordinate of the contact point. See Also -------- * [Contact](contact "Contact") love Joint:setCollideConnected Joint:setCollideConnected ========================= **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in that and later versions. Sets whether the connected Bodies should collide with each other. Function -------- ### Synopsis ``` Joint:setCollideConnected( collide ) ``` ### Arguments `[boolean](boolean "boolean") collide` True for the Bodies to collide, false otherwise. ### Returns Nothing. See Also -------- * [Joint](joint "Joint") love Body:applyForce Body:applyForce =============== Apply force to a Body. A force pushes a body in a direction. A body with with a larger mass will react less. The reaction also depends on how long a force is applied: since the force acts continuously over the entire timestep, a short timestep will only push the body for a short time. Thus forces are best used for many timesteps to give a continuous push to a body (like gravity). For a single push that is independent of timestep, it is better to use [Body:applyLinearImpulse](body-applylinearimpulse "Body:applyLinearImpulse"). If the position to apply the force is not given, it will act on the center of mass of the body. The part of the force not directed towards the center of mass will cause the body to spin (and depends on the rotational inertia). Note that the force components and position must be given in world coordinates. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in earlier versions. ### Synopsis ``` Body:applyForce( fx, fy ) ``` ### Arguments `[number](number "number") fx` The x component of force to apply to the center of mass. `[number](number "number") fy` The y component of force to apply to the center of mass. ### Returns Nothing. Function -------- ### Synopsis ``` Body:applyForce( fx, fy, x, y ) ``` ### Arguments `[number](number "number") fx` The x component of force to apply. `[number](number "number") fy` The y component of force to apply. `[number](number "number") x` The x position to apply the force. `[number](number "number") y` The y position to apply the force. ### Returns Nothing. See Also -------- * [Body](body "Body") * [Body:applyTorque](body-applytorque "Body:applyTorque") * [Body:applyLinearImpulse](body-applylinearimpulse "Body:applyLinearImpulse") love (File):getMode (File):getMode ============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the [FileMode](filemode "FileMode") the file has been opened with. Function -------- ### Synopsis ``` mode = File:getMode( ) ``` ### Arguments None. ### Returns `[FileMode](filemode "FileMode") mode` The mode this file has been opened with. See Also -------- * [File](file "File") * [FileMode](filemode "FileMode") love (File):close (File):close ============ Closes a [File](file "File"). Function -------- ### Synopsis ``` success = File:close( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") success` Whether closing was successful. See Also -------- * [File](file "File") love Decoder:getBits Decoder:getBits =============== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [Decoder:getBitDepth](decoder-getbitdepth "Decoder:getBitDepth"). Returns the number of bits per sample. Function -------- ### Synopsis ``` bitSize = Decoder:getBits( ) ``` ### Arguments None. ### Returns `[number](number "number") bitSize` Either 8, or 16. See Also -------- * [Decoder](decoder "Decoder") love Source:setPitch Source:setPitch =============== Sets the pitch of the Source. Function -------- ### Synopsis ``` Source:setPitch( pitch ) ``` ### Arguments `[number](number "number") pitch` Calculated with regard to 1 being the base pitch. Each reduction by 50 percent equals a pitch shift of -12 semitones (one octave reduction). Each doubling equals a pitch shift of 12 semitones (one octave increase). Zero is not a legal value. ### Returns Nothing. Examples -------- ``` function love.load() sound = love.audio.newSource("sound.wav")   -- Note that this code, as-is, will set the pitch to 1.0, as per the last line, and that's how sound:play() will play it back. sound:setPitch(0.5) -- One octave lower sound:setPitch(2) -- One octave higher sound:setPitch(1) -- Reset to normal pitch end ``` See Also -------- * [Source](source "Source") love Body:setAllowSleeping Body:setAllowSleeping ===================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been replaced by [Body:setSleepingAllowed](body-setsleepingallowed "Body:setSleepingAllowed"). Set the sleep behaviour of a body. A sleeping body is much more efficient to simulate than when awake. If sleeping is allowed, a body that has come to rest will sleep. Function -------- ### Synopsis ``` Body:setAllowSleeping( permission ) ``` ### Arguments `[boolean](boolean "boolean") permission` Permission for the body to sleep. ### Returns Nothing. See Also -------- * [Body](body "Body") love SpriteBatch:setq SpriteBatch:setq ================ **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been merged into [SpriteBatch:set](spritebatch-set "SpriteBatch:set"). Changes a sprite with a quad in the batch. This requires the identifier returned by add and addq. Function -------- ### Synopsis ``` SpriteBatch:setq( id, quad, x, y, r, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[number](number "number") id` The identifier of the sprite that will be changed. `[Quad](quad "Quad") quad` The quad used on the image of the batch. `[number](number "number") x` The position to draw the object (x-axis). `[number](number "number") y` The position to draw the object (y-axis). `[number](number "number") r (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Shear factor (x-axis). `[number](number "number") ky (0)` Shear factor (y-axis). ### Returns Nothing. See Also -------- * [SpriteBatch](spritebatch "SpriteBatch") * [SpriteBatch:add](spritebatch-add "SpriteBatch:add") * [SpriteBatch:addq](spritebatch-addq "SpriteBatch:addq") * [SpriteBatch:set](spritebatch-set "SpriteBatch:set") love CompressedImageData:getWidth CompressedImageData:getWidth ============================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the width of the CompressedImageData. Function -------- ### Synopsis ``` width = CompressedImageData:getWidth( ) ``` ### Arguments None. ### Returns `[number](number "number") width` The width of the CompressedImageData. Function -------- ### Synopsis ``` width = CompressedImageData:getWidth( level ) ``` ### Arguments `[number](number "number") level` A mipmap level. Must be in the range of [1, [CompressedImageData:getMipmapCount()](compressedimagedata-getmipmapcount "CompressedImageData:getMipmapCount")]. ### Returns `[number](number "number") width` The width of a specific mipmap level of the CompressedImageData. See Also -------- * [CompressedImageData](compressedimagedata "CompressedImageData") * [CompressedImageData:getHeight](compressedimagedata-getheight "CompressedImageData:getHeight") * [CompressedImageData:getMipmapCount](compressedimagedata-getmipmapcount "CompressedImageData:getMipmapCount") love love.math.setRandomSeed love.math.setRandomSeed ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Sets the seed of the random number generator using the specified integer number. This is called internally at startup, so you generally don't need to call it yourself. Function -------- ### Synopsis ``` love.math.setRandomSeed( seed ) ``` ### Arguments `[number](number "number") seed` The integer number with which you want to seed the randomization. Must be within the range of [0, 2^53 - 1]. ### Returns Nothing. ### Notes Due to Lua's use of double-precision floating point numbers, integer values above 2^53 cannot be accurately represented. Use the other variant of the function if you want to use a larger number. Function -------- Combines two 32-bit integer numbers into a 64-bit integer value and sets the seed of the random number generator using the value. ### Synopsis ``` love.math.setRandomSeed( low, high ) ``` ### Arguments `[number](number "number") low` The lower 32 bits of the seed value. Must be within the range of [0, 2^32 - 1]. `[number](number "number") high` The higher 32 bits of the seed value. Must be within the range of [0, 2^32 - 1]. ### Returns Nothing. Examples -------- ### Set a random seed ``` love.math.setRandomSeed(love.timer.getTime()) ``` See Also -------- * [love.math](love.math "love.math") * [love.math.getRandomSeed](love.math.getrandomseed "love.math.getRandomSeed") love BezierCurve BezierCurve =========== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This type is not supported in earlier versions. A Bézier curve object that can evaluate and render Bézier curves of arbitrary degree. For more information on Bézier curves check [this great article on Wikipedia](https://en.wikipedia.org/wiki/Bezier_curve). Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.math.newBezierCurve](love.math.newbeziercurve "love.math.newBezierCurve") | Creates a new **BezierCurve** object. | 0.9.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [BezierCurve:evaluate](beziercurve-evaluate "BezierCurve:evaluate") | Evaluate Bézier curve at parameter t. | 0.9.0 | | | [BezierCurve:getControlPoint](beziercurve-getcontrolpoint "BezierCurve:getControlPoint") | Get coordinates of the i-th control point. | 0.9.0 | | | [BezierCurve:getControlPointCount](beziercurve-getcontrolpointcount "BezierCurve:getControlPointCount") | Get the number of control points in the Bézier curve. | 0.9.0 | | | [BezierCurve:getDegree](beziercurve-getdegree "BezierCurve:getDegree") | Get degree of the Bézier curve. | 0.9.0 | | | [BezierCurve:getDerivative](beziercurve-getderivative "BezierCurve:getDerivative") | Get derivate of the Bézier curve. | 0.9.0 | | | [BezierCurve:getSegment](beziercurve-getsegment "BezierCurve:getSegment") | Gets a BezierCurve that corresponds to the specified segment of this BezierCurve. | 0.10.0 | | | [BezierCurve:insertControlPoint](beziercurve-insertcontrolpoint "BezierCurve:insertControlPoint") | Insert control point after the i-th control point. | 0.9.0 | | | [BezierCurve:removeControlPoint](beziercurve-removecontrolpoint "BezierCurve:removeControlPoint") | Removes the specified control point. | 0.10.0 | | | [BezierCurve:render](beziercurve-render "BezierCurve:render") | Get a list of points on the curve. | 0.9.0 | | | [BezierCurve:renderSegment](beziercurve-rendersegment "BezierCurve:renderSegment") | Get a list of points on a specific part of the curve. | 0.10.0 | | | [BezierCurve:rotate](beziercurve-rotate "BezierCurve:rotate") | Rotate the Bézier curve. | 0.9.0 | | | [BezierCurve:scale](beziercurve-scale "BezierCurve:scale") | Scale the Bézier curve. | 0.9.0 | | | [BezierCurve:setControlPoint](beziercurve-setcontrolpoint "BezierCurve:setControlPoint") | Set coordinates of the i-th control point. | 0.9.0 | | | [BezierCurve:translate](beziercurve-translate "BezierCurve:translate") | Move the Bézier curve. | 0.9.0 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Supertypes ---------- * [Object](object "Object") See Also -------- * [love.math](love.math "love.math")
programming_docs
love ColorMode ColorMode ========= **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This enum is not supported in that and later versions. Controls whether images will be affected by the current color. Constants --------- modulate Images (etc) will be affected by the current color. replace Replace color mode. Images (etc) will not be affected by current color. combine (since 0.8.0) Colorize images (etc) with the current color. While 'modulate' works like a filter that absorbs colors that differ from the current color (possibly to a point where a color channel is entirely absorbed), 'combine' tints the image in a way that preserves a hint of the original colors. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setColorMode](love.graphics.setcolormode "love.graphics.setColorMode") * [love.graphics.getColorMode](love.graphics.getcolormode "love.graphics.getColorMode") love RecordingDevice:getChannelCount RecordingDevice:getChannelCount =============================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the number of channels currently being recorded (mono or stereo). Function -------- ### Synopsis ``` channels = RecordingDevice:getChannelCount( ) ``` ### Arguments None. ### Returns `[number](number "number") channels` The number of channels being recorded (1 for mono, 2 for stereo). See Also -------- * [RecordingDevice](recordingdevice "RecordingDevice") * [RecordingDevice:start](recordingdevice-start "RecordingDevice:start") love love.window.setIcon love.window.setIcon =================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Sets the window icon until the game is quit. Not all operating systems support very large icon images. Function -------- ### Synopsis ``` success = love.window.setIcon( imagedata ) ``` ### Arguments `[ImageData](imagedata "ImageData") imagedata` The window icon image. ### Returns `[boolean](boolean "boolean") success` Whether the icon has been set successfully. See Also -------- * [love.window](love.window "love.window") * [love.window.getIcon](love.window.geticon "love.window.getIcon") love love.errhand love.errhand ============ | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | This function has been renamed to [love.errorhandler](love.errorhandler "love.errorhandler"). | The error handler, used to display error messages. Function -------- ### Synopsis ``` love.errhand( msg ) ``` ### Arguments `[string](string "string") msg` The error message. ### Returns Nothing. Examples -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. ### The default function used if you don't supply your own. ``` local function error_printer(msg, layer) print((debug.traceback("Error: " .. tostring(msg), 1+(layer or 1)):gsub("\n[^\n]+$", ""))) end   function love.errhand(msg) msg = tostring(msg)   error_printer(msg, 2)   if not love.window or not love.graphics or not love.event then return end   if not love.graphics.isCreated() or not love.window.isOpen() then local success, status = pcall(love.window.setMode, 800, 600) if not success or not status then return end end   -- Reset state. if love.mouse then love.mouse.setVisible(true) love.mouse.setGrabbed(false) love.mouse.setRelativeMode(false) end if love.joystick then -- Stop all joystick vibrations. for i,v in ipairs(love.joystick.getJoysticks()) do v:setVibration() end end if love.audio then love.audio.stop() end love.graphics.reset() local font = love.graphics.setNewFont(math.floor(love.window.toPixels(14)))   love.graphics.setBackgroundColor(89, 157, 220) love.graphics.setColor(255, 255, 255, 255)   local trace = debug.traceback()   love.graphics.clear(love.graphics.getBackgroundColor()) love.graphics.origin()   local err = {}   table.insert(err, "Error\n") table.insert(err, msg.."\n\n")   for l in string.gmatch(trace, "(.-)\n") do if not string.match(l, "boot.lua") then l = string.gsub(l, "stack traceback:", "Traceback\n") table.insert(err, l) end end   local p = table.concat(err, "\n")   p = string.gsub(p, "\t", "") p = string.gsub(p, "%[string \"(.-)\"%]", "%1")   local function draw() local pos = love.window.toPixels(70) love.graphics.clear(love.graphics.getBackgroundColor()) love.graphics.printf(p, pos, pos, love.graphics.getWidth() - pos) love.graphics.present() end   while true do love.event.pump()   for e, a, b, c in love.event.poll() do if e == "quit" then return elseif e == "keypressed" and a == "escape" then return elseif e == "touchpressed" then local name = love.window.getTitle() if #name == 0 or name == "Untitled" then name = "Game" end local buttons = {"OK", "Cancel"} local pressed = love.window.showMessageBox("Quit "..name.."?", "", buttons) if pressed == 1 then return end end end   draw()   if love.timer then love.timer.sleep(0.1) end end   end ``` **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier or later versions. ### The default function used if you don't supply your own. ``` local function error_printer(msg, layer) print((debug.traceback("Error: " .. tostring(msg), 1+(layer or 1)):gsub("\n[^\n]+$", ""))) end   function love.errhand(msg) msg = tostring(msg)   error_printer(msg, 2)   if not love.window or not love.graphics or not love.event then return end   if not love.graphics.isCreated() or not love.window.isCreated() then local success, status = pcall(love.window.setMode, 800, 600) if not success or not status then return end end   -- Reset state. if love.mouse then love.mouse.setVisible(true) love.mouse.setGrabbed(false) end if love.joystick then -- Stop all joystick vibrations. for i,v in ipairs(love.joystick.getJoysticks()) do v:setVibration() end end if love.audio then love.audio.stop() end love.graphics.reset() local font = love.graphics.setNewFont(math.floor(love.window.toPixels(14)))   local sRGB = select(3, love.window.getMode()).srgb if sRGB and love.math then love.graphics.setBackgroundColor(love.math.gammaToLinear(89, 157, 220)) else love.graphics.setBackgroundColor(89, 157, 220) end   love.graphics.setColor(255, 255, 255, 255)   local trace = debug.traceback()   love.graphics.clear() love.graphics.origin()   local err = {}   table.insert(err, "Error\n") table.insert(err, msg.."\n\n")   for l in string.gmatch(trace, "(.-)\n") do if not string.match(l, "boot.lua") then l = string.gsub(l, "stack traceback:", "Traceback\n") table.insert(err, l) end end   local p = table.concat(err, "\n")   p = string.gsub(p, "\t", "") p = string.gsub(p, "%[string \"(.-)\"%]", "%1")   local function draw() local pos = love.window.toPixels(70) love.graphics.clear() love.graphics.printf(p, pos, pos, love.graphics.getWidth() - pos) love.graphics.present() end   while true do love.event.pump()   for e, a, b, c in love.event.poll() do if e == "quit" then return end if e == "keypressed" and a == "escape" then return end end   draw()   if love.timer then love.timer.sleep(0.1) end end end ``` **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0") and removed in LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This variant is not supported in earlier or later versions. ### The default function used if you don't supply your own. ``` local function error_printer(msg, layer) print((debug.traceback("Error: " .. tostring(msg), 1+(layer or 1)):gsub("\n[^\n]+$", ""))) end   function love.errhand(msg) msg = tostring(msg)   error_printer(msg, 2)   if not love.window or not love.graphics or not love.event then return end   if not love.graphics.isCreated() or not love.window.isCreated() then if not pcall(love.window.setMode, 800, 600) then return end end   -- Reset state. if love.mouse then love.mouse.setVisible(true) love.mouse.setGrabbed(false) end if love.joystick then for i,v in ipairs(love.joystick.getJoysticks()) do v:setVibration() -- Stop all joystick vibrations. end end if love.audio then love.audio.stop() end love.graphics.reset() love.graphics.setBackgroundColor(89, 157, 220) local font = love.graphics.setNewFont(14)   love.graphics.setColor(255, 255, 255, 255)   local trace = debug.traceback()   love.graphics.clear() love.graphics.origin()   local err = {}   table.insert(err, "Error\n") table.insert(err, msg.."\n\n")   for l in string.gmatch(trace, "(.-)\n") do if not string.match(l, "boot.lua") then l = string.gsub(l, "stack traceback:", "Traceback\n") table.insert(err, l) end end   local p = table.concat(err, "\n")   p = string.gsub(p, "\t", "") p = string.gsub(p, "%[string \"(.-)\"%]", "%1")   local function draw() love.graphics.clear() love.graphics.printf(p, 70, 70, love.graphics.getWidth() - 70) love.graphics.present() end   while true do love.event.pump()   for e, a, b, c in love.event.poll() do if e == "quit" then return end if e == "keypressed" and a == "escape" then return end end   draw()   if love.timer then love.timer.sleep(0.1) end end   end ``` **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in that and later versions. ### The default function used if you don't supply your own. ``` local function error_printer(msg, layer) print((debug.traceback("Error: " .. tostring(msg), 1+(layer or 1)):gsub("\n[^\n]+$", ""))) end   function love.errhand(msg) msg = tostring(msg)   error_printer(msg, 2)   if not love.graphics or not love.event or not love.graphics.isCreated() then return end   -- Load. if love.audio then love.audio.stop() end love.graphics.reset() love.graphics.setBackgroundColor(89, 157, 220) local font = love.graphics.newFont(14) love.graphics.setFont(font)   love.graphics.setColor(255, 255, 255, 255)   local trace = debug.traceback()   love.graphics.clear()   local err = {}   table.insert(err, "Error\n") table.insert(err, msg.."\n\n")   for l in string.gmatch(trace, "(.-)\n") do if not string.match(l, "boot.lua") then l = string.gsub(l, "stack traceback:", "Traceback\n") table.insert(err, l) end end   local p = table.concat(err, "\n")   p = string.gsub(p, "\t", "") p = string.gsub(p, "%[string \"(.-)\"%]", "%1")   local function draw() love.graphics.clear() love.graphics.printf(p, 70, 70, love.graphics.getWidth() - 70) love.graphics.present() end   draw()   local e, a, b, c while true do e, a, b, c = love.event.wait()   if e == "quit" then return end if e == "keypressed" and a == "escape" then return end   draw()   end   end ``` See Also -------- * [love](love "love") love Fixture:setDensity Fixture:setDensity ================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Sets the density of the fixture. Call [Body:resetMassData](body-resetmassdata "Body:resetMassData") if this needs to take effect immediately. Function -------- ### Synopsis ``` Fixture:setDensity( density ) ``` ### Arguments `[number](number "number") density` The fixture density in kilograms per square meter. ### Returns Nothing. See Also -------- * [Fixture](fixture "Fixture") * [Fixture:getDensity](fixture-getdensity "Fixture:getDensity") love ParticleSystem:setRelativeRotation ParticleSystem:setRelativeRotation ================================== **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. Sets whether particle angles and rotations are relative to their velocities. If enabled, particles are aligned to the angle of their velocities and rotate relative to that angle. Function -------- ### Synopsis ``` ParticleSystem:setRelativeRotation( enable ) ``` ### Arguments `[boolean](boolean "boolean") enable` True to enable relative particle rotation, false to disable it. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:hasRelativeRotation](particlesystem-hasrelativerotation "ParticleSystem:hasRelativeRotation") love RecordingDevice:start RecordingDevice:start ===================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Begins recording audio using this device. Function -------- ### Synopsis ``` success = RecordingDevice:start( samplecount, samplerate, bitdepth, channels ) ``` ### Arguments `[number](number "number") samplecount` The maximum number of samples to store in an internal ring buffer when recording. [RecordingDevice:getData](recordingdevice-getdata "RecordingDevice:getData") clears the internal buffer when called. `[number](number "number") samplerate (8000)` The number of samples per second to store when recording. `[number](number "number") bitdepth (16)` The number of bits per sample. `[number](number "number") channels (1)` Whether to record in mono or stereo. Most microphones don't support more than 1 channel. ### Returns `[boolean](boolean "boolean") success` True if the device successfully began recording using the specified parameters, false if not. Notes ----- A ring buffer is used internally to store recorded data until [RecordingDevice:getData](recordingdevice-getdata "RecordingDevice:getData") or [RecordingDevice:stop](recordingdevice-stop "RecordingDevice:stop") are called – the former clears the buffer. If the buffer completely fills up before getData or stop are called, the oldest data that doesn't fit into the buffer will be lost. See Also -------- * [RecordingDevice](recordingdevice "RecordingDevice") * [RecordingDevice:getData](recordingdevice-getdata "RecordingDevice:getData") * [RecordingDevice:stop](recordingdevice-stop "RecordingDevice:stop") love World:getContactList World:getContactList ==================== Not stable in 0.8.0. You may experience crashing. | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | This function has been renamed to [World:getContacts](world-getcontacts "World:getContacts"). | **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns a table with all contacts. Function -------- ### Synopsis ``` contacts = World:getContactList( ) ``` ### Arguments None. ### Returns `[table](table "table") contacts` A [sequence](sequence "sequence") with all contacts. See Also -------- * [World](world "World") love RevoluteJoint:getUpperLimit RevoluteJoint:getUpperLimit =========================== Gets the upper limit. Function -------- ### Synopsis ``` upper = RevoluteJoint:getUpperLimit( ) ``` ### Arguments None. ### Returns `[number](number "number") upper` The upper limit, in radians. See Also -------- * [RevoluteJoint](revolutejoint "RevoluteJoint") love enet.host:check events enet.host:check events ====================== Checks for any queued events and dispatches one if available. Returns the associated [event](enet.event "enet.event") if something was dispatched, otherwise [nil](nil "nil"). Function -------- ### Synopsis ``` event = host:check_events() ``` ### Arguments None. ### Returns `[table](table "table") event` An [event](enet.event "enet.event") or nil if no events are available. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.event](enet.event "enet.event") * [enet.host:service](enet.host-service "enet.host:service") love love.audio.getNumSources love.audio.getNumSources ======================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [love.audio.getSourceCount](love.audio.getsourcecount "love.audio.getSourceCount"). Gets the current number of simultaneously playing sources. Function -------- ### Synopsis ``` numSources = love.audio.getNumSources( ) ``` ### Arguments None. ### Returns `[number](number "number") numSources` The current number of simultaneously playing sources. See Also -------- * [love.audio](love.audio "love.audio") love love.math.isConvex love.math.isConvex ================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Checks whether a polygon is convex. [PolygonShapes](polygonshape "PolygonShape") in [love.physics](love.physics "love.physics"), some forms of [Meshes](mesh "Mesh"), and polygons drawn with [love.graphics.polygon](love.graphics.polygon "love.graphics.polygon") must be simple convex polygons. Function -------- ### Synopsis ``` convex = love.math.isConvex( vertices ) ``` ### Arguments `[table](table "table") vertices` The vertices of the polygon as a table in the form of `{x1, y1, x2, y2, x3, y3, ...}`. ### Returns `[boolean](boolean "boolean") convex` Whether the given polygon is convex. Function -------- ### Synopsis ``` convex = love.math.isConvex( x1, y1, x2, y2, x3, y3, ... ) ``` ### Arguments `[number](number "number") x1` The position of the first vertex of the polygon on the x-axis. `[number](number "number") y1` The position of the first vertex of the polygon on the y-axis. `[number](number "number") x2` The position of the second vertex of the polygon on the x-axis. `[number](number "number") y2` The position of the second vertex of the polygon on the y-axis. `[number](number "number") x3` The position of the third vertex of the polygon on the x-axis. `[number](number "number") y3` The position of the third vertex of the polygon on the y-axis. ### Returns `[boolean](boolean "boolean") convex` Whether the given polygon is convex. See Also -------- * [love.math.triangulate](love.math.triangulate "love.math.triangulate") * [love.math](love.math "love.math") love Fixture:setGroupIndex Fixture:setGroupIndex ===================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Sets the group the fixture belongs to. Fixtures with the same group will always collide if the group is positive or never collide if it's negative. The group zero means no group. The groups range from -32768 to 32767. Function -------- ### Synopsis ``` Fixture:setGroupIndex( group ) ``` ### Arguments `[number](number "number") group` The group as an integer from -32768 to 32767. ### Returns Nothing. See Also -------- * [Fixture](fixture "Fixture") * [Fixture:getGroupIndex](fixture-getgroupindex "Fixture:getGroupIndex") love DistanceJoint:setLength DistanceJoint:setLength ======================= Sets the equilibrium distance between the two Bodies. Function -------- ### Synopsis ``` DistanceJoint:setLength( l ) ``` ### Arguments `[number](number "number") l` The length between the two Bodies. ### Returns Nothing. See Also -------- * [DistanceJoint](distancejoint "DistanceJoint") love RevoluteJoint:enableMotor RevoluteJoint:enableMotor ========================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [RevoluteJoint:setMotorEnabled](revolutejoint-setmotorenabled "RevoluteJoint:setMotorEnabled"). Starts or stops the joint motor. Function -------- ### Synopsis ``` RevoluteJoint:enableMotor( enable ) ``` ### Arguments `[boolean](boolean "boolean") enable` True to enable, false to disable. ### Returns Nothing. See Also -------- * [RevoluteJoint](revolutejoint "RevoluteJoint")
programming_docs
love ParticleSystem:setGravity ParticleSystem:setGravity ========================= **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been replaced by [ParticleSystem:setLinearAcceleration](particlesystem-setlinearacceleration "ParticleSystem:setLinearAcceleration"). Sets the gravity affecting the particles (acceleration along the y-axis). Every particle created will have a gravity between min and max. Function -------- ### Synopsis ``` ParticleSystem:setGravity( min, max ) ``` ### Arguments `[number](number "number") min` The minimum gravity. `[number](number "number") max (min)` The maximum gravity. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love CursorType CursorType ========== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This enum is not supported in earlier versions. Types of hardware cursors. Not all cursor types are available on all operating systems. If an unsupported type is used, it will default to something else. Constants --------- image The cursor is using a custom image. arrow An arrow pointer. ibeam An I-beam, normally used when mousing over editable or selectable text. wait Wait graphic. waitarrow Small wait cursor with an arrow pointer. crosshair Crosshair symbol. sizenwse Double arrow pointing to the top-left and bottom-right. sizenesw Double arrow pointing to the top-right and bottom-left. sizewe Double arrow pointing left and right. sizens Double arrow pointing up and down. sizeall Four-pointed arrow pointing up, down, left, and right. no Slashed circle or crossbones. hand Hand symbol. Notes ----- See Also -------- * [love.mouse](love.mouse "love.mouse") * [Cursor](cursor "Cursor") * [Cursor:getType](cursor-gettype "Cursor:getType") * [love.mouse.newCursor](love.mouse.newcursor "love.mouse.newCursor") love PrismaticJoint:getMaxMotorForce PrismaticJoint:getMaxMotorForce =============================== Gets the maximum motor force. Function -------- ### Synopsis ``` f = PrismaticJoint:getMaxMotorForce( ) ``` ### Arguments None. ### Returns `[number](number "number") f` The maximum motor force, usually in N. See Also -------- * [PrismaticJoint](prismaticjoint "PrismaticJoint") love Data:getString Data:getString ============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the full Data as a [string](string "String"). Function -------- ### Synopsis ``` data = Data:getString( ) ``` ### Arguments None. ### Returns `[string](string "string") data` The raw data. Notes ----- The returned string count towards of LuaJIT 1GB/2GB memory limit, in some platforms. See Also -------- * [Data](data "Data") love Text:getHeight Text:getHeight ============== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets the height of the text in pixels. Function -------- ### Synopsis ``` height = Text:getHeight( ) ``` ### Arguments None. ### Returns `[number](number "number") height` The height of the text. If multiple sub-strings have been added with [Text:add](text-add "Text:add"), the height of the last sub-string is returned. Function -------- Gets the height of a specific sub-string that was previously added to the Text object. ### Synopsis ``` height = Text:getHeight( index ) ``` ### Arguments `[number](number "number") index` An index number returned by [Text:add](text-add "Text:add") or [Text:addf](text-addf "Text:addf"). ### Returns `[number](number "number") height` The height of the sub-string (before scaling and other transformations). See Also -------- * [Text](text "Text") * [Text:getWidth](text-getwidth "Text:getWidth") * [Text:set](text-set "Text:set") * [Text:setf](text-setf "Text:setf") * [Text:add](text-add "Text:add") * [Text:addf](text-addf "Text:addf") love love.graphics.isSupported love.graphics.isSupported ========================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** It has been replaced by [love.graphics.getSupported](love.graphics.getsupported "love.graphics.getSupported"). Checks if certain graphics functions can be used. Older and low-end systems do not always support all graphics extensions. Function -------- ### Synopsis ``` isSupported = love.graphics.isSupported( support1, support2, support3, ... ) ``` ### Arguments `[GraphicsFeature](graphicsfeature "GraphicsFeature") supportN` The graphics feature to check for. ### Returns `[boolean](boolean "boolean") isSupported` True if everything is supported, false otherwise. Examples -------- ### Error smoothly if the graphics card does not support canvases ``` assert(love.graphics.isSupported("canvas"), "Your graphics card does not support canvases, sorry!") ``` See Also -------- * [love.graphics](love.graphics "love.graphics") love love.graphics.newVideo love.graphics.newVideo ====================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Creates a new drawable [Video](video "Video"). Currently only Ogg Theora video files are supported. This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- ### Synopsis ``` video = love.graphics.newVideo( filename ) ``` ### Arguments `[string](string "string") filename` The file path to the Ogg Theora video file. ### Returns `[Video](video "Video") video` A new Video. Function -------- ### Synopsis ``` video = love.graphics.newVideo( videostream ) ``` ### Arguments `[VideoStream](videostream "VideoStream") videostream` A video stream object. ### Returns `[Video](video "Video") video` A new Video. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` video = love.graphics.newVideo( filename, settings ) ``` ### Arguments `[string](string "string") filename` The file path to the Ogg Theora video file (or [VideoStream](videostream "VideoStream")). `[table](table "table") settings` A table containing the following fields: `[boolean](boolean "boolean") audio (false)` Whether to try to load the video's audio into an audio [Source](source "Source"). If not explicitly set to true or false, it will try without causing an error if the video has no audio. `[number](number "number") dpiscale ([love.graphics.getDPIScale](love.graphics.getdpiscale "love.graphics.getDPIScale")())` The DPI scale factor of the video. ### Returns `[Video](video "Video") video` A new Video. Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0") and removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier or later versions. ### Synopsis ``` video = love.graphics.newVideo( filename, loadaudio ) ``` ### Arguments `[string](string "string") filename` The file path to the Ogg Theora video file. `[boolean](boolean "boolean") loadaudio (nil)` Whether to try to load the video's audio into an audio [Source](source "Source"). If not explicitly set to true or false, it will try without causing an error if the video has no audio. ### Returns `[Video](video "Video") video` A new Video. Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0") and removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier or later versions. ### Synopsis ``` video = love.graphics.newVideo( videostream, loadaudio ) ``` ### Arguments `[VideoStream](videostream "VideoStream") videostream` A video stream object. `[boolean](boolean "boolean") loadaudio (nil)` Whether to try to load the video's audio into an audio [Source](source "Source"). If not explicitly set to true or false, it will try without causing an error if the video has no audio. ### Returns `[Video](video "Video") video` A new Video. Examples -------- Load and play a video. ``` function love.load() video = love.graphics.newVideo("myvideo.ogv") video:play() end   function love.draw() love.graphics.draw(video, 0, 0) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [Video](video "Video") * [love.graphics.draw](love.graphics.draw "love.graphics.draw") love Canvas:generateMipmaps Canvas:generateMipmaps ====================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Generates mipmaps for the Canvas, based on the contents of the highest-resolution mipmap level. The Canvas must be [created](love.graphics.newcanvas "love.graphics.newCanvas") with mipmaps set to a [MipmapMode](mipmapmode "MipmapMode") other than "none" for this function to work. It should only be called while the Canvas is not the active render target. If the mipmap mode is set to "auto", this function is automatically called inside [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas") when switching from this Canvas to another Canvas or to the main screen. Function -------- ### Synopsis ``` Canvas:generateMipmaps( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Canvas](canvas "Canvas") * [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") * [Canvas:getMipmapMode](canvas-getmipmapmode "Canvas:getMipmapMode") love love.graphics.getFont love.graphics.getFont ===================== Gets the current Font object. Function -------- **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in earlier versions. ### Synopsis ``` font = love.graphics.getFont( ) ``` ### Arguments None. ### Returns `[Font](font "Font") font` The current Font. Automatically creates and sets the default font, if none is set yet. Function -------- **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in that and later versions. ### Synopsis ``` font = love.graphics.getFont( ) ``` ### Arguments None. ### Returns `[Font](font "Font") font` The current Font, or nil if none is set. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setFont](love.graphics.setfont "love.graphics.setFont") love love.hasDeprecationOutput love.hasDeprecationOutput ========================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets whether LÖVE displays warnings when using deprecated functionality. It is disabled by default in [fused mode](love.filesystem.isfused "love.filesystem.isFused"), and enabled by default otherwise. When deprecation output is enabled, the first use of a formally deprecated LÖVE API will show a message at the bottom of the screen for a short time, and print the message to the console. Function -------- ### Synopsis ``` enabled = love.hasDeprecationOutput( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") enabled` Whether deprecation output is enabled. See Also -------- * [love](love "love") * [love.setDeprecationOutput](love.setdeprecationoutput "love.setDeprecationOutput") love PixelEffect PixelEffect =========== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [Shader](shader "Shader"). A PixelEffect is used for advanced hardware-accelerated pixel manipulation. These effects are written in a language based on GLSL (OpenGL Shading Language) with a few things simplified for easier coding. Potential uses for pixel effects include HDR/bloom, motion blur, grayscale/invert/sepia/any kind of color effect, reflection/refraction, distortions, and much more! Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.graphics.newPixelEffect](love.graphics.newpixeleffect "love.graphics.newPixelEffect") | Creates a new **PixelEffect**. | 0.8.0 | 0.9.0 | Functions --------- | | | | | | --- | --- | --- | --- | | [PixelEffect:getWarnings](pixeleffect-getwarnings "PixelEffect:getWarnings") | Gets warning messages (if any). | 0.8.0 | 0.9.0 | | [PixelEffect:send](pixeleffect-send "PixelEffect:send") | Sends one or more values to the pixel effect. | 0.8.0 | 0.9.0 | Supertypes ---------- * [Object](object "Object") See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setPixelEffect](love.graphics.setpixeleffect "love.graphics.setPixelEffect") love ParticleSystem:setImage ParticleSystem:setImage ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [ParticleSystem:setSprite](particlesystem-setsprite "ParticleSystem:setSprite"). **Removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** Use [ParticleSystem:setTexture](particlesystem-settexture "ParticleSystem:setTexture") instead. Sets the image to be used for the particles. Function -------- ### Synopsis ``` ParticleSystem:setImage( image ) ``` ### Arguments `[Image](image "Image") image` An Image to use for the particles. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love Text:setf Text:setf ========= **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Replaces the contents of the Text object with a new formatted string. Function -------- ### Synopsis ``` Text:setf( textstring, wraplimit, alignmode ) ``` ### Arguments `[string](string "string") textstring` The new string of text to use. `[number](number "number") wraplimit` The maximum width in pixels of the text before it gets automatically wrapped to a new line. `[AlignMode](alignmode "AlignMode") align` The alignment of the text. ### Returns Nothing. Function -------- ### Synopsis ``` Text:setf( coloredtext, wraplimit, alignmode ) ``` ### Arguments `[table](table "table") coloredtext` A table containing colors and strings to use as the new text, in the form of `{color1, string1, color2, string2, ...}`. `[table](table "table") 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}`. `[string](string "string") string1` A string of text which has a color specified by the previous color. `[table](table "table") 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}`. `[string](string "string") string2` A string of text which has a color specified by the previous color. `[tables and strings](https://love2d.org/w/index.php?title=tables_and_strings&action=edit&redlink=1 "tables and strings (page does not exist)") ...` Additional colors and strings. `[number](number "number") wraplimit` The maximum width in pixels of the text before it gets automatically wrapped to a new line. `[AlignMode](alignmode "AlignMode") align` The alignment of the text. ### Returns Nothing. ### Notes The color set by [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor") will be combined (multiplied) with the colors of the text, when drawing the Text object. See Also -------- * [Text](text "Text") * [Text:set](text-set "Text:set") * [Text:add](text-add "Text:add") * [Text:addf](text-addf "Text:addf") * [Text:clear](text-clear "Text:clear") love love.keyboard.isScancodeDown love.keyboard.isScancodeDown ============================ **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Checks whether the specified [Scancodes](scancode "Scancode") are pressed. Not to be confused with [love.keypressed](love.keypressed "love.keypressed") or [love.keyreleased](love.keyreleased "love.keyreleased"). Unlike regular [KeyConstants](keyconstant "KeyConstant"), Scancodes are keyboard layout-independent. The scancode "w" is used if the key in the same place as the "w" key on an [American keyboard](https://en.wikipedia.org/wiki/British_and_American_keyboards#/media/File:KB_United_States-NoAltGr.svg) is pressed, no matter what the key is labelled or what the user's operating system settings are. Function -------- ### Synopsis ``` down = love.keyboard.isScancodeDown( scancode, ... ) ``` ### Arguments `[Scancode](scancode "Scancode") scancode` A Scancode to check. `[Scancode](scancode "Scancode") ...` Additional Scancodes to check. ### Returns `[boolean](boolean "boolean") down` True if any supplied Scancode is down, false if not. See Also -------- * [love.keyboard](love.keyboard "love.keyboard") * [love.keyboard.isDown](love.keyboard.isdown "love.keyboard.isDown") * [love.keyboard.getKeyFromScancode](love.keyboard.getkeyfromscancode "love.keyboard.getKeyFromScancode") * [love.keyboard.getScancodeFromKey](love.keyboard.getscancodefromkey "love.keyboard.getScancodeFromKey") * [love.keypressed](love.keypressed "love.keypressed") * [love.keyreleased](love.keyreleased "love.keyreleased") love love.keyboard.setKeyRepeat love.keyboard.setKeyRepeat ========================== Enables or disables key repeat for [love.keypressed](love.keypressed "love.keypressed"). It is disabled by default. Function -------- **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.keyboard.setKeyRepeat( enable ) ``` ### Arguments `[boolean](boolean "boolean") enable` Whether repeat keypress events should be enabled when a key is held down. ### Returns Nothing. ### Notes The interval between repeats depends on the user's system settings. This function doesn't affect whether [love.textinput](love.textinput "love.textinput") is called multiple times while a key is held down. Function -------- **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in that and later versions. Enables key repeating and sets the delay and interval. ### Synopsis ``` love.keyboard.setKeyRepeat( delay, interval ) ``` ### Arguments `[number](number "number") delay` The amount of time before repeating the key (in seconds). 0 disables key repeat. `[number](number "number") interval` The amount of time between repeats (in seconds) ### Returns Nothing. Examples -------- Hold left or right to change the position. ``` function love.load() love.keyboard.setKeyRepeat(true) x = 50 end   function love.keypressed(key, scancode, isrepeat) if key == "right" then x = (x + 80) % love.graphics.getWidth() elseif key == "left" then x = (x - 80) % love.graphics.getWidth() end end   function love.draw() love.graphics.circle("fill", x, 100, 50, 50) end ``` See Also -------- * [love.keyboard](love.keyboard "love.keyboard") * [love.keyboard.hasKeyRepeat](love.keyboard.haskeyrepeat "love.keyboard.hasKeyRepeat") * [love.keypressed](love.keypressed "love.keypressed")
programming_docs
love Body:getLinearVelocityFromWorldPoint Body:getLinearVelocityFromWorldPoint ==================================== Get the linear velocity of a point on the body. The linear velocity for a point on the body is the velocity of the body center of mass plus the velocity at that point from the body spinning. The point on the body must given in world coordinates. Use [Body:getLinearVelocityFromLocalPoint](body-getlinearvelocityfromlocalpoint "Body:getLinearVelocityFromLocalPoint") to specify this with local coordinates. Function -------- ### Synopsis ``` vx, vy = Body:getLinearVelocityFromWorldPoint( x, y ) ``` ### Arguments `[number](number "number") x` The x position to measure velocity. `[number](number "number") y` The y position to measure velocity. ### Returns `[number](number "number") vx` The x component of velocity at point (x,y). `[number](number "number") vy` The y component of velocity at point (x,y). See Also -------- * [Body](body "Body") love love.font.newFontData love.font.newFontData ===================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0") and removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier or later versions. Creates a new FontData. Function -------- ### Synopsis ``` fontData = love.font.newFontData( rasterizer ) ``` ### Arguments `[Rasterizer](rasterizer "Rasterizer") rasterizer` The Rasterizer containing the font. ### Returns `[FontData](fontdata "FontData") fontData` The FontData. See Also -------- * [love.font](love.font "love.font") * [FontData](fontdata "FontData") love Transform:setMatrix Transform:setMatrix =================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Directly sets the Transform's internal 4x4 transformation matrix. Function -------- ### Synopsis ``` transform = Transform:setMatrix( e1_1, e1_2, ..., e4_4 ) ``` ### Arguments `[number](number "number") e1_1` The first column of the first row of the matrix. `[number](number "number") e1_2` The second column of the first row of the matrix. `[number](number "number") ...` Additional matrix elements. `[number](number "number") e4_4` The fourth column of the fourth row of the matrix. ### Returns `[Transform](transform "Transform") transform` The Transform object the method was called on. Allows easily chaining Transform methods. Function -------- ### Synopsis ``` transform = Transform:setMatrix( layout, e1_1, e1_2, ..., e4_4 ) ``` ### Arguments `[MatrixLayout](matrixlayout "MatrixLayout") layout` How to interpret the matrix element arguments (row-major or column-major). `[number](number "number") e1_1` The first column of the first row of the matrix. `[number](number "number") e1_2` The second column of the first row or the first column of the second row of the matrix, depending on the specified layout. `[number](number "number") ...` Additional matrix elements. `[number](number "number") e4_4` The fourth column of the fourth row of the matrix. ### Returns `[Transform](transform "Transform") transform` The Transform object the method was called on. Allows easily chaining Transform methods. Function -------- ### Synopsis ``` transform = Transform:setMatrix( layout, matrix ) ``` ### Arguments `[MatrixLayout](matrixlayout "MatrixLayout") layout` How to interpret the matrix element arguments (row-major or column-major). `[table](table "table") matrix` A flat table containing the 16 matrix elements. ### Returns `[Transform](transform "Transform") transform` The Transform object the method was called on. Allows easily chaining Transform methods. Function -------- ### Synopsis ``` transform = Transform:setMatrix( layout, matrix ) ``` ### Arguments `[MatrixLayout](matrixlayout "MatrixLayout") layout` How to interpret the matrix element arguments (row-major or column-major). `[table](table "table") matrix` A table of 4 tables, with each sub-table containing 4 matrix elements. ### Returns `[Transform](transform "Transform") transform` The Transform object the method was called on. Allows easily chaining Transform methods. See Also -------- * [Transform](transform "Transform") * [Transform:getMatrix](transform-getmatrix "Transform:getMatrix") love Object Object ====== The superclass of all LÖVE types. Functions --------- | | | | | | --- | --- | --- | --- | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Subtypes -------- | | | | | | --- | --- | --- | --- | | [BezierCurve](beziercurve "BezierCurve") | A Bézier curve object that can evaluate and render Bézier curves of arbitrary degree. | 0.9.0 | | | [Body](body "Body") | Bodies are objects with velocity and position. | | | | [ByteData](bytedata "ByteData") | Data object containing arbitrary bytes in an contiguous memory. | 11.0 | | | [Canvas](canvas "Canvas") | Off-screen render target. | 0.8.0 | | | [ChainShape](chainshape "ChainShape") | A ChainShape consists of multiple line segments. | | | | [Channel](channel "Channel") | An object which can be used to send and receive data between different threads. | 0.9.0 | | | [CircleShape](circleshape "CircleShape") | Circle extends Shape and adds a radius and a local position. | | | | [CompressedData](compresseddata "CompressedData") | Byte data compressed using a specific algorithm. | 0.10.0 | | | [CompressedImageData](compressedimagedata "CompressedImageData") | Compressed image data designed to stay compressed in RAM and on the GPU. | 0.9.0 | | | [Contact](contact "Contact") | Contacts are objects created to manage collisions in worlds. | | | | [Cursor](cursor "Cursor") | Represents a hardware cursor. | 0.9.0 | | | [Data](data "Data") | The superclass of all data. | | | | [Decoder](decoder "Decoder") | An object which can gradually decode a sound file. | | | | [DistanceJoint](distancejoint "DistanceJoint") | Keeps two bodies at the same distance. | | | | [Drawable](drawable "Drawable") | Superclass for all things that can be drawn on screen. | | | | [DroppedFile](droppedfile "DroppedFile") | Represents a file dropped from the window. | 0.10.0 | | | [EdgeShape](edgeshape "EdgeShape") | EdgeShape is a line segment. | | | | [File](file "File") | Represents a file on the filesystem. | | | | [FileData](filedata "FileData") | [Data](data "Data") representing the contents of a file. | | | | [Fixture](fixture "Fixture") | Fixtures attach shapes to bodies. | 0.8.0 | | | [Font](font "Font") | Defines the shape of characters than can be drawn onto the screen. | | | | [FontData](fontdata "FontData") | A FontData represents a font. | 0.7.0 | 0.8.0 | | [Framebuffer](framebuffer "Framebuffer") | Off-screen render target. | 0.7.0 | 0.8.0 | | [FrictionJoint](frictionjoint "FrictionJoint") | A FrictionJoint applies friction to a body. | 0.8.0 | | | [GearJoint](gearjoint "GearJoint") | Keeps bodies together in such a way that they act like gears. | | | | [GlyphData](glyphdata "GlyphData") | A GlyphData represents a drawable symbol of a font. | 0.7.0 | | | [Image](image "Image") | Drawable image type. | | | | [ImageData](imagedata "ImageData") | Raw (decoded) image data. | | | | [Joint](joint "Joint") | Attach multiple bodies together to interact in unique ways. | | | | [Joystick](joystick "Joystick") | Represents a physical joystick. | 0.9.0 | | | [Mesh](mesh "Mesh") | A 2D polygon mesh used for drawing arbitrary textured shapes. | 0.9.0 | | | [MotorJoint](motorjoint "MotorJoint") | Controls the relative motion between two [Bodies](body "Body") | 0.9.0 | | | [MouseJoint](mousejoint "MouseJoint") | For controlling objects with the mouse. | | | | [ParticleSystem](particlesystem "ParticleSystem") | Used to create cool effects, like fire. | | | | [PixelEffect](pixeleffect "PixelEffect") | Pixel shader effect. | 0.8.0 | 0.9.0 | | [PolygonShape](polygonshape "PolygonShape") | Polygon is a convex polygon with up to 8 sides. | | | | [PrismaticJoint](prismaticjoint "PrismaticJoint") | Restricts relative motion between Bodies to one shared axis. | | | | [PulleyJoint](pulleyjoint "PulleyJoint") | Allows you to simulate bodies connected through pulleys. | | | | [Quad](quad "Quad") | A quadrilateral with texture coordinate information. | | | | [RandomGenerator](randomgenerator "RandomGenerator") | A random number generation object which has its own random state. | 0.9.0 | | | [Rasterizer](rasterizer "Rasterizer") | A Rasterizer represents font data and glyphs. | 0.7.0 | | | [RecordingDevice](recordingdevice "RecordingDevice") | Represents an audio input device capable of recording sounds. | 11.0 | | | [RecordingDevice (Français)](https://love2d.org/wiki/RecordingDevice_(Fran%C3%A7ais) "RecordingDevice (Français)") | Représente un périphérique d'entrée audio capable d'enregistrer des sons. | 11.0 | | | [RevoluteJoint](revolutejoint "RevoluteJoint") | Allow two Bodies to revolve around a shared point. | | | | [RopeJoint](ropejoint "RopeJoint") | Enforces a maximum distance between two points on two bodies. | 0.8.0 | | | [Shader](shader "Shader") | Shader effect. | 0.9.0 | | | [Shape](shape "Shape") | [Shapes](shape "Shape") are objects used to control mass and collisions. | | | | [SoundData](sounddata "SoundData") | Contains raw audio samples. | | | | [Source](source "Source") | A Source represents audio you can play back. | | | | [SpriteBatch](spritebatch "SpriteBatch") | Store image positions in a buffer, and draw it in one call. | | | | [Text](text "Text") | Drawable text. | 0.10.0 | | | [Texture](texture "Texture") | Superclass for drawable objects which represent a texture. | 0.9.1 | | | [Texture (Français)](https://love2d.org/wiki/Texture_(Fran%C3%A7ais) "Texture (Français)") | Super classe pour les objets pouvant être dessinés (drawable) qui représente une texture. | 0.9.1 | | | [Thread](thread "Thread") | A Thread represents a thread. | 0.7.0 | | | [Transform](transform "Transform") | Object containing a coordinate system transformation. | 11.0 | | | [Video](video "Video") | A drawable video. | 0.10.0 | | | [VideoStream](videostream "VideoStream") | An object which decodes, streams, and controls [Videos](video "Video"). | 0.10.0 | | | [WeldJoint](weldjoint "WeldJoint") | A WeldJoint essentially glues two bodies together. | 0.8.0 | | | [WheelJoint](wheeljoint "WheelJoint") | Restricts a point on the second body to a line on the first body. | | | | [World](world "World") | A world is an object that contains all bodies and joints. | | | See Also -------- * [love](love "love") love ParticleSystem:emit ParticleSystem:emit =================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Emits a burst of particles from the particle emitter. Function -------- ### Synopsis ``` ParticleSystem:emit( numparticles ) ``` ### Arguments `[number](number "number") numparticles` The amount of particles to emit. The number of emitted particles will be truncated if the particle system's max [buffer size](particlesystem-getbuffersize "ParticleSystem:getBufferSize") is reached. ### Returns Nothing. Examples -------- ### Spawn a bunch of particles This example will create a burst of particles when the spacebar is pressed. You can use the [löve logo](https://love2d.org/wiki/File:Love-game-logo-256x256.png "File:Love-game-logo-256x256.png") as an example image. ``` function love.load() local img = love.graphics.newImage('logo.png')   psystem = love.graphics.newParticleSystem(img, 32) psystem:setParticleLifetime(2, 5) -- Particles live at least 2s and at most 5s. psystem:setLinearAcceleration(-5, -5, 50, 100) -- Randomized movement towards the bottom of the screen. psystem:setColors(255, 255, 255, 255, 255, 255, 255, 0) -- Fade to black. end   function love.draw() -- Draw the particle system at the center of the game window. love.graphics.draw(psystem, love.graphics.getWidth() * 0.5, love.graphics.getHeight() * 0.5) end   function love.update(dt) psystem:update(dt) end   function love.keypressed(key) if key == 'space' then psystem:emit(32) end end ``` See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love WheelJoint:isMotorEnabled WheelJoint:isMotorEnabled ========================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Checks if the joint motor is running. Function -------- ### Synopsis ``` on = WheelJoint:isMotorEnabled( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") on` The status of the joint motor. See Also -------- * [WheelJoint](wheeljoint "WheelJoint") love Transform:apply Transform:apply =============== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Applies the given other Transform object to this one. This effectively multiplies this Transform's internal transformation matrix with the other Transform's (i.e. `self * other`), and stores the result in this object. Function -------- ### Synopsis ``` transform = Transform:apply( other ) ``` ### Arguments `[Transform](transform "Transform") other` The other Transform object to apply to this Transform. ### Returns `[Transform](transform "Transform") transform` The Transform object the method was called on. Allows easily chaining Transform methods. See Also -------- * [Transform](transform "Transform") love Body:getType Body:getType ============ **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the type of the body. Function -------- ### Synopsis ``` type = Body:getType( ) ``` ### Arguments None. ### Returns `[BodyType](bodytype "BodyType") type` The body type. See Also -------- * [Body](body "Body") * [Body:setType](body-settype "Body:setType") love love.mouse.isVisible love.mouse.isVisible ==================== Checks if the cursor is visible. Function -------- ### Synopsis ``` visible = love.mouse.isVisible( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") visible` True if the cursor to visible, false if the cursor is hidden. Examples -------- Toggle mouse visibility by pressing tab (using [setVisible](love.mouse.setvisible "love.mouse.setVisible")). ``` function love.keypressed(key) if key == "tab" then local state = not love.mouse.isVisible() -- the opposite of whatever it currently is love.mouse.setVisible(state) end end ``` See Also -------- * [love.mouse](love.mouse "love.mouse") * [love.mouse.setVisible](love.mouse.setvisible "love.mouse.setVisible") love Decoder:getBitDepth Decoder:getBitDepth =================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [Decoder:getBits](decoder-getbits "Decoder:getBits"). Returns the number of bits per sample. Function -------- ### Synopsis ``` bitDepth = Decoder:getBitDepth( ) ``` ### Arguments None. ### Returns `[number](number "number") bitDepth` Either 8, or 16. See Also -------- * [Decoder](decoder "Decoder") love Framebuffer Framebuffer =========== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0") and removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been renamed to [Canvas](canvas "Canvas"). A Framebuffer is used for off-screen rendering. Think of it as an invisible screen that you can draw to, but that will not be visible until you draw it to the actual visible screen. It is also known as "render to texture". By drawing things that do not change position often (such as background items) to the Framebuffer, and then drawing the entire Framebuffer instead of each item, you can reduce the number of draw operations performed each frame. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.graphics.newFramebuffer](love.graphics.newframebuffer "love.graphics.newFramebuffer") | Creates a new **Framebuffer**. | 0.7.0 | 0.8.0 | Functions --------- | | | | | | --- | --- | --- | --- | | [Framebuffer:getImageData](framebuffer-getimagedata "Framebuffer:getImageData") | Get stored [ImageData](imagedata "ImageData"). | 0.7.0 | 0.8.0 | | [Framebuffer:getWrap](framebuffer-getwrap "Framebuffer:getWrap") | Gets the wrapping properties of a Framebuffer. | 0.7.2 | 0.8.0 | | [Framebuffer:renderTo](framebuffer-renderto "Framebuffer:renderTo") | Render to a framebuffer using a function. | 0.7.0 | 0.8.0 | | [Framebuffer:setWrap](framebuffer-setwrap "Framebuffer:setWrap") | Sets the wrapping properties of a Framebuffer. | 0.7.2 | 0.8.0 | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Supertypes ---------- * [Drawable](drawable "Drawable") * [Object](object "Object") Examples -------- ### sample from the forum [http://love2d.org/forums/viewtopic.php?f=4&t=2136&hilit=Framebuffer&start=20](https://love2d.org/forums/viewtopic.php?f=4&t=2136&hilit=Framebuffer&start=20) See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.newFramebuffer](love.graphics.newframebuffer "love.graphics.newFramebuffer") * [love.graphics.setRenderTarget](love.graphics.setrendertarget "love.graphics.setRenderTarget") love Joystick Joystick ======== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This type is not supported in earlier versions. Represents a physical joystick. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.joystick.getJoysticks](love.joystick.getjoysticks "love.joystick.getJoysticks") | Gets a list of connected Joysticks. | 0.9.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Joystick:getAxes](joystick-getaxes "Joystick:getAxes") | Gets the direction of each axis. | 0.9.0 | | | [Joystick:getAxis](joystick-getaxis "Joystick:getAxis") | Gets the direction of an axis. | 0.9.0 | | | [Joystick:getAxisCount](joystick-getaxiscount "Joystick:getAxisCount") | Gets the number of axes on the joystick. | 0.9.0 | | | [Joystick:getButtonCount](joystick-getbuttoncount "Joystick:getButtonCount") | Gets the number of buttons on the joystick. | 0.9.0 | | | [Joystick:getConnectedIndex](joystick-getconnectedindex "Joystick:getConnectedIndex") | Gets joystick connected index. | 0.9.0 | | | [Joystick:getDeviceInfo](joystick-getdeviceinfo "Joystick:getDeviceInfo") | Gets the OS-independent device info of the joystick. | 11.3 | | | [Joystick:getGUID](joystick-getguid "Joystick:getGUID") | Gets a stable GUID unique to the type of the physical joystick. | 0.9.0 | | | [Joystick:getGamepadAxis](joystick-getgamepadaxis "Joystick:getGamepadAxis") | Gets the direction of a virtual gamepad axis. | 0.9.0 | | | [Joystick:getGamepadMapping](joystick-getgamepadmapping "Joystick:getGamepadMapping") | Gets the button, axis or hat that a virtual gamepad input is bound to. | 0.9.0 | | | [Joystick:getGamepadMappingString](joystick-getgamepadmappingstring "Joystick:getGamepadMappingString") | Gets the full gamepad mapping string of this Joystick, or nil if it's not recognized as a [gamepad](joystick-isgamepad "Joystick:isGamepad"). | 11.3 | | | [Joystick:getHat](joystick-gethat "Joystick:getHat") | Gets the direction of a hat. | 0.9.0 | | | [Joystick:getHatCount](joystick-gethatcount "Joystick:getHatCount") | Gets the number of hats on the joystick. | 0.9.0 | | | [Joystick:getID](joystick-getid "Joystick:getID") | Gets the joystick's unique identifier. | 0.9.0 | | | [Joystick:getName](joystick-getname "Joystick:getName") | Gets the name of the joystick. | 0.9.0 | | | [Joystick:getVibration](joystick-getvibration "Joystick:getVibration") | Gets the current vibration motor strengths on a Joystick with rumble support. | 0.9.0 | | | [Joystick:isConnected](joystick-isconnected "Joystick:isConnected") | Gets whether the Joystick is connected. | 0.9.0 | | | [Joystick:isDown](joystick-isdown "Joystick:isDown") | Checks if a button on the Joystick is pressed. | 0.9.0 | | | [Joystick:isGamepad](joystick-isgamepad "Joystick:isGamepad") | Gets whether the Joystick is recognized as a gamepad. | 0.9.0 | | | [Joystick:isGamepadDown](joystick-isgamepaddown "Joystick:isGamepadDown") | Checks if a virtual gamepad button on the Joystick is pressed. | 0.9.0 | | | [Joystick:isVibrationSupported](joystick-isvibrationsupported "Joystick:isVibrationSupported") | Gets whether the Joystick supports vibration. | 0.9.0 | | | [Joystick:setVibration](joystick-setvibration "Joystick:setVibration") | Sets the vibration motor speeds on a Joystick with rumble support. | 0.9.0 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Enums ----- | | | | | | --- | --- | --- | --- | | [GamepadAxis](gamepadaxis "GamepadAxis") | Virtual gamepad axes. | 0.9.0 | | | [GamepadButton](gamepadbutton "GamepadButton") | Virtual gamepad buttons. | 0.9.0 | | | [JoystickHat](joystickhat "JoystickHat") | Joystick hat positions. | 0.5.0 | | | [JoystickInputType](joystickinputtype "JoystickInputType") | Types of Joystick inputs. | 0.9.0 | | Supertypes ---------- * [Object](object "Object") Examples -------- ### Display the last button pressed of a controller on-screen ``` local lastbutton = "none"   function love.gamepadpressed(joystick, button) lastbutton = button end   function love.draw() love.graphics.print("Last gamepad button pressed: "..lastbutton, 10, 10) end ``` ### Move a circle with the d-pad of a controller ``` function love.load() local joysticks = love.joystick.getJoysticks() joystick = joysticks[1]   position = {x = 400, y = 300} speed = 300 end   function love.update(dt) if not joystick then return end   if joystick:isGamepadDown("dpleft") then position.x = position.x - speed * dt elseif joystick:isGamepadDown("dpright") then position.x = position.x + speed * dt end   if joystick:isGamepadDown("dpup") then position.y = position.y - speed * dt elseif joystick:isGamepadDown("dpdown") then position.y = position.y + speed * dt end end   function love.draw() love.graphics.circle("fill", position.x, position.y, 50) end ``` See Also -------- * [love.joystick](love.joystick "love.joystick") * [love.joystick.getJoystickCount](love.joystick.getjoystickcount "love.joystick.getJoystickCount") * [love.joystickadded](love.joystickadded "love.joystickadded") * [love.joystickremoved](love.joystickremoved "love.joystickremoved") * [love.joystickpressed](love.joystickpressed "love.joystickpressed") * [love.joystickreleased](love.joystickreleased "love.joystickreleased") * [love.joystickaxis](love.joystickaxis "love.joystickaxis") * [love.joystickhat](love.joystickhat "love.joystickhat") * [love.gamepadpressed](love.gamepadpressed "love.gamepadpressed") * [love.gamepadreleased](love.gamepadreleased "love.gamepadreleased") * [love.gamepadaxis](love.gamepadaxis "love.gamepadaxis")
programming_docs
love Channel:getCount Channel:getCount ================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Retrieves the number of messages in the thread Channel queue. Function -------- ### Synopsis ``` value = Channel:getCount( ) ``` ### Arguments None. ### Returns `[number](number "number") count` The number of messages in the queue. See Also -------- * [Channel](channel "Channel") * [Channel:pop](channel-pop "Channel:pop") love Fixture:getFriction Fixture:getFriction =================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the friction of the fixture. Function -------- ### Synopsis ``` friction = Fixture:getFriction( ) ``` ### Arguments None. ### Returns `[number](number "number") friction` The fixture friction. See Also -------- * [Fixture](fixture "Fixture") * [Fixture:setFriction](fixture-setfriction "Fixture:setFriction") love Contact:getSeparation Contact:getSeparation ===================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in that and later versions. Get the separation between two shapes that are in contact. The return value of this function is always zero or negative, with a negative value indicating overlap between the two shapes. Function -------- ### Synopsis ``` distance = Contact:getSeparation( ) ``` ### Arguments None. ### Returns `[number](number "number") distance` The separation between the two shapes. See Also -------- * [Contact](contact "Contact") love Font Font ==== Defines the shape of characters that can be drawn onto the screen. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.graphics.newFont](love.graphics.newfont "love.graphics.newFont") | Creates a new **Font** from a TrueType Font or BMFont file. | | | | [love.graphics.newImageFont](love.graphics.newimagefont "love.graphics.newImageFont") | Creates a new **Font** by loading a specifically formatted image. | 0.2.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Font:getAscent](font-getascent "Font:getAscent") | Gets the ascent of the Font in pixels. | 0.9.0 | | | [Font:getBaseline](font-getbaseline "Font:getBaseline") | Gets the baseline of the Font in pixels. | 0.9.0 | | | [Font:getDPIScale](font-getdpiscale "Font:getDPIScale") | Gets the DPI scale factor of the Font. | 11.0 | | | [Font:getDescent](font-getdescent "Font:getDescent") | Gets the descent of the Font in pixels. | 0.9.0 | | | [Font:getFilter](font-getfilter "Font:getFilter") | Gets the filter mode for a font. | 0.9.0 | | | [Font:getHeight](font-getheight "Font:getHeight") | Gets the height of the Font in pixels. | | | | [Font:getLineHeight](font-getlineheight "Font:getLineHeight") | Gets the line height. | | | | [Font:getWidth](font-getwidth "Font:getWidth") | Determines the width of the given text. | | | | [Font:getWrap](font-getwrap "Font:getWrap") | Gets formatting information for text, given a wrap limit. | 0.7.0 | | | [Font:hasGlyphs](font-hasglyphs "Font:hasGlyphs") | Gets whether the Font can render a character or string. | 0.9.0 | | | [Font:setFallbacks](font-setfallbacks "Font:setFallbacks") | Sets other Fonts to use if this Font doesn't have a specific character. | 0.10.0 | | | [Font:setFilter](font-setfilter "Font:setFilter") | Sets the filter mode for a font. | 0.9.0 | | | [Font:setLineHeight](font-setlineheight "Font:setLineHeight") | Sets the line height. | | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Supertypes ---------- * [Object](object "Object") See Also -------- * [love.graphics](love.graphics "love.graphics") love Shape:getRadius Shape:getRadius =============== Gets the radius of the shape. Function -------- ### Synopsis ``` radius = Shape:getRadius() ``` From the Box2D manual: > Polygons inherit a radius from [Shape](shape "Shape"). The radius creates a skin around the polygon. The skin is used in stacking scenarios to keep polygons slightly separated. This allows continuous collision to work against the core polygon. > > ### Arguments None. ### Returns `[number](number "number") radius` The radius of the shape. See Also -------- * [Shape](shape "Shape") love Joystick:setVibration Joystick:setVibration ===================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Sets the vibration motor speeds on a Joystick with rumble support. Most common gamepads have this functionality, although not all drivers give proper support. Use [Joystick:isVibrationSupported](joystick-isvibrationsupported "Joystick:isVibrationSupported") to check. Function -------- ### Synopsis ``` success = Joystick:setVibration( left, right ) ``` ### Arguments `[number](number "number") left` Strength of the left vibration motor on the Joystick. Must be in the range of [0, 1]. `[number](number "number") right` Strength of the right vibration motor on the Joystick. Must be in the range of [0, 1]. ### Returns `[boolean](boolean "boolean") success` True if the vibration was successfully applied, false if not. Function -------- Disables vibration. ### Synopsis ``` success = Joystick:setVibration( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") success` True if the vibration was successfully disabled, false if not. Function -------- **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This variant is not supported in earlier versions. ### Synopsis ``` success = Joystick:setVibration( left, right, duration ) ``` ### Arguments `[number](number "number") left` Strength of the left vibration motor on the Joystick. Must be in the range of [0, 1]. `[number](number "number") right` Strength of the right vibration motor on the Joystick. Must be in the range of [0, 1]. `[number](number "number") duration (-1)` The duration of the vibration in seconds. A negative value means infinite duration. ### Returns `[boolean](boolean "boolean") success` True if the vibration was successfully applied, false if not. Notes ----- If the Joystick only has a single vibration motor, it will still work but it will use the largest value of the left and right parameters. The Xbox 360 controller on Mac OS X only has support for vibration if a [modified version](https://github.com/d235j/360Controller/releases) of the Tattiebogle driver is used. The very first call to this function may take more time than expected because SDL's Haptic / Force Feedback subsystem needs to be initialized. See Also -------- * [Joystick](joystick "Joystick") * [Joystick:getVibration](joystick-getvibration "Joystick:getVibration") * [Joystick:isVibrationSupported](joystick-isvibrationsupported "Joystick:isVibrationSupported") love VertexAttributeStep VertexAttributeStep =================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This enum is not supported in earlier versions. The frequency at which a vertex shader fetches the vertex attribute's data from the Mesh when it's drawn. Per-instance attributes can be used to render a Mesh many times with different positions, colors, or other attributes via a single [love.graphics.drawInstanced](love.graphics.drawinstanced "love.graphics.drawInstanced") call, without using the `love_InstanceID` vertex shader variable. Constants --------- pervertex The vertex attribute will have a unique value for each vertex in the Mesh within a single instance. perinstance The vertex attribute will have a unique value for each [instance](love.graphics.drawinstanced "love.graphics.drawInstanced") of the Mesh. See Also -------- * [love.graphics](love.graphics "love.graphics") * [Mesh:attachAttribute](mesh-attachattribute "Mesh:attachAttribute") * [love.graphics.drawInstanced](love.graphics.drawinstanced "love.graphics.drawInstanced") * [Mesh](mesh "Mesh") love Body:setUserData Body:setUserData ================ **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This method is not supported in earlier versions. Associates a Lua value with the Body. To delete the reference, explicitly pass nil. Use this function in one thread and one thread only. Using it in more threads will make Lua cry and most likely crash. Function -------- ### Synopsis ``` Body:setUserData( value ) ``` ### Arguments `[any](https://love2d.org/w/index.php?title=any&action=edit&redlink=1 "any (page does not exist)") value` The Lua value to associate with the Body. ### Returns Nothing. See Also -------- * [Body](body "Body") * [Body:getUserData](body-getuserdata "Body:getUserData") love Source:getEffect Source:getEffect ================ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the filter settings associated to a specific effect. This function returns nil if the effect was applied with no filter settings associated to it. Function -------- ### Synopsis ``` filtersettings = Source:getEffect( name, filtersettings ) ``` ### Arguments `[string](string "string") name` The name of the effect. `[table](table "table") filtersettings ({})` An optional empty table that will be filled with the filter settings. ### Returns `[table](table "table") filtersettings` The settings for the filter associated to this effect, or nil if the effect is not present in this Source or has no filter associated. The table has the following fields: `[number](number "number") volume` The overall volume of the audio. `[number](number "number") highgain` Volume of high-frequency audio. Only applies to low-pass and band-pass filters. `[number](number "number") lowgain` Volume of low-frequency audio. Only applies to high-pass and band-pass filters. See Also -------- * [Source](source "Source") * [Source:setEffect](source-seteffect "Source:setEffect") * [love.audio.setEffect](love.audio.seteffect "love.audio.setEffect") love Shader:hasUniform Shader:hasUniform ================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** It has replaced [Shader:getExternVariable](shader-getexternvariable "Shader:getExternVariable"). Gets whether a uniform / extern variable exists in the Shader. If a graphics driver's shader compiler determines that a uniform / extern variable doesn't affect the final output of the shader, it may optimize the variable out. This function will return false in that case. Function -------- ### Synopsis ``` hasuniform = Shader:hasUniform( name ) ``` ### Arguments `[string](string "string") name` The name of the uniform variable. ### Returns `[boolean](boolean "boolean") hasuniform` Whether the uniform exists in the shader and affects its final output. See Also -------- * [Shader](shader "Shader") * [Shader:send](shader-send "Shader:send") love ParticleSystem:getY ParticleSystem:getY =================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** Use [ParticleSystem:getPosition](particlesystem-getposition "ParticleSystem:getPosition"). Gets the y-coordinate of the particle emitter's position. Function -------- ### Synopsis ``` y = ParticleSystem:getY( ) ``` ### Arguments None. ### Returns `[number](number "number") y` Position along y-axis. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love love.data.decode love.data.decode ================ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Decode Data or a string from any of the [EncodeFormats](encodeformat "EncodeFormat") to Data or string. Function -------- ### Synopsis ``` decoded = love.data.decode( container, format, sourceString ) ``` ### Arguments `[ContainerType](containertype "ContainerType") container` What type to return the decoded data as. `[EncodeFormat](encodeformat "EncodeFormat") format` The format of the input data. `[string](string "string") sourceString` The raw (encoded) data to decode. ### Returns `[value](value "value") decoded` [ByteData](bytedata "ByteData")/[string](string "string") which contains the decoded version of source. Function -------- ### Synopsis ``` decoded = love.data.decode( container, format, sourceData ) ``` ### Arguments `[ContainerType](containertype "ContainerType") container` What type to return the decoded data as. `[EncodeFormat](encodeformat "EncodeFormat") format` The format of the input data. `[Data](data "Data") sourceData` The raw (encoded) data to decode. ### Returns `[value](value "value") decoded` [ByteData](bytedata "ByteData")/[string](string "string") which contains the decoded version of source. See Also -------- * [love.data](love.data "love.data") * [love.data.encode](love.data.encode "love.data.encode") love love.mouse.getCursor love.mouse.getCursor ==================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the current Cursor. Function -------- ### Synopsis ``` cursor = love.mouse.getCursor( ) ``` ### Arguments None. ### Returns `[Cursor](cursor "Cursor") cursor (nil)` The current cursor, or nil if no cursor is set. See Also -------- * [love.mouse](love.mouse "love.mouse") * [love.mouse.setCursor](love.mouse.setcursor "love.mouse.setCursor") love love.math.decompress love.math.decompress ==================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | This function is deprecated and is replaced by [love.data.decompress](love.data.decompress "love.data.decompress"). | Decompresses a [CompressedData](compresseddata "CompressedData") or previously compressed string or [Data](data "Data") object. Function -------- ### Synopsis ``` rawstring = love.math.decompress( compressedData ) ``` ### Arguments `[CompressedData](compresseddata "CompressedData") compressedData` The compressed data to decompress. ### Returns `[string](string "string") rawstring` A string containing the raw decompressed data. Function -------- ### Synopsis ``` rawstring = love.math.decompress( compressedString, format ) ``` ### Arguments `[string](string "string") compressedstring` A string containing data previously compressed with [love.math.compress](love.math.compress "love.math.compress"). `[CompressedDataFormat](compresseddataformat "CompressedDataFormat") format` The format that was used to compress the given string. ### Returns `[string](string "string") rawstring` A string containing the raw decompressed data. Function -------- ### Synopsis ``` rawstring = love.math.decompress( data, format ) ``` ### Arguments `[Data](data "Data") data` A Data object containing data previously compressed with [love.math.compress](love.math.compress "love.math.compress"). `[CompressedDataFormat](compresseddataformat "CompressedDataFormat") format` The format that was used to compress the given data. ### Returns `[string](string "string") rawstring` A string containing the raw decompressed data. See Also -------- * [love.math](love.math "love.math") * [love.math.compress](love.math.compress "love.math.compress") love Quad:flip Quad:flip ========= **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in that and later versions. Flips this quad horizontally, vertically, or both. Function -------- ### Synopsis ``` Quad:flip( x, y ) ``` ### Arguments `[boolean](boolean "boolean") x` True to flip horizontally, false to leave as-is. `[boolean](boolean "boolean") y` True to flip vertically, false to leave as-is. ### Returns Nothing. See Also -------- * [Quad](quad "Quad") love PrismaticJoint:isMotorEnabled PrismaticJoint:isMotorEnabled ============================= Checks whether the motor is enabled. Function -------- ### Synopsis ``` enabled = PrismaticJoint:isMotorEnabled( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") enabled` True if enabled, false if disabled. See Also -------- * [PrismaticJoint](prismaticjoint "PrismaticJoint") love SpriteBatch:set SpriteBatch:set =============== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Changes a sprite in the batch. This requires the sprite index returned by [SpriteBatch:add](spritebatch-add "SpriteBatch:add") or [SpriteBatch:addLayer](spritebatch-addlayer "SpriteBatch:addLayer"). Function -------- ### Synopsis ``` SpriteBatch:set( spriteindex, x, y, r, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[number](number "number") spriteindex` The index of the sprite that will be changed. `[number](number "number") x` The position to draw the object (x-axis). `[number](number "number") y` The position to draw the object (y-axis). `[number](number "number") r (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Shear factor (x-axis). `[number](number "number") ky (0)` Shear factor (y-axis). ### Returns Nothing. Function -------- **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant has replaced [SpriteBatch:setq](spritebatch-setq "SpriteBatch:setq"). Changes a sprite with a [Quad](quad "Quad") in the batch. This requires the index returned by [SpriteBatch:add](spritebatch-add "SpriteBatch:add") or [SpriteBatch:addLayer](spritebatch-addlayer "SpriteBatch:addLayer"). ### Synopsis ``` SpriteBatch:set( spriteindex, quad, x, y, r, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[number](number "number") spriteindex` The index of the sprite that will be changed. `[Quad](quad "Quad") quad` The Quad used on the image of the batch. `[number](number "number") x` The position to draw the object (x-axis). `[number](number "number") y` The position to draw the object (y-axis). `[number](number "number") r (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Shear factor (x-axis). `[number](number "number") ky (0)` Shear factor (y-axis). ### Returns Nothing. Notes ----- SpriteBatches do not support removing individual sprites. One can do a pseudo removal (instead of clearing and re-adding everything) by: ``` SpriteBatch:set(id, 0, 0, 0, 0, 0) ``` This makes all the sprite's vertices equal (because the x and y scales are 0), which prevents the GPU from fully processing the sprite when drawing the SpriteBatch. See Also -------- * [SpriteBatch](spritebatch "SpriteBatch") * [SpriteBatch:add](spritebatch-add "SpriteBatch:add") * [SpriteBatch:addLayer](spritebatch-addlayer "SpriteBatch:addLayer") * [SpriteBatch:setLayer](spritebatch-setlayer "SpriteBatch:setLayer")
programming_docs
love Source:isLooping Source:isLooping ================ Returns whether the Source will loop. Function -------- ### Synopsis ``` loop = Source:isLooping( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") loop` True if the Source will loop, false otherwise. See Also -------- * [Source](source "Source") love VideoStream:setSync VideoStream:setSync =================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. TODO Function -------- TODO ### Synopsis ``` VideoStream:setSync( source ) ``` ### Arguments `[Source](source "Source") source` TODO ### Returns None. Function -------- TODO ### Synopsis ``` VideoStream:setSync( source ) ``` ### Arguments `[VideoStream](videostream "VideoStream") source` TODO ### Returns None. Function -------- TODO ### Synopsis ``` VideoStream:setSync( ) ``` ### Arguments None. ### Returns None. See Also -------- * [VideoStream](videostream "VideoStream") love love.graphics.point love.graphics.point =================== **Removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** It has been replaced by [love.graphics.points](love.graphics.points "love.graphics.points"). Draws a point. Function -------- ### Synopsis ``` love.graphics.point( x, y ) ``` ### Arguments `[number](number "number") x` The position on the x-axis. `[number](number "number") y` The position on the y-axis. ### Returns Nothing. Notes ----- 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 [love.graphics.scale](love.graphics.scale "love.graphics.scale") - their [size](love.graphics.setpointsize "love.graphics.setPointSize") is always in pixels. Examples -------- Render a starfield ``` function love.load() local screen_width, screen_height = love.graphics.getDimensions() local max_stars = 100 -- how many stars we want   stars = {} -- table which will hold our stars   for i=1, max_stars do -- generate the coords of our stars local x = love.math.random(5, screen_width-5) -- generate a "random" number for the x coord of this star local y = love.math.random(5, screen_height-5) -- both coords are limited to the screen size, minus 5 pixels of padding stars[i] = {x, y} -- stick the values into the table end end   function love.draw() for i, star in ipairs(stars) do -- loop through all of our stars love.graphics.point(star[1], star[2]) -- draw each point end end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setPointSize](love.graphics.setpointsize "love.graphics.setPointSize") * [love.graphics.setPointStyle](love.graphics.setpointstyle "love.graphics.setPointStyle") love SoundData SoundData ========= Contains raw audio samples. You can not play SoundData back directly. You must wrap a [Source](source "Source") object around it. Constructors ------------ | | | | | | --- | --- | --- | --- | | [Decoder:decode](decoder-decode "Decoder:decode") | Decodes a chunk of audio data to a SoundData. | 11.0 | | | [RecordingDevice:getData](recordingdevice-getdata "RecordingDevice:getData") | Gets all recorded audio **SoundData** stored in the device's internal ring buffer. | 11.0 | | | [love.sound.newSoundData](love.sound.newsounddata "love.sound.newSoundData") | Creates a new SoundData. | | | Functions --------- | | | | | | --- | --- | --- | --- | | [Data:clone](data-clone "Data:clone") | Creates a new copy of the Data object. | 11.0 | | | [Data:getFFIPointer](data-getffipointer "Data:getFFIPointer") | Gets an FFI pointer to the Data. | 11.3 | | | [Data:getPointer](data-getpointer "Data:getPointer") | Gets a pointer to the Data. | | | | [Data:getSize](data-getsize "Data:getSize") | Gets the [Data](data "Data")'s size in bytes. | | | | [Data:getString](data-getstring "Data:getString") | Gets the full Data as a string. | 0.9.0 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | | [SoundData:getBitDepth](sounddata-getbitdepth "SoundData:getBitDepth") | Returns the number of bits per sample. | 0.9.0 | | | [SoundData:getBits](sounddata-getbits "SoundData:getBits") | Returns the number of bits per sample. | | 0.9.0 | | [SoundData:getChannelCount](sounddata-getchannelcount "SoundData:getChannelCount") | Returns the number of channels in the SoundData. | 11.0 | | | [SoundData:getChannels](sounddata-getchannels "SoundData:getChannels") | Returns the number of channels in the stream. | | 11.0 | | [SoundData:getDuration](sounddata-getduration "SoundData:getDuration") | Gets the duration of the sound data. | 0.9.0 | | | [SoundData:getSample](sounddata-getsample "SoundData:getSample") | Gets the value of the samplepoint at the specified position. | | | | [SoundData:getSampleCount](sounddata-getsamplecount "SoundData:getSampleCount") | Returns the sample count of the SoundData. | 0.9.0 | | | [SoundData:getSampleRate](sounddata-getsamplerate "SoundData:getSampleRate") | Returns the sample rate of the SoundData. | | | | [SoundData:setSample](sounddata-setsample "SoundData:setSample") | Sets the sample at the specified position. | | | Supertypes ---------- * [Data](data "Data") * [Object](object "Object") See Also -------- * [love.sound](love.sound "love.sound") * [love.audio](love.audio "love.audio") * [Source](source "Source") love Fixture:setSensor Fixture:setSensor ================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Sets whether the fixture should act as a sensor. Sensors do not cause collision responses, but the begin-contact and end-contact [World callbacks](world-setcallbacks "World:setCallbacks") will still be called for this fixture. Function -------- ### Synopsis ``` Fixture:setSensor( sensor ) ``` ### Arguments `[boolean](boolean "boolean") sensor` The sensor status. ### Returns Nothing. See Also -------- * [Fixture](fixture "Fixture") * [Fixture:isSensor](fixture-issensor "Fixture:isSensor") love WheelJoint WheelJoint ========== Restricts a point on the second body to a line on the first body. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.physics.newWheelJoint](love.physics.newwheeljoint "love.physics.newWheelJoint") | Creates a wheel joint. | 0.8.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Joint:destroy](joint-destroy "Joint:destroy") | Explicitly destroys the Joint. | | | | [Joint:getAnchors](joint-getanchors "Joint:getAnchors") | Get the anchor points of the joint. | | | | [Joint:getBodies](joint-getbodies "Joint:getBodies") | Gets the [bodies](body "Body") that the Joint is attached to. | 0.9.2 | | | [Joint:getCollideConnected](joint-getcollideconnected "Joint:getCollideConnected") | Gets whether the connected Bodies collide. | | | | [Joint:getReactionForce](joint-getreactionforce "Joint:getReactionForce") | Returns the reaction force on the second body. | | | | [Joint:getReactionTorque](joint-getreactiontorque "Joint:getReactionTorque") | Returns the reaction torque on the second body. | | | | [Joint:getType](joint-gettype "Joint:getType") | Gets a string representing the type. | | | | [Joint:getUserData](joint-getuserdata "Joint:getUserData") | Returns the Lua value associated with this Joint. | 0.9.2 | | | [Joint:isDestroyed](joint-isdestroyed "Joint:isDestroyed") | Gets whether the Joint is destroyed. | 0.9.2 | | | [Joint:setCollideConnected](joint-setcollideconnected "Joint:setCollideConnected") | Sets whether the connected Bodies should collide with each other. | | 0.8.0 | | [Joint:setUserData](joint-setuserdata "Joint:setUserData") | Associates a Lua value with the Joint. | 0.9.2 | | | [WheelJoint:enableMotor](wheeljoint-enablemotor "WheelJoint:enableMotor") | Starts and stops the joint motor. | 0.8.0 | 0.9.0 | | [WheelJoint:getAxis](wheeljoint-getaxis "WheelJoint:getAxis") | Gets the world-space axis vector of the Prismatic Joint. | 0.10.2 | | | [WheelJoint:getJointSpeed](wheeljoint-getjointspeed "WheelJoint:getJointSpeed") | Returns the current joint translation speed. | 0.8.0 | | | [WheelJoint:getJointTranslation](wheeljoint-getjointtranslation "WheelJoint:getJointTranslation") | Returns the current joint translation. | 0.8.0 | | | [WheelJoint:getMaxMotorTorque](wheeljoint-getmaxmotortorque "WheelJoint:getMaxMotorTorque") | Returns the maximum motor torque. | 0.8.0 | | | [WheelJoint:getMotorSpeed](wheeljoint-getmotorspeed "WheelJoint:getMotorSpeed") | Returns the speed of the motor. | 0.8.0 | | | [WheelJoint:getMotorTorque](wheeljoint-getmotortorque "WheelJoint:getMotorTorque") | Returns the current torque on the motor. | 0.8.0 | | | [WheelJoint:getSpringDampingRatio](wheeljoint-getspringdampingratio "WheelJoint:getSpringDampingRatio") | Returns the damping ratio. | 0.8.0 | | | [WheelJoint:getSpringFrequency](wheeljoint-getspringfrequency "WheelJoint:getSpringFrequency") | Returns the spring frequency. | 0.8.0 | | | [WheelJoint:isMotorEnabled](wheeljoint-ismotorenabled "WheelJoint:isMotorEnabled") | Checks if the joint motor is running. | 0.8.0 | | | [WheelJoint:setMaxMotorTorque](wheeljoint-setmaxmotortorque "WheelJoint:setMaxMotorTorque") | Sets a new maximum motor torque. | 0.8.0 | | | [WheelJoint:setMotorEnabled](wheeljoint-setmotorenabled "WheelJoint:setMotorEnabled") | Starts and stops the joint motor. | 0.9.0 | | | [WheelJoint:setMotorSpeed](wheeljoint-setmotorspeed "WheelJoint:setMotorSpeed") | Sets a new speed for the motor. | 0.8.0 | | | [WheelJoint:setSpringDampingRatio](wheeljoint-setspringdampingratio "WheelJoint:setSpringDampingRatio") | Sets a new damping ratio. | 0.8.0 | | | [WheelJoint:setSpringFrequency](wheeljoint-setspringfrequency "WheelJoint:setSpringFrequency") | Sets a new spring frequency. | 0.8.0 | | Supertypes ---------- * [Joint](joint "Joint") * [Object](object "Object") See Also -------- * [love.physics](love.physics "love.physics") love Rasterizer:getHeight Rasterizer:getHeight ==================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Gets font height. Function -------- ### Synopsis ``` height = Rasterizer:getHeight() ``` ### Arguments None. ### Returns `[number](number "number") height` Font height See Also -------- * [Rasterizer](rasterizer "Rasterizer") love PulleyJoint:getLengthB PulleyJoint:getLengthB ====================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Get the current length of the rope segment attached to the second body. Function -------- ### Synopsis ``` length = PulleyJoint:getLengthB( ) ``` ### Arguments None. ### Returns `[number](number "number") length` The length of the rope segment. See Also -------- * [PulleyJoint](pulleyjoint "PulleyJoint") love Data Data ==== The superclass of all data. Functions --------- | | | | | | --- | --- | --- | --- | | [Data:clone](data-clone "Data:clone") | Creates a new copy of the Data object. | 11.0 | | | [Data:getFFIPointer](data-getffipointer "Data:getFFIPointer") | Gets an FFI pointer to the Data. | 11.3 | | | [Data:getPointer](data-getpointer "Data:getPointer") | Gets a pointer to the Data. | | | | [Data:getSize](data-getsize "Data:getSize") | Gets the **Data**'s size in bytes. | | | | [Data:getString](data-getstring "Data:getString") | Gets the full Data as a string. | 0.9.0 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Supertypes ---------- * [Object](object "Object") Subtypes -------- | | | | | | --- | --- | --- | --- | | [ByteData](bytedata "ByteData") | Data object containing arbitrary bytes in an contiguous memory. | 11.0 | | | [CompressedData](compresseddata "CompressedData") | Byte data compressed using a specific algorithm. | 0.10.0 | | | [CompressedImageData](compressedimagedata "CompressedImageData") | Compressed image data designed to stay compressed in RAM and on the GPU. | 0.9.0 | | | [FileData](filedata "FileData") | **Data** representing the contents of a file. | | | | [FontData](fontdata "FontData") | A FontData represents a font. | 0.7.0 | 0.8.0 | | [GlyphData](glyphdata "GlyphData") | A GlyphData represents a drawable symbol of a font. | 0.7.0 | | | [ImageData](imagedata "ImageData") | Raw (decoded) image data. | | | | [SoundData](sounddata "SoundData") | Contains raw audio samples. | | | See Also -------- * [love](love "love") * [love.data](love.data "love.data") love love.graphics.newStencil love.graphics.newStencil ======================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** Lua functions can be used directly with [love.graphics.stencil](love.graphics.stencil "love.graphics.stencil") (or [love.graphics.setStencil](love.graphics.setstencil "love.graphics.setStencil") in 0.9). Creates a new stencil. Function -------- ### Synopsis ``` myStencil = love.graphics.newStencil( stencilFunction ) ``` ### Arguments `[function](function "function") stencilFunction` Function that draws the stencil. ### Returns `[function](function "function") myStencil` Function that defines the new stencil. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setStencil](love.graphics.setstencil "love.graphics.setStencil") * [love.graphics.setInvertedStencil](love.graphics.setinvertedstencil "love.graphics.setInvertedStencil") love love.window.updateMode love.window.updateMode ====================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Sets the display mode and properties of the window, without modifying unspecified properties. If width or height is 0, updateMode will use the width and height of the desktop. Changing the display mode may have side effects: for example, [canvases](canvas "Canvas") will be cleared. Make sure to save the contents of [canvases](canvas "Canvas") beforehand or re-draw to them afterward if you need to. Function -------- ### Synopsis ``` success = love.window.updateMode( width, height, settings ) ``` ### Arguments `[number](number "number") width` Window width. `[number](number "number") height` Window height. `[table](table "table") settings` The settings table with the following optional fields. Any field not filled in will use the current value that would be returned by [love.window.getMode](love.window.getmode "love.window.getMode"). `[boolean](boolean "boolean") fullscreen` Fullscreen (true), or windowed (false). `[FullscreenType](fullscreentype "FullscreenType") fullscreentype` The type of fullscreen to use. `[boolean](boolean "boolean") vsync` True if LÖVE should wait for vsync, false otherwise. `[number](number "number") msaa` The number of antialiasing samples. `[boolean](boolean "boolean") resizable` True if the window should be resizable in windowed mode, false otherwise. `[boolean](boolean "boolean") borderless` True if the window should be borderless in windowed mode, false otherwise. `[boolean](boolean "boolean") centered` True if the window should be centered in windowed mode, false otherwise. `[number](number "number") display` The index of the display to show the window in, if multiple monitors are available. `[number](number "number") minwidth` The minimum width of the window, if it's resizable. Cannot be less than 1. `[number](number "number") minheight` The minimum height of the window, if it's resizable. Cannot be less than 1. `[boolean](boolean "boolean") highdpi` True if [high-dpi mode](love.window.getdpiscale "love.window.getDPIScale") should be used on Retina displays in macOS and iOS. Does nothing on non-Retina displays. `[number](number "number") x` The x-coordinate of the window's position in the specified display. `[number](number "number") y` The y-coordinate of the window's position in the specified display. ### Returns `[boolean](boolean "boolean") success` True if successful, false otherwise. Notes ----- * If fullscreen is enabled and the width or height is not supported (see [love.window.getFullscreenModes](love.window.getfullscreenmodes "love.window.getFullscreenModes")), the window may be resized to the closest available resolution and a [resize](love.resize "love.resize") event will be triggered. * If the fullscreen type is "desktop", then the window will be automatically resized to the desktop resolution. * In Android, the aspect ratio deducted from the width and the height is used to determine whetever the game run in landscape or portrait. * Transparent backgrounds are currently not supported. See Also -------- * [love.window](love.window "love.window") * [love.window.setMode](love.window.setmode "love.window.setMode") * [love.window.getMode](love.window.getmode "love.window.getMode") * [love.window.getFullscreenModes](love.window.getfullscreenmodes "love.window.getFullscreenModes") * [love.resize](love.resize "love.resize") love ParticleSystem:getRadialAcceleration ParticleSystem:getRadialAcceleration ==================================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the radial acceleration (away from the emitter). Function -------- ### Synopsis ``` min, max = ParticleSystem:getRadialAcceleration( ) ``` ### Arguments Nothing. ### Returns `[number](number "number") min` The minimum acceleration. `[number](number "number") max` The maximum acceleration. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setRadialAcceleration](particlesystem-setradialacceleration "ParticleSystem:setRadialAcceleration") love ParticleSystem:hasRelativeRotation ParticleSystem:hasRelativeRotation ================================== **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. Gets whether particle angles and rotations are relative to their velocities. If enabled, particles are aligned to the angle of their velocities and rotate relative to that angle. Function -------- ### Synopsis ``` relative = ParticleSystem:hasRelativeRotation( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") enable` True if relative particle rotation is enabled, false if it's disabled. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setRelativeRotation](particlesystem-setrelativerotation "ParticleSystem:setRelativeRotation") love Source:setRelative Source:setRelative ================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Sets whether the [Source](source "Source")'s position, velocity, direction, and cone angles are relative to the listener, or absolute. By default, all sources are absolute and therefore relative to the origin of love's coordinate system [0, 0, 0]. Only absolute sources are affected by the position of the listener. Please note that positional audio only works for mono (i.e. non-stereo) sources. Function -------- ### Synopsis ``` Source:setRelative( enable ) ``` ### Arguments `[boolean](boolean "boolean") enable (false)` True to make the position, velocity, direction and cone angles relative to the listener, false to make them absolute. ### Returns Nothing. ### Absolute Source Demonstration This example demonstrates how an absolute source is affected by the position of the listener. ``` local x, y, z = 0, 0, 0; local snd; local relative;   function love.load() snd = love.audio.newSource('beep.wav', 'static') snd:setLooping(true); snd:play();   -- By default the sound is not relative. relative = snd:isRelative(); end   function love.keypressed(key) -- Move the listener via WASD. if key == 'a' then x = x - 1; elseif key == 'd' then x = x + 1; elseif key == 'w' then y = y - 1; elseif key == 's' then y = y + 1; end love.audio.setPosition(x, y, z);   -- Toggle between a relative and absolute source. if key == 'r' then relative = snd:isRelative(); snd:setRelative(not relative); end end   function love.draw() love.graphics.print('Relative: ' .. tostring(relative), 20, 20); love.graphics.print('Listener: (x = ' .. x .. ', y = ' .. y .. ')', 20, 40); end ``` See Also -------- * [Source](source "Source") * [Source:isRelative](source-isrelative "Source:isRelative")
programming_docs
love SpriteBatch:getBufferSize SpriteBatch:getBufferSize ========================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the maximum number of sprites the SpriteBatch can hold. Function -------- ### Synopsis ``` size = SpriteBatch:getBufferSize( ) ``` ### Arguments None. ### Returns `[number](number "number") size` The maximum number of sprites the batch can hold. See Also -------- * [SpriteBatch](spritebatch "SpriteBatch") * [SpriteBatch:setBufferSize](spritebatch-setbuffersize "SpriteBatch:setBufferSize") * [SpriteBatch:getCount](spritebatch-getcount "SpriteBatch:getCount") love love.graphics.quad love.graphics.quad ================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in that and later versions. Use [love.graphics.polygon](love.graphics.polygon "love.graphics.polygon") instead. Draws a quadrilateral shape. Function -------- ### Synopsis ``` love.graphics.quad( mode, x1, y1, x2, y2, x3, y3, x4, y4 ) ``` ### Arguments `[DrawMode](drawmode "DrawMode") mode` How to draw the quad. `[number](number "number") x1` The position of the top left corner along x-axis. `[number](number "number") y1` The position of the top left corner along y-axis. `[number](number "number") x2` The position of the top right corner along x-axis. `[number](number "number") y2` The position of the top right corner along y-axis. `[number](number "number") x3` The position of the bottom right corner along x-axis. `[number](number "number") y3` The position of the bottom right corner along y-axis. `[number](number "number") x4` The position of the bottom left corner along x-axis. `[number](number "number") y4` The position of the bottom left corner along y-axis. ### Returns Nothing. Examples -------- ### A quadrilateral that has its top left corner located at 0,0 and whose width and height are 100 pixels. ``` function love.draw() love.graphics.quad("fill", 0, 0, 100, 0, 100, 100, 0, 100) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") love CompressedImageData:getFormat CompressedImageData:getFormat ============================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the format of the CompressedImageData. Function -------- ### Synopsis ``` format = CompressedImageData:getFormat( ) ``` ### Arguments None. ### Returns `[CompressedImageFormat](compressedimageformat "CompressedImageFormat") format` The format of the CompressedImageData. See Also -------- * [CompressedImageData](compressedimagedata "CompressedImageData") love utf8 utf8 ==== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This module is not supported in earlier versions. This library provides basic support for handling UTF-8 encoded strings. It provides all its functions inside the table returned by `require("utf8")`. This library does not provide any support for Unicode other than handling UTF-8 encoding. Any operation that needs the meaning of a character, such as character classification, is outside its scope. For detailed usage, see the [reference manual](https://www.lua.org/manual/5.3/manual.html#6.5). The utf8.char function does not work correctly in [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2"); However, it is not an issue since [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0") Examples -------- Print text the user writes, and erase it using the UTF-8 module. ``` local utf8 = require("utf8")   function love.load() text = "Type away! -- "   -- enable key repeat so backspace can be held down to trigger love.keypressed multiple times. love.keyboard.setKeyRepeat(true) end   function love.textinput(t) text = text .. t end   function love.keypressed(key) if key == "backspace" then -- get the byte offset to the last UTF-8 character in the string. local byteoffset = utf8.offset(text, -1)   if byteoffset then -- remove the last UTF-8 character. -- string.sub operates on bytes rather than UTF-8 characters, so we couldn't do string.sub(text, 1, -2). text = string.sub(text, 1, byteoffset - 1) end end end   function love.draw() love.graphics.printf(text, 0, 0, love.graphics.getWidth()) end ``` See Also -------- * [love](love "love") * [love.textinput](love.textinput "love.textinput") love love.graphics.printf love.graphics.printf ==================== Draws formatted text, with word wrap and alignment. See additional notes in [love.graphics.print](love.graphics.print "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](https://love2d.org/wiki/0.9.2 "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](https://love2d.org/wiki/0.10.0 "0.10.0") and newer this is no longer the case. In versions prior to [11.0](https://love2d.org/wiki/11.0 "11.0"), color and byte component values were within the range of 0 to 255 instead of 0 to 1. Aligning does not work as one might expect! It doesn't align to the x/y coordinates given, but in a rectangle, where the limit is the width. Text may appear blurry if it's rendered at non-integer pixel locations. Function -------- ### Synopsis ``` love.graphics.printf( text, x, y, limit, align, r, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[string](string "string") text` A text string. `[number](number "number") x` The position on the x-axis. `[number](number "number") y` The position on the y-axis. `[number](number "number") limit` Wrap the line after this many horizontal pixels. `[AlignMode](alignmode "AlignMode") align ("left")` The alignment. `[number](number "number") r (0)` Available since 0.9.0 Orientation (radians). `[number](number "number") sx (1)` Available since 0.9.0 Scale factor (x-axis). `[number](number "number") sy (sx)` Available since 0.9.0 Scale factor (y-axis). `[number](number "number") ox (0)` Available since 0.9.0 Origin offset (x-axis). `[number](number "number") oy (0)` Available since 0.9.0 Origin offset (y-axis). `[number](number "number") kx (0)` Available since 0.9.0 Shearing factor (x-axis). `[number](number "number") ky (0)` Available since 0.9.0 Shearing factor (y-axis). ### Returns Nothing. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.printf( text, font, x, y, limit, align, r, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[string](string "string") text` A text string. `[Font](font "Font") font` The Font object to use. `[number](number "number") x` The position on the x-axis. `[number](number "number") y` The position on the y-axis. `[number](number "number") limit` Wrap the line after this many horizontal pixels. `[AlignMode](alignmode "AlignMode") align ("left")` The alignment. `[number](number "number") r (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Shearing factor (x-axis). `[number](number "number") ky (0)` Shearing factor (y-axis). ### Returns Nothing. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.printf( text, transform, limit, align ) ``` ### Arguments `[string](string "string") text` A text string. `[Transform](transform "Transform") transform` Transformation object. `[number](number "number") limit` Wrap the line after this many horizontal pixels. `[AlignMode](alignmode "AlignMode") align ("left")` The alignment. ### Returns Nothing. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.printf( text, font, transform, limit, align ) ``` ### Arguments `[string](string "string") text` A text string. `[Font](font "Font") font` The Font object to use. `[Transform](transform "Transform") transform` Transformation object. `[number](number "number") limit` Wrap the line after this many horizontal pixels. `[AlignMode](alignmode "AlignMode") align ("left")` The alignment. ### Returns Nothing. Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.printf( coloredtext, x, y, limit, align, angle, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[table](table "table") coloredtext` A table containing colors and strings to add to the object, in the form of `{color1, string1, color2, string2, ...}`. `[table](table "table") 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}`. `[string](string "string") string1` A string of text which has a color specified by the previous color. `[table](table "table") 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}`. `[string](string "string") string2` A string of text which has a color specified by the previous color. `[tables and strings](https://love2d.org/w/index.php?title=tables_and_strings&action=edit&redlink=1 "tables and strings (page does not exist)") ...` Additional colors and strings. `[number](number "number") x` The position of the text (x-axis). `[number](number "number") y` The position of the text (y-axis). `[number](number "number") limit` The maximum width in pixels of the text before it gets automatically wrapped to a new line. `[AlignMode](alignmode "AlignMode") align` The alignment of the text. `[number](number "number") angle (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Shearing / skew factor (x-axis). `[number](number "number") ky (0)` Shearing / skew factor (y-axis). ### Returns Nothing. ### Notes The color set by [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor") will be combined (multiplied) with the colors of the text. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.printf( coloredtext, font, x, y, limit, align, angle, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[table](table "table") coloredtext` A table containing colors and strings to add to the object, in the form of `{color1, string1, color2, string2, ...}`. `[table](table "table") 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}`. `[string](string "string") string1` A string of text which has a color specified by the previous color. `[table](table "table") 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}`. `[string](string "string") string2` A string of text which has a color specified by the previous color. `[tables and strings](https://love2d.org/w/index.php?title=tables_and_strings&action=edit&redlink=1 "tables and strings (page does not exist)") ...` Additional colors and strings. `[Font](font "Font") font` The Font object to use. `[number](number "number") x` The position on the x-axis. `[number](number "number") y` The position on the y-axis. `[number](number "number") limit` Wrap the line after this many horizontal pixels. `[AlignMode](alignmode "AlignMode") align ("left")` The alignment. `[number](number "number") angle (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Shearing factor (x-axis). `[number](number "number") ky (0)` Shearing factor (y-axis). ### Returns Nothing. ### Notes The color set by [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor") will be combined (multiplied) with the colors of the text. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.printf( coloredtext, transform, limit, align ) ``` ### Arguments `[table](table "table") coloredtext` A table containing colors and strings to add to the object, in the form of `{color1, string1, color2, string2, ...}`. `[table](table "table") 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}`. `[string](string "string") string1` A string of text which has a color specified by the previous color. `[table](table "table") 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}`. `[string](string "string") string2` A string of text which has a color specified by the previous color. `[tables and strings](https://love2d.org/w/index.php?title=tables_and_strings&action=edit&redlink=1 "tables and strings (page does not exist)") ...` Additional colors and strings. `[Transform](transform "Transform") transform` Transformation object. `[number](number "number") limit` Wrap the line after this many horizontal pixels. `[AlignMode](alignmode "AlignMode") align ("left")` The alignment. ### Returns Nothing. ### Notes The color set by [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor") will be combined (multiplied) with the colors of the text. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.printf( coloredtext, font, transform, limit, align ) ``` ### Arguments `[table](table "table") coloredtext` A table containing colors and strings to add to the object, in the form of `{color1, string1, color2, string2, ...}`. `[table](table "table") 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}`. `[string](string "string") string1` A string of text which has a color specified by the previous color. `[table](table "table") 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}`. `[string](string "string") string2` A string of text which has a color specified by the previous color. `[tables and strings](https://love2d.org/w/index.php?title=tables_and_strings&action=edit&redlink=1 "tables and strings (page does not exist)") ...` Additional colors and strings. `[Font](font "Font") font` The Font object to use. `[Transform](transform "Transform") transform` Transformation object. `[number](number "number") limit` Wrap the line after this many horizontal pixels. `[AlignMode](alignmode "AlignMode") align ("left")` The alignment. ### Returns Nothing. ### Notes The color set by [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor") will be combined (multiplied) with the colors of the text. Examples -------- Draw text to the screen with right alignment and a horizontal limit of 125. ``` love.graphics.printf("This text is aligned right, and wraps when it gets too big.", 25, 25, 125, "right") ``` Notes ----- Note that the limit argument affects the position of your text for 'center' and 'right' alignment. ``` love.graphics.printf("This text is aligned center",100, 100, 200,"center") -- center your text around x = 200/2 + 100 = 200 love.graphics.printf("This text is aligned right",100, 100, 200,"right") -- align right to x = 100 + 200 = 300 ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [Font:getWrap](font-getwrap "Font:getWrap") love Texture:getDepthSampleMode Texture:getDepthSampleMode ========================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the comparison mode used when sampling from a [depth texture](pixelformat "PixelFormat") in a shader. Depth texture comparison modes are advanced low-level functionality typically used with shadow mapping in 3D. Function -------- ### Synopsis ``` compare = Texture:getDepthSampleMode( ) ``` ### Arguments None. ### Returns `[CompareMode](comparemode "CompareMode") compare (nil)` The comparison mode used when sampling from this texture in a shader, or nil if setDepthSampleMode has not been called on this Texture. See Also -------- * [Texture](texture "Texture") * [Texture:setDepthSampleMode](texture-setdepthsamplemode "Texture:setDepthSampleMode") * [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") love enet.peer:state enet.peer:state =============== Returns the state of the [peer](enet.peer "enet.peer") as a [string](string "string"). Function -------- ### Synopsis ``` peer:state() ``` ### Arguments None. ### Returns `[string](string "string") state` The [peer's](enet.peer "enet.peer") current state. It can be any of the following: * "disconnected" * "connecting" * "acknowledging\_connect" * "connection\_pending" * "connection\_succeeded" * "connected" * "disconnect\_later" * "disconnecting" * "acknowledging\_disconnect" * "zombie" * "unknown" See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.peer](enet.peer "enet.peer") love enet:host create enet:host create ================ Returns a new [host](enet.host "enet.host"). All arguments are optional. A bind\_address of [nil](nil "nil") makes a [host](enet.host "enet.host") that can not be connected to (typically a client). Otherwise the address can either be of the form <ipaddress>:<port>, <hostname>:<port>, or \*:<port>. Example addresses include "127.0.0.1:8888", "localhost:2232", and "\*:6767". If port is 0, the system automatically chooses an ephemeral port and you can get port number by [host:get\_socket\_address](enet.host-get_socket_address "enet.host:get socket address")(). Function -------- ### Synopsis ``` host = enet.host_create(bind_address, peer_count, channel_count, in_bandwidth, out_bandwidth) ``` ### Arguments `[string](string "string") bind_address` The address to connect to in the format "ip:port". `[number](number "number") peer_count` The max number of peers. Defaults to 64. `[number](number "number") channel_count` The max number of channels. Defaults to 1. `[number](number "number") in_bandwidth` Downstream bandwidth in bytes/sec. Defaults to 0 (unlimited). `[number](number "number") out_bandwidth` Upstream bandwidth in bytes/sec. Defaults to 0 (unlimited). ### Returns `[enet.host](enet.host "enet.host") host` The requested [host](enet.host "enet.host"). See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.host](enet.host "enet.host") * [enet.host:channel\_limit](enet.host-channel_limit "enet.host:channel limit") * [enet.host:bandwidth\_limit](enet.host-bandwidth_limit "enet.host:bandwidth limit")
programming_docs
love love.mouse.setVisible love.mouse.setVisible ===================== Sets the current visibility of the cursor. Function -------- ### Synopsis ``` love.mouse.setVisible( visible ) ``` ### Arguments `[boolean](boolean "boolean") visible` True to set the cursor to visible, false to hide the cursor. ### Returns Nothing. Examples -------- Toggle mouse visibility by pressing tab. ``` function love.keypressed(key) if key == "tab" then local state = not love.mouse.isVisible() -- the opposite of whatever it currently is love.mouse.setVisible(state) end end ``` See Also -------- * [love.mouse](love.mouse "love.mouse") * [love.mouse.isVisible](love.mouse.isvisible "love.mouse.isVisible") love enet.peer:throttle configure enet.peer:throttle configure ============================ Changes the probability at which unreliable packets should not be dropped. Function -------- ### Synopsis ``` peer:throttle_configure(interval, acceleration, deceleration) ``` ### Arguments `[number](number "number") interval` Interval in milliseconds to measure lowest mean [RTT](enet.peer-round_trip_time "enet.peer:round trip time"). `[number](number "number") acceleration` Rate at which to increase throttle probability as mean [RTT](enet.peer-round_trip_time "enet.peer:round trip time") declines. `[number](number "number") deceleration` Rate at which to decrease throttle probability as mean [RTT](enet.peer-round_trip_time "enet.peer:round trip time") increases. ### Returns Nothing. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.peer](enet.peer "enet.peer") * [enet.peer:round\_trip\_time](enet.peer-round_trip_time "enet.peer:round trip time") love love.displayrotated love.displayrotated =================== **Available since LÖVE [11.3](https://love2d.org/wiki/11.3 "11.3")** This callback is not supported in earlier versions. Called when the device display orientation changed, for example, user rotated their phone 180 degrees. Function -------- ### Synopsis ``` love.displayrotated( index, orientation ) ``` ### Arguments `[number](number "number") index` The index of the display that changed orientation. `[DisplayOrientation](displayorientation "DisplayOrientation") orientation` The new orientation. ### Returns Nothing. See Also -------- * [love](love "love") * [love.window.getDisplayOrientation](love.window.getdisplayorientation "love.window.getDisplayOrientation") love love.graphics.setPoint love.graphics.setPoint ====================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** Use [love.graphics.setPointSize](love.graphics.setpointsize "love.graphics.setPointSize") and [love.graphics.setPointStyle](love.graphics.setpointstyle "love.graphics.setPointStyle"). Sets the point size and style. Function -------- ### Synopsis ``` love.graphics.setPoint( size, style ) ``` ### Arguments `[number](number "number") size` The new point size. `[PointStyle](pointstyle "PointStyle") style` The new point style. ### Returns Nothing. Examples -------- Increase the point size by 1 and set it to smooth. ``` local s = love.graphics.getPointSize() + 1 love.graphics.setPoint(s, "smooth") ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setPointSize](love.graphics.setpointsize "love.graphics.setPointSize") * [love.graphics.setPointStyle](love.graphics.setpointstyle "love.graphics.setPointStyle") love love.graphics.newCanvas love.graphics.newCanvas ======================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been renamed from [love.graphics.newFramebuffer](love.graphics.newframebuffer "love.graphics.newFramebuffer"). Creates a new [Canvas](canvas "Canvas") object for offscreen rendering. This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- ### Synopsis ``` canvas = love.graphics.newCanvas( ) ``` ### Arguments None. ### Returns `[Canvas](canvas "Canvas") canvas` A new Canvas with dimensions equal to the window's size in pixels. Function -------- ### Synopsis ``` canvas = love.graphics.newCanvas( width, height ) ``` ### Arguments `[number](number "number") width` The desired width of the Canvas. `[number](number "number") height` The desired height of the Canvas. ### Returns `[Canvas](canvas "Canvas") canvas` A new Canvas with specified width and height. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. Creates a 2D or [cubemap](texturetype "TextureType") Canvas using the given settings. ### Synopsis ``` canvas = love.graphics.newCanvas( width, height, settings ) ``` ### Arguments `[number](number "number") width` The desired width of the Canvas. `[number](number "number") height` The desired height of the Canvas. `[table](table "table") settings` A table containing the given fields: `[TextureType](texturetype "TextureType") type ("2d")` The type of Canvas to create. `[PixelFormat](pixelformat "PixelFormat") format ("normal")` The format of the Canvas. `[boolean](boolean "boolean") readable` Whether the Canvas is [readable](texture-isreadable "Texture:isReadable") (drawable and accessible in a [Shader](shader "Shader")). True by default for regular formats, false by default for depth/stencil formats. `[number](number "number") msaa (0)` The desired number of multisample antialiasing (MSAA) samples used when drawing to the Canvas. `[number](number "number") dpiscale ([love.graphics.getDPIScale](love.graphics.getdpiscale "love.graphics.getDPIScale")())` The [DPI scale factor](texture-getdpiscale "Texture:getDPIScale") of the Canvas, used when drawing to the Canvas as well as when drawing the Canvas to the screen. `[MipmapMode](mipmapmode "MipmapMode") mipmaps ("none")` Whether the Canvas has mipmaps, and whether to automatically regenerate them if so. ### Returns `[Canvas](canvas "Canvas") canvas` A new Canvas with specified width and height. ### Notes Some Canvas formats have higher system requirements than the default format. Use [love.graphics.getCanvasFormats](love.graphics.getcanvasformats "love.graphics.getCanvasFormats") to check for support. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. Creates a [volume or array](texturetype "TextureType") texture-type Canvas. ### Synopsis ``` canvas = love.graphics.newCanvas( width, height, layers, settings ) ``` ### Arguments `[number](number "number") width` The desired width of the Canvas. `[number](number "number") height` The desired height of the Canvas. `[number](number "number") layers` The number of array layers (if the Canvas is an Array Texture), or the volume depth (if the Canvas is a Volume Texture). `[table](table "table") settings` A table containing the given fields: `[TextureType](texturetype "TextureType") type ("array")` The type of Canvas to create. `[PixelFormat](pixelformat "PixelFormat") format ("normal")` The format of the Canvas. `[boolean](boolean "boolean") readable` Whether the Canvas is [readable](texture-isreadable "Texture:isReadable") (drawable and accessible in a [Shader](shader "Shader")). True by default for regular formats, false by default for depth/stencil formats. `[number](number "number") msaa (0)` The desired number of multisample antialiasing (MSAA) samples used when drawing to the Canvas. `[number](number "number") dpiscale ([love.graphics.getDPIScale](love.graphics.getdpiscale "love.graphics.getDPIScale")())` The [DPI scale factor](texture-getdpiscale "Texture:getDPIScale") of the Canvas, used when drawing to the Canvas as well as when drawing the Canvas to the screen. `[MipmapMode](mipmapmode "MipmapMode") mipmaps ("none")` Whether the Canvas has mipmaps, and whether to automatically regenerate them if so. ### Returns `[Canvas](canvas "Canvas") canvas` A new Canvas with specified width and height. ### Notes Not all texture types are supported by all systems. [love.graphics.getTextureTypes](love.graphics.gettexturetypes "love.graphics.getTextureTypes") can check for support. Function -------- **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0") and removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier or later versions. ### Synopsis ``` canvas = love.graphics.newCanvas( width, height, format ) ``` ### Arguments `[number](number "number") width (window_width)` The desired width of the Canvas. `[number](number "number") height (window_height)` The desired height of the Canvas. `[CanvasFormat](canvasformat "CanvasFormat") format ("normal")` The desired texture format of the Canvas. ### Returns `[Canvas](canvas "Canvas") canvas` A new Canvas with specified width and height. ### Notes Some Canvas formats have higher system requirements than the default format. Use [love.graphics.getCanvasFormats](love.graphics.getcanvasformats "love.graphics.getCanvasFormats") to check for support. Function -------- **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1") and removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier or later versions. ### Synopsis ``` canvas = love.graphics.newCanvas( width, height, format, msaa ) ``` ### Arguments `[number](number "number") width (window_width)` The desired width of the Canvas. `[number](number "number") height (window_height)` The desired height of the Canvas. `[CanvasFormat](canvasformat "CanvasFormat") format ("normal")` The desired texture format of the Canvas. `[number](number "number") msaa (0)` The desired number of multisample antialiasing (MSAA) samples used when drawing to the Canvas. ### Returns `[Canvas](canvas "Canvas") canvas` A new Canvas with specified width and height. Notes ----- * Not all texture types are supported by all systems. [love.graphics.getTextureTypes](love.graphics.gettexturetypes "love.graphics.getTextureTypes") can check for support. * Some Canvas formats have higher system requirements than the default format. Use [love.graphics.getCanvasFormats](love.graphics.getcanvasformats "love.graphics.getCanvasFormats") to check for support. * The supported maximum number of MSAA samples varies depending on the system. Use [love.graphics.getSystemLimits](love.graphics.getsystemlimits "love.graphics.getSystemLimits") to check. * If the number of MSAA samples specified is greater than the maximum supported by the system, the Canvas will still be created but only using the maximum supported amount (**this includes 0.**) See Also -------- * [love.graphics](love.graphics "love.graphics") * [Canvas](canvas "Canvas") * [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas") love love.graphics.getPixelEffect love.graphics.getPixelEffect ============================ **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [love.graphics.getShader](love.graphics.getshader "love.graphics.getShader"). Returns the current PixelEffect. Returns nil if none is set. Function -------- ### Synopsis ``` pe = love.graphics.getPixelEffect( ) ``` ### Arguments None. ### Returns `[PixelEffect](pixeleffect "PixelEffect") pe` The current PixelEffect. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setPixelEffect](love.graphics.setpixeleffect "love.graphics.setPixelEffect") love World:setGravity World:setGravity ================ Set the gravity of the world. Function -------- ### Synopsis ``` World:setGravity( x, y ) ``` ### Arguments `[number](number "number") x` The x component of gravity. `[number](number "number") y` The y component of gravity. ### Returns Nothing. See Also -------- * [World](world "World") love RevoluteJoint:hasLimitsEnabled RevoluteJoint:hasLimitsEnabled ============================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [RevoluteJoint:isLimitsEnabled](revolutejoint-islimitsenabled "RevoluteJoint:isLimitsEnabled"). | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | This function has been renamed to [RevoluteJoint:areLimitsEnabled](revolutejoint-arelimitsenabled "RevoluteJoint:areLimitsEnabled"). | Checks whether limits are enabled. Function -------- ### Synopsis ``` enabled = RevoluteJoint:hasLimitsEnabled( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") enabled` True if enabled, false otherwise. See Also -------- * [RevoluteJoint](revolutejoint "RevoluteJoint") love love.graphics.isActive love.graphics.isActive ====================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets whether the graphics module is able to be used. If it is not active, [love.graphics](love.graphics "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. Function -------- ### Synopsis ``` active = love.graphics.isActive( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") active` Whether the graphics module is active and able to be used. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.window.close](love.window.close "love.window.close") * [love.window.setMode](love.window.setmode "love.window.setMode") love MouseJoint:getFrequency MouseJoint:getFrequency ======================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the frequency. Function -------- ### Synopsis ``` freq = MouseJoint:getFrequency( ) ``` ### Arguments None. ### Returns `[number](number "number") freq` The frequency in hertz. See Also -------- * [MouseJoint](mousejoint "MouseJoint") * [MouseJoint:setFrequency](mousejoint-setfrequency "MouseJoint:setFrequency") love GamepadButton GamepadButton ============= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This enum is not supported in earlier versions. Virtual gamepad buttons. Constants --------- a Bottom face button (A). b Right face button (B). x Left face button (X). y Top face button (Y). back Back button. guide Guide button. start Start button. leftstick Left stick click button. rightstick Right stick click button. leftshoulder Left bumper. rightshoulder Right bumper. dpup D-pad up. dpdown D-pad down. dpleft D-pad left. dpright D-pad right. Notes ----- The physical locations of the virtual gamepad buttons for a [Joystick](joystick "Joystick") correspond as closely as possible to the layout of the buttons on a standard Xbox 360 controller. See Also -------- * [love.joystick](love.joystick "love.joystick") * [Joystick](joystick "Joystick") * [Joystick:isGamepadDown](joystick-isgamepaddown "Joystick:isGamepadDown") love BezierCurve:getControlPointCount BezierCurve:getControlPointCount ================================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Get the number of control points in the Bézier curve. Function -------- ### Synopsis ``` count = BezierCurve:getControlPointCount( ) ``` ### Arguments None. ### Returns `[number](number "number") count` The number of control points. See Also -------- * [BezierCurve](beziercurve "BezierCurve") * [BezierCurve:getControlPoint](beziercurve-getcontrolpoint "BezierCurve:getControlPoint") * [BezierCurve:setControlPoint](beziercurve-setcontrolpoint "BezierCurve:setControlPoint") * [BezierCurve:insertControlPoint](beziercurve-insertcontrolpoint "BezierCurve:insertControlPoint") * [love.math](love.math "love.math") love MouseJoint:getDampingRatio MouseJoint:getDampingRatio ========================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the damping ratio. Function -------- ### Synopsis ``` ratio = MouseJoint:getDampingRatio( ) ``` ### Arguments None. ### Returns `[number](number "number") ratio` The new damping ratio. See Also -------- * [MouseJoint](mousejoint "MouseJoint") * [MouseJoint:setDampingRatio](mousejoint-setdampingratio "MouseJoint:setDampingRatio") love love.physics.getMeter love.physics.getMeter ===================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Returns the meter scale factor. All coordinates in the physics module are divided by this number, creating a convenient way to draw the objects directly to the screen without the need for graphics transformations. It is recommended to create shapes no larger than 10 times the scale. This is important because Box2D is tuned to work well with shape sizes from 0.1 to 10 meters. Function -------- ### Synopsis ``` scale = love.physics.getMeter( ) ``` ### Arguments None. ### Returns `[number](number "number") scale` The scale factor as an integer. See Also -------- * [love.physics](love.physics "love.physics") * [love.physics.setMeter](love.physics.setmeter "love.physics.setMeter") love string string ====== From the Lua 5.1 [reference manual §2.2](https://www.lua.org/manual/5.1/manual.html#2.2): String represents arrays of characters. Lua is 8-bit clean: strings can contain any 8-bit character, including embedded zeros ('\0') (see [§2.1](https://www.lua.org/manual/5.1/manual.html#2.1)). love love.data.newDataView love.data.newDataView ===================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Creates a new Data referencing a subsection of an existing Data object. This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- ### Synopsis ``` view = love.data.newDataView( data, offset, size ) ``` ### Arguments `[Data](data "Data") data` The Data object to reference. `[number](number "number") offset` The offset of the subsection to reference, in bytes. `[number](number "number") size` The size in bytes of the subsection to reference. ### Returns `[Data](data "Data") view` The new Data view. Notes ----- [Data:getString](data-getstring "Data:getString") and [Data:getPointer](data-getpointer "Data:getPointer") will return the original Data object's contents, with the view's offset and size applied. See Also -------- * [love.data](love.data "love.data") love enet.linked version enet.linked version =================== Returns the included ENet's version as a string. Function -------- ### Synopsis ``` version = enet.linked_version() ``` ### Arguments None. ### Returns `[string](string "string") version` ENet's version. See Also -------- * [lua-enet](lua-enet "lua-enet")
programming_docs
love GlyphData:getBoundingBox GlyphData:getBoundingBox ======================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Gets glyph bounding box. Function -------- ### Synopsis ``` x, y, width, height = GlyphData:getBoundingBox() ``` ### Arguments None. ### Returns `[number](number "number") x` Glyph position x. `[number](number "number") y` Glyph position y. `[number](number "number") width` Glyph width. `[number](number "number") height` Glyph height. See Also -------- * [GlyphData](glyphdata "GlyphData") love Texture:getFormat Texture:getFormat ================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the [pixel format](pixelformat "PixelFormat") of the Texture. Function -------- ### Synopsis ``` format = Texture:getFormat( ) ``` ### Arguments None. ### Returns `[PixelFormat](pixelformat "PixelFormat") format` The pixel format the Texture was created with. See Also -------- * [Texture](texture "Texture") love Mesh:getDrawRange Mesh:getDrawRange ================= **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. Gets the range of vertices used when drawing the Mesh. Function -------- ### Synopsis ``` min, max = Mesh:getDrawRange( ) ``` ### Arguments None. ### Returns `[number](number "number") min (nil)` The index of the first vertex used when drawing, or the index of the first value in the vertex map used if one is set for this Mesh. `[number](number "number") max (nil)` The index of the last vertex used when drawing, or the index of the last value in the vertex map used if one is set for this Mesh. ### Notes If the Mesh's draw range has not been set previously with [Mesh:setDrawRange](mesh-setdrawrange "Mesh:setDrawRange"), this function will return nil. See Also -------- * [Mesh](mesh "Mesh") * [Mesh:setDrawRange](mesh-setdrawrange "Mesh:setDrawRange") love love.touch.getPressure love.touch.getPressure ====================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets the current pressure of the specified touch-press. Function -------- ### Synopsis ``` pressure = love.touch.getPressure( id ) ``` ### Arguments `[light userdata](light_userdata "light userdata") id` The identifier of the touch-press. Use [love.touch.getTouches](love.touch.gettouches "love.touch.getTouches"), [love.touchpressed](love.touchpressed "love.touchpressed"), or [love.touchmoved](love.touchmoved "love.touchmoved") to obtain touch id values. ### Returns `[number](number "number") pressure` The pressure of the touch-press. Most touch screens aren't pressure sensitive, in which case the pressure will be 1. See Also -------- * [love.touch](love.touch "love.touch") * [love.touch.getTouches](love.touch.gettouches "love.touch.getTouches") * [love.touchpressed](love.touchpressed "love.touchpressed") * [love.touchmoved](love.touchmoved "love.touchmoved") love Fixture:getBoundingBox Fixture:getBoundingBox ====================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the points of the fixture bounding box. In case the fixture has multiple children a 1-based index can be specified. For example, a fixture will have multiple children with a chain shape. Function -------- ### Synopsis ``` topLeftX, topLeftY, bottomRightX, bottomRightY = Fixture:getBoundingBox( index ) ``` ### Arguments `[number](number "number") index (1)` A bounding box of the fixture. ### Returns `[number](number "number") topLeftX` The x position of the top-left point. `[number](number "number") topLeftY` The y position of the top-left point. `[number](number "number") bottomRightX` The x position of the bottom-right point. `[number](number "number") bottomRightY` The y position of the bottom-right point. See Also -------- * [Fixture](fixture "Fixture") love love.audio.getEffect love.audio.getEffect ==================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the settings associated with an effect. Function -------- ### Synopsis ``` settings = love.audio.getEffect(name) ``` ### Arguments `[string](string "string") name` The name of the effect. ### Returns `[table](table "table") settings` The settings associated with the effect. See Also -------- * [love.audio](love.audio "love.audio") * [love.audio.setEffect](love.audio.seteffect "love.audio.setEffect") love SpriteBatch:setBufferSize SpriteBatch:setBufferSize ========================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0") and removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** SpriteBatches now automatically grow when necessary. Sets the maximum number of sprites the SpriteBatch can hold. Existing sprites in the batch (up to the new maximum) will *not* be cleared when this function is called. This function can be slow if it is called every frame, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). Function -------- ### Synopsis ``` SpriteBatch:setBufferSize( size ) ``` ### Arguments `[number](number "number") size` The new maximum number of sprites the batch can hold. ### Returns Nothing. See Also -------- * [SpriteBatch](spritebatch "SpriteBatch") * [SpriteBatch:getBufferSize](spritebatch-getbuffersize "SpriteBatch:getBufferSize") * [SpriteBatch:getCount](spritebatch-getcount "SpriteBatch:getCount") love love.physics.newWheelJoint love.physics.newWheelJoint ========================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Creates a wheel joint. Function -------- ### Synopsis ``` joint = love.physics.newWheelJoint( body1, body2, x, y, ax, ay, collideConnected ) ``` ### Arguments `[Body](body "Body") body1` The first body. `[Body](body "Body") body2` The second body. `[number](number "number") x` The x position of the anchor point. `[number](number "number") y` The y position of the anchor point. `[number](number "number") ax` The x position of the axis unit vector. `[number](number "number") ay` The y position of the axis unit vector. `[boolean](boolean "boolean") collideConnected (false)` Specifies whether the two bodies should collide with each other. ### Returns `[WheelJoint](wheeljoint "WheelJoint") joint` The new WheelJoint. Function -------- ### Synopsis ``` joint = love.physics.newWheelJoint( body1, body2, x1, y1, x2, y2, ax, ay, collideConnected ) ``` ### Arguments `[Body](body "Body") body1` The first body. `[Body](body "Body") body2` The second body. `[number](number "number") x1` The x position of the first anchor point. `[number](number "number") y1` The y position of the first anchor point. `[number](number "number") x2` The x position of the second anchor point. `[number](number "number") y2` The y position of the second anchor point. `[number](number "number") ax` The x position of the axis unit vector. `[number](number "number") ay` The y position of the axis unit vector. `[boolean](boolean "boolean") collideConnected (false)` Specifies whether the two bodies should collide with each other. ### Returns `[WheelJoint](wheeljoint "WheelJoint") joint` The new WheelJoint. See Also -------- * [love.physics](love.physics "love.physics") * [WheelJoint](wheeljoint "WheelJoint") * [Joint](joint "Joint") love GamepadAxis GamepadAxis =========== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This enum is not supported in earlier versions. Virtual gamepad axes. Constants --------- leftx The x-axis of the left thumbstick. lefty The y-axis of the left thumbstick. rightx The x-axis of the right thumbstick. righty The y-axis of the right thumbstick. triggerleft Left analog trigger. triggerright Right analog trigger. Notes ----- The physical locations of the virtual gamepad axes for a [Joystick](joystick "Joystick") correspond as closely as possible to the layout of the axes on a standard Xbox 360 controller. See Also -------- * [love.joystick](love.joystick "love.joystick") * [Joystick](joystick "Joystick") * [Joystick:getGamepadAxis](joystick-getgamepadaxis "Joystick:getGamepadAxis") love love.math.triangulate love.math.triangulate ===================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Decomposes a simple convex or concave polygon into triangles. Function -------- ### Synopsis ``` triangles = love.math.triangulate( polygon ) ``` ### Arguments `[table](table "table") polygon` Polygon to triangulate. Must not intersect itself. ### Returns `[table](table "table") triangles` List of triangles the polygon is composed of, in the form of `{{x1, y1, x2, y2, x3, y3}, {x1, y1, x2, y2, x3, y3}, ...}`. Function -------- ### Synopsis ``` triangles = love.math.triangulate( x1, y1, x2, y2, x3, y3, ... ) ``` ### Arguments `[number](number "number") x1` The position of the first vertex of the polygon on the x-axis. `[number](number "number") y1` The position of the first vertex of the polygon on the y-axis. `[number](number "number") x2` The position of the second vertex of the polygon on the x-axis. `[number](number "number") y2` The position of the second vertex of the polygon on the y-axis. `[number](number "number") x3` The position of the third vertex of the polygon on the x-axis. `[number](number "number") y3` The position of the third vertex of the polygon on the y-axis. ### Returns `[table](table "table") triangles` List of triangles the polygon is composed of, in the form of `{{x1, y1, x2, y2, x3, y3}, {x1, y1, x2, y2, x3, y3}, ...}`. See Also -------- * [love.math](love.math "love.math") * [love.graphics.polygon](love.graphics.polygon "love.graphics.polygon") * [love.physics.newPolygonShape](love.physics.newpolygonshape "love.physics.newPolygonShape") love love.graphics.translate love.graphics.translate ======================= 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](love.draw "love.draw")() exits or else a [love.graphics.pop](love.graphics.pop "love.graphics.pop") reverts to a previous [love.graphics.push](love.graphics.push "love.graphics.push"). Translating using whole numbers will prevent tearing/blurring of images and fonts draw after translating. Function -------- ### Synopsis ``` love.graphics.translate( dx, dy ) ``` ### Arguments `[number](number "number") dx` The translation relative to the x-axis. `[number](number "number") dy` The translation relative to the y-axis. ### Returns Nothing. Examples -------- Translate down and to the right by 10 pixels. Remember, the translation is reset at the end of each [love.draw](love.draw "love.draw"). ``` function love.draw() love.graphics.translate(10, 10) love.graphics.print("Text", 5, 5) -- will effectively render at 15x15 end ``` Move the coordinate system with the mouse: ``` tx=0 ty=0 function love.draw() mx = love.mouse.getX() my = love.mouse.getY() if love.mouse.isDown(1) then if not mouse_pressed then mouse_pressed = true dx = tx-mx dy = ty-my else tx = mx+dx ty = my+dy end elseif mouse_pressed then mouse_pressed = false end love.graphics.translate(tx, ty)   -- example graphics: love.graphics.circle( "line", 0, 0, 400 ) love.graphics.line(-440, 0, 440, 0) love.graphics.line(0, -440, 0, 440) end   -- restore position with the right mouse button: function love.mousepressed(x, y, button, istouch) if button == 2 then tx = 0 ty = 0 end end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.pop](love.graphics.pop "love.graphics.pop") * [love.graphics.push](love.graphics.push "love.graphics.push") * [love.graphics.rotate](love.graphics.rotate "love.graphics.rotate") * [love.graphics.scale](love.graphics.scale "love.graphics.scale") * [love.graphics.shear](love.graphics.shear "love.graphics.shear") * [love.graphics.origin](love.graphics.origin "love.graphics.origin") love love.joystick.getJoysticks love.joystick.getJoysticks ========================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets a list of connected Joysticks. Function -------- ### Synopsis ``` joysticks = love.joystick.getJoysticks( ) ``` ### Arguments None. ### Returns `[table](table "table") joysticks` The list of currently connected [Joysticks](joystick "Joystick"). Examples -------- ``` function love.draw() local joysticks = love.joystick.getJoysticks() for i, joystick in ipairs(joysticks) do love.graphics.print(joystick:getName(), 10, i * 20) end end ``` See Also -------- * [Joystick](joystick "Joystick") * [love.joystick](love.joystick "love.joystick") * [love.joystick.getJoystickCount](love.joystick.getjoystickcount "love.joystick.getJoystickCount") * [love.joystickadded](love.joystickadded "love.joystickadded") * [love.joystickremoved](love.joystickremoved "love.joystickremoved") love RecordingDevice:stop RecordingDevice:stop ==================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Stops recording audio from this device. Any sound data currently in the device's buffer will be returned. Function -------- ### Synopsis ``` data = RecordingDevice:stop( ) ``` ### Arguments None. ### Returns `[SoundData](sounddata "SoundData") data (nil)` The sound data currently in the device's buffer, or nil if the device wasn't recording. See Also -------- * [RecordingDevice](recordingdevice "RecordingDevice") * [RecordingDevice:start](recordingdevice-start "RecordingDevice:start") * [RecordingDevice:getData](recordingdevice-getdata "RecordingDevice:getData") love (File):getFilename (File):getFilename ================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets the filename that the File object was created with. If the file object originated from the [love.filedropped](love.filedropped "love.filedropped") callback, the filename will be the full platform-dependent file path. Function -------- ### Synopsis ``` filename = File:getFilename( ) ``` ### Arguments None. ### Returns `[string](string "string") filename` The filename of the File. See Also -------- * [File](file "File") love variable variable ======== A variable is a value like val, var, and any other letter or word that is not already assigned to something else. Example ------- Changes a variable by 1 each time the left mouse button is clicked ``` function love.mousepressed( x, y, button ) if button == 1 then -- Versions prior to 0.10.0 use the MouseConstant 'l' time = time + 1 end end ``` See Also -------- * [love.mousepressed](love.mousepressed "love.mousepressed") love Channel Channel ======= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This type is not supported in earlier versions. An object which can be used to send and receive data between different threads. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.thread.getChannel](love.thread.getchannel "love.thread.getChannel") | Creates or retrieves a named thread channel. | 0.9.0 | | | [love.thread.newChannel](love.thread.newchannel "love.thread.newChannel") | Creates a new unnamed thread channel. | 0.9.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Channel:clear](channel-clear "Channel:clear") | Clears all the messages in the Channel queue. | 0.9.0 | | | [Channel:demand](channel-demand "Channel:demand") | Wait for and retrieve the value of a Channel message. | 0.9.0 | | | [Channel:getCount](channel-getcount "Channel:getCount") | Retrieves the number of messages in the Channel queue. | 0.9.0 | | | [Channel:hasRead](channel-hasread "Channel:hasRead") | Gets whether a pushed value has been popped or otherwise removed from the Channel. | 11.0 | | | [Channel:peek](channel-peek "Channel:peek") | Receive a message from a thread Channel, but leave it in the queue. | 0.9.0 | | | [Channel:performAtomic](channel-performatomic "Channel:performAtomic") | Executes the specified function atomically with respect to this Channel. | 0.10.0 | | | [Channel:pop](channel-pop "Channel:pop") | Retrieve the value of a Channel message. | 0.9.0 | | | [Channel:push](channel-push "Channel:push") | Send a message to a thread Channel. | 0.9.0 | | | [Channel:supply](channel-supply "Channel:supply") | Send a message to a thread Channel and wait for a thread to accept it. | 0.9.0 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Supertypes ---------- * [Object](object "Object") See Also -------- * [love.thread](love.thread "love.thread") love love.graphics.getShader love.graphics.getShader ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [love.graphics.getPixelEffect](love.graphics.getpixeleffect "love.graphics.getPixelEffect"). Gets the current [Shader](shader "Shader"). Returns nil if none is set. Function -------- ### Synopsis ``` shader = love.graphics.getShader( ) ``` ### Arguments None. ### Returns `[Shader](shader "Shader") shader` The currently active Shader, or [nil](nil "nil") if none is set. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setShader](love.graphics.setshader "love.graphics.setShader") love SpriteBatch:clear SpriteBatch:clear ================= Removes all sprites from the buffer. Function -------- ### Synopsis ``` SpriteBatch:clear( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [SpriteBatch](spritebatch "SpriteBatch") love SoundData:getBits SoundData:getBits ================= **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [SoundData:getBitDepth](sounddata-getbitdepth "SoundData:getBitDepth"). Returns the number of bits per sample. Function -------- ### Synopsis ``` bits = SoundData:getBits( ) ``` ### Arguments None. ### Returns `[number](number "number") bits` Either 8, or 16. See Also -------- * [SoundData](sounddata "SoundData") love number number ====== From the Lua 5.1 [reference manual §2.2](https://www.lua.org/manual/5.1/manual.html#2.2): Number represents real (double-precision floating-point) numbers. love love.graphics.clear love.graphics.clear =================== Clears the screen or active [Canvas](canvas "Canvas") to the specified color. This function is called automatically before [love.draw](love.draw "love.draw") in the default [love.run](love.run "love.run") function. See the example in [love.run](love.run "love.run") for a typical use of this function. Note that the [scissor area](love.graphics.setscissor "love.graphics.setScissor") bounds the cleared region. In versions prior to [11.0](https://love2d.org/wiki/11.0 "11.0"), color component values were within the range of 0 to 255 instead of 0 to 1. In versions prior to [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0"), this function clears the screen to the currently set [background color](love.graphics.setbackgroundcolor "love.graphics.setBackgroundColor") instead. Function -------- Clears the screen to the background color in 0.9.2 and earlier, or to transparent black (0, 0, 0, 0) in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0") and newer. ### Synopsis ``` love.graphics.clear( ) ``` ### Arguments None. ### Returns Nothing. Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. Clears the screen or active [Canvas](canvas "Canvas") to the specified color. ### Synopsis ``` love.graphics.clear( r, g, b, a, clearstencil, cleardepth ) ``` ### Arguments `[number](number "number") r` The red channel of the color to clear the screen to. `[number](number "number") g` The green channel of the color to clear the screen to. `[number](number "number") b` The blue channel of the color to clear the screen to. `[number](number "number") a (1)` The alpha channel of the color to clear the screen to. `[boolean](boolean "boolean") clearstencil (true)` Available since 11.0 Whether to clear the active stencil buffer, [if present](love.graphics.setcanvas "love.graphics.setCanvas"). It can also be an integer between 0 and 255 to clear the stencil buffer to a specific value. `[boolean](boolean "boolean") cleardepth (true)` Available since 11.0 Whether to clear the active depth buffer, [if present](love.graphics.setcanvas "love.graphics.setCanvas"). It can also be a number between 0 and 1 to clear the depth buffer to a specific value. ### Returns Nothing. Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. Clears multiple active [Canvases](canvas "Canvas") to different colors, if multiple Canvases are active at once via [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas"). ### Synopsis ``` love.graphics.clear( color, ..., clearstencil, cleardepth ) ``` ### Arguments `[table](table "table") color` A table in the form of `{r, g, b, a}` containing the color to clear the first active Canvas to. `[table](table "table") ...` Additional tables for each active Canvas. `[boolean](boolean "boolean") clearstencil (true)` Available since 11.0 Whether to clear the active stencil buffer, [if present](love.graphics.setcanvas "love.graphics.setCanvas"). It can also be an integer between 0 and 255 to clear the stencil buffer to a specific value. `[boolean](boolean "boolean") cleardepth (true)` Available since 11.0 Whether to clear the active depth buffer, [if present](love.graphics.setcanvas "love.graphics.setCanvas"). It can also be a number between 0 and 1 to clear the depth buffer to a specific value. ### Returns Nothing. ### Notes A color must be specified for each active Canvas, when this function variant is used. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. Clears the stencil or depth buffers without having to clear the color canvas as well. ### Synopsis ``` love.graphics.clear( clearcolor, clearstencil, cleardepth ) ``` ### Arguments `[boolean](boolean "boolean") clearcolor` Whether to clear the active color canvas to transparent black (`0, 0, 0, 0`). Typically this should be set to false with this variant of the function. `[boolean](boolean "boolean") clearstencil` Whether to clear the active stencil buffer, [if present](love.graphics.setcanvas "love.graphics.setCanvas"). It can also be an integer between 0 and 255 to clear the stencil buffer to a specific value. `[boolean](boolean "boolean") cleardepth` Whether to clear the active depth buffer, [if present](love.graphics.setcanvas "love.graphics.setCanvas"). It can also be a number between 0 and 1 to clear the depth buffer to a specific value. ### Returns Nothing. Examples -------- ### Clear canvas before drawing If the c-key is pressed the canvas will be cleared before drawing a new line on the screen. ``` local canvas = love.graphics.newCanvas() local clear   function love.update() -- Use an anonymous function to draw lines on our canvas. canvas:renderTo( function() if clear then love.graphics.clear() -- Clear the canvas before drawing lines. end   -- Draw lines from the screen's origin to a random x and y coordinate. local rx, ry = love.math.random( 0, love.graphics.getWidth() ), love.math.random( 0, love.graphics.getHeight() ) love.graphics.setColor( love.math.random( ), 0, 0 ) love.graphics.line( 0, 0, rx, ry ) love.graphics.setColor( 1, 1, 1 ) end) end   function love.draw() love.graphics.draw( canvas ) end   function love.keypressed( key ) if key == "c" then clear = not clear end end ``` See Also -------- * [love.graphics.present](love.graphics.present "love.graphics.present") * [love.graphics.setBackgroundColor](love.graphics.setbackgroundcolor "love.graphics.setBackgroundColor") * [love.graphics.setScissor](love.graphics.setscissor "love.graphics.setScissor") * [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas") * [love.graphics](love.graphics "love.graphics")
programming_docs
love love.filesystem.load love.filesystem.load ==================== **Available since LÖVE [0.5.0](https://love2d.org/wiki/0.5.0 "0.5.0")** This function is not supported in earlier versions. Loads a Lua file (but does not run it). Function -------- ### Synopsis ``` chunk, errormsg = love.filesystem.load( name ) ``` ### Arguments `[string](string "string") name` The name (and path) of the file. ### Returns `[function](function "function") chunk` The loaded chunk. `[string](string "string") errormsg (nil)` The error message if file could not be opened. Example ------- It is important to note that love.filesystem.load does **not** invoke the code, it just creates a function (a 'chunk') that will contain the contents of the file inside it. In order to execute the chunk, you have to put () behind it. Also, it is worth noting that loaded files can return values. For example, the following file: ``` return 1+1 ``` Will return 2, when called like this: ``` chunk = love.filesystem.load( name ) -- load the chunk local result = chunk() -- execute the chunk print('result: ' .. tostring(result)) -- prints 'result: 2' ``` This bluescreens if there is a syntax error in the loaded file. If you want to continue your game if the file is not valid (for example if you expect it to be written by users), you can protect the calling of the chunk with [**pcall**](https://www.lua.org/manual/5.1/manual.html#pdf-pcall): ``` local ok, chunk, result ok, chunk = pcall( love.filesystem.load, name ) -- load the chunk safely if not ok then print('The following error happened: ' .. tostring(chunk)) else ok, result = pcall(chunk) -- execute the chunk safely   if not ok then -- will be false if there is an error print('The following error happened: ' .. tostring(result)) else print('The result of loading is: ' .. tostring(result)) end end ``` See Also -------- * [love.filesystem](love.filesystem "love.filesystem") love Source:getFreeBufferCount Source:getFreeBufferCount ========================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the number of free buffer slots in a [queueable Source](love.audio.newqueueablesource "love.audio.newQueueableSource"). If the queueable Source is playing, this value will increase up to the amount the Source was created with. If the queueable Source is stopped, it will process all of its internal buffers first, in which case this function will always return the amount it was created with. Function -------- ### Synopsis ``` settings = Source:getFreeBufferCount( ) ``` ### Arguments None. ### Returns `[number](number "number") buffers` How many more SoundData objects can be queued up. See Also -------- * [Source](source "Source") * [love.audio.newQueueableSource](love.audio.newqueueablesource "love.audio.newQueueableSource") love PrismaticJoint:getMotorForce PrismaticJoint:getMotorForce ============================ Returns the current motor force. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in earlier versions. ### Synopsis ``` force = PrismaticJoint:getMotorForce( invdt ) ``` ### Arguments `[number](number "number") invdt` How long the force applies. Usually the inverse time step or 1/dt. ### Returns `[number](number "number") force` The force on the motor in newtons. Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. ### Synopsis ``` f = PrismaticJoint:getMotorForce( ) ``` ### Arguments None. ### Returns `[number](number "number") f` The current motor force, usually in N. See Also -------- * [PrismaticJoint](prismaticjoint "PrismaticJoint") love love.graphics.captureScreenshot love.graphics.captureScreenshot =============================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function replaces [love.graphics.newScreenshot](love.graphics.newscreenshot "love.graphics.newScreenshot"). Creates a screenshot once the current frame is done (after [love.draw](love.draw "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](love.update "love.update") and it will still capture all of what's drawn to the screen in that frame. This function creates a new [ImageData](imagedata "ImageData") object and can cause love to slow down significantly if it's called every frame. Function -------- Capture a screenshot and save it to a file at the end of the current frame. ### Synopsis ``` love.graphics.captureScreenshot( filename ) ``` ### Arguments `[string](string "string") filename` The 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](imageencodeformat "ImageFormat"). ### Returns Nothing. Function -------- Capture a screenshot and call a callback with the generated [ImageData](imagedata "ImageData") at the end of the current frame. ### Synopsis ``` love.graphics.captureScreenshot( callback ) ``` ### Arguments `[function](function "function") callback` Function which gets called once the screenshot has been captured. An [ImageData](imagedata "ImageData") is passed into the function as its only argument. ### Returns Nothing. Function -------- Capture a screenshot and push the generated [ImageData](imagedata "ImageData") to a [Channel](channel "Channel") at the end of the current frame. ### Synopsis ``` love.graphics.captureScreenshot( channel ) ``` ### Arguments `[Channel](channel "Channel") channel` The Channel to [push](channel-push "Channel:push") the generated [ImageData](imagedata "ImageData") to. ### Returns Nothing. Examples -------- Create a new screenshot and write it to the save directory. ``` function love.load() love.filesystem.setIdentity("screenshot_example") end   function love.keypressed(key) if key == "c" then love.graphics.captureScreenshot(os.time() .. ".png") end end   function love.draw() love.graphics.circle("fill", 400, 300, 200) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [ImageData](imagedata "ImageData") * [ImageData:encode](imagedata-encode "ImageData:encode") * [Channel](channel "Channel") love love.filedropped love.filedropped ================ **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Callback function triggered when a file is dragged and dropped onto the window. Function -------- ### Synopsis ``` love.filedropped( file ) ``` ### Arguments `[DroppedFile](droppedfile "DroppedFile") file` The unopened File object representing the file that was dropped. ### Returns Nothing. Examples -------- Read and print the file, drag-and-dropped to love window using [(File):read]((file)-read "(File):read") and [(File):getFilename]((file)-getfilename "(File):getFilename"). ``` function love.filedropped(file) file:open("r") local data = file:read() print("Content of " .. file:getFilename() .. ' is') print(data) print("End of file") end ``` Notes ----- [File:open]((file)-open "(File):open") must be called on the file before reading from or writing to it. [File:getFilename]((file)-getfilename "(File):getFilename") will return the full platform-dependent path to the file. See Also -------- * [love](love "love") * [love.directorydropped](love.directorydropped "love.directorydropped") love enet.peer:index enet.peer:index =============== Returns the index of the [peer](enet.peer "enet.peer"). All [peers](enet.peer "enet.peer") of an ENet [host](enet.host "enet.host") are kept in an array. This function finds and returns the index of the [peer](enet.peer "enet.peer") of its [host](enet.host "enet.host") structure. Function -------- ### Synopsis ``` peer:index() ``` ### Arguments None. ### Returns `[number](number "number") index` The index of the peer. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.peer](enet.peer "enet.peer") * [enet.host](enet.host "enet.host") love MouseJoint:getTarget MouseJoint:getTarget ==================== Gets the target point. Function -------- ### Synopsis ``` x, y = MouseJoint:getTarget( ) ``` ### Arguments None. ### Returns `[number](number "number") x` The x-component of the target. `[number](number "number") y` The x-component of the target. See Also -------- * [MouseJoint](mousejoint "MouseJoint") love love.window.fromPixels love.window.fromPixels ====================== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Converts a number from pixels to density-independent units. 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](love.window.setmode "love.window.setMode") enabled, the window may take up the same physical size as an 800x600 window, but the area inside the window uses 1600x1200 pixels. `love.window.fromPixels(1600)` would return `800` in that case. This function converts coordinates from pixels to the size users are expecting them to display at onscreen. [love.window.toPixels](love.window.topixels "love.window.toPixels") does the opposite. 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. Most LÖVE functions return values and expect arguments in terms of pixels rather than density-independent units. Function -------- ### Synopsis ``` value = love.window.fromPixels( pixelvalue ) ``` ### Arguments `[number](number "number") pixelvalue` A number in pixels to convert to density-independent units. ### Returns `[number](number "number") value` The converted number, in density-independent units. Function -------- ### Synopsis ``` x, y = love.window.fromPixels( px, py ) ``` ### Arguments `[number](number "number") px` The x-axis value of a coordinate in pixels. `[number](number "number") py` The y-axis value of a coordinate in pixels. ### Returns `[number](number "number") x` The converted x-axis value of the coordinate, in density-independent units. `[number](number "number") y` The converted y-axis value of the coordinate, in density-independent units. Notes ----- The units of [love.graphics.getWidth](love.graphics.getwidth "love.graphics.getWidth"), [love.graphics.getHeight](love.graphics.getheight "love.graphics.getHeight"), [love.mouse.getPosition](love.mouse.getposition "love.mouse.getPosition"), mouse events, [love.touch.getPosition](love.touch.getposition "love.touch.getPosition"), and touch events are always in terms of pixels. See Also -------- * [love.window](love.window "love.window") * [love.window.toPixels](love.window.topixels "love.window.toPixels") * [love.window.getPixelScale](love.window.getpixelscale "love.window.getPixelScale") * [love.window.setMode](love.window.setmode "love.window.setMode") * [Config Files](love.conf "Config Files") love Mesh:setVertexAttribute Mesh:setVertexAttribute ======================= **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Sets the properties of a specific attribute within a vertex in the Mesh. Meshes without a custom vertex format specified in [love.graphics.newMesh](love.graphics.newmesh "love.graphics.newMesh") have position as their first attribute, texture coordinates as their second attribute, and color as their third attribute. Function -------- ### Synopsis ``` Mesh:setVertexAttribute( vertexindex, attributeindex, value1, value2, ... ) ``` ### Arguments `[number](number "number") vertexindex` The index of the the vertex to be modified (one-based). `[number](number "number") attributeindex` The index of the attribute within the vertex to be modified (one-based). `[number](number "number") value1` The new value for the first component of the attribute. `[number](number "number") value2` The new value for the second component of the attribute. `[number](number "number") ...` Any additional vertex attribute components. ### Returns Nothing. ### Notes Attribute components which exist within the attribute but are not specified as arguments default to 0 for attributes with the `float` data type, and 1 for the `byte` data type. Examples -------- Modify the colors of a standard mesh after it's created. ``` -- Standard mesh with position, texture coordinates, and color attributes. mesh = love.graphics.newMesh { {0, 0, 0, 0, 1, 1, 1, 1}, -- first vertex positioned at (0, 0) {400, 0, 0, 0, 1, 1, 1, 1}, -- second vertex positioned at (400, 0) {200, 400, 0, 0, 1, 1, 1, 1}, -- third vertex positioned at (200, 400) }   local time = 0   function love.update(dt) time = time + dt   for i = 1, mesh:getVertexCount() do -- The 3rd vertex attribute for a standard mesh is its color. mesh:setVertexAttribute(i, 3, (time * 10) % 1, 1, 1) end end   function love.draw() love.graphics.draw(mesh) end ``` See Also -------- * [Mesh](mesh "Mesh") * [Mesh:getVertexAttribute](mesh-getvertexattribute "Mesh:getVertexAttribute") * [Mesh:getVertexCount](mesh-getvertexcount "Mesh:getVertexCount") * [Mesh:getVertexFormat](mesh-getvertexformat "Mesh:getVertexFormat") * [Mesh:setVertex](mesh-setvertex "Mesh:setVertex") love Scancode Scancode ======== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This enum is not supported in earlier versions. Keyboard scancodes. Scancodes are keyboard layout-independent, so the scancode "w" will be generated if the key in the same place as the "w" key on an [American QWERTY keyboard](https://en.wikipedia.org/wiki/Keyboard_layout#/media/File:ISO_keyboard_(105)_QWERTY_UK.svg) is pressed, no matter what the key is labelled or what the user's operating system settings are. Using scancodes, rather than keycodes, is useful because keyboards with layouts differing from the US/UK layout(s) might have keys that generate 'unknown' keycodes, but the scancodes will still be detected. This however would necessitate having a list for each keyboard layout one would choose to support. One could use textinput or textedited instead, but those only give back the end result of keys used, i.e. you can't get modifiers on their own from it, only the final symbols that were generated. Constants --------- a The 'A' key on an American layout. b The 'B' key on an American layout. c The 'C' key on an American layout. d The 'D' key on an American layout. e The 'E' key on an American layout. f The 'F' key on an American layout. g The 'G' key on an American layout. h The 'H' key on an American layout. i The 'I' key on an American layout. j The 'J' key on an American layout. k The 'K' key on an American layout. l The 'L' key on an American layout. m The 'M' key on an American layout. n The 'N' key on an American layout. o The 'O' key on an American layout. p The 'P' key on an American layout. q The 'Q' key on an American layout. r The 'R' key on an American layout. s The 'S' key on an American layout. t The 'T' key on an American layout. u The 'U' key on an American layout. v The 'V' key on an American layout. w The 'W' key on an American layout. x The 'X' key on an American layout. y The 'Y' key on an American layout. z The 'Z' key on an American layout. 1 The '1' key on an American layout. 2 The '2' key on an American layout. 3 The '3' key on an American layout. 4 The '4' key on an American layout. 5 The '5' key on an American layout. 6 The '6' key on an American layout. 7 The '7' key on an American layout. 8 The '8' key on an American layout. 9 The '9' key on an American layout. 0 The '0' key on an American layout. return The 'return' / 'enter' key on an American layout. escape The 'escape' key on an American layout. backspace The 'backspace' key on an American layout. tab The 'tab' key on an American layout. space The spacebar on an American layout. - The minus key on an American layout. = The equals key on an American layout. [ The left-bracket key on an American layout. ] The right-bracket key on an American layout. \ The backslash key on an American layout. nonus# The non-U.S. hash scancode. ; The semicolon key on an American layout. ' The apostrophe key on an American layout. ` The back-tick / grave key on an American layout. , The comma key on an American layout. . The period key on an American layout. / The forward-slash key on an American layout. capslock The capslock key on an American layout. f1 The F1 key on an American layout. f2 The F2 key on an American layout. f3 The F3 key on an American layout. f4 The F4 key on an American layout. f5 The F5 key on an American layout. f6 The F6 key on an American layout. f7 The F7 key on an American layout. f8 The F8 key on an American layout. f9 The F9 key on an American layout. f10 The F10 key on an American layout. f11 The F11 key on an American layout. f12 The F12 key on an American layout. f13 The F13 key on an American layout. f14 The F14 key on an American layout. f15 The F15 key on an American layout. f16 The F16 key on an American layout. f17 The F17 key on an American layout. f18 The F18 key on an American layout. f19 The F19 key on an American layout. f20 The F20 key on an American layout. f21 The F21 key on an American layout. f22 The F22 key on an American layout. f23 The F23 key on an American layout. f24 The F24 key on an American layout. lctrl The left control key on an American layout. lshift The left shift key on an American layout. lalt The left alt / option key on an American layout. lgui The left GUI (command / windows / super) key on an American layout. rctrl The right control key on an American layout. rshift The right shift key on an American layout. ralt The right alt / option key on an American layout. rgui The right GUI (command / windows / super) key on an American layout. printscreen The printscreen key on an American layout. scrolllock The scroll-lock key on an American layout. pause The pause key on an American layout. insert The insert key on an American layout. home The home key on an American layout. numlock The numlock / clear key on an American layout. pageup The page-up key on an American layout. delete The forward-delete key on an American layout. end The end key on an American layout. pagedown The page-down key on an American layout. right The right-arrow key on an American layout. left The left-arrow key on an American layout. down The down-arrow key on an American layout. up The up-arrow key on an American layout. nonusbackslash The non-U.S. backslash scancode. application The application key on an American layout. Windows contextual menu, compose key. execute The 'execute' key on an American layout. help The 'help' key on an American layout. menu The 'menu' key on an American layout. select The 'select' key on an American layout. stop The 'stop' key on an American layout. again The 'again' key on an American layout. undo The 'undo' key on an American layout. cut The 'cut' key on an American layout. copy The 'copy' key on an American layout. paste The 'paste' key on an American layout. find The 'find' key on an American layout. ### Keypad scancodes kp/ The keypad forward-slash key on an American layout. kp\* The keypad '\*' key on an American layout. kp- The keypad minus key on an American layout. kp+ The keypad plus key on an American layout. kp= The keypad equals key on an American layout. kpenter The keypad enter key on an American layout. kp1 The keypad '1' key on an American layout. kp2 The keypad '2' key on an American layout. kp3 The keypad '3' key on an American layout. kp4 The keypad '4' key on an American layout. kp5 The keypad '5' key on an American layout. kp6 The keypad '6' key on an American layout. kp7 The keypad '7' key on an American layout. kp8 The keypad '8' key on an American layout. kp9 The keypad '9' key on an American layout. kp0 The keypad '0' key on an American layout. kp. The keypad period key on an American layout. ### International / language scancodes international1 The 1st international key on an American layout. Used on Asian keyboards. international2 The 2nd international key on an American layout. international3 The 3rd international key on an American layout. Yen. international4 The 4th international key on an American layout. international5 The 5th international key on an American layout. international6 The 6th international key on an American layout. international7 The 7th international key on an American layout. international8 The 8th international key on an American layout. international9 The 9th international key on an American layout. lang1 Hangul/English toggle scancode. lang2 Hanja conversion scancode. lang3 Katakana scancode. lang4 Hiragana scancode. lang5 Zenkaku/Hankaku scancode. ### Media scancodes mute The mute key on an American layout. volumeup The volume up key on an American layout. volumedown The volume down key on an American layout. audionext The audio next track key on an American layout. audioprev The audio previous track key on an American layout. audiostop The audio stop key on an American layout. audioplay The audio play key on an American layout. audiomute The audio mute key on an American layout. mediaselect The media select key on an American layout. www The 'WWW' key on an American layout. mail The Mail key on an American layout. calculator The calculator key on an American layout. computer The 'computer' key on an American layout. acsearch The AC Search key on an American layout. achome The AC Home key on an American layout. acback The AC Back key on an American layout. acforward The AC Forward key on an American layout. acstop Th AC Stop key on an American layout. acrefresh The AC Refresh key on an American layout. acbookmarks The AC Bookmarks key on an American layout. ### Hardware setting scancodes power The system power scancode. brightnessdown The brightness-down scancode. brightnessup The brightness-up scancode. displayswitch The display switch scancode. kbdillumtoggle The keyboard illumination toggle scancode. kbdillumdown The keyboard illumination down scancode. kbdillumup The keyboard illumination up scancode. eject The eject scancode. sleep The system sleep scancode. ### Misc. alterase The alt-erase key on an American layout. sysreq The sysreq key on an American layout. cancel The 'cancel' key on an American layout. clear The 'clear' key on an American layout. prior The 'prior' key on an American layout. return2 The 'return2' key on an American layout. separator The 'separator' key on an American layout. out The 'out' key on an American layout. oper The 'oper' key on an American layout. clearagain The 'clearagain' key on an American layout. crsel The 'crsel' key on an American layout. exsel The 'exsel' key on an American layout. kp00 The keypad 00 key on an American layout. kp000 The keypad 000 key on an American layout. thsousandsseparator The thousands-separator key on an American layout. decimalseparator The decimal separator key on an American layout. currencyunit The currency unit key on an American layout. currencysubunit The currency sub-unit key on an American layout. app1 The 'app1' scancode. app2 The 'app2' scancode. unknown An unknown key. See Also -------- * [Scancodes in plain text](https://pastebin.com/kpxCK6qU) * [love.keyboard](love.keyboard "love.keyboard") * [love.keypressed](love.keypressed "love.keypressed") * [love.keyreleased](love.keyreleased "love.keyreleased") * [love.keyboard.isScancodeDown](love.keyboard.isscancodedown "love.keyboard.isScancodeDown") * [love.keyboard.getScancodeFromKey](love.keyboard.getscancodefromkey "love.keyboard.getScancodeFromKey") * [love.keyboard.getKeyFromScancode](love.keyboard.getkeyfromscancode "love.keyboard.getKeyFromScancode")
programming_docs
love love.font love.font ========= **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This module is not supported in earlier versions. Allows you to work with fonts. Types ----- | | | | | | --- | --- | --- | --- | | [FontData](fontdata "FontData") | A FontData represents a font. | 0.7.0 | 0.8.0 | | [GlyphData](glyphdata "GlyphData") | A GlyphData represents a drawable symbol of a font. | 0.7.0 | | | [Rasterizer](rasterizer "Rasterizer") | A Rasterizer represents font data and glyphs. | 0.7.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [love.font.newBMFontRasterizer](love.font.newbmfontrasterizer "love.font.newBMFontRasterizer") | Creates a new BMFont Rasterizer. | 0.7.0 | | | [love.font.newFontData](love.font.newfontdata "love.font.newFontData") | Creates a new FontData. | 0.7.0 | 0.8.0 | | [love.font.newGlyphData](love.font.newglyphdata "love.font.newGlyphData") | Creates a new GlyphData. | 0.7.0 | | | [love.font.newImageRasterizer](love.font.newimagerasterizer "love.font.newImageRasterizer") | Creates a new Image Rasterizer. | 0.7.0 | | | [love.font.newRasterizer](love.font.newrasterizer "love.font.newRasterizer") | Creates a new Rasterizer. | 0.7.0 | | | [love.font.newTrueTypeRasterizer](love.font.newtruetyperasterizer "love.font.newTrueTypeRasterizer") | Creates a new TrueType Rasterizer. | 0.7.0 | | Enums ----- | | | | | | --- | --- | --- | --- | | [HintingMode](hintingmode "HintingMode") | True Type hinting mode. | 0.10.0 | | | [PixelFormat](pixelformat "PixelFormat") | Pixel formats for [Textures](texture "Texture"), [ImageData](imagedata "ImageData"), and [CompressedImageData](compressedimagedata "CompressedImageData"). | 11.0 | | See Also -------- * [Font](font "Font") * [love](love "love") love RevoluteJoint:getMaxMotorTorque RevoluteJoint:getMaxMotorTorque =============================== Gets the maximum motor force. Function -------- ### Synopsis ``` f = RevoluteJoint:getMaxMotorTorque( ) ``` ### Arguments None. ### Returns `[number](number "number") f` The maximum motor force, in Nm. See Also -------- * [RevoluteJoint](revolutejoint "RevoluteJoint") love PulleyJoint PulleyJoint =========== Allows you to simulate bodies connected through pulleys. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.physics.newPulleyJoint](love.physics.newpulleyjoint "love.physics.newPulleyJoint") | Creates a **PulleyJoint** to join two bodies to each other and the ground. | | | Functions --------- | | | | | | --- | --- | --- | --- | | [Joint:destroy](joint-destroy "Joint:destroy") | Explicitly destroys the Joint. | | | | [Joint:getAnchors](joint-getanchors "Joint:getAnchors") | Get the anchor points of the joint. | | | | [Joint:getBodies](joint-getbodies "Joint:getBodies") | Gets the [bodies](body "Body") that the Joint is attached to. | 0.9.2 | | | [Joint:getCollideConnected](joint-getcollideconnected "Joint:getCollideConnected") | Gets whether the connected Bodies collide. | | | | [Joint:getReactionForce](joint-getreactionforce "Joint:getReactionForce") | Returns the reaction force on the second body. | | | | [Joint:getReactionTorque](joint-getreactiontorque "Joint:getReactionTorque") | Returns the reaction torque on the second body. | | | | [Joint:getType](joint-gettype "Joint:getType") | Gets a string representing the type. | | | | [Joint:getUserData](joint-getuserdata "Joint:getUserData") | Returns the Lua value associated with this Joint. | 0.9.2 | | | [Joint:isDestroyed](joint-isdestroyed "Joint:isDestroyed") | Gets whether the Joint is destroyed. | 0.9.2 | | | [Joint:setCollideConnected](joint-setcollideconnected "Joint:setCollideConnected") | Sets whether the connected Bodies should collide with each other. | | 0.8.0 | | [Joint:setUserData](joint-setuserdata "Joint:setUserData") | Associates a Lua value with the Joint. | 0.9.2 | | | [PulleyJoint:getConstant](pulleyjoint-getconstant "PulleyJoint:getConstant") | Get the total length of the rope. | | | | [PulleyJoint:getGroundAnchors](pulleyjoint-getgroundanchors "PulleyJoint:getGroundAnchors") | Get the ground anchor positions in world coordinates. | | | | [PulleyJoint:getLength1](pulleyjoint-getlength1 "PulleyJoint:getLength1") | Get the current length of the segment attached to the first body. | | 0.8.0 | | [PulleyJoint:getLength2](pulleyjoint-getlength2 "PulleyJoint:getLength2") | Get the current length of the segment attached to the second body. | | 0.8.0 | | [PulleyJoint:getLengthA](pulleyjoint-getlengtha "PulleyJoint:getLengthA") | Get the current length of the segment attached to the first body. | 0.8.0 | | | [PulleyJoint:getLengthB](pulleyjoint-getlengthb "PulleyJoint:getLengthB") | Get the current length of the segment attached to the second body. | 0.8.0 | | | [PulleyJoint:getMaxLengths](pulleyjoint-getmaxlengths "PulleyJoint:getMaxLengths") | Get the maximum lengths of the rope segments. | | | | [PulleyJoint:getRatio](pulleyjoint-getratio "PulleyJoint:getRatio") | Get the pulley ratio. | | | | [PulleyJoint:setConstant](pulleyjoint-setconstant "PulleyJoint:setConstant") | Set the total length of the rope. | | | | [PulleyJoint:setMaxLengths](pulleyjoint-setmaxlengths "PulleyJoint:setMaxLengths") | Set the maximum lengths of the rope segments. | | | | [PulleyJoint:setRatio](pulleyjoint-setratio "PulleyJoint:setRatio") | Set the pulley ratio. | | | Supertypes ---------- * [Joint](joint "Joint") * [Object](object "Object") See Also -------- * [love.physics](love.physics "love.physics") love love.font.newRasterizer love.font.newRasterizer ======================= **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Creates a new Rasterizer. Function -------- ### Synopsis ``` rasterizer = love.font.newRasterizer( filename ) ``` ### Arguments `[string](string "string") filename` The font file. ### Returns `[Rasterizer](rasterizer "Rasterizer") rasterizer` The rasterizer. Function -------- ### Synopsis ``` rasterizer = love.font.newRasterizer( data ) ``` ### Arguments `[FileData](filedata "FileData") data` The FileData of the font file. ### Returns `[Rasterizer](rasterizer "Rasterizer") rasterizer` The rasterizer. Function -------- Create a TrueTypeRasterizer with the default font. ### Synopsis ``` rasterizer = love.font.newRasterizer( size, hinting, dpiscale ) ``` ### Arguments `[number](number "number") size (12)` The font size. `[HintingMode](hintingmode "HintingMode") hinting ("normal")` Available since 0.10.0 True Type hinting mode. `[number](number "number") dpiscale ([love.window.getDPIScale](love.window.getdpiscale "love.window.getDPIScale")())` Available since 11.0 The font DPI scale. ### Returns `[Rasterizer](rasterizer "Rasterizer") rasterizer` The rasterizer. Function -------- Create a TrueTypeRasterizer with custom font. ### Synopsis ``` rasterizer = love.font.newRasterizer( fileName, size, hinting, dpiscale ) ``` ### Arguments `[string](string "string") fileName` Path to font file. `[number](number "number") size (12)` The font size. `[HintingMode](hintingmode "HintingMode") hinting ("normal")` Available since 0.10.0 True Type hinting mode. `[number](number "number") dpiscale ([love.window.getDPIScale](love.window.getdpiscale "love.window.getDPIScale")())` Available since 11.0 The font DPI scale. ### Returns `[Rasterizer](rasterizer "Rasterizer") rasterizer` The rasterizer. Function -------- Create a TrueTypeRasterizer with custom font. ### Synopsis ``` rasterizer = love.font.newRasterizer( fileData, size, hinting, dpiscale ) ``` ### Arguments `[FileData](filedata "FileData") fileData` File data containing font. `[number](number "number") size (12)` The font size. `[HintingMode](hintingmode "HintingMode") hinting ("normal")` Available since 0.10.0 True Type hinting mode. `[number](number "number") dpiscale ([love.window.getDPIScale](love.window.getdpiscale "love.window.getDPIScale")())` Available since 11.0 The font DPI scale. ### Returns `[Rasterizer](rasterizer "Rasterizer") rasterizer` The rasterizer. Function -------- Creates a new BMFont Rasterizer. ### Synopsis ``` rasterizer = love.font.newRasterizer( imageData, glyphs, dpiscale ) ``` ### Arguments `[ImageData](imagedata "ImageData") imageData` The image data containing the drawable pictures of font glyphs. `[string](string "string") glyphs` The sequence of glyphs in the ImageData. `[number](number "number") dpiscale (1)` Available since 11.0 DPI scale. ### Returns `[Rasterizer](rasterizer "Rasterizer") rasterizer` The rasterizer. Function -------- Creates a new BMFont Rasterizer. ### Synopsis ``` rasterizer = love.font.newRasterizer( fileName, glyphs, dpiscale ) ``` ### Arguments `[string](string "string") fileName` The path to file containing the drawable pictures of font glyphs. `[string](string "string") glyphs` The sequence of glyphs in the ImageData. `[number](number "number") dpiscale (1)` Available since 11.0 DPI scale. ### Returns `[Rasterizer](rasterizer "Rasterizer") rasterizer` The rasterizer. See Also -------- * [love.font](love.font "love.font") * [love.font.newTrueTypeRasterizer](love.font.newtruetyperasterizer "love.font.newTrueTypeRasterizer") * [love.font.newBMFontRasterizer](love.font.newbmfontrasterizer "love.font.newBMFontRasterizer") * [love.font.newImageRasterizer](love.font.newimagerasterizer "love.font.newImageRasterizer") * [Rasterizer](rasterizer "Rasterizer") love Fixture:setFriction Fixture:setFriction =================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Sets the friction of the fixture. Friction determines how shapes react when they "slide" along other shapes. Low friction indicates a slippery surface, like ice, while high friction indicates a rough surface, like concrete. Range: 0.0 - 1.0. Function -------- ### Synopsis ``` Fixture:setFriction( friction ) ``` ### Arguments `[number](number "number") friction` The fixture friction. ### Returns Nothing. See Also -------- * [Fixture](fixture "Fixture") * [Fixture:getFriction](fixture-getfriction "Fixture:getFriction") love love.filesystem.isFused love.filesystem.isFused ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets whether the game is in fused mode or not. If a game is in fused mode, its save directory will be directly in the Appdata directory instead of Appdata/LOVE/. The game will also be able to load C Lua dynamic libraries which are located in the save directory. A game is in fused mode if the source .love has been fused to the executable (see [Game Distribution](https://love2d.org/wiki/Game_Distribution "Game Distribution")), or if "--fused" has been given as a command-line argument when starting the game. Function -------- ### Synopsis ``` fused = love.filesystem.isFused( ) ``` ### Arguments None ### Returns `[boolean](boolean "boolean") fused` True if the game is in fused mode, false otherwise. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") love Framebuffer:getImageData Framebuffer:getImageData ======================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been renamed to [Canvas:getImageData](canvas-getimagedata "Canvas:getImageData"). Returns the image data stored in the [Framebuffer](framebuffer "Framebuffer"). Think of it as a screenshot of the hidden screen that is the framebuffer. Function -------- ### Synopsis ``` data = Framebuffer:getImageData( ) ``` ### Arguments None. ### Returns `[ImageData](imagedata "ImageData") data` The image data stored in the framebuffer. See Also -------- * [Framebuffer](framebuffer "Framebuffer") * [love.graphics.newScreenshot](love.graphics.newscreenshot "love.graphics.newScreenshot") love Shape:computeMass Shape:computeMass ================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Computes the mass properties for the shape with the specified density. Function -------- ### Synopsis ``` x, y, mass, inertia = Shape:computeMass( density ) ``` ### Arguments `[number](number "number") density` The shape density. ### Returns `[number](number "number") x` The x postition of the center of mass. `[number](number "number") y` The y postition of the center of mass. `[number](number "number") mass` The mass of the shape. `[number](number "number") inertia` The rotational inertia. See Also -------- * [Shape](shape "Shape") love WheelJoint:getJointSpeed WheelJoint:getJointSpeed ======================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the current joint translation speed. Function -------- ### Synopsis ``` speed = WheelJoint:getJointSpeed( ) ``` ### Arguments None. ### Returns `[number](number "number") speed` The translation speed of the joint in meters per second. See Also -------- * [WheelJoint](wheeljoint "WheelJoint") love Shape:testPoint Shape:testPoint =============== This is particularly useful for mouse interaction with the shapes. By looping through all shapes and testing the mouse position with this function, we can find which shapes the mouse touches. There's a bug in [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") preventing this function from working. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in earlier versions. ### Synopsis ``` hit = Shape:testPoint( tx, ty, tr, x, y ) ``` ### Arguments `[number](number "number") tx` Translates the shape along the x-axis. `[number](number "number") ty` Translates the shape along the y-axis. `[number](number "number") tr` Rotates the shape. `[number](number "number") x` The x-component of the point. `[number](number "number") y` The y-component of the point. ### Returns `[boolean](boolean "boolean") hit` True if inside, false if outside Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. ### Synopsis ``` hit = Shape:testPoint( x, y ) ``` ### Arguments `[number](number "number") x` The x-component of the point. `[number](number "number") y` The y-component of the point. ### Returns `[boolean](boolean "boolean") hit` True if inside, false if outside See Also -------- * [Shape](shape "Shape") love Body:setBullet Body:setBullet ============== Set the bullet status of a body. There are two methods to check for body collisions: * at their location when the world is updated (default) * using continuous collision detection (CCD) The default method is efficient, but a body moving very quickly may sometimes jump over another body without producing a collision. A body that is set as a bullet will use CCD. This is less efficient, but is guaranteed not to jump when moving quickly. Note that static bodies (with zero mass) always use CCD, so your walls will not let a fast moving body pass through even if it is not a bullet. Function -------- ### Synopsis ``` Body:setBullet( status ) ``` ### Arguments `[boolean](boolean "boolean") status` The bullet status of the body. ### Returns Nothing. See Also -------- * [Body](body "Body") * [Body:isBullet](body-isbullet "Body:isBullet") love TextureType TextureType =========== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This enum is not supported in earlier versions. Types of textures (2D, cubemap, etc.) Constants --------- 2d Regular 2D texture with width and height. array Several same-size 2D textures organized into a single object. Similar to a texture atlas / sprite sheet, but avoids sprite bleeding and other issues. cube [Cubemap](https://en.wikipedia.org/wiki/Cube_mapping) texture with 6 faces. Requires a custom shader (and [Shader:send](shader-send "Shader:send")) to use. Sampling from a cube texture in a shader takes a 3D direction vector instead of a texture coordinate. volume 3D texture with width, height, and [depth](texture-getdepth "Texture:getDepth"). Requires a custom shader to use. Volume textures can have [texture filtering](texture-setfilter "Texture:setFilter") applied along the 3rd axis. Notes ----- [Array textures](http://codeflow.org/entries/2010/dec/09/minecraft-like-rendering-experiments-in-opengl-4/illustrations/textures.jpg) can be rendered with [love.graphics.drawLayer](love.graphics.drawlayer "love.graphics.drawLayer"), with [love.graphics.draw](love.graphics.draw "love.graphics.draw") and a [Quad](quad "Quad") via [Quad:setLayer](https://love2d.org/w/index.php?title=Quad:setLayer&action=edit&redlink=1 "Quad:setLayer (page does not exist)"), or by [sending](shader-send "Shader:send") it to a custom [Shader](shader "Shader"). When getting the pixels of a layer of an Array Texture in a shader, a third texture coordinate component is used to choose which layer to get. When using a custom Shader, each texture type has a different GLSL type. * `Image` (or `sampler2D`) is a 2D texture. * `ArrayImage` (or `sampler2DArray`) is an array texture. * `CubeImage` (or `samplerCube`) is a cubemap texture. * `VolumeImage` (or `sampler3D`) is a volume texture. The `Texel` shader function can be used to sample from all types of textures in a shader. `Texel` is recommended instead of `texture2D`, `textureCube` etc., because the latter do not work across all versions of GLSL supported by LÖVE, whereas Texel does (GLSL 3 removed `texture2D` and added a generic `texture` function). Each texture type has a different [maximum size](graphicslimit "GraphicsLimit") on a user's system. Use [love.graphics.getSystemLimits](love.graphics.getsystemlimits "love.graphics.getSystemLimits") to check. Not all texture types are supported by all systems. [love.graphics.getTextureTypes](love.graphics.gettexturetypes "love.graphics.getTextureTypes") can check for support. 2D and cube texture types are supported everywhere. Array textures require a system that supports OpenGL 3 or OpenGL ES 3. Volume / 3D textures require a system that supports OpenGL 2 or OpenGL ES 3. See Also -------- * [love.graphics](love.graphics "love.graphics") * [Texture](texture "Texture") * [Texture:getTextureType](texture-gettexturetype "Texture:getTextureType") * [love.graphics.newImage](love.graphics.newimage "love.graphics.newImage") * [love.graphics.newArrayImage](love.graphics.newarrayimage "love.graphics.newArrayImage") * [love.graphics.newCubeImage](love.graphics.newcubeimage "love.graphics.newCubeImage") * [love.graphics.newVolumeImage](love.graphics.newvolumeimage "love.graphics.newVolumeImage") * [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") * [love.graphics.drawLayer](love.graphics.drawlayer "love.graphics.drawLayer") love Shape:setMask Shape:setMask ============= **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** Use [Fixture:setMask](fixture-setmask "Fixture:setMask") instead. Sets which categories this shape should **NOT** collide with. With this function, you can exclude certain shape categories from collisions with this shape. The categories passed as parameters will be excluded from collisions - all others included. Function -------- ### Synopsis ``` Shape:setMask( ... ) ``` ### Arguments `[number](number "number") ...` Numbers from 1-16. ### Returns Nothing. Examples -------- ### Only collide with category 6 ``` shape:setMask(1, 2, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 15, 16) ``` See Also -------- * [Shape](shape "Shape") * [Shape:getMask](shape-getmask "Shape:getMask") Others Languages ----------------
programming_docs
love Rasterizer:getGlyphData Rasterizer:getGlyphData ======================= **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Gets glyph data of a specified glyph. Function -------- ### Synopsis ``` glyphData = Rasterizer:getGlyphData( glyph ) ``` ### Arguments `[string](string "string") glyph` Glyph ### Returns `[GlyphData](glyphdata "GlyphData") glyphData` Glyph data Function -------- ### Synopsis ``` glyphData = Rasterizer:getGlyphData( glyphNumber ) ``` ### Arguments `[number](number "number") glyphNumber` Glyph number ### Returns `[GlyphData](glyphdata "GlyphData") glyphData` Glyph data See Also -------- * [Rasterizer](rasterizer "Rasterizer") * [GlyphData](glyphdata "GlyphData") love WheelJoint:setSpringDampingRatio WheelJoint:setSpringDampingRatio ================================ **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Sets a new damping ratio. Function -------- ### Synopsis ``` WheelJoint:setSpringDampingRatio( ratio ) ``` ### Arguments `[number](number "number") ratio` The new damping ratio. ### Returns Nothing. See Also -------- * [WheelJoint](wheeljoint "WheelJoint") * [WheelJoint:getSpringDampingRatio](wheeljoint-getspringdampingratio "WheelJoint:getSpringDampingRatio") love PolygonShape:getPoints PolygonShape:getPoints ====================== Get the local coordinates of the polygon's vertices. This function has a variable number of return values. It can be used in a nested fashion with [love.graphics.polygon](love.graphics.polygon "love.graphics.polygon"). Function -------- ### Synopsis ``` x1, y1, x2, y2, ... x8, y8 = PolygonShape:getPoints( ) ``` ### Arguments None. ### Returns `[number](number "number") x1` The x-component of the first vertex. `[number](number "number") y1` The y-component of the first vertex. `[number](number "number") x2` The x-component of the second vertex. `[number](number "number") y2` The y-component of the second vertex. And so on, for up to eight vertices. This function may have up to 16 return values, since it returns two values for each vertex in the polygon. In other words, it can return the coordinates of up to 8 points. See Also -------- * [PolygonShape](polygonshape "PolygonShape") * [Body:getWorldPoints](body-getworldpoints "Body:getWorldPoints") love World:setCallbacks World:setCallbacks ================== Sets functions for the collision callbacks during the world update. Four Lua functions can be given as arguments. The value nil removes a function. When called, each function will be passed three arguments. The first two arguments are the colliding fixtures and the third argument is the [Contact](contact "Contact") between them. The postSolve callback additionally gets the normal and tangent impulse for each contact point. See notes. If you are interested to know when exactly each callback is called, consult a Box2d [manual](http://www.iforce2d.net/b2dtut/collision-anatomy) Making changes to a [World](world "World") is not allowed inside of the [beginContact](https://love2d.org/w/index.php?title=beginContact&action=edit&redlink=1 "beginContact (page does not exist)"), [endContact](https://love2d.org/w/index.php?title=endContact&action=edit&redlink=1 "endContact (page does not exist)"), [preSolve](https://love2d.org/w/index.php?title=preSolve&action=edit&redlink=1 "preSolve (page does not exist)"), and [postSolve](https://love2d.org/w/index.php?title=postSolve&action=edit&redlink=1 "postSolve (page does not exist)") callback functions, as BOX2D locks the world during these callbacks. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. ### Synopsis ``` World:setCallbacks( beginContact, endContact, preSolve, postSolve ) ``` ### Arguments `[function](function "function") beginContact` Gets called when two fixtures begin to overlap. `[function](function "function") endContact` Gets called when two fixtures cease to overlap. This will also be called outside of a world update, when colliding objects are destroyed. `[function](function "function") preSolve` Gets called before a collision gets resolved. `[function](function "function") postSolve` Gets called after the collision has been resolved. ### Returns Nothing. Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. ### Synopsis ``` World:setCallbacks( add, persist, remove, result ) ``` ### Arguments `[function](function "function") add` Called when two shapes first collide. `[function](function "function") persist` Called each frame, if collision lasts more than 1 frame. `[function](function "function") remove` Called when two shapes finish colliding. `[function](function "function") result` Called after a collision has been calculated. Note: This callback is not properly bound in LOVE at the time of writing, as a result, this callback does not get called, nor do proper arguments get passed for it. ### Returns Nothing. Notes ----- Below are the parameters for the postSolve callback. Note that the numbers of normal and tangent impulse correspond with the numbers of contact points. ``` function postSolve(fixture1, fixture2, contact, normal_impulse1, tangent_impulse1, normal_impulse2, tangent_impulse2) -- do stuff end ``` See Also -------- * [World](world "World") * [Tutorial:PhysicsCollisionCallbacks](https://love2d.org/wiki/Tutorial:PhysicsCollisionCallbacks "Tutorial:PhysicsCollisionCallbacks") love love.sound.newDecoder love.sound.newDecoder ===================== Attempts to find a decoder for the encoded sound data in the specified file. Function -------- ### Synopsis ``` decoder = love.sound.newDecoder( file, buffer ) ``` ### Arguments `[File](file "File") file` The file with encoded sound data. `[number](number "number") buffer (2048)` The size of each decoded chunk, in bytes. ### Returns `[Decoder](decoder "Decoder") decoder` A new Decoder object. Function -------- ### Synopsis ``` decoder = love.sound.newDecoder( filename, buffer ) ``` ### Arguments `[string](string "string") filename` The filename of the file with encoded sound data. `[number](number "number") buffer (2048)` The size of each decoded chunk, in bytes. ### Returns `[Decoder](decoder "Decoder") decoder` A new Decoder object. Function -------- **Removed in LÖVE [0.7.1](https://love2d.org/wiki/0.7.1 "0.7.1")** This variant is not supported in that and later versions. ### Synopsis ``` decoder = love.sound.newDecoder( file, buffer, rate ) ``` ### Arguments `[File](file "File") file` The file with encoded sound data. `[number](number "number") buffer (2048)` The size of each decoded chunk, in bytes. `[number](number "number") rate (44100)` Samples per second, or quality of the audio. Use either 44100 (good), 22050 (medium) or 11025 (poor). ### Returns `[Decoder](decoder "Decoder") decoder` A new Decoder object. Function -------- **Removed in LÖVE [0.7.1](https://love2d.org/wiki/0.7.1 "0.7.1")** This variant is not supported in that and later versions. ### Synopsis ``` decoder = love.sound.newDecoder( filename, buffer, rate ) ``` ### Arguments `[string](string "string") filename` The filename of the file with encoded sound data. `[number](number "number") buffer (2048)` The size of each decoded chunk, in bytes. `[number](number "number") rate (44100)` Samples per second, or quality of the audio. Use either 44100 (good), 22050 (medium) or 11025 (poor). ### Returns `[Decoder](decoder "Decoder") decoder` A new Decoder object. See Also -------- * [love.sound](love.sound "love.sound") * [Decoder](decoder "Decoder") love Body:getUserData Body:getUserData ================ **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This method is not supported in earlier versions. Returns the Lua value associated with this Body. Use this function in one thread and one thread only. Using it in more threads will make Lua cry and most likely crash. Function -------- ### Synopsis ``` value = Body:getUserData( ) ``` ### Arguments None. ### Returns `[any](https://love2d.org/w/index.php?title=any&action=edit&redlink=1 "any (page does not exist)") value` The Lua value associated with the Body. See Also -------- * [Body](body "Body") * [Body:setUserData](body-setuserdata "Body:setUserData") love Decoder:getDuration Decoder:getDuration =================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets the duration of the sound file. It may not always be sample-accurate, and it may return -1 if the duration cannot be determined at all. Function -------- ### Synopsis ``` duration = Decoder:getDuration( ) ``` ### Arguments None. ### Returns `[number](number "number") duration` The duration of the sound file in seconds, or -1 if it cannot be determined. See Also -------- * [Decoder](decoder "Decoder") * [Source:getDuration](source-getduration "Source:getDuration") * [SoundData:getDuration](sounddata-getduration "SoundData:getDuration") love love.data.getPackedSize love.data.getPackedSize ======================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the size in bytes that a given format used with [love.data.pack](love.data.pack "love.data.pack") will use. This function behaves the same as Lua 5.3's [string.packsize](https://www.lua.org/manual/5.3/manual.html#pdf-string.packsize). Function -------- ### Synopsis ``` size = love.data.getPackedSize( format ) ``` ### Arguments `[string](string "string") format` A string determining how the values are packed. Follows the rules of [Lua 5.3's string.pack format strings](https://www.lua.org/manual/5.3/manual.html#6.4.2). ### Returns `[number](number "number") size` The size in bytes that the packed data will use. Notes ----- The format string cannot have the variable-length options 's' or 'z'. See Also -------- * [love.data](love.data "love.data") * [love.data.pack](love.data.pack "love.data.pack") * [love.data.unpack](love.data.unpack "love.data.unpack") love love.window.getFullscreen love.window.getFullscreen ========================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets whether the window is fullscreen. Function -------- ### Synopsis ``` fullscreen, fstype = love.window.getFullscreen( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") fullscreen` True if the window is fullscreen, false otherwise. `[FullscreenType](fullscreentype "FullscreenType") fstype` The type of fullscreen mode used. See Also -------- * [love.window](love.window "love.window") * [love.window.setFullscreen](love.window.setfullscreen "love.window.setFullscreen") * [love.window.setMode](love.window.setmode "love.window.setMode") love love.image.isCompressed love.image.isCompressed ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Determines whether a file can be loaded as [CompressedImageData](compressedimagedata "CompressedImageData"). Function -------- ### Synopsis ``` compressed = love.image.isCompressed( filename ) ``` ### Arguments `[string](string "string") filename` The filename of the potentially compressed image file. ### Returns `[boolean](boolean "boolean") compressed` Whether the file can be loaded as [CompressedImageData](compressedimagedata "CompressedImageData") or not. Function -------- ### Synopsis ``` compressed = love.image.isCompressed( fileData ) ``` ### Arguments `[FileData](filedata "FileData") fileData` A FileData potentially containing a compressed image. ### Returns `[boolean](boolean "boolean") compressed` Whether the FileData can be loaded as [CompressedImageData](compressedimagedata "CompressedImageData") or not. See Also -------- * [love.image](love.image "love.image") * [love.image.newCompressedData](love.image.newcompresseddata "love.image.newCompressedData") love love.data love.data ========= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This module is not supported in earlier versions. Provides functionality for creating and transforming data. Types ----- | | | | | | --- | --- | --- | --- | | [ByteData](bytedata "ByteData") | Data object containing arbitrary bytes in an contiguous memory. | 11.0 | | | [CompressedData](compresseddata "CompressedData") | Byte data compressed using a specific algorithm. | 0.10.0 | | | [Data](data "Data") | The superclass of all data. | | | Functions --------- | | | | | | --- | --- | --- | --- | | [love.data.compress](love.data.compress "love.data.compress") | Compresses a string or data using a specific compression algorithm. | 11.0 | | | [love.data.decode](love.data.decode "love.data.decode") | Decode Data or a string from any of the [EncodeFormats](encodeformat "EncodeFormat") to Data or string. | 11.0 | | | [love.data.decompress](love.data.decompress "love.data.decompress") | Decompresses a [CompressedData](compresseddata "CompressedData") or previously compressed string or [Data](data "Data") object. | 11.0 | | | [love.data.encode](love.data.encode "love.data.encode") | Encode Data or a string to a Data or string in one of the [EncodeFormats](encodeformat "EncodeFormat"). | 11.0 | | | [love.data.getPackedSize](love.data.getpackedsize "love.data.getPackedSize") | Gets the size in bytes that a given format used with [love.data.pack](love.data.pack "love.data.pack") will use. | 11.0 | | | [love.data.hash](love.data.hash "love.data.hash") | Compute message digest using specific hash algorithm. | 11.0 | | | [love.data.newByteData](love.data.newbytedata "love.data.newByteData") | Creates a new Data object containing arbitrary bytes. | 11.0 | | | [love.data.newDataView](love.data.newdataview "love.data.newDataView") | Creates a new Data referencing a subsection of an existing Data object. | 11.0 | | | [love.data.pack](love.data.pack "love.data.pack") | Packs (serializes) simple Lua values. | 11.0 | | | [love.data.unpack](love.data.unpack "love.data.unpack") | Unpacks (deserializes) a byte-string or Data into simple Lua values. | 11.0 | | Enums ----- | | | | | | --- | --- | --- | --- | | [CompressedDataFormat](compresseddataformat "CompressedDataFormat") | Compressed data formats. | 0.10.0 | | | [ContainerType](containertype "ContainerType") | Return type of data-returning functions. | 11.0 | | | [EncodeFormat](encodeformat "EncodeFormat") | Encoding format used to [encode](love.data.encode "love.data.encode") or [decode](love.data.decode "love.data.decode") data. | 11.0 | | | [HashFunction](hashfunction "HashFunction") | Hash algorithm of [hash function](love.data.hash "love.data.hash"). | 11.0 | | See Also -------- * [love](love "love") love ImageData:getWidth ImageData:getWidth ================== Gets the width of the ImageData in pixels. Function -------- ### Synopsis ``` width = ImageData:getWidth( ) ``` ### Arguments None. ### Returns `[number](number "number") width` The width of the [ImageData](imagedata "ImageData") in pixels. See Also -------- * [ImageData](imagedata "ImageData") love SpriteBatchUsage SpriteBatchUsage ================ **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This enum is not supported in earlier versions. Usage hints for [SpriteBatches](spritebatch "SpriteBatch") and [Meshes](mesh "Mesh") to optimize data storage and access. Constants --------- dynamic The object's data will change occasionally during its lifetime. static The object will not be modified after initial sprites or vertices are added. stream The object data will always change between draws. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.newMesh](love.graphics.newmesh "love.graphics.newMesh") * [love.graphics.newSpriteBatch](love.graphics.newspritebatch "love.graphics.newSpriteBatch") * [SpriteBatch](spritebatch "SpriteBatch") love Canvas:getWrap Canvas:getWrap ============== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been renamed from [Framebuffer:getWrap](framebuffer-getwrap "Framebuffer:getWrap"). Gets the wrapping properties of a Canvas. This function returns the currently set horizontal and vertical [wrapping modes](wrapmode "WrapMode") for the Canvas. Function -------- ### Synopsis ``` horiz, vert = Canvas:getWrap( ) ``` ### Arguments None. ### Returns `[WrapMode](wrapmode "WrapMode") horiz` Horizontal wrapping mode of the Canvas. `[WrapMode](wrapmode "WrapMode") vert` Vertical wrapping mode of the Canvas. See Also -------- * [Canvas](canvas "Canvas") * [Canvas:setWrap](canvas-setwrap "Canvas:setWrap") * [WrapMode](wrapmode "WrapMode") love Shape:setRestitution Shape:setRestitution ==================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in that and later versions. Sets the restitution of the shape. Restitution indicates the "bounciness" of the shape. High restitution can be used to model stuff like a rubber ball, while low restitution can be used for "dull" objects, like a bag of sand. Function -------- ### Synopsis ``` Shape:setRestitution( restitution ) ``` ### Arguments `[number](number "number") restitution` The restitution of the shape. ### Returns Nothing. Notes ----- A shape with a restitution of 0 will still bounce a little if the shape it collides with has a restitution higher than 0. See Also -------- * [Shape](shape "Shape") love enet.host:total sent data enet.host:total sent data ========================= Returns the number of bytes that were sent through the given [host](enet.host "enet.host"). Function -------- ### Synopsis ``` host:total_sent_data() ``` ### Arguments None. ### Returns `[number](number "number") bytes` The total number of bytes sent. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.host](enet.host "enet.host") * [enet.host:total\_received\_data](enet.host-total_received_data "enet.host:total received data") love PulleyJoint:getLengthA PulleyJoint:getLengthA ====================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Get the current length of the rope segment attached to the first body. Function -------- ### Synopsis ``` length = PulleyJoint:getLengthA( ) ``` ### Arguments None. ### Returns `[number](number "number") length` The length of the rope segment. See Also -------- * [PulleyJoint](pulleyjoint "PulleyJoint") love ParticleSystem:setInsertMode ParticleSystem:setInsertMode ============================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Sets the mode to use when the ParticleSystem adds new particles. Function -------- ### Synopsis ``` ParticleSystem:setInsertMode( mode ) ``` ### Arguments `[ParticleInsertMode](particleinsertmode "ParticleInsertMode") mode` The mode to use when the ParticleSystem adds new particles. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:getInsertMode](particlesystem-getinsertmode "ParticleSystem:getInsertMode")
programming_docs
love love.font.newBMFontRasterizer love.font.newBMFontRasterizer ============================= **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Creates a new BMFont Rasterizer. Function -------- ### Synopsis ``` rasterizer = love.font.newBMFontRasterizer( imageData, glyphs, dpiscale ) ``` ### Arguments `[ImageData](imagedata "ImageData") imageData` The image data containing the drawable pictures of font glyphs. `[string](string "string") glyphs` The sequence of glyphs in the ImageData. `[number](number "number") dpiscale (1)` Available since 11.0 DPI scale. ### Returns `[Rasterizer](rasterizer "Rasterizer") rasterizer` The rasterizer. Function -------- ### Synopsis ``` rasterizer = love.font.newBMFontRasterizer( fileName, glyphs, dpiscale ) ``` ### Arguments `[string](string "string") fileName` The path to file containing the drawable pictures of font glyphs. `[string](string "string") glyphs` The sequence of glyphs in the ImageData. `[number](number "number") dpiscale (1)` Available since 11.0 DPI scale. ### Returns `[Rasterizer](rasterizer "Rasterizer") rasterizer` The rasterizer. See Also -------- * [love.font](love.font "love.font") * [love.font.newRasterizer](love.font.newrasterizer "love.font.newRasterizer") * [love.font.newTrueTypeRasterizer](love.font.newtruetyperasterizer "love.font.newTrueTypeRasterizer") * [love.font.newImageRasterizer](love.font.newimagerasterizer "love.font.newImageRasterizer") * [Rasterizer](rasterizer "Rasterizer") love ShapeType ShapeType ========= The different types of [Shapes](shape "Shape"), as returned by [Shape:getType](shape-gettype "Shape:getType"). Constants --------- circle The Shape is a [CircleShape](circleshape "CircleShape"). polygon The Shape is a [PolygonShape](polygonshape "PolygonShape"). edge Available since 0.8.0 The Shape is a [EdgeShape](edgeshape "EdgeShape"). chain Available since 0.8.0 The Shape is a [ChainShape](chainshape "ChainShape"). See Also -------- * [love.physics](love.physics "love.physics") * [Shape](shape "Shape") love enet.host:service time enet.host:service time ====================== Returns the time-stamp of the last call to [host:service()](enet.host-service "enet.host:service") or [host:flush()](enet.host-flush "enet.host:flush"). The time-stamp is in milliseconds of the current time of day. Function -------- ### Synopsis ``` host:channel_limit(limit) ``` ### Arguments None. ### Returns `[number](number "number") timestamp` A time-stamp in milliseconds. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.host](enet.host "enet.host") * [enet.host:service](enet.host-service "enet.host:service") * [enet.host:flush](enet.host-flush "enet.host:flush") love love.filesystem.init love.filesystem.init ==================== Initializes love.filesystem, will be called internally, so should not be used explicitly. Function -------- ### Synopsis ``` love.filesystem.init( appname ) ``` ### Arguments `[string](string "string") appname` The name of the application binary, typically `love`. ### Returns Nothing. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") love StencilAction StencilAction ============= **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This enum is not supported in earlier versions. How a [stencil function](love.graphics.stencil "love.graphics.stencil") modifies the stencil values of pixels it touches. Constants --------- replace The stencil value of a pixel will be replaced by the value specified in [love.graphics.stencil](love.graphics.stencil "love.graphics.stencil"), if any object touches the pixel. increment The stencil value of a pixel will be incremented by 1 for each object that touches the pixel. If the stencil value reaches 255 it will stay at 255. decrement The stencil value of a pixel will be decremented by 1 for each object that touches the pixel. If the stencil value reaches 0 it will stay at 0. incrementwrap The stencil value of a pixel will be incremented by 1 for each object that touches the pixel. If a stencil value of 255 is incremented it will be set to 0. decrementwrap The stencil value of a pixel will be decremented by 1 for each object that touches the pixel. If the stencil value of 0 is decremented it will be set to 255. invert The stencil value of a pixel will be bitwise-inverted for each object that touches the pixel. If a stencil value of 0 is inverted it will become 255. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.stencil](love.graphics.stencil "love.graphics.stencil") * [love.graphics.setStencilTest](love.graphics.setstenciltest "love.graphics.setStencilTest") love ImageData:getHeight ImageData:getHeight =================== Gets the height of the ImageData in pixels. Function -------- ### Synopsis ``` height = ImageData:getHeight( ) ``` ### Arguments None. ### Returns `[number](number "number") height` The height of the [ImageData](imagedata "ImageData") in pixels. See Also -------- * [ImageData](imagedata "ImageData") love Body:setAngle Body:setAngle ============= Set the angle of the body. The angle is measured in [radians](https://en.wikipedia.org/wiki/Radian). If you need to transform it from degrees, use [math.rad](https://www.lua.org/manual/5.1/manual.html#pdf-math.rad). A value of 0 radians will mean "looking to the right". Although radians increase counter-clockwise, the y axis points down so it becomes *clockwise* from our point of view. It is possible to cause a collision with another body by changing its angle. Function -------- ### Synopsis ``` Body:setAngle( angle ) ``` ### Arguments `[number](number "number") angle` The angle in radians. ### Returns Nothing. See Also -------- * [Body](body "Body") love Fixture:rayCast Fixture:rayCast =============== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Casts a ray against the shape of the fixture and returns the surface normal vector and the line position where the ray hit. If the ray missed the shape, nil will be returned. The ray starts on the first point of the input line and goes towards the second point of the line. The fifth argument is the maximum distance the ray is going to travel as a scale factor of the input line length. The childIndex parameter is used to specify which child of a parent shape, such as a ChainShape, will be ray casted. For ChainShapes, the index of 1 is the first edge on the chain. Ray casting a parent shape will only test the child specified so if you want to test every shape of the parent, you must loop through all of its children. The world position of the impact can be calculated by multiplying the line vector with the third return value and adding it to the line starting point. ``` hitx, hity = x1 + (x2 - x1) * fraction, y1 + (y2 - y1) * fraction ``` There is a bug in [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") where the normal vector returned by this function gets scaled by [love.physics.getMeter](love.physics.getmeter "love.physics.getMeter"). Function -------- ### Synopsis ``` xn, yn, fraction = Fixture:rayCast( x1, y1, x2, y2, maxFraction, childIndex ) ``` ### Arguments `[number](number "number") x1` The x position of the input line starting point. `[number](number "number") y1` The y position of the input line starting point. `[number](number "number") x2` The x position of the input line end point. `[number](number "number") y2` The y position of the input line end point. `[number](number "number") maxFraction` Ray length parameter. `[number](number "number") childIndex (1)` The index of the child the ray gets cast against. ### Returns `[number](number "number") xn` The x component of the normal vector of the edge where the ray hit the shape. `[number](number "number") yn` The y component of the normal vector of the edge where the ray hit the shape. `[number](number "number") fraction` The position on the input line where the intersection happened as a factor of the line length. Examples -------- ### Casting 2 different rays against a box. ``` function love.load() -- Setting this to 1 to avoid all current scaling bugs. love.physics.setMeter(1)   World = love.physics.newWorld()   Box = {} Box.Body = love.physics.newBody(World, 400, 300, "dynamic") Box.Shape = love.physics.newRectangleShape(150, 150) Box.Fixture = love.physics.newFixture(Box.Body, Box.Shape)   -- Giving the box a gentle spin. Box.Body:setAngularVelocity(0.5)   Ray1 = { point1 = {}, point2 = {}, } Ray1.point1.x, Ray1.point1.y = 50, 50 Ray1.point2.x, Ray1.point2.y = 400, 300 Ray1.scale = 1   Ray2 = { point1 = {}, point2 = {}, } Ray2.point1.x, Ray2.point1.y = 500, 400 Ray2.point2.x, Ray2.point2.y = Ray2.point1.x + math.cos(math.pi*1.45), Ray2.point1.y + math.sin(math.pi*1.45) Ray2.scale = 150 end   function love.update(dt) World:update(dt) end   function love.draw() -- Drawing the box. love.graphics.setColor(1, 1, 1) love.graphics.polygon("line", Box.Body:getWorldPoints( Box.Shape:getPoints() ))   -- Drawing the input lines of the rays and the reach of ray 2 in gray. love.graphics.setLineWidth(3) love.graphics.setColor(50/255, 50/255, 50/255) love.graphics.line(Ray2.point1.x, Ray2.point1.y, Ray2.point1.x + (Ray2.point2.x - Ray2.point1.x) * Ray2.scale, Ray2.point1.y + (Ray2.point2.y - Ray2.point1.y) * Ray2.scale) love.graphics.setColor(1, 1, 1) love.graphics.line(Ray1.point1.x, Ray1.point1.y, Ray1.point2.x, Ray1.point2.y) love.graphics.line(Ray2.point1.x, Ray2.point1.y, Ray2.point2.x, Ray2.point2.y) love.graphics.setLineWidth(1)   -- Remember that the ray cast can return nil if it hits nothing. local r1nx, r1ny, r1f = Box.Fixture:rayCast(Ray1.point1.x, Ray1.point1.y, Ray1.point2.x, Ray1.point2.y, Ray1.scale) local r2nx, r2ny, r2f = Box.Fixture:rayCast(Ray2.point1.x, Ray2.point1.y, Ray2.point2.x, Ray2.point2.y, Ray2.scale)   if r1nx then -- Calculating the world position where the ray hit. local r1HitX = Ray1.point1.x + (Ray1.point2.x - Ray1.point1.x) * r1f local r1HitY = Ray1.point1.y + (Ray1.point2.y - Ray1.point1.y) * r1f   -- Drawing the ray from the starting point to the position on the shape. love.graphics.setColor(1, 0, 0) love.graphics.line(Ray1.point1.x, Ray1.point1.y, r1HitX, r1HitY)   -- We also get the surface normal of the edge the ray hit. Here drawn in green love.graphics.setColor(0, 1, 0) love.graphics.line(r1HitX, r1HitY, r1HitX + r1nx * 25, r1HitY + r1ny * 25) end   if r2nx then -- Calculating the world position where the ray hit. local r2HitX = Ray2.point1.x + (Ray2.point2.x - Ray2.point1.x) * r2f local r2HitY = Ray2.point1.y + (Ray2.point2.y - Ray2.point1.y) * r2f   -- Drawing the ray from the starting point to the position on the shape. love.graphics.setColor(1, 0, 0) love.graphics.line(Ray2.point1.x, Ray2.point1.y, r2HitX, r2HitY)   -- We also get the surface normal of the edge the ray hit. Here drawn in green love.graphics.setColor(0, 1, 0) love.graphics.line(r2HitX, r2HitY, r2HitX + r2nx * 25, r2HitY + r2ny * 25) end end ``` Screenshot of this example See Also -------- * [Fixture](fixture "Fixture") love love.filesystem.enumerate love.filesystem.enumerate ========================= **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [love.filesystem.getDirectoryItems](love.filesystem.getdirectoryitems "love.filesystem.getDirectoryItems"). Returns a table with the names of files and subdirectories in the specified path. The table is not sorted in any way; the order is undefined. If the path passed to the function exists in the game and the save directory, it will list the files and directories from both places. Function -------- ### Synopsis ``` files = love.filesystem.enumerate( dir ) ``` ### Arguments `[string](string "string") dir` The directory. ### Returns `[table](table "table") files` A [sequence](sequence "sequence") with the names of all files and subdirectories as strings. Examples -------- ### Simple Example ``` local dir = "" --assuming that our path is full of lovely files (it should at least contain main.lua in this case) local files = love.filesystem.enumerate(dir) for k, file in ipairs(files) do print(k .. ". " .. file) --outputs something like "1. main.lua" end ``` ### Recursively find and display all files and folders in a folder and its subfolders. ``` function love.load() filesString = recursiveEnumerate("", "") end   -- This function will return a string filetree of all files -- in the folder and files in all subfolders function recursiveEnumerate(folder, fileTree) local lfs = love.filesystem local filesTable = lfs.enumerate(folder) for i,v in ipairs(filesTable) do local file = folder.."/"..v if lfs.isFile(file) then fileTree = fileTree.."\n"..file elseif lfs.isDirectory(file) then fileTree = fileTree.."\n"..file.." (DIR)" fileTree = recursiveEnumerate(file, fileTree) end end return fileTree end   function love.draw() love.graphics.print(filesString, 0, 0) end ``` See Also -------- * [love.filesystem](love.filesystem "love.filesystem") love love.filesystem.createDirectory love.filesystem.createDirectory =============================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [love.filesystem.mkdir](love.filesystem.mkdir "love.filesystem.mkdir"). Recursively creates a directory. When called with "a/b" it creates both "a" and "a/b", if they don't exist already. Function -------- ### Synopsis ``` success = love.filesystem.createDirectory( name ) ``` ### Arguments `[string](string "string") name` The directory to create. ### Returns `[boolean](boolean "boolean") success` True if the directory was created, false if not. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") love love.graphics.triangle love.graphics.triangle ====================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in that and later versions. Use [love.graphics.polygon](love.graphics.polygon "love.graphics.polygon") instead. Draws a triangle. Function -------- ### Synopsis ``` love.graphics.triangle( mode, x1, y1, x2, y2, x3, y3 ) ``` ### Arguments `[DrawMode](drawmode "DrawMode") mode` How to draw the triangle. `[number](number "number") x1` The position of first point on the x-axis. `[number](number "number") y1` The position of first point on the y-axis. `[number](number "number") x2` The position of second point on the x-axis. `[number](number "number") y2` The position of second point on the y-axis. `[number](number "number") x3` The position of third point on the x-axis. `[number](number "number") y3` The position of third point on the y-axis. ### Returns Nothing. See Also -------- * [love.graphics](love.graphics "love.graphics") love World:getGravity World:getGravity ================ Get the gravity of the world. Function -------- ### Synopsis ``` x, y = World:getGravity( ) ``` ### Arguments None. ### Returns `[number](number "number") x` The x component of gravity. `[number](number "number") y` The y component of gravity. See Also -------- * [World](world "World") love Event Event ===== **Available since LÖVE [0.6.0](https://love2d.org/wiki/0.6.0 "0.6.0")** This enum is not supported in earlier versions. Arguments to `love.event.push()` and the like. Constants --------- Since [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0"), event names are no longer abbreviated. focus Available since 0.8.0 Window focus gained or lost joystickpressed Available since 0.8.0 Joystick pressed joystickreleased Available since 0.8.0 Joystick released keypressed Available since 0.8.0 Key pressed keyreleased Available since 0.8.0 Key released mousepressed Available since 0.8.0 Mouse pressed mousereleased Available since 0.8.0 Mouse released quit Available since 0.8.0 Quit resize Available since 0.9.0 Window size changed by the user visible Available since 0.9.0 Window is minimized or un-minimized by the user mousefocus Available since 0.9.0 Window mouse focus gained or lost threaderror Available since 0.9.0 A Lua error has occurred in a [thread](thread "Thread") joystickadded Available since 0.9.0 Joystick connected joystickremoved Available since 0.9.0 Joystick disconnected joystickaxis Available since 0.9.0 Joystick axis motion joystickhat Available since 0.9.0 Joystick hat pressed gamepadpressed Available since 0.9.0 Joystick's virtual gamepad button pressed gamepadreleased Available since 0.9.0 Joystick's virtual gamepad button released gamepadaxis Available since 0.9.0 Joystick's virtual gamepad axis moved textinput Available since 0.9.0 User entered text mousemoved Available since 0.9.2 Mouse position changed lowmemory Available since 0.10.0 Running out of memory on mobile devices system textedited Available since 0.10.0 Candidate text for an IME changed wheelmoved Available since 0.10.0 Mouse wheel moved touchpressed Available since 0.10.0 Touch screen touched touchreleased Available since 0.10.0 Touch screen stop touching touchmoved Available since 0.10.0 Touch press moved inside touch screen directorydropped Available since 0.10.0 Directory is dragged and dropped onto the window filedropped Available since 0.10.0 File is dragged and dropped onto the window. jp Removed in 0.8.0 Joystick pressed jr Removed in 0.8.0 Joystick released kp Removed in 0.8.0 Key pressed kr Removed in 0.8.0 Key released mp Removed in 0.8.0 Mouse pressed mr Removed in 0.8.0 Mouse released q Removed in 0.8.0 Quit f Available since 0.7.0 and removed in LÖVE 0.8.0 Window focus gained or lost See Also -------- * [love.event](love.event "love.event") * [love.event.push](love.event.push "love.event.push") love Rasterizer:getLineHeight Rasterizer:getLineHeight ======================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Gets line height of a font. Function -------- ### Synopsis ``` height = Rasterizer:getLineHeigt() ``` ### Arguments None. ### Returns `[number](number "number") height` Line height of a font. See Also -------- * [Rasterizer](rasterizer "Rasterizer") love Body:applyTorque Body:applyTorque ================ Apply torque to a body. Torque is like a force that will change the angular velocity (spin) of a body. The effect will depend on the rotational inertia a body has. Function -------- ### Synopsis ``` Body:applyTorque( torque ) ``` ### Arguments `[number](number "number") torque` The torque to apply. ### Returns Nothing. See Also -------- * [Body](body "Body") * [Body:applyForce](body-applyforce "Body:applyForce") * [Body:applyAngularImpulse](body-applyangularimpulse "Body:applyAngularImpulse") * [Body:getAngle](body-getangle "Body:getAngle") * [Body:getAngularVelocity](body-getangularvelocity "Body:getAngularVelocity") * [Body:setAngularVelocity](body-setangularvelocity "Body:setAngularVelocity") * [Body:getInertia](body-getinertia "Body:getInertia") love ParticleSystem:getInsertMode ParticleSystem:getInsertMode ============================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the mode used when the ParticleSystem adds new particles. Function -------- ### Synopsis ``` mode = ParticleSystem:getInsertMode( ) ``` ### Arguments None. ### Returns `[ParticleInsertMode](particleinsertmode "ParticleInsertMode") mode` The mode used when the ParticleSystem adds new particles. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setInsertMode](particlesystem-setinsertmode "ParticleSystem:setInsertMode")
programming_docs
love WheelJoint:getAxis WheelJoint:getAxis ================== **Available since LÖVE [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2")** This function is not supported in earlier versions. Gets the world-space axis vector of the Wheel Joint. Function -------- ### Synopsis ``` x, y = WheelJoint:getAxis( ) ``` ### Arguments None. ### Returns `[number](number "number") x` The x-axis coordinate of the world-space axis vector. `[number](number "number") y` The y-axis coordinate of the world-space axis vector. See Also -------- * [WheelJoint](wheeljoint "WheelJoint") * [love.physics.newWheelJoint](love.physics.newwheeljoint "love.physics.newWheelJoint") love PointStyle PointStyle ========== **Removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This enum is not supported in that and later versions. How points should be drawn. Constants --------- rough Draw rough points. smooth Draw smooth points. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getPointStyle](love.graphics.getpointstyle "love.graphics.getPointStyle") * [love.graphics.setPointStyle](love.graphics.setpointstyle "love.graphics.setPointStyle") love EncodeFormat EncodeFormat ============ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This enum is not supported in earlier versions. Encoding format used to [encode](love.data.encode "love.data.encode") or [decode](love.data.decode "love.data.decode") data. Constants --------- base64 Encode/decode data as base64 binary-to-text encoding. hex Encode/decode data as hexadecimal string. See Also -------- * [love.data](love.data "love.data") * [love.data.encode](love.data.encode "love.data.encode") * [love.data.decode](love.data.decode "love.data.decode") love love.window.setFullscreen love.window.setFullscreen ========================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Enters or exits fullscreen. The display to use when entering fullscreen is chosen based on which display the window is currently in, if multiple monitors are connected. Function -------- ### Synopsis ``` success = love.window.setFullscreen( fullscreen ) ``` ### Arguments `[boolean](boolean "boolean") fullscreen` Whether to enter or exit fullscreen mode. ### Returns `[boolean](boolean "boolean") success` True if an attempt to enter fullscreen was successful, false otherwise. Function -------- ### Synopsis ``` success = love.window.setFullscreen( fullscreen, fstype ) ``` ### Arguments `[boolean](boolean "boolean") fullscreen` Whether to enter or exit fullscreen mode. `[FullscreenType](fullscreentype "FullscreenType") fstype` The type of fullscreen mode to use. ### Returns `[boolean](boolean "boolean") success` True if an attempt to enter fullscreen was successful, false otherwise. Notes ----- If fullscreen mode is entered and the window size doesn't match one of the monitor's display modes (in normal fullscreen mode) or the window size doesn't match the desktop size (in 'desktop' fullscreen mode), the window will be resized appropriately. The window will revert back to its original size again when fullscreen mode is exited using this function. Examples -------- Make the window fullscreen in desktop mode. ``` function love.load() love.window.setFullscreen(true, "desktop") end ``` See Also -------- * [love.window](love.window "love.window") * [love.window.getFullscreen](love.window.getfullscreen "love.window.getFullscreen") * [love.window.setMode](love.window.setmode "love.window.setMode") * [love.resize](love.resize "love.resize") love love.joystickremoved love.joystickremoved ==================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Called when a [Joystick](joystick "Joystick") is disconnected. Function -------- ### Synopsis ``` love.joystickremoved( joystick ) ``` ### Arguments `[Joystick](joystick "Joystick") joystick` The now-disconnected Joystick object. ### Returns Nothing. See Also -------- * [love](love "love") * [love.joystickadded](love.joystickadded "love.joystickadded") * [Joystick:isConnected](joystick-isconnected "Joystick:isConnected") love love.filesystem.mount love.filesystem.mount ===================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Mounts a zip file or folder in the game's save directory for reading. It is also possible to mount [love.filesystem.getSourceBaseDirectory](love.filesystem.getsourcebasedirectory "love.filesystem.getSourceBaseDirectory") if the game is in fused mode. Function -------- ### Synopsis ``` success = love.filesystem.mount( archive, mountpoint, appendToPath ) ``` ### Arguments `[string](string "string") archive` The folder or zip file in the game's save directory to mount. `[string](string "string") mountpoint` The new path the archive will be mounted to. `[boolean](boolean "boolean") appendToPath (false)` Whether the archive will be searched when reading a filepath before or after already-mounted archives. This includes the game's source and save directories. ### Returns `[boolean](boolean "boolean") success` True if the archive was successfully mounted, false otherwise. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. Mounts the contents of the given FileData in memory. The FileData's data must contain a zipped directory structure. ### Synopsis ``` success = love.filesystem.mount( filedata, mountpoint, appendToPath ) ``` ### Arguments `[FileData](filedata "FileData") filedata` The FileData object in memory to mount. `[string](string "string") mountpoint` The new path the archive will be mounted to. `[boolean](boolean "boolean") appendToPath (false)` Whether the archive will be searched when reading a filepath before or after already-mounted archives. This includes the game's source and save directories. ### Returns `[boolean](boolean "boolean") success` True if the archive was successfully mounted, false otherwise. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. Mounts the contents of the given Data object in memory. The data must contain a zipped directory structure. ### Synopsis ``` success = love.filesystem.mount( data, archivename, mountpoint, appendToPath ) ``` ### Arguments `[Data](data "Data") data` The Data object in memory to mount. `[string](string "string") archivename` The name to associate the mounted data with, for use with [love.filesystem.unmount](love.filesystem.unmount "love.filesystem.unmount"). Must be unique compared to other mounted data. `[string](string "string") mountpoint` The new path the archive will be mounted to. `[boolean](boolean "boolean") appendToPath (false)` Whether the archive will be searched when reading a filepath before or after already-mounted archives. This includes the game's source and save directories. ### Returns `[boolean](boolean "boolean") success` True if the archive was successfully mounted, false otherwise. Examples -------- ### Mount a zip file. ``` -- Assuming content.zip exists in the game's save directory and contains a file called 'myimage.png'. love.filesystem.mount("content.zip", "content")   assert(love.filesystem.getInfo("content/myimage.png") ~= nil) ``` See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [love.filesystem.unmount](love.filesystem.unmount "love.filesystem.unmount") * [love.filesystem.getSourceBaseDirectory](love.filesystem.getsourcebasedirectory "love.filesystem.getSourceBaseDirectory") * [love.directorydropped](love.directorydropped "love.directorydropped") love World:getJoints World:getJoints =============== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** It has been renamed from [World:getJointList](world-getjointlist "World:getJointList"). Returns a table with all joints. Function -------- ### Synopsis ``` joints = World:getJoints( ) ``` ### Arguments None. ### Returns `[table](table "table") joints` A [sequence](sequence "sequence") with all joints. See Also -------- * [World](world "World") love Source:rewind Source:rewind ============= **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0") and removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** It has been replaced by [Source:stop](source-stop "Source:stop") or [Source:seek](source-seek "Source:seek")(0). Rewinds a Source. Function -------- ### Synopsis ``` Source:rewind() ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Source](source "Source") love RandomGenerator:randomNormal RandomGenerator:randomNormal ============================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Get a normally distributed pseudo random number. Function -------- ### Synopsis ``` number = RandomGenerator:randomNormal( stddev, mean ) ``` ### Arguments `[number](number "number") stddev (1)` Standard deviation of the distribution. `[number](number "number") mean (0)` The mean of the distribution. ### Returns `[number](number "number") number` Normally distributed random number with variance (stddev)² and the specified mean. See Also -------- * [RandomGenerator](randomgenerator "RandomGenerator") * [love.math.randomNormal](love.math.randomnormal "love.math.randomNormal") * [love.math](love.math "love.math") love love.graphics.drawInstanced love.graphics.drawInstanced =========================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Draws many instances of a [Mesh](mesh "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 [Shader](shader "Shader") along with either [per-instance vertex attributes](mesh-attachattribute "Mesh:attachAttribute") or the `love_InstanceID` GLSL 3 vertex [shader variable](shader_variables "Shader Variables") 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](love.graphics.getsupported "love.graphics.getSupported") to check. Function -------- ### Synopsis ``` love.graphics.drawInstanced( mesh, instancecount, x, y, r, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[Mesh](mesh "Mesh") mesh` The mesh to render. `[number](number "number") instancecount` The number of instances to render. `[number](number "number") x (0)` The position to draw the instances (x-axis). `[number](number "number") y (0)` The position to draw the instances (y-axis). `[number](number "number") r (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Shearing factor (x-axis). `[number](number "number") ky (0)` Shearing factor (y-axis). ### Returns Nothing. Function -------- ### Synopsis ``` love.graphics.drawInstanced( mesh, instancecount, transform ) ``` ### Arguments `[Mesh](mesh "Mesh") mesh` The mesh to render. `[number](number "number") instancecount` The number of instances to render. `[Transform](transform "Transform") transform` A transform object. ### Returns Nothing. Examples -------- ### Use vertex attribute instancing to draw many triangles in a single draw call ``` -- A simple small triangle with the default position, texture coordinate, and color vertex attributes. local vertices = { {0, 0, 0,0, 1.0,0.2,0.2,1.0}, {20,0, 0,0, 0.2,1.0,0.2,1.0}, {20,20, 0,0, 0.2,0.2,1.0,1.0}, }   local mesh = love.graphics.newMesh(vertices, "triangles", "static")   -- Unique positions for each instance that will be rendered. local instancepositions = {} for y=0, love.graphics.getHeight()-1, 30 do for x = 0, love.graphics.getWidth()-1, 30 do local pos = {x, y} table.insert(instancepositions, pos) end end   -- Create a mesh containing the per-instance position data. -- It won't be drawn directly, but it will be referenced by the triangle's mesh. local instancemesh = love.graphics.newMesh({{"InstancePosition", "float", 2}}, instancepositions, nil, "static")   -- When the triangle's mesh is rendered, the vertex shader will pull in a different -- value of the InstancePosition attribute for each instance, instead of for each vertex. mesh:attachAttribute("InstancePosition", instancemesh, "perinstance")   -- Vertex shader which uses the InstancePosition vertex attribute. local shader = love.graphics.newShader[[ attribute vec2 InstancePosition;   vec4 position(mat4 transform_projection, vec4 vertex_position) { vertex_position.xy += InstancePosition; return transform_projection * vertex_position; } ]]   function love.draw() love.graphics.setShader(shader)   -- Draw the mesh many times in one draw call, using instancing. local instancecount = #instancepositions love.graphics.drawInstanced(mesh, instancecount, 0, 0) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [Mesh](mesh "Mesh") * [Mesh:attachAttribute](mesh-attachattribute "Mesh:attachAttribute") * [love.graphics.newShader](love.graphics.newshader "love.graphics.newShader") * [GraphicsFeature](graphicsfeature "GraphicsFeature") love FrictionJoint:getMaxTorque FrictionJoint:getMaxTorque ========================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Gets the maximum friction torque in Newton-meters. Function -------- ### Synopsis ``` torque = FrictionJoint:getMaxTorque( ) ``` ### Arguments None. ### Returns `[number](number "number") torque` Maximum torque in Newton-meters. See Also -------- * [FrictionJoint](frictionjoint "FrictionJoint") * [FrictionJoint:setMaxTorque](frictionjoint-setmaxtorque "FrictionJoint:setMaxTorque") love love.mouse.setGrab love.mouse.setGrab ================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [love.mouse.setGrabbed](love.mouse.setgrabbed "love.mouse.setGrabbed"). Grabs the mouse and confines it to the window. Function -------- ### Synopsis ``` love.mouse.setGrab( grab ) ``` ### Arguments `[boolean](boolean "boolean") grab` True to confine the mouse, false to let it leave the window. ### Returns Nothing. Examples -------- Toggles whether the mouse is grabbed by pressing tab, with the help of [love.mouse.isGrabbed](love.mouse.isgrabbed "love.mouse.isGrabbed"). ``` function love.keypressed(key) if key == "tab" then local state = not love.mouse.isGrabbed() -- the opposite of whatever it currently is love.mouse.setGrab(state) end end ``` See Also -------- * [love.mouse](love.mouse "love.mouse") * [love.mouse.isGrabbed](love.mouse.isgrabbed "love.mouse.isGrabbed") love ImageData:mapPixel ImageData:mapPixel ================== Transform an image by applying a function to every pixel. This function is a [higher-order function](https://en.wikipedia.org/wiki/Higher-order_function). It takes another function as a parameter, and calls it once for each pixel in the ImageData. The passed function is called with six parameters for each pixel in turn. The parameters are numbers that represent the x and y coordinates of the pixel and its red, green, blue and alpha values. The function should return the new red, green, blue, and alpha values for that pixel. ``` function pixelFunction(x, y, r, g, b, a) -- template for defining your own pixel mapping function -- perform computations giving the new values for r, g, b and a -- ... return r, g, b, a end ``` In versions prior to [11.0](https://love2d.org/wiki/11.0 "11.0"), color component values were within the range of 0 to 255 instead of 0 to 1. Function -------- ### Synopsis ``` ImageData:mapPixel( pixelFunction, x, y, width, height ) ``` ### Arguments `[function](function "function") pixelFunction` Function to apply to every pixel. `[number](number "number") x (0)` Available since 0.9.0 The x-axis of the top-left corner of the area within the ImageData to apply the function to. `[number](number "number") y (0)` Available since 0.9.0 The y-axis of the top-left corner of the area within the ImageData to apply the function to. `[number](number "number") width (ImageData:getWidth())` Available since 0.9.0 The width of the area within the ImageData to apply the function to. `[number](number "number") height (ImageData:getHeight())` Available since 0.9.0 The height of the area within the ImageData to apply the function to. ### Returns Nothing. Examples -------- ### Brighten an image: ``` function brighten( x, y, r, g, b, a ) r = math.min(r * 3, 1) g = math.min(g * 3, 1) b = math.min(b * 3, 1) return r,g,b,a end   imageData:mapPixel( brighten ) ``` ### Add colored stripes to an image: ``` function stripey( x, y, r, g, b, a ) r = math.min(r * math.sin(x*100)*2, 1) g = math.min(g * math.cos(x*150)*2, 1) b = math.min(b * math.sin(x*50)*2, 1) return r,g,b,a end   imageData:mapPixel( stripey ) ``` source: <http://khason.net/blog/hlsl-pixel-shader-effects-tutorial/> (broken 11/16. See [blogs.microsoft.co.il](http://blogs.microsoft.co.il/tamir/2008/06/17/hlsl-pixel-shader-effects-tutorial/) or [archive.org](https://web.archive.org/web/20150515111551/http://khason.net/blog/hlsl-pixel-shader-effects-tutorial/) mirrors.) See Also -------- * [ImageData](imagedata "ImageData") love Body:wakeUp Body:wakeUp =========== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in that and later versions. Wake a sleeping body up. A sleeping body is much more efficient to simulate than when awake. A sleeping body will also wake up if another body collides with it or if a joint or contact attached to it is destroyed. Function -------- ### Synopsis ``` Body:wakeUp( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Body](body "Body") love love.joystickadded love.joystickadded ================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Called when a [Joystick](joystick "Joystick") is connected. Function -------- ### Synopsis ``` love.joystickadded( joystick ) ``` ### Arguments `[Joystick](joystick "Joystick") joystick` The newly connected Joystick object. ### Returns Nothing. Notes ----- This callback is also triggered after [love.load](love.load "love.load") for every Joystick which was already connected when the game started up. See Also -------- * [love](love "love") * [love.joystick](love.joystick "love.joystick") * [love.joystickremoved](love.joystickremoved "love.joystickremoved") * [Joystick:isConnected](joystick-isconnected "Joystick:isConnected") love love.physics.newChainShape love.physics.newChainShape ========================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Creates a new [ChainShape](chainshape "ChainShape"). Due to a limitation of the current collision algorithm, collision with chain shapes can react in a odd manner. see [[here](https://code.google.com/p/box2d/issues/detail?id=286)] Making changes to a [World](world "World") is not allowed inside of the [beginContact](https://love2d.org/w/index.php?title=beginContact&action=edit&redlink=1 "beginContact (page does not exist)"), [endContact](https://love2d.org/w/index.php?title=endContact&action=edit&redlink=1 "endContact (page does not exist)"), [preSolve](https://love2d.org/w/index.php?title=preSolve&action=edit&redlink=1 "preSolve (page does not exist)"), and [postSolve](https://love2d.org/w/index.php?title=postSolve&action=edit&redlink=1 "postSolve (page does not exist)") callback functions, as BOX2D locks the world during these callbacks. Function -------- ### Synopsis ``` shape = love.physics.newChainShape( loop, x1, y1, x2, y2, ... ) ``` ### Arguments `[boolean](boolean "boolean") loop` If the chain should loop back to the first point. `[number](number "number") x1` The x position of the first point. `[number](number "number") y1` The y position of the first point. `[number](number "number") x2` The x position of the second point. `[number](number "number") y2` The y position of the second point. `[number](number "number") ...` Additional point positions. ### Returns `[ChainShape](chainshape "ChainShape") shape` The new shape. Function -------- **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This variant is not supported in earlier versions. ### Synopsis ``` shape = love.physics.newChainShape( loop, points ) ``` ### Arguments `[boolean](boolean "boolean") loop` If the chain should loop back to the first point. `[table](table "table") points` A list of points to construct the ChainShape, in the form of `{x1, y1, x2, y2, ...}`. ### Returns `[ChainShape](chainshape "ChainShape") shape` The new shape. See Also -------- * [love.physics](love.physics "love.physics") * [ChainShape](chainshape "ChainShape") * [Shape](shape "Shape")
programming_docs
love ChainShape:getChildEdge ChainShape:getChildEdge ======================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Returns a child of the shape as an EdgeShape. Function -------- ### Synopsis ``` shape = ChainShape:getChildEdge( index ) ``` ### Arguments `[number](number "number") index` The index of the child. ### Returns `[EdgeShape](edgeshape "EdgeShape") shape` The child as an EdgeShape. See Also -------- * [ChainShape](chainshape "ChainShape") love PulleyJoint:setMaxLengths PulleyJoint:setMaxLengths ========================= Set the maximum lengths of the rope segments. The physics module also imposes maximum values for the rope segments. If the parameters exceed these values, the maximum values are set instead of the requested values. Function -------- ### Synopsis ``` PulleyJoint:setMaxLengths( max1, max2 ) ``` ### Arguments `[number](number "number") max1` The new maximum length of the first segment. `[number](number "number") max2` The new maximum length of the second segment. ### Returns Nothing. See Also -------- * [PulleyJoint](pulleyjoint "PulleyJoint") love Shape:getType Shape:getType ============= Gets a string representing the Shape. This function can be useful for conditional debug drawing. Function -------- ### Synopsis ``` type = Shape:getType( ) ``` ### Arguments None. ### Returns `[ShapeType](shapetype "ShapeType") type` The type of the Shape. Examples -------- ### Printing the type of a shape ``` shape1 = love.physics.newCircleShape( my_body, 0, 0, 20 ) print(shape1:getType()) -- outputs: 'circle'   shape2 = love.physics.newPolygonShape( my_body, ... ) print(shape2:getType()) -- outputs: 'polygon'   shape3 = love.physics.newRectangleShape( my_body, x, y, w, h, angle ) print(shape3:getType()) -- outputs: 'polygon' ``` See Also -------- * [Shape](shape "Shape") love love.mouse.getPosition love.mouse.getPosition ====================== Returns the current position of the mouse. Function -------- ### Synopsis ``` x, y = love.mouse.getPosition( ) ``` ### Arguments None. ### Returns `[number](number "number") x` The position of the mouse along the x-axis. `[number](number "number") y` The position of the mouse along the y-axis. Examples -------- ### Use getPosition to help draw a custom mouse image ``` function love.load() love.mouse.setVisible(false) -- make default mouse invisible img = love.graphics.newImage("mouse.png") -- load in a custom mouse image end function love.draw() local x, y = love.mouse.getPosition() -- get the position of the mouse love.graphics.draw(img, x, y) -- draw the custom mouse image end ``` See Also -------- * [love.mouse](love.mouse "love.mouse") * [love.mouse.getX](love.mouse.getx "love.mouse.getX") * [love.mouse.getY](love.mouse.gety "love.mouse.getY") love love.audio.rewind love.audio.rewind ================= **Removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** Use [Source:seek](source-seek "Source:seek")(0) instead. Rewinds all playing audio. Function -------- ### Synopsis ``` love.audio.rewind( ) ``` ### Arguments None. ### Returns Nothing. Function -------- ### Synopsis ``` love.audio.rewind( source ) ``` ### Arguments `[Source](source "Source") source` The source to rewind. ### Returns Nothing. See Also -------- * [love.audio](love.audio "love.audio") love Joystick:isConnected Joystick:isConnected ==================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets whether the Joystick is connected. Function -------- ### Synopsis ``` connected = Joystick:isConnected( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") connected` True if the Joystick is currently connected, false otherwise. See Also -------- * [Joystick](joystick "Joystick") * [love.joystickadded](love.joystickadded "love.joystickadded") * [love.joystickremoved](love.joystickremoved "love.joystickremoved") love Body:getY Body:getY ========= Get the y position of the body in world coordinates. Function -------- ### Synopsis ``` y = Body:getY( ) ``` ### Arguments None. ### Returns `[number](number "number") y` The y position in world coordinates. See Also -------- * [Body](body "Body") love love.system love.system =========== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This module is not supported in earlier versions. Provides access to information about the user's system. Functions --------- | | | | | | --- | --- | --- | --- | | [love.system.getClipboardText](love.system.getclipboardtext "love.system.getClipboardText") | Gets text from the clipboard. | 0.9.0 | | | [love.system.getOS](love.system.getos "love.system.getOS") | Gets the current operating system. | 0.9.0 | | | [love.system.getPowerInfo](love.system.getpowerinfo "love.system.getPowerInfo") | Gets information about the system's power supply. | 0.9.0 | | | [love.system.getProcessorCount](love.system.getprocessorcount "love.system.getProcessorCount") | Gets the amount of logical processor in the system. | 0.9.0 | | | [love.system.hasBackgroundMusic](love.system.hasbackgroundmusic "love.system.hasBackgroundMusic") | Gets whether another application on the system is playing music in the background. | 11.0 | | | [love.system.openURL](love.system.openurl "love.system.openURL") | Opens a URL with the user's web or file browser. | 0.9.1 | | | [love.system.setClipboardText](love.system.setclipboardtext "love.system.setClipboardText") | Puts text in the clipboard. | 0.9.0 | | | [love.system.vibrate](love.system.vibrate "love.system.vibrate") | Causes the device to vibrate, if possible. | 0.10.0 | | Enums ----- | | | | | | --- | --- | --- | --- | | [PowerState](powerstate "PowerState") | The basic state of the system's power supply. | 0.9.0 | | See Also -------- * [love](love "love") love love.window.isCreated love.window.isCreated ===================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function has been renamed to [love.window.isOpen](love.window.isopen "love.window.isOpen"). Checks if the window has been created. Function -------- ### Synopsis ``` created = love.window.isCreated( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") created` True if the window has been created, false otherwise. See Also -------- * [love.window](love.window "love.window") love love.data.decompress love.data.decompress ==================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** Deprecates [love.math.decompress](love.math.decompress "love.math.decompress"). Decompresses a [CompressedData](compresseddata "CompressedData") or previously compressed string or [Data](data "Data") object. Function -------- ### Synopsis ``` decompressedData = love.data.decompress( container, compressedData ) ``` ### Arguments `[ContainerType](containertype "ContainerType") container` What type to return the decompressed data as. `[CompressedData](compresseddata "CompressedData") compressedData` The compressed data to decompress. ### Returns `[value](value "value") decompressedData` [Data](data "Data")/[string](string "string") containing the raw decompressed data. Function -------- ### Synopsis ``` decompressedData = love.data.decompress( container, format, compressedString ) ``` ### Arguments `[ContainerType](containertype "ContainerType") container` What type to return the decompressed data as. `[CompressedDataFormat](compresseddataformat "CompressedDataFormat") format` The format that was used to compress the given string. `[string](string "string") compressedString` A string containing data previously compressed with [love.data.compress](love.data.compress "love.data.compress"). ### Returns `[value](value "value") decompressedData` [Data](data "Data")/[string](string "string") containing the raw decompressed data. Function -------- ### Synopsis ``` decompressedData = love.data.decompress( container, format, data ) ``` ### Arguments `[ContainerType](containertype "ContainerType") container` What type to return the decompressed data as. `[CompressedDataFormat](compresseddataformat "CompressedDataFormat") format` The format that was used to compress the given data. `[Data](data "Data") data` A Data object containing data previously compressed with [love.data.compress](love.data.compress "love.data.compress"). ### Returns `[value](value "value") decompressedData` [Data](data "Data")/[string](string "string") containing the raw decompressed data. See Also -------- * [love.data](love.data "love.data") * [love.data.compress](love.data.compress "love.data.compress") love Fixture:getShape Fixture:getShape ================ **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the shape of the fixture. This shape is a reference to the actual data used in the simulation. It's possible to change its values between timesteps. Do not call any functions on this shape after the parent fixture has been destroyed. This shape will point to an invalid memory address and likely cause crashes if you interact further with it. Function -------- ### Synopsis ``` shape = Fixture:getShape( ) ``` ### Arguments None. ### Returns `[Shape](shape "Shape") shape` The fixture's shape. See Also -------- * [Fixture](fixture "Fixture") love love.filesystem.getSource love.filesystem.getSource ========================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Returns the full path to the the .love file or directory. If the game is [fused](love.filesystem.isfused "love.filesystem.isFused") to the LÖVE executable, then the executable is returned. Function -------- ### Synopsis ``` path = love.filesystem.getSource( ) ``` ### Arguments None. ### Returns `[string](string "string") path` The full platform-dependent path of the .love file or directory. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [love.filesystem.isFused](love.filesystem.isfused "love.filesystem.isFused") * [love.filesystem.getSourceBaseDirectory](love.filesystem.getsourcebasedirectory "love.filesystem.getSourceBaseDirectory") love GearJoint:getJoints GearJoint:getJoints =================== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Get the Joints connected by this GearJoint. Function -------- ### Synopsis ``` joint1, joint2 = GearJoint:getJoints( ) ``` ### Arguments None. ### Returns `[Joint](joint "Joint") joint1` The first connected Joint. `[Joint](joint "Joint") joint2` The second connected Joint. See Also -------- * [GearJoint](gearjoint "GearJoint") love love.math.newBezierCurve love.math.newBezierCurve ======================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Creates a new [BezierCurve](beziercurve "BezierCurve") object. The number of vertices in the control polygon determines the degree of the curve, e.g. three vertices define a quadratic (degree 2) Bézier curve, four vertices define a cubic (degree 3) Bézier curve, etc. Function -------- ### Synopsis ``` curve = love.math.newBezierCurve( vertices ) ``` ### Arguments `[table](table "table") vertices` The vertices of the control polygon as a table in the form of `{x1, y1, x2, y2, x3, y3, ...}`. ### Returns `[BezierCurve](beziercurve "BezierCurve") curve` A Bézier curve object. Function -------- ### Synopsis ``` curve = love.math.newBezierCurve( x1, y1, x2, y2, x3, y3, ... ) ``` ### Arguments `[number](number "number") x1` The position of the first vertex of the control polygon on the x-axis. `[number](number "number") y1` The position of the first vertex of the control polygon on the y-axis. `[number](number "number") x2` The position of the second vertex of the control polygon on the x-axis. `[number](number "number") y2` The position of the second vertex of the control polygon on the y-axis. `[number](number "number") x3` The position of the third vertex of the control polygon on the x-axis. `[number](number "number") y3` The position of the third vertex of the control polygon on the y-axis. ### Returns `[BezierCurve](beziercurve "BezierCurve") curve` A Bézier curve object. See Also -------- * [love.math](love.math "love.math") * [BezierCurve](beziercurve "BezierCurve") love RecordingDevice:getData RecordingDevice:getData ======================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets all recorded audio [SoundData](sounddata "SoundData") stored in the device's internal ring buffer. The internal ring buffer is cleared when this function is called, so calling it again will only get audio recorded after the previous call. If the device's internal ring buffer completely fills up before this function is called, the oldest data that doesn't fit into the buffer will be lost. Function -------- ### Synopsis ``` data = RecordingDevice:getData( ) ``` ### Arguments None. ### Returns `[SoundData](sounddata "SoundData") data (nil)` The recorded audio data, or nil if the device isn't recording. See Also -------- * [RecordingDevice](recordingdevice "RecordingDevice") * [RecordingDevice:start](recordingdevice-start "RecordingDevice:start") * [RecordingDevice:stop](recordingdevice-stop "RecordingDevice:stop") * [SoundData](sounddata "SoundData") love PulleyJoint:getMaxLengths PulleyJoint:getMaxLengths ========================= Get the maximum lengths of the rope segments. Function -------- ### Synopsis ``` len1, len2 = PulleyJoint:getMaxLengths( ) ``` ### Arguments None. ### Returns `[number](number "number") len1` The maximum length of the first rope segment. `[number](number "number") len2` The maximum length of the second rope segment. See Also -------- * [PulleyJoint](pulleyjoint "PulleyJoint") love love.filesystem.isFile love.filesystem.isFile ====================== | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | This function is deprecated and is replaced by [love.filesystem.getInfo](love.filesystem.getinfo "love.filesystem.getInfo"). | Check whether something is a file. Function -------- ### Synopsis ``` isFile = love.filesystem.isFile( filename ) ``` ### Arguments `[string](string "string") filename` The path to a potential file. ### Returns `[boolean](boolean "boolean") isFile` True if there is a file with the specified name. False otherwise. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [love.filesystem.isDirectory](love.filesystem.isdirectory "love.filesystem.isDirectory") * [love.filesystem.exists](love.filesystem.exists "love.filesystem.exists") love enet.host:destroy enet.host:destroy ================= Destroys the [host](enet.host "enet.host") structure and closes all of its connections. This function is also ran automatically by lua's garbage collector, since it's an alias to *host:\_\_gc*. Function -------- ### Synopsis ``` host:destroy() ``` ### Arguments None. ### Returns Nothing. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.host](enet.host "enet.host") love Canvas:renderTo Canvas:renderTo =============== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been renamed from [Framebuffer:renderTo](framebuffer-renderto "Framebuffer:renderTo"). Render to the [Canvas](canvas "Canvas") using a function. This is a shortcut to [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas"): ``` canvas:renderTo( func ) ``` is the same as ``` love.graphics.setCanvas( canvas ) func() love.graphics.setCanvas() ``` Function -------- ### Synopsis ``` Canvas:renderTo( func ) ``` ### Arguments `[function](function "function") func` A function performing drawing operations. ### Returns Nothing. Examples -------- ### Using an anonymous function for drawing to a Canvas This example randomly draws a bunch of red lines from the top left corner of the screen to the bottom. ``` local canvas = love.graphics.newCanvas() function love.update() canvas:renderTo(function() love.graphics.setColor(love.math.random(), 0, 0); love.graphics.line(0, 0, love.math.random(0, love.graphics.getWidth()), love.math.random(0, love.graphics.getHeight())); end); end   function love.draw() love.graphics.setColor(1, 1, 1); love.graphics.draw(canvas); end ``` See Also -------- * [Canvas](canvas "Canvas") * [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas") love Texture:getFilter Texture:getFilter ================= Gets the [filter mode](filtermode "FilterMode") of the Texture. Function -------- ### Synopsis ``` min, mag = Texture:getFilter( ) ``` ### Arguments None. ### Returns `[FilterMode](filtermode "FilterMode") min` Filter mode to use when minifying the texture (rendering it at a smaller size on-screen than its size in pixels). `[FilterMode](filtermode "FilterMode") mag` Filter mode to use when magnifying the texture (rendering it at a smaller size on-screen than its size in pixels). Function -------- **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in earlier versions. ### Synopsis ``` min, mag, anisotropy = Texture:getFilter( ) ``` ### Arguments None. ### Returns `[FilterMode](filtermode "FilterMode") min` Filter mode to use when minifying the texture (rendering it at a smaller size on-screen than its size in pixels). `[FilterMode](filtermode "FilterMode") mag` Filter mode to use when magnifying the texture (rendering it at a smaller size on-screen than its size in pixels). `[number](number "number") anisotropy` Maximum amount of anisotropic filtering used. ### Notes When mipmapping is used, higher anisotropic filtering values increase the quality of the texture when rendering it with a non-uniform scale, at the expense of a bit of performance. Most systems support up to 8x or 16x anisotropic filtering. See Also -------- * [Texture](texture "Texture") * [Texture:setFilter](texture-setfilter "Texture:setFilter") love Font:getDPIScale Font:getDPIScale ================ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This method is not supported in earlier versions. Gets the DPI scale factor of the Font. The DPI scale factor represents relative pixel density. A DPI scale factor of 2 means the font's glyphs have twice the pixel density in each dimension (4 times as many pixels in the same area) compared to a font with a DPI scale factor of 1. The font size of TrueType fonts is scaled internally by the font's specified DPI scale factor. By default, LÖVE uses the [screen's DPI scale factor](love.graphics.getdpiscale "love.graphics.getDPIScale") when creating TrueType fonts. Function -------- ### Synopsis ``` dpiscale = Font:getDPIScale( ) ``` ### Arguments None. ### Returns `[number](number "number") dpiscale` The DPI scale factor of the Font. See Also -------- * [Font](font "Font") * [love.graphics.newFont](love.graphics.newfont "love.graphics.newFont") * [love.graphics.getDPIScale](love.graphics.getdpiscale "love.graphics.getDPIScale") * [Config Files](love.conf "Config Files")
programming_docs
love Body:isFrozen Body:isFrozen ============= **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in that and later versions. Get the frozen status of the body. A body becomes frozen when it goes outside the world boundary. A frozen body is no longer changed by [World:update](world-update "World:update"). Function -------- ### Synopsis ``` status = Body:isFrozen( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") status` The frozen status of the body. See Also -------- * [Body](body "Body") love love.event.quit love.event.quit =============== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Adds the quit event to the queue. The quit event is a signal for the event handler to close LÖVE. It's possible to abort the exit process with the [love.quit](love.quit "love.quit") callback. Equivalent to love.event.push("quit", exitstatus) Function -------- ### Synopsis ``` love.event.quit( exitstatus ) ``` ### Arguments `[number](number "number") exitstatus (0)` Available since 0.10.0 The program exit status to use when closing the application. ### Returns Nothing. Function -------- **Available since LÖVE [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2")** This variant is not supported in earlier versions. Restarts the game without relaunching the executable. This cleanly shuts down the main Lua state instance and creates a brand new one. ### Synopsis ``` love.event.quit( "restart" ) ``` ### Arguments `[string](string "string") "restart"` Tells the default [love.run](love.run "love.run") to exit and restart the game without relaunching the executable. ### Returns Nothing. Example ------- ``` function love.keypressed(k) if k == 'escape' then love.event.quit() end end ``` See Also -------- * [love.event](love.event "love.event") * [love.quit](love.quit "love.quit") love love.graphics.setRenderTarget love.graphics.setRenderTarget ============================= **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0") and removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been renamed to [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas"). Sets or resets a [Framebuffer](framebuffer "Framebuffer") as render target. All drawing operations until the next *love.graphics.setRenderTarget* will be directed to the [Framebuffer](framebuffer "Framebuffer") object specified. Function -------- ### Synopsis ``` love.graphics.setRenderTarget( framebuffer ) ``` ### Arguments `[Framebuffer](framebuffer "Framebuffer") framebuffer` The new render target. ### Returns Nothing. ### Notes Sets the render target to a specified [Framebuffer](framebuffer "Framebuffer"). The specified [Framebuffer](framebuffer "Framebuffer") will be cleared. All drawing operations until the next *love.graphics.setRenderTarget* will be redirected to the [Framebuffer](framebuffer "Framebuffer") and not shown on the screen. Function -------- ### Synopsis ``` love.graphics.setRenderTarget( ) ``` ### Arguments None. ### Returns Nothing. ### Notes Resets the render target to the screen, i.e. re-enables drawing to the screen. Examples -------- ### Drawing to a framebuffer ``` -- draw colored square to framebuffer love.graphics.setRenderTarget(framebuffer) love.graphics.setColor(230,240,120) love.graphics.rectangle('fill',0,0,100,100) love.graphics.setRenderTarget()   -- draw scaled framebuffer to screen love.graphics.setColor(255,255,255) love.graphics.draw(framebuffer, 200,100, 0, .5,.5) ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [Framebuffer](framebuffer "Framebuffer") * [Framebuffer:renderTo](framebuffer-renderto "Framebuffer:renderTo") love love.graphics.getCaption love.graphics.getCaption ======================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** Moved to the [love.window](love.window "love.window") module as [love.window.getTitle](love.window.gettitle "love.window.getTitle"). Gets the window caption. Function -------- ### Synopsis ``` caption = love.graphics.getCaption( ) ``` ### Arguments None. ### Returns `[string](string "string") caption` The current window caption. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setCaption](love.graphics.setcaption "love.graphics.setCaption") love Mesh:getVertex Mesh:getVertex ============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the properties of a vertex in the Mesh. In versions prior to [11.0](https://love2d.org/wiki/11.0 "11.0"), color and byte component values were within the range of 0 to 255 instead of 0 to 1. Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. ### Synopsis ``` attributecomponent, ... = Mesh:getVertex( index ) ``` ### Arguments `[number](number "number") index` The one-based index of the vertex you want to retrieve the information for. ### Returns `[number](number "number") attributecomponent` The first component of the first vertex attribute in the specified vertex. `[number](number "number") ...` Additional components of all vertex attributes in the specified vertex. ### Notes The values are returned in the same order as the vertex attributes in the Mesh's [vertex format](mesh-getvertexformat "Mesh:getVertexFormat"). A standard Mesh that wasn't [created](love.graphics.newmesh "love.graphics.newMesh") with a custom vertex format will return two position numbers, two texture coordinate numbers, and four color components: x, y, u, v, r, g, b, a. Function -------- Gets the vertex components of a Mesh that wasn't [created](love.graphics.newmesh "love.graphics.newMesh") with a custom vertex format. ### Synopsis ``` x, y, u, v, r, g, b, a = Mesh:getVertex( index ) ``` ### Arguments `[number](number "number") index` The index of the vertex you want to retrieve the information for. ### Returns `[number](number "number") x` The position of the vertex on the x-axis. `[number](number "number") y` The position of the vertex on the y-axis. `[number](number "number") u` The horizontal component of the texture coordinate. `[number](number "number") v` The vertical component of the texture coordinate. `[number](number "number") r` The red component of the vertex's color. `[number](number "number") g` The green component of the vertex's color. `[number](number "number") b` The blue component of the vertex's color. `[number](number "number") a` The alpha component of the vertex's color. See Also -------- * [Mesh](mesh "Mesh") * [Mesh:setVertex](mesh-setvertex "Mesh:setVertex") * [Mesh:getVertexCount](mesh-getvertexcount "Mesh:getVertexCount") * [Mesh:getVertexAttribute](mesh-getvertexattribute "Mesh:getVertexAttribute") * [Mesh:getVertexFormat](mesh-getvertexformat "Mesh:getVertexFormat") * [love.graphics.newMesh](love.graphics.newmesh "love.graphics.newMesh") love love.physics.newWeldJoint love.physics.newWeldJoint ========================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Creates a constraint joint between two bodies. A [WeldJoint](weldjoint "WeldJoint") essentially glues two bodies together. The constraint is a bit soft, however, due to Box2D's iterative solver. Making changes to a [World](world "World") is not allowed inside of the [beginContact](https://love2d.org/w/index.php?title=beginContact&action=edit&redlink=1 "beginContact (page does not exist)"), [endContact](https://love2d.org/w/index.php?title=endContact&action=edit&redlink=1 "endContact (page does not exist)"), [preSolve](https://love2d.org/w/index.php?title=preSolve&action=edit&redlink=1 "preSolve (page does not exist)"), and [postSolve](https://love2d.org/w/index.php?title=postSolve&action=edit&redlink=1 "postSolve (page does not exist)") callback functions, as BOX2D locks the world during these callbacks. Function -------- ### Synopsis ``` joint = love.physics.newWeldJoint( body1, body2, x, y, collideConnected ) ``` ### Arguments `[Body](body "Body") body1` The first body to attach to the joint. `[Body](body "Body") body2` The second body to attach to the joint. `[number](number "number") x` The x position of the anchor point (world space). `[number](number "number") y` The y position of the anchor point (world space). `[boolean](boolean "boolean") collideConnected (false)` Specifies whether the two bodies should collide with each other. ### Returns `[WeldJoint](weldjoint "WeldJoint") joint` The new WeldJoint. Function -------- ### Synopsis ``` joint = love.physics.newWeldJoint( body1, body2, x1, y1, x2, y2, collideConnected ) ``` ### Arguments `[Body](body "Body") body1` The first body to attach to the joint. `[Body](body "Body") body2` The second body to attach to the joint. `[number](number "number") x1` The x position of the first anchor point (world space). `[number](number "number") y1` The y position of the first anchor point (world space). `[number](number "number") x2` The x position of the second anchor point (world space). `[number](number "number") y2` The y position of the second anchor point (world space). `[boolean](boolean "boolean") collideConnected (false)` Specifies whether the two bodies should collide with each other. ### Returns `[WeldJoint](weldjoint "WeldJoint") joint` The new WeldJoint. Function -------- **Available since LÖVE [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2")** This variant is not supported in earlier versions. ### Synopsis ``` joint = love.physics.newWeldJoint( body1, body2, x1, y1, x2, y2, collideConnected, referenceAngle ) ``` ### Arguments `[Body](body "Body") body1` The first body to attach to the joint. `[Body](body "Body") body2` The second body to attach to the joint. `[number](number "number") x1` The x position of the first anchor point (world space). `[number](number "number") y1` The y position of the first anchor point (world space). `[number](number "number") x2` The x position of the second anchor point (world space). `[number](number "number") y2` The y position of the second anchor point (world space). `[boolean](boolean "boolean") collideConnected (false)` Specifies whether the two bodies should collide with each other. `[number](number "number") referenceAngle (0)` The reference angle between body1 and body2, in radians. ### Returns `[WeldJoint](weldjoint "WeldJoint") joint` The new WeldJoint. See Also -------- * [love.physics](love.physics "love.physics") * [WeldJoint](weldjoint "WeldJoint") * [Joint](joint "Joint") love Mesh:getTexture Mesh:getTexture =============== **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. Gets the texture ([Image](image "Image") or [Canvas](canvas "Canvas")) used when drawing the Mesh. Function -------- ### Synopsis ``` texture = Mesh:getTexture( ) ``` ### Arguments None. ### Returns `[Texture](texture "Texture") texture (nil)` The Image or Canvas to texture the Mesh with when drawing, or nil if none is set. See Also -------- * [Mesh](mesh "Mesh") * [Mesh:setTexture](mesh-settexture "Mesh:setTexture") love Mesh:setAttributeEnabled Mesh:setAttributeEnabled ======================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Enables or disables a specific vertex attribute in the Mesh. Vertex data from disabled attributes is not used when drawing the Mesh. Function -------- ### Synopsis ``` Mesh:setAttributeEnabled( name, enable ) ``` ### Arguments `[string](string "string") name` The name of the vertex attribute to enable or disable. `[boolean](boolean "boolean") enable` Whether the vertex attribute is used when drawing this Mesh. ### Returns Nothing. Notes ----- If a Mesh wasn't [created](love.graphics.newmesh "love.graphics.newMesh") with a custom vertex format, it will have 3 vertex attributes named `VertexPosition`, `VertexTexCoord`, and `VertexColor`. Otherwise the attribute name must either match one of the vertex attributes specified in the [vertex format](mesh-getvertexformat "Mesh:getVertexFormat") when [creating the Mesh](love.graphics.newmesh "love.graphics.newMesh"), or must match a vertex attribute from another Mesh attached to this Mesh via [Mesh:attachAttribute](mesh-attachattribute "Mesh:attachAttribute"). See Also -------- * [Mesh](mesh "Mesh") * [Mesh:isAttributeEnabled](mesh-isattributeenabled "Mesh:isAttributeEnabled") * [Mesh:getVertexFormat](mesh-getvertexformat "Mesh:getVertexFormat") * [love.graphics.draw](love.graphics.draw "love.graphics.draw") love Source:getPosition Source:getPosition ================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Gets the position of the Source. Function -------- ### Synopsis ``` x, y, z = Source:getPosition( ) ``` ### Arguments None. ### Returns `[number](number "number") x` The X position of the Source. `[number](number "number") y` The Y position of the Source. `[number](number "number") z` The Z position of the Source. See Also -------- * [Source](source "Source") love enet.host enet.host ========= Description ----------- An ENet host for communicating with peers. On creation it will bind to a port on an address, unless otherwise specified, which will keep other applications from binding to the same port and address. One can free the port by calling its destroy method; nil-ing the host object and calling collectgarbage() would work as well, since :destroy calls host:\_\_gc internally, but this is cleaner: ``` local host = enet.host_create("*:6789") host:destroy() ``` Functions --------- | Function | Description | | --- | --- | | [host:service](enet.host-service "enet.host:service") | Wait for [events](enet.event "enet.event"), send and receive any ready packets. | | [host:check\_events](enet.host-check_events "enet.host:check events") | Checks for any queued [events](enet.event "enet.event") and dispatches one if available. | | [host:compress\_with\_range\_coder](enet.host-compress_with_range_coder "enet.host:compress with range coder") | Toggles an adaptive order-2 PPM range coder for the transmitted data of all peers. | | [host:connect](enet.host-connect "enet.host:connect") | Connects a host to a remote host. Returns [peer](enet.peer "enet.peer") object associated with remote host. | | [host:flush](enet.host-flush "enet.host:flush") | Sends any queued packets. | | [host:broadcast](enet.host-broadcast "enet.host:broadcast") | Queues a packet to be sent to all connected peers. | | [host:channel\_limit](enet.host-channel_limit "enet.host:channel limit") | Sets the maximum number of channels allowed. | | [host:bandwidth\_limit](enet.host-bandwidth_limit "enet.host:bandwidth limit") | Sets the bandwidth limits of the host in bytes/sec. | | [host:get\_socket\_address](enet.host-get_socket_address "enet.host:get socket address") | Returns a [string](string "string") that describes the socket address of the given host. | | [host:socket\_get\_address](enet.host-get_socket_address "enet.host:get socket address") | Deprecated version of host:get\_socket\_address. | | [host:destroy](enet.host-destroy "enet.host:destroy") | Destroys the host, freeing any bound ports and addresses. Alias for the host:\_\_gc method. | | [host:total\_sent\_data](enet.host-total_sent_data "enet.host:total sent data") | Returns the [number](number "number") of bytes that were sent through the given host. | | [host:total\_received\_data](enet.host-total_received_data "enet.host:total received data") | Returns the [number](number "number") of bytes that were received by the given host. | | [host:service\_time](enet.host-service_time "enet.host:service time") | Returns the timestamp of the last call to [host:service()](enet.host-service "enet.host:service") or [host:flush()](enet.host-flush "enet.host:flush"). | | [host:peer\_count](enet.host-peer_count "enet.host:peer count") | Returns the number of peers that are allocated for the given host. | | [host:get\_peer](enet.host-get_peer "enet.host:get peer") | Returns the connected [peer](enet.peer "enet.peer") at the specified index (starting at 1). | | [host:\_\_gc](enet.host-destroy "enet.host:destroy") | Destroys the host, freeing any bound ports and addresses. | See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet:host\_create](enet-host_create "enet:host create") * [enet.event](enet.event "enet.event") * [enet.peer](enet.peer "enet.peer") love WheelJoint:getMotorTorque WheelJoint:getMotorTorque ========================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the current torque on the motor. Function -------- ### Synopsis ``` torque = WheelJoint:getMotorTorque( invdt ) ``` ### Arguments `[number](number "number") invdt` How long the force applies. Usually the inverse time step or 1/dt. ### Returns `[number](number "number") torque` The torque on the motor in newton meters. See Also -------- * [WheelJoint](wheeljoint "WheelJoint") love love.system.openURL love.system.openURL =================== **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. Opens a URL with the user's web or file browser. Function -------- ### Synopsis ``` success = love.system.openURL( url ) ``` ### Arguments `[string](string "string") url` The URL to open. Must be formatted as a proper URL. ### Returns `[boolean](boolean "boolean") success` Whether the URL was opened successfully. Notes ----- Passing `file://` scheme in Android 7.0 (Nougat) and later always result in [failure](https://developer.android.com/about/versions/nougat/android-7.0-changes.html#sharing-files). Prior to [11.2](https://love2d.org/wiki/11.2 "11.2"), this will crash LÖVE instead of returning false. Examples -------- ### Open love2d.org when the game is loaded. ``` function love.load() love.system.openURL("http://love2d.org/") end ``` ### Open the game's save directory when "s" is pressed. ``` function love.load() -- Make sure the save directory exists by writing an empty file. love.filesystem.write("test.txt", "") end   function love.keypressed(key) if key == "s" then -- To open a file or folder, "file://" must be prepended to the path. love.system.openURL("file://"..love.filesystem.getSaveDirectory()) end end ``` See Also -------- * [love.system](love.system "love.system") love Mesh:getVertexMap Mesh:getVertexMap ================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the vertex map for the Mesh. The vertex map describes the order in which the vertices are used when the Mesh is drawn. The vertices, vertex map, and mesh draw mode work together to determine what exactly is displayed on the screen. If no vertex map has been set previously via [Mesh:setVertexMap](mesh-setvertexmap "Mesh:setVertexMap"), then this function will return [nil](nil "nil") in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")+, or an empty table in [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2") and older. Function -------- ### Synopsis ``` map = Mesh:getVertexMap( ) ``` ### Arguments None. ### Returns `[table](table "table") map` A table containing the list of vertex indices used when drawing. See Also -------- * [Mesh](mesh "Mesh") * [Mesh:setVertexMap](mesh-setvertexmap "Mesh:setVertexMap")
programming_docs
love ParticleSystem:isFull ParticleSystem:isFull ===================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** Use [ParticleSystem:getCount](particlesystem-getcount "ParticleSystem:getCount") and [ParticleSystem:getBufferSize](particlesystem-getbuffersize "ParticleSystem:getBufferSize"). Checks whether the particle system is full of particles. Function -------- ### Synopsis ``` full = ParticleSystem:isFull( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") full` True if no more particles can be added, false otherwise. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love Body:setInertia Body:setInertia =============== Set the inertia of a body. Function -------- ### Synopsis ``` Body:setInertia( inertia ) ``` ### Arguments `[number](number "number") inertia` The new moment of inertia, in kilograms \* pixel squared. ### Returns Nothing. See Also -------- * [Body](body "Body") love Thread:kill Thread:kill =========== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0") and removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier or later versions. Forcefully terminate the thread. This function terminates the thread wherever it is, which is capable of locking the game, or doing anything evil for that matter, its use is strongly discouraged. Function -------- ### Synopsis ``` Thread:kill( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Thread](thread "Thread") love love.audio love.audio ========== Provides of audio interface for playback/recording sound. Types ----- | | | | | | --- | --- | --- | --- | | [RecordingDevice](recordingdevice "RecordingDevice") | Represents an audio input device capable of recording sounds. | 11.0 | | | [Source](source "Source") | A Source represents audio you can play back. | | | Functions --------- | | | | | | --- | --- | --- | --- | | [love.audio.getActiveEffects](love.audio.getactiveeffects "love.audio.getActiveEffects") | Gets a list of the names of the currently enabled effects. | 11.0 | | | [love.audio.getActiveSourceCount](love.audio.getactivesourcecount "love.audio.getActiveSourceCount") | Gets the current number of simultaneously playing sources. | 11.0 | | | [love.audio.getDistanceModel](love.audio.getdistancemodel "love.audio.getDistanceModel") | Returns the distance attenuation model. | 0.8.0 | | | [love.audio.getDopplerScale](love.audio.getdopplerscale "love.audio.getDopplerScale") | Gets the global scale factor for doppler effects. | 0.9.2 | | | [love.audio.getEffect](love.audio.geteffect "love.audio.getEffect") | Gets the settings associated with an effect. | 11.0 | | | [love.audio.getMaxSceneEffects](love.audio.getmaxsceneeffects "love.audio.getMaxSceneEffects") | Gets the maximum number of active effects. | 11.0 | | | [love.audio.getMaxSourceEffects](love.audio.getmaxsourceeffects "love.audio.getMaxSourceEffects") | Gets the maximum number of active Effects for each [Source](source "Source"). | 11.0 | | | [love.audio.getNumSources](love.audio.getnumsources "love.audio.getNumSources") | Gets the current number of simultaneously playing sources. | | 0.9.0 | | [love.audio.getOrientation](love.audio.getorientation "love.audio.getOrientation") | Returns the orientation of the listener. | | | | [love.audio.getPosition](love.audio.getposition "love.audio.getPosition") | Returns the position of the listener. | | | | [love.audio.getRecordingDevices](love.audio.getrecordingdevices "love.audio.getRecordingDevices") | Gets a list of [RecordingDevices](recordingdevice "RecordingDevice") on the system. | 11.0 | | | [love.audio.getSourceCount](love.audio.getsourcecount "love.audio.getSourceCount") | Gets the current number of simultaneously playing sources. | 0.9.0 | 11.0 | | [love.audio.getVelocity](love.audio.getvelocity "love.audio.getVelocity") | Returns the velocity of the listener. | | | | [love.audio.getVolume](love.audio.getvolume "love.audio.getVolume") | Returns the master volume. | | | | [love.audio.isEffectsSupported](love.audio.iseffectssupported "love.audio.isEffectsSupported") | Gets whether Effects are supported in the system. | 11.0 | | | [love.audio.newQueueableSource](love.audio.newqueueablesource "love.audio.newQueueableSource") | Creates a new Source usable for real-time generated sound playback with [Source:queue](source-queue "Source:queue"). | 11.0 | | | [love.audio.newSource](love.audio.newsource "love.audio.newSource") | Creates a new [Source](source "Source") from a file, [SoundData](sounddata "SoundData"), or [Decoder](decoder "Decoder"). | | | | [love.audio.pause](love.audio.pause "love.audio.pause") | Pauses specific or all currently played [Sources](source "Source"). | | | | [love.audio.play](love.audio.play "love.audio.play") | Plays the specified Source. | | | | [love.audio.resume](love.audio.resume "love.audio.resume") | Resumes all audio. | | 11.0 | | [love.audio.rewind](love.audio.rewind "love.audio.rewind") | Rewinds all playing audio. | | 11.0 | | [love.audio.setDistanceModel](love.audio.setdistancemodel "love.audio.setDistanceModel") | Sets the distance attenuation model. | 0.8.0 | | | [love.audio.setDopplerScale](love.audio.setdopplerscale "love.audio.setDopplerScale") | Sets a global scale factor for doppler effects. | 0.9.2 | | | [love.audio.setEffect](love.audio.seteffect "love.audio.setEffect") | Defines an effect that can be applied to a Source. | 11.0 | | | [love.audio.setMixWithSystem](love.audio.setmixwithsystem "love.audio.setMixWithSystem") | Sets whether the system should mix the audio with the system's audio. | 11.0 | | | [love.audio.setOrientation](love.audio.setorientation "love.audio.setOrientation") | Sets the orientation of the listener. | | | | [love.audio.setPosition](love.audio.setposition "love.audio.setPosition") | Sets the position of the listener. | | | | [love.audio.setVelocity](love.audio.setvelocity "love.audio.setVelocity") | Sets the velocity of the listener. | | | | [love.audio.setVolume](love.audio.setvolume "love.audio.setVolume") | Sets the master volume. | | | | [love.audio.stop](love.audio.stop "love.audio.stop") | Stops currently played [sources](source "Source"). | | | Enums ----- | | | | | | --- | --- | --- | --- | | [DistanceModel](distancemodel "DistanceModel") | The different distance models. | 0.8.0 | | | [EffectType](effecttype "EffectType") | Different types of audio effects. | 11.0 | | | [EffectWaveform](effectwaveform "EffectWaveform") | Types of waveforms for **ringmodulator** effect. | 11.0 | | | [SourceType](sourcetype "SourceType") | Types of audio sources. | | | | [TimeUnit](timeunit "TimeUnit") | Units that represent time. | 0.8.0 | | See Also -------- * [love](love "love") * [Tutorial:Audio](https://love2d.org/wiki/Tutorial:Audio "Tutorial:Audio") * [Audio Formats](audio_formats "Audio Formats") love love.sound love.sound ========== This module is responsible for decoding sound files. It can't play the sounds, see [love.audio](love.audio "love.audio") for that. Types ----- | | | | | | --- | --- | --- | --- | | [Decoder](decoder "Decoder") | An object which can gradually decode a sound file. | | | | [SoundData](sounddata "SoundData") | Contains raw audio samples. | | | Functions --------- | | | | | | --- | --- | --- | --- | | [love.sound.newDecoder](love.sound.newdecoder "love.sound.newDecoder") | Attempts to find a decoder for the encoded sound data in the specified file. | | | | [love.sound.newSoundData](love.sound.newsounddata "love.sound.newSoundData") | Creates a new SoundData. | | | See Also -------- * [love](love "love") * [Audio Formats](audio_formats "Audio Formats") love enet.peer:disconnect enet.peer:disconnect ==================== Requests a disconnection from the [peer](enet.peer "enet.peer"). The message is sent on the next [host:service()](enet.host-service "enet.host:service") or [host:flush()](enet.host-flush "enet.host:flush"). Function -------- ### Synopsis ``` peer:disconnect(data) ``` ### Arguments `[number](number "number") data` An optional integer value to be associated with the disconnect. ### Returns Nothing. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.host](enet.host "enet.host") * [enet.host:flush](enet.host-flush "enet.host:flush") * [enet.host:service](enet.host-service "enet.host:service") * [enet.peer](enet.peer "enet.peer") love ParticleSystem:getSpin ParticleSystem:getSpin ====================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the spin of the sprite. Function -------- ### Synopsis ``` min, max, variation = ParticleSystem:getSpin( ) ``` ### Arguments Nothing. ### Returns `[number](number "number") min` The minimum spin (radians per second). `[number](number "number") max (min)` The maximum spin (radians per second). `[number](number "number") variation (0)` The degree of variation (0 meaning no variation and 1 meaning full variation between start and end). See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setSpin](particlesystem-setspin "ParticleSystem:setSpin") love Body:isStatic Body:isStatic ============= **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in that and later versions. Get the static status of the body. A static body has no mass and a constant position. It will not react to collisions. Often used for walls. A dynamic body has mass and can move. It will react to collisions when the world is updated. Function -------- ### Synopsis ``` status = Body:isStatic( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") status` The static status of the body. See Also -------- * [Body](body "Body") love Body:setAngularVelocity Body:setAngularVelocity ======================= Sets the angular velocity of a Body. The angular velocity is the *rate of change of angle over time*. This function will not accumulate anything; any impulses previously applied since the last call to [World:update](world-update "World:update") will be lost. Function -------- ### Synopsis ``` Body:setAngularVelocity( w ) ``` ### Arguments `[number](number "number") w` The new angular velocity, in radians per second ### Returns Nothing. See Also -------- * [Body](body "Body") love ParticleSystem:getQuads ParticleSystem:getQuads ======================= **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Gets the series of [Quads](quad "Quad") used for the particle sprites. Function -------- ### Synopsis ``` quads = ParticleSystem:getQuads( ) ``` ### Arguments Nothing. ### Returns `[table](table "table") quads` A table containing the Quads used. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setQuads](particlesystem-setquads "ParticleSystem:setQuads") love ImageData ImageData ========= Raw (decoded) image data. You can't draw ImageData directly to screen. See [Image](image "Image") for that. Constructors ------------ | | | | | | --- | --- | --- | --- | | [Canvas:newImageData](canvas-newimagedata "Canvas:newImageData") | Generates **ImageData** from the contents of the Canvas. | 0.10.0 | | | [love.graphics.newScreenshot](love.graphics.newscreenshot "love.graphics.newScreenshot") | Creates a screenshot and returns the **ImageData**. | | 11.0 | | [love.image.newImageData](love.image.newimagedata "love.image.newImageData") | Creates a new ImageData object. | | | Functions --------- | | | | | | --- | --- | --- | --- | | [Data:clone](data-clone "Data:clone") | Creates a new copy of the Data object. | 11.0 | | | [Data:getFFIPointer](data-getffipointer "Data:getFFIPointer") | Gets an FFI pointer to the Data. | 11.3 | | | [Data:getPointer](data-getpointer "Data:getPointer") | Gets a pointer to the Data. | | | | [Data:getSize](data-getsize "Data:getSize") | Gets the [Data](data "Data")'s size in bytes. | | | | [Data:getString](data-getstring "Data:getString") | Gets the full Data as a string. | 0.9.0 | | | [ImageData:encode](imagedata-encode "ImageData:encode") | Encodes the ImageData to a file format and optionally writes it to the [save directory](love.filesystem "love.filesystem"). | | | | [ImageData:getDimensions](imagedata-getdimensions "ImageData:getDimensions") | Gets the width and height of the ImageData in pixels. | 0.9.0 | | | [ImageData:getFormat](imagedata-getformat "ImageData:getFormat") | Gets the [pixel format](pixelformat "PixelFormat") of the ImageData. | 11.0 | | | [ImageData:getHeight](imagedata-getheight "ImageData:getHeight") | Gets the height of the ImageData in pixels. | | | | [ImageData:getPixel](imagedata-getpixel "ImageData:getPixel") | Gets the color of a pixel. | | | | [ImageData:getString](imagedata-getstring "ImageData:getString") | Gets the full ImageData as a string. | | 0.9.0 | | [ImageData:getWidth](imagedata-getwidth "ImageData:getWidth") | Gets the width of the ImageData in pixels. | | | | [ImageData:mapPixel](imagedata-mappixel "ImageData:mapPixel") | Transform an image by applying a function to every pixel. | | | | [ImageData:paste](imagedata-paste "ImageData:paste") | Paste into ImageData from another source ImageData. | | | | [ImageData:setPixel](imagedata-setpixel "ImageData:setPixel") | Sets the color of a pixel. | | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Enums ----- | | | | | | --- | --- | --- | --- | | [ImageEncodeFormat](imageencodeformat "ImageEncodeFormat") | Image file formats supported by [ImageData:encode](imagedata-encode "ImageData:encode"). | | | Supertypes ---------- * [Data](data "Data") * [Object](object "Object") See Also -------- * [love.image](love.image "love.image") * [Image](image "Image") love FontData FontData ======== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0") and removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This type is not supported in earlier or later versions. A FontData represents a font, containing the font Rasterizer and its glyphs. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.font.newFontData](love.font.newfontdata "love.font.newFontData") | Creates a new FontData. | 0.7.0 | 0.8.0 | Functions --------- | | | | | | --- | --- | --- | --- | | [Data:clone](data-clone "Data:clone") | Creates a new copy of the Data object. | 11.0 | | | [Data:getFFIPointer](data-getffipointer "Data:getFFIPointer") | Gets an FFI pointer to the Data. | 11.3 | | | [Data:getPointer](data-getpointer "Data:getPointer") | Gets a pointer to the Data. | | | | [Data:getSize](data-getsize "Data:getSize") | Gets the [Data](data "Data")'s size in bytes. | | | | [Data:getString](data-getstring "Data:getString") | Gets the full Data as a string. | 0.9.0 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Supertypes ---------- * [Data](data "Data") * [Object](object "Object") See Also -------- * [love.font](love.font "love.font") love love.data.hash love.data.hash ============== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Compute the message digest of a string using a specified hash algorithm. There's [bug](https://github.com/love2d/love/issues/1458) in version, up to [11.2](https://love2d.org/wiki/11.2 "11.2") which gives wrong result for very-specific input length (112 + 128n for SHA512 and SHA384, 56 + 64n for other hash functions). Function -------- ### Synopsis ``` rawdigest = love.data.hash( hashFunction, string ) ``` ### Arguments `[HashFunction](hashfunction "HashFunction") hashFunction` Hash algorithm to use. `[string](string "string") string` String to hash. ### Returns `[string](string "string") rawdigest` Raw message digest string. Function -------- ### Synopsis ``` rawdigest = love.data.hash( hashFunction, data ) ``` ### Arguments `[HashFunction](hashfunction "HashFunction") hashFunction` Hash algorithm to use. `[Data](data "Data") data` Data to hash. ### Returns `[string](string "string") rawdigest` Raw message digest string. Notes ----- To return the hex string representation of the hash, use [love.data.encode](love.data.encode "love.data.encode") ``` hexDigestString = love.data.encode("string", "hex", love.data.hash(algo, data)) ``` See Also -------- * [love.data](love.data "love.data") * [love.data.encode](love.data.encode "love.data.encode") * [HashFunction](hashfunction "HashFunction") love ParticleSystem:setColor ParticleSystem:setColor ======================= **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been replaced with [ParticleSystem:setColors](particlesystem-setcolors "ParticleSystem:setColors"). Sets the color of the image. Function -------- ### Synopsis ``` ParticleSystem:setColor( r1, g1, b1, a1, r2, g2, b2, a2 ) ``` ### Arguments `[number](number "number") r1` Start color, red component (0-255). `[number](number "number") g1` Start color, green component (0-255). `[number](number "number") b1` Start color, blue component (0-255). `[number](number "number") a1` Start color, alpha component (0-255). `[number](number "number") r2 (r1)` End color, red component (0-255). `[number](number "number") g2 (g1)` End color, green component (0-255). `[number](number "number") b2 (b1)` End color, blue component (0-255). `[number](number "number") a2 (a1)` End color, alpha component (0-255). ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love love.joystick.isDown love.joystick.isDown ==================== **Available since LÖVE [0.5.0](https://love2d.org/wiki/0.5.0 "0.5.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been moved to [Joystick:isDown](joystick-isdown "Joystick:isDown"). Checks if a button on a joystick is pressed. Function -------- ### Synopsis ``` down = love.joystick.isDown( joystick, button ) ``` ### Arguments `[number](number "number") joystick` The joystick to be checked `[number](number "number") button` The button to be checked ### Returns `[boolean](boolean "boolean") down` True if the button is down, false if it is not Function -------- **Available since LÖVE [0.7.2](https://love2d.org/wiki/0.7.2 "0.7.2")** This variant is not supported in earlier versions. ### Synopsis ``` anyDown = love.joystick.isDown( joystick, button1, button2, button3, ... ) ``` ### Arguments `[number](number "number") joystick` The joystick to be checked `[number](number "number") buttonN` A button to check ### Returns `[boolean](boolean "boolean") anyDown` True if any supplied button is down, false if not. See Also -------- * [love.joystick](love.joystick "love.joystick")
programming_docs
love Fixture:getDensity Fixture:getDensity ================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the density of the fixture. Function -------- ### Synopsis ``` density = Fixture:getDensity( ) ``` ### Arguments None. ### Returns `[number](number "number") density` The fixture density in kilograms per square meter. See Also -------- * [Fixture](fixture "Fixture") * [Fixture:setDensity](fixture-setdensity "Fixture:setDensity") love love.graphics.setLineStipple love.graphics.setLineStipple ============================ **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in that and later versions. Sets the line stipple pattern. Function -------- ### Synopsis ``` love.graphics.setLineStipple( pattern, repeat ) ``` ### Arguments `[number](number "number") pattern` A 16-bit pattern. `[number](number "number") repeat (1)` Repeat factor. ### Returns Nothing. Additional Information ---------------------- A stipple pattern is made up of a 16bit sequence of 0s and 1s, Just like binary. The pattern is repeated to complete the line. Using the repeat will stretch the pattern and multiplies each 1 and 0. For example if three 1s are consecutively placed they are stretched to six if the repeat is 2. The maximum repeat is 255, and the minimum repeat is 1. A 1 is a a cue to draw a pixel whereas 0 is the opposite and does not draw a pixel, This is done per pixel for the given line. A pattern is read from back to front. 0x3F07 would equal to 0011111100000111 in binary. You can visualise the pattern by reading the binary sequence backwards. See Also -------- * [love.graphics](love.graphics "love.graphics") love Joystick:isDown Joystick:isDown =============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been moved from [love.joystick.isDown](love.joystick.isdown "love.joystick.isDown"). Checks if a button on the Joystick is pressed. LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0") had a bug which required the button indices passed to Joystick:isDown to be 0-based instead of 1-based, for example button 1 would be 0 for this function. It was fixed in [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1"). Function -------- ### Synopsis ``` anyDown = Joystick:isDown( buttonN, ... ) ``` ### Arguments `[number](number "number") buttonN` The index of a button to check. ### Returns `[boolean](boolean "boolean") anyDown` True if any supplied button is down, false if not. See Also -------- * [Joystick](joystick "Joystick") * [Joystick:getButtonCount](joystick-getbuttoncount "Joystick:getButtonCount") * [love.joystickpressed](love.joystickpressed "love.joystickpressed") * [love.joystickreleased](love.joystickreleased "love.joystickreleased") love Data:getFFIPointer Data:getFFIPointer ================== **Available since LÖVE [11.3](https://love2d.org/wiki/11.3 "11.3")** This function is not supported in earlier versions. Gets an [FFI](https://luajit.org/ext_ffi.html) pointer to the Data. This function should be preferred instead of [Data:getPointer](data-getpointer "Data:getPointer") because the latter uses [light userdata](light_userdata "light userdata") which can't store more all possible memory addresses on some new ARM64 architectures, when LuaJIT is used. Use at your own risk. Directly reading from and writing to the raw memory owned by the Data will bypass any safety checks and thread-safety the Data might normally have. Function -------- ### Synopsis ``` pointer = Data:getFFIPointer( ) ``` ### Arguments None. ### Returns `[cdata](cdata "cdata") pointer` A raw `void*` pointer to the Data, or `nil` if FFI is unavailable. See Also -------- * [Data](data "Data") * [Data:getPointer](data-getpointer "Data:getPointer") * [Data:getSize](data-getsize "Data:getSize") * [Data:getString](data-getstring "Data:getString") love love.physics.newFixture love.physics.newFixture ======================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Creates and attaches a [Fixture](fixture "Fixture") to a body. Note that the [Shape](shape "Shape") object is copied rather than kept as a reference when the Fixture is created. To get the Shape object that the Fixture owns, use [Fixture:getShape](fixture-getshape "Fixture:getShape"). Function -------- ### Synopsis ``` fixture = love.physics.newFixture( body, shape, density ) ``` ### Arguments `[Body](body "Body") body` The body which gets the fixture attached. `[Shape](shape "Shape") shape` The shape to be copied to the fixture. `[number](number "number") density (1)` The density of the fixture. ### Returns `[Fixture](fixture "Fixture") fixture` The new fixture. See Also -------- * [love.physics](love.physics "love.physics") * [Fixture](fixture "Fixture") love enet.peer:disconnect later enet.peer:disconnect later ========================== Request a disconnection from [peer](enet.peer "enet.peer"), but only after all queued outgoing packets are sent. Function -------- ### Synopsis ``` peer:disconnect_later(data) ``` ### Arguments `[number](number "number") data` Optional integer value to be associated with the disconnect. ### Returns Nothing. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.peer](enet.peer "enet.peer") love Body:setX Body:setX ========= Set the x position of the body. This function cannot wake up the body. Function -------- ### Synopsis ``` Body:setX( x ) ``` ### Arguments `[number](number "number") x` The x position. ### Returns Nothing. See Also -------- * [Body](body "Body") love Image Formats Image Formats ============= In addition to [compressed image formats](compressedimageformat "CompressedImageFormat"), the following formats are supported: | Format Name | Common Extension | Can Decode | [Can Encode](imagedata-encode "ImageData:encode") | Note(s) | | --- | --- | --- | --- | --- | | Joint Photographic Experts Group / JPEG | .jpg, .jpeg | Yes | | | | Portable Network Graphics / PNG | .png | Yes | Yes | | | Bitmap image file / BMP | .bmp | Yes | | | | Truevision TGA / TARGA | .tga | Yes | Yes | | | Radiance HDR / RGBE | .hdr, .pic | Yes | | | | OpenEXR | .exr | Yes | | | See Also -------- * [love.image](love.image "love.image") * [love.graphics](love.graphics "love.graphics") * [ImageEncodeFormat](imageencodeformat "ImageEncodeFormat") love Channel:clear Channel:clear ============= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Clears all the messages in the Channel queue. This function doesn't free up the memory used by a Channel, it needs to be garbage collected to release the memory. Function -------- ### Synopsis ``` Channel:clear( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Channel](channel "Channel") love BezierCurve:getDegree BezierCurve:getDegree ===================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Get degree of the Bézier curve. The degree is equal to number-of-control-points - 1. Function -------- ### Synopsis ``` degree = BezierCurve:getDegree( ) ``` ### Arguments None. ### Returns `[number](number "number") degree` Degree of the Bézier curve. See Also -------- * [BezierCurve](beziercurve "BezierCurve") * [BezierCurve:getControlPoint](beziercurve-getcontrolpoint "BezierCurve:getControlPoint") * [BezierCurve:setControlPoint](beziercurve-setcontrolpoint "BezierCurve:setControlPoint") * [BezierCurve:insertControlPoint](beziercurve-insertcontrolpoint "BezierCurve:insertControlPoint") * [love.math](love.math "love.math") love enet.host:service enet.host:service ================= Wait for [events](enet.event "enet.event"), send and receive any ready packets. If an [event](enet.event "enet.event") is in the queue it will be returned and dequeued. Generally you will want to dequeue all waiting [events](enet.event "enet.event") every frame. Function -------- ### Synopsis ``` event = host:service( timeout ) ``` ### Arguments `[number](number "number") timeout` The max number of milliseconds to be waited for an [event](enet.event "enet.event"). Default is 0. ### Returns `[table](table "table") event` An [event](enet.event "enet.event") or nil if no events occured. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.event](enet.event "enet.event") love love.graphics.getBackgroundColor love.graphics.getBackgroundColor ================================ Gets the current background color. In versions prior to [11.0](https://love2d.org/wiki/11.0 "11.0"), color component values were within the range of 0 to 255 instead of 0 to 1. Function -------- ### Synopsis ``` r, g, b, a = love.graphics.getBackgroundColor( ) ``` ### Arguments None. ### Returns `[number](number "number") r` The red component (0-1). `[number](number "number") g` The green component (0-1). `[number](number "number") b` The blue component (0-1). `[number](number "number") a` The alpha component (0-1). See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setBackgroundColor](love.graphics.setbackgroundcolor "love.graphics.setBackgroundColor") love love.mouse.isDown love.mouse.isDown ================= Checks whether a certain mouse button is down. This function does not detect mouse wheel scrolling; you must use the [love.wheelmoved](love.wheelmoved "love.wheelmoved") (or [love.mousepressed](love.mousepressed "love.mousepressed") in version [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2") and older) callback for that. Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. ### Synopsis ``` down = love.mouse.isDown( button, ... ) ``` ### Arguments `[number](number "number") button` The index of a button to check. 1 is the primary mouse button, 2 is the secondary mouse button and 3 is the middle button. Further buttons are mouse dependant. `[number](number "number") ...` Additional button numbers to check. ### Returns `[boolean](boolean "boolean") down` True if any specified button is down. Function -------- **Removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in that and later versions. ### Synopsis ``` down = love.mouse.isDown( button ) ``` ### Arguments `[MouseConstant](mouseconstant "MouseConstant") button` The button to check. ### Returns `[boolean](boolean "boolean") down` True if the specified button is down. Function -------- **Available since LÖVE [0.7.2](https://love2d.org/wiki/0.7.2 "0.7.2") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier or later versions. ### Synopsis ``` anyDown = love.mouse.isDown( button1, button2, button3, ... ) ``` ### Arguments `[MouseConstant](mouseconstant "MouseConstant") buttonN` A button to check. ### Returns `[boolean](boolean "boolean") anyDown` True if any specified button is down, false otherwise. Example ------- ### Increase a value while the right mouse button is held ``` val = 0 -- establish a variable for later use function love.update(dt) if love.mouse.isDown(2) then val = val + dt -- we will increase the variable by 1 for every second the button is held down end end ``` See Also -------- * [Mouse Constant / buttons](mouseconstant "MouseConstant") * [love.mouse](love.mouse "love.mouse") * [love.mousepressed](love.mousepressed "love.mousepressed") * [love.mousereleased](love.mousereleased "love.mousereleased") * [love.keyboard.isDown](love.keyboard.isdown "love.keyboard.isDown") love love.physics.newEdgeShape love.physics.newEdgeShape ========================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Creates a new [EdgeShape](edgeshape "EdgeShape"). Function -------- ### Synopsis ``` shape = love.physics.newEdgeShape( x1, y1, x2, y2 ) ``` ### Arguments `[number](number "number") x1` The x position of the first point. `[number](number "number") y1` The y position of the first point. `[number](number "number") x2` The x position of the second point. `[number](number "number") y2` The y position of the second point. ### Returns `[EdgeShape](edgeshape "EdgeShape") shape` The new shape. See Also -------- * [love.physics](love.physics "love.physics") * [EdgeShape](edgeshape "EdgeShape") * [Shape](shape "Shape") love Shape:getFilterData Shape:getFilterData =================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in that and later versions. Gets the filter data of the Shape. Function -------- ### Synopsis ``` categoryBits, maskBits, groupIndex = Shape:getFilterData( ) ``` ### Arguments None. ### Returns `[number](number "number") categoryBits` A 16-bit integer representing category membership. `[number](number "number") maskBits` A 16-bit integer representing masked categories. `[number](number "number") groupIndex` An integer representing the group index. See Also -------- * [Shape](shape "Shape") love love.filesystem.mkdir love.filesystem.mkdir ===================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [love.filesystem.createDirectory](love.filesystem.createdirectory "love.filesystem.createDirectory"). Recursively creates a directory. When called with "a/b" it creates both "a" and "a/b", if they don't exist already. Function -------- ### Synopsis ``` ok = love.filesystem.mkdir( name ) ``` ### Arguments `[string](string "string") name` The directory to create. ### Returns `[boolean](boolean "boolean") ok` True if the directory was created, false if not. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") love PulleyJoint:getGroundAnchors PulleyJoint:getGroundAnchors ============================ Get the ground anchor positions in world coordinates. Function -------- ### Synopsis ``` a1x, a1y, a2x, a2y = PulleyJoint:getGroundAnchors( ) ``` ### Arguments None. ### Returns `[number](number "number") a1x` The x coordinate of the first anchor. `[number](number "number") a1y` The y coordinate of the first anchor. `[number](number "number") a2x` The x coordinate of the second anchor. `[number](number "number") a2y` The y coordinate of the second anchor. See Also -------- * [PulleyJoint](pulleyjoint "PulleyJoint") love CircleShape:getPoint CircleShape:getPoint ==================== **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. Gets the center point of the circle shape. Function -------- ### Synopsis ``` x, y = CircleShape:getPoint( ) ``` ### Arguments None. ### Returns `[number](number "number") x` The x-component of the center point of the circle. `[number](number "number") y` The y-component of the center point of the circle. See Also -------- * [CircleShape](circleshape "CircleShape") * [CircleShape:setPoint](circleshape-setpoint "CircleShape:setPoint") love MotorJoint:setLinearOffset MotorJoint:setLinearOffset ========================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This method is not supported in earlier versions. Sets the target linear offset between the two Bodies the Joint is attached to. Function -------- ### Synopsis ``` MotorJoint:setLinearOffset( x, y ) ``` ### Arguments `[number](number "number") x` The x component of the target linear offset, relative to the first Body. `[number](number "number") y` The y component of the target linear offset, relative to the first Body. ### Returns Nothing. See Also -------- * [MotorJoint](motorjoint "MotorJoint") * [MotorJoint:getLinearOffset](motorjoint-getlinearoffset "MotorJoint:getLinearOffset") love Video:getFilter Video:getFilter =============== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets the scaling filters used when drawing the Video. Function -------- ### Synopsis ``` min, mag, anisotropy = Video:getFilter( ) ``` ### Arguments None. ### Returns `[FilterMode](filtermode "FilterMode") min` The filter mode used when scaling the Video down. `[FilterMode](filtermode "FilterMode") mag` The filter mode used when scaling the Video up. `[number](number "number") anisotropy (1)` Maximum amount of anisotropic filtering used. See Also -------- * [Video](video "Video") * [Video:setFilter](video-setfilter "Video:setFilter") * [FilterMode](filtermode "FilterMode") love love.joystick.getNumHats love.joystick.getNumHats ======================== **Available since LÖVE [0.5.0](https://love2d.org/wiki/0.5.0 "0.5.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been moved to [Joystick:getHatCount](joystick-gethatcount "Joystick:getHatCount"). Returns the number of hats on the joystick. Function -------- ### Synopsis ``` hats = love.joystick.getNumHats( joystick ) ``` ### Arguments `[number](number "number") joystick` The joystick to be checked ### Returns `[number](number "number") hats` How many hats the joystick has See Also -------- * [love.joystick](love.joystick "love.joystick") love love.mouse.getRelativeMode love.mouse.getRelativeMode ========================== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Gets whether relative mode is enabled for the mouse. If relative mode is enabled, the cursor is hidden and doesn't move when the mouse does, but relative mouse motion events are still generated via [love.mousemoved](love.mousemoved "love.mousemoved"). This lets the mouse move in any direction indefinitely without the cursor getting stuck at the edges of the screen. The reported position of the mouse is not updated while relative mode is enabled, even when relative mouse [motion events](love.mousemoved "love.mousemoved") are generated. Function -------- ### Synopsis ``` enabled = love.mouse.getRelativeMode( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") enabled` True if relative mode is enabled, false if it's disabled. See Also -------- * [love.mouse](love.mouse "love.mouse") * [love.mouse.setRelativeMode](love.mouse.setrelativemode "love.mouse.setRelativeMode") * [love.mousemoved](love.mousemoved "love.mousemoved") love love.joystick.getNumJoysticks love.joystick.getNumJoysticks ============================= **Available since LÖVE [0.5.0](https://love2d.org/wiki/0.5.0 "0.5.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [love.joystick.getJoystickCount](love.joystick.getjoystickcount "love.joystick.getJoystickCount"). Returns how many joysticks are available. Function -------- ### Synopsis ``` joysticks = love.joystick.getNumJoysticks( ) ``` ### Arguments None. ### Returns `[number](number "number") joysticks` The number of joysticks available See Also -------- * [love.joystick](love.joystick "love.joystick")
programming_docs
love love.filesystem.getSourceBaseDirectory love.filesystem.getSourceBaseDirectory ====================================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Returns the full path to the directory containing the .love file. If the game is [fused](love.filesystem.isfused "love.filesystem.isFused") to the LÖVE executable, then the directory containing the executable is returned. If [love.filesystem.isFused](love.filesystem.isfused "love.filesystem.isFused") is true, the path returned by this function can be passed to [love.filesystem.mount](love.filesystem.mount "love.filesystem.mount"), which will make the directory containing the main game (e.g. `C:\Program Files\coolgame\`) readable by love.filesystem. Function -------- ### Synopsis ``` path = love.filesystem.getSourceBaseDirectory( ) ``` ### Arguments None. ### Returns `[string](string "string") path` The full platform-dependent path of the directory containing the .love file. Examples -------- ### read files in the same folder as the game's .exe file ``` if love.filesystem.isFused() then local dir = love.filesystem.getSourceBaseDirectory() local success = love.filesystem.mount(dir, "coolgame")   if success then -- If the game is fused and it's located in C:\Program Files\mycoolgame\, -- then we can now load files from that path. coolimage = love.graphics.newImage("coolgame/coolimage.png") end end   function love.draw() if coolimage then love.graphics.draw(coolimage, 0, 0) end end ``` See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [love.filesystem.mount](love.filesystem.mount "love.filesystem.mount") * [love.filesystem.isFused](love.filesystem.isfused "love.filesystem.isFused") * [love.filesystem.getSource](love.filesystem.getsource "love.filesystem.getSource") love love.window.requestAttention love.window.requestAttention ============================ **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Causes the window to request the attention of the user if it is not in the foreground. In Windows the taskbar icon will flash, and in OS X the dock icon will bounce. Function -------- ### Synopsis ``` love.window.requestAttention( continuous ) ``` ### Arguments `[boolean](boolean "boolean") continuous (false)` Whether to continuously request attention until the window becomes active, or to do it only once. ### Returns Nothing. See Also -------- * [love.window](love.window "love.window") love love.graphics.setLine love.graphics.setLine ===================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** Use [love.graphics.setLineWidth](love.graphics.setlinewidth "love.graphics.setLineWidth") and [love.graphics.setLineStyle](love.graphics.setlinestyle "love.graphics.setLineStyle"). Sets the line width and style. Function -------- ### Synopsis ``` love.graphics.setLine( width, style ) ``` ### Arguments `[number](number "number") width` The width of the line. `[LineStyle](linestyle "LineStyle") style ("smooth")` The LineStyle to use. ### Returns Nothing. Example ------- ``` love.graphics.setLine(2, "smooth") love.graphics.line(15, 25, 69, 89) ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setLineWidth](love.graphics.setlinewidth "love.graphics.setLineWidth") * [love.graphics.setLineStyle](love.graphics.setlinestyle "love.graphics.setLineStyle") love love.timer.getTime love.timer.getTime ================== **Available since LÖVE [0.3.2](https://love2d.org/wiki/0.3.2 "0.3.2")** This function is not supported in earlier versions. Returns the value of a timer with an unspecified starting time. This function should only be used to calculate differences between points in time, as the starting time of the timer is unknown. Function -------- ### Synopsis ``` time = love.timer.getTime( ) ``` ### Arguments None. ### Returns `[number](number "number") time` The time in seconds. Given as a decimal, accurate to the microsecond. Examples -------- ### Checking how long something takes ``` local start = love.timer.getTime()   -- Concatenate "bar" 1000 times. local foo = "" for _ = 1, 1000 do foo = foo .. "bar" end   -- Resulting time difference in seconds. Multiplying it by 1000 gives us the value in milliseconds. local result = love.timer.getTime() - start print( string.format( "It took %.3f milliseconds to concatenate 'bar' 1000 times!", result * 1000 )) ``` See Also -------- * [love.timer](love.timer "love.timer") love WheelJoint:getMaxMotorTorque WheelJoint:getMaxMotorTorque ============================ **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the maximum motor torque. Function -------- ### Synopsis ``` maxTorque = WheelJoint:getMaxMotorTorque( ) ``` ### Arguments None. ### Returns `[number](number "number") maxTorque` The maximum torque of the joint motor in newton meters. See Also -------- * [WheelJoint](wheeljoint "WheelJoint") * [WheelJoint:setMaxMotorTorque](wheeljoint-setmaxmotortorque "WheelJoint:setMaxMotorTorque") love Shape:setFilterData Shape:setFilterData =================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in that and later versions. Sets the filter data for a Shape. Info stolen from box2d.org: *Collision filtering is a system for preventing collision between shapes. For example, say you make a character that rides a bicycle. You want the bicycle to collide with the terrain and the character to collide with the terrain, but you don't want the character to collide with the bicycle (because they must overlap). Box2D supports such collision filtering using categories and groups.* Read more about this in the [Box2D documentation](http://box2d.org/manual.html#d0e845). Function -------- ### Synopsis ``` Shape:setFilterData( categoryBits, maskBits, groupIndex ) ``` ### Arguments `[number](number "number") categoryBits` A 16-bit integer representing category membership. `[number](number "number") maskBits` A 16-bit integer representing masked categories. `[number](number "number") groupIndex` An integer representing the group index. ### Returns Nothing. See Also -------- * [Shape](shape "Shape") love FilterMode FilterMode ========== How the image is filtered when scaling. Constants --------- linear Scale image with linear interpolation. nearest Scale image with nearest neighbor interpolation. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setDefaultFilter](love.graphics.setdefaultfilter "love.graphics.setDefaultFilter") * [Texture:getFilter](texture-getfilter "Texture:getFilter") * [Texture:setFilter](texture-setfilter "Texture:setFilter") love ParticleSystem:moveTo ParticleSystem:moveTo ===================== **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. Moves the position of the emitter. This results in smoother particle spawning behaviour than if [ParticleSystem:setPosition](particlesystem-setposition "ParticleSystem:setPosition") is used every frame. Function -------- ### Synopsis ``` ParticleSystem:moveTo( x, y ) ``` ### Arguments `[number](number "number") x` Position along x-axis. `[number](number "number") y` Position along y-axis. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love Font:getWidth Font:getWidth ============= Determines the maximum width (accounting for newlines) taken by the given string. Function -------- ### Synopsis ``` width = Font:getWidth( text ) ``` ### Arguments `[string](string "string") text` A string. ### Returns `[number](number "number") width` The width of the text. See Also -------- * [Font](font "Font") love PowerState PowerState ========== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This enum is not supported in earlier versions. The basic state of the system's power supply. Constants --------- unknown Cannot determine power status. battery Not plugged in, running on a battery. nobattery Plugged in, no battery available. charging Plugged in, charging battery. charged Plugged in, battery is fully charged. See Also -------- * [love.system](love.system "love.system") * [love.system.getPowerInfo](love.system.getpowerinfo "love.system.getPowerInfo") love (File):lines (File):lines ============ Iterate over all the lines in a [file](file "File"). Function -------- ### Synopsis ``` iterator = File:lines( ) ``` ### Arguments None. ### Returns `[function](function "function") iterator` The iterator (can be used in for loops). See Also -------- * [File](file "File") love enet.peer:ping enet.peer:ping ============== Send a ping request to [peer](enet.peer "enet.peer"), updates [round\_trip\_time](enet.peer-round_trip_time "enet.peer:round trip time"). This is called automatically at regular intervals. Function -------- ### Synopsis ``` peer:ping() ``` ### Arguments None. ### Returns Nothing. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.peer](enet.peer "enet.peer") * [enet.peer:round\_trip\_time](enet.peer-round_trip_time "enet.peer:round trip time") love LineStyle LineStyle ========= The styles in which lines are drawn. Constants --------- rough Draw rough lines. smooth Draw smooth lines. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setLineStyle](love.graphics.setlinestyle "love.graphics.setLineStyle") * [love.graphics.setLineStipple](love.graphics.setlinestipple "love.graphics.setLineStipple") love IndexDataType IndexDataType ============= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This enum is not supported in earlier versions. Vertex map datatype for [Data](data "Data") variant of [Mesh:setVertexMap](mesh-setvertexmap "Mesh:setVertexMap"). Constants --------- uint16 The vertex map is array of unsigned word (16-bit). uint32 The vertex map is array of unsigned dword (32-bit). See Also -------- * [love.graphics](love.graphics "love.graphics") * [Mesh:setVertexMap](mesh-setvertexmap "Mesh:setVertexMap") * [Mesh](mesh "Mesh") love BufferMode BufferMode ========== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This enum is not supported in earlier versions. Buffer modes for [File](file "File") objects. Constants --------- none No buffering. The result of write and append operations appears immediately. line Line buffering. Write and append operations are buffered until a newline is output or the buffer size limit is reached. full Full buffering. Write and append operations are always buffered until the buffer size limit is reached. See Also -------- * [File](file "File") * [File:setBuffer]((file)-setbuffer "(File):setBuffer") * [File:getBuffer]((file)-getbuffer "(File):getBuffer") love love.filesystem.getLastModified love.filesystem.getLastModified =============================== | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | This function is deprecated and is replaced by [love.filesystem.getInfo](love.filesystem.getinfo "love.filesystem.getInfo"). | Gets the last modification time of a file. Function -------- ### Synopsis ``` modtime, errormsg = love.filesystem.getLastModified( filename ) ``` ### Arguments `[string](string "string") filename` The path and name to a file. ### Returns `[number](number "number") modtime` The last modification time in seconds since the unix epoch or nil on failure. `[string](string "string") errormsg` The error message on failure. Examples -------- ### Getting the time of a file and printing it as a date. ``` modtime, errormsg = love.filesystem.getLastModified("file.dat")   if modtime then print(os.date("%c", modtime)) -- "02/15/2011 12:32:11" (Depends on the system and locale) end ``` See Also -------- * [love.filesystem](love.filesystem "love.filesystem") love Video:rewind Video:rewind ============ **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Rewinds the Video to the beginning. Function -------- ### Synopsis ``` Video:rewind( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Video](video "Video") * [Video:play](video-play "Video:play") * [Video:seek](video-seek "Video:seek") * [Video:tell](video-tell "Video:tell") love love.graphics.drawq love.graphics.drawq =================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been merged into [love.graphics.draw](love.graphics.draw "love.graphics.draw"). Draw a Quad with the specified Image on screen. Function -------- ### Synopsis ``` love.graphics.drawq( image, quad, x, y, r, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[Image](image "Image") image` An image to texture the quad with. `[Quad](quad "Quad") quad` The quad to draw on screen. `[number](number "number") x` The position to draw the object (x-axis). `[number](number "number") y` The position to draw the object (y-axis). `[number](number "number") r (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Available since 0.8.0 Shearing factor (x-axis). `[number](number "number") ky (0)` Available since 0.8.0 Shearing factor (y-axis). ### Returns Nothing. Function -------- ### Synopsis ``` love.graphics.drawq( canvas, quad, x, y, r, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[Canvas](canvas "Canvas") canvas` A canvas to texture the quad with. `[Quad](quad "Quad") quad` The quad to draw on screen. `[number](number "number") x` The position to draw the object (x-axis). `[number](number "number") y` The position to draw the object (y-axis). `[number](number "number") r (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Available since 0.8.0 Shearing factor (x-axis). `[number](number "number") ky (0)` Available since 0.8.0 Shearing factor (y-axis). ### Returns Nothing. Examples -------- ### Draw the top half of an image (the [Hamster Ball](https://love2d.org/wiki/File:Resource-HamsterBall.png "File:Resource-HamsterBall.png")) at 100 by 100 pixels. ``` image = love.graphics.newImage("hamster.png") quad = love.graphics.newQuad(0, 0, 128, 64, image:getWidth(), image:getHeight())   function love.draw() love.graphics.drawq(image, quad, 100, 100) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.draw](love.graphics.draw "love.graphics.draw") love Joystick:getAxis Joystick:getAxis ================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been moved from [love.joystick.getAxis](love.joystick.getaxis "love.joystick.getAxis"). Gets the direction of an axis. Function -------- ### Synopsis ``` direction = Joystick:getAxis( axis ) ``` ### Arguments `[number](number "number") axis` The index of the axis to be checked. ### Returns `[number](number "number") direction` Current value of the axis. See Also -------- * [Joystick](joystick "Joystick") * [Joystick:getAxes](joystick-getaxes "Joystick:getAxes") * [Joystick:getAxisCount](joystick-getaxiscount "Joystick:getAxisCount") love love.mouse.setRelativeMode love.mouse.setRelativeMode ========================== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Sets whether relative mode is enabled for the mouse. When relative mode is enabled, the cursor is hidden and doesn't move when the mouse does, but relative mouse motion events are still generated via [love.mousemoved](love.mousemoved "love.mousemoved"). This lets the mouse move in any direction indefinitely without the cursor getting stuck at the edges of the screen. The reported position of the mouse may not be updated while relative mode is enabled, even when relative mouse [motion events](love.mousemoved "love.mousemoved") are generated. Function -------- ### Synopsis ``` love.mouse.setRelativeMode( enable ) ``` ### Arguments `[boolean](boolean "boolean") enable` True to enable relative mode, false to disable it. ### Returns Nothing. See Also -------- * [love.mouse](love.mouse "love.mouse") * [love.mouse.getRelativeMode](love.mouse.getrelativemode "love.mouse.getRelativeMode") * [love.mousemoved](love.mousemoved "love.mousemoved") love Data:getPointer Data:getPointer =============== Gets a pointer to the Data. Can be used with libraries such as LuaJIT's [FFI](https://luajit.org/ext_ffi.html). Use at your own risk. Directly reading from and writing to the raw memory owned by the Data will bypass any safety checks and thread-safety the Data might normally have. Since LÖVE [11.3](https://love2d.org/wiki/11.3 "11.3"), [Data:getFFIPointer](data-getffipointer "Data:getFFIPointer") is a preferred alternative because it can work with new 64-bit architectures. Function -------- ### Synopsis ``` pointer = Data:getPointer( ) ``` ### Arguments None. ### Returns `[light userdata](light_userdata "light userdata") pointer` A raw pointer to the Data. See Also -------- * [Data](data "Data") * [Data:getSize](data-getsize "Data:getSize") * [Data:getString](data-getstring "Data:getString") * [Data:getFFIPointer](data-getffipointer "Data:getFFIPointer") love ArcType ArcType ======= **Available since LÖVE [0.10.1](https://love2d.org/wiki/0.10.1 "0.10.1")** This enum is not supported in earlier versions. Different types of [arcs](love.graphics.arc "love.graphics.arc") that can be drawn. Constants --------- pie The arc is drawn like a slice of pie, with the arc circle connected to the center at its end-points. open The arc circle's two end-points are unconnected when the arc is drawn as a line. Behaves like the "closed" arc type when the arc is drawn in filled mode. closed The arc circle's two end-points are connected to each other. Notes ----- See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.arc](love.graphics.arc "love.graphics.arc") love Fixture:getMassData Fixture:getMassData =================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the mass, its center and the rotational inertia. Function -------- ### Synopsis ``` x, y, mass, inertia = Fixture:getMassData( ) ``` ### Arguments None. ### Returns `[number](number "number") x` The x position of the center of mass. `[number](number "number") y` The y position of the center of mass. `[number](number "number") mass` The mass of the fixture. `[number](number "number") inertia` The rotational inertia. See Also -------- * [Fixture](fixture "Fixture")
programming_docs
love File File ==== Represents a file on the filesystem. A function that takes a file path can also take a File. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.filesystem.newFile](love.filesystem.newfile "love.filesystem.newFile") | Creates a new **File** object. | | | Functions --------- These functions have parentheses in odd places. This is because the *File:* namespace is reserved in Mediawiki. | | | | | | --- | --- | --- | --- | | [(File):close]((file)-close "(File):close") | Closes a **File**. | | | | [(File):eof]((file)-eof "(File):eof") | If the end-of-file has been reached | | 0.10.0 | | [(File):flush]((file)-flush "(File):flush") | Flushes any buffered written data in the file to disk. | 0.9.0 | | | [(File):getBuffer]((file)-getbuffer "(File):getBuffer") | Gets the buffer mode of a file. | 0.9.0 | | | [(File):getFilename]((file)-getfilename "(File):getFilename") | Gets the filename that the File object was created with. | 0.10.0 | | | [(File):getMode]((file)-getmode "(File):getMode") | Gets the [FileMode](filemode "FileMode") the file has been opened with. | 0.9.0 | | | [(File):getSize]((file)-getsize "(File):getSize") | Returns the **file** size. | | | | [(File):isEOF]((file)-iseof "(File):isEOF") | Gets whether end-of-file has been reached. | 0.10.0 | | | [(File):isOpen]((file)-isopen "(File):isOpen") | Gets whether the file is open. | 0.9.0 | | | [(File):lines]((file)-lines "(File):lines") | Iterate over all the lines in a file. | | | | [(File):open]((file)-open "(File):open") | Open the file for write, read or append. | | | | [(File):read]((file)-read "(File):read") | Read a number of bytes from a file | | | | [(File):seek]((file)-seek "(File):seek") | Seek to a position in a file | | | | [(File):setBuffer]((file)-setbuffer "(File):setBuffer") | Sets the buffer mode for a file opened for writing or appending. | 0.9.0 | | | [(File):tell]((file)-tell "(File):tell") | Returns the position in the file. | | | | [(File):write]((file)-write "(File):write") | Write data to a file. | | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Enums ----- | | | | | | --- | --- | --- | --- | | [BufferMode](buffermode "BufferMode") | Buffer modes for **File** objects. | 0.9.0 | | | [FileMode](filemode "FileMode") | The different modes you can open a **File** in. | | | Supertypes ---------- * [Object](object "Object") See Also -------- * [love.filesystem](love.filesystem "love.filesystem") love Source:clone Source:clone ============ **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. Creates an identical copy of the Source in the stopped state. Static Sources will use significantly less memory and take much less time to be created if **Source:clone** is used to create them instead of [love.audio.newSource](love.audio.newsource "love.audio.newSource"), so this method should be preferred when making multiple Sources which play the same sound. Function -------- ### Synopsis ``` source = Source:clone( ) ``` ### Arguments None. ### Returns `[Source](source "Source") source` The new identical copy of this Source. Notes ----- Cloned Sources inherit all the set-able state of the original Source, but they are initialized stopped. See Also -------- * [Source](source "Source") love ParticleSystem:setAreaSpread ParticleSystem:setAreaSpread ============================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | This function has been renamed to [ParticleSystem:setEmissionArea](particlesystem-setemissionarea "ParticleSystem:setEmissionArea"). | Sets area-based spawn parameters for the particles. Newly created particles will spawn in an area around the emitter based on the parameters to this function. Function -------- ### Synopsis ``` ParticleSystem:setAreaSpread( distribution, dx, dy ) ``` ### Arguments `[AreaSpreadDistribution](areaspreaddistribution "AreaSpreadDistribution") distribution` The type of distribution for new particles. `[number](number "number") dx` The maximum spawn distance from the emitter along the x-axis for uniform distribution, or the standard deviation along the x-axis for normal distribution. `[number](number "number") dy` The maximum spawn distance from the emitter along the y-axis for uniform distribution, or the standard deviation along the y-axis for normal distribution. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:getAreaSpread](particlesystem-getareaspread "ParticleSystem:getAreaSpread") love love.directorydropped love.directorydropped ===================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Callback function triggered when a directory is dragged and dropped onto the window. Function -------- ### Synopsis ``` love.directorydropped( path ) ``` ### Arguments `[string](string "string") path` The full platform-dependent path to the directory. It can be used as an argument to [love.filesystem.mount](love.filesystem.mount "love.filesystem.mount"), in order to gain read access to the directory with love.filesystem. ### Returns Nothing. Notes ----- Paths passed into this callback are able to be used with [love.filesystem.mount](love.filesystem.mount "love.filesystem.mount"), which is the only way to get read access via love.filesystem to the dropped directory. love.filesystem.mount does not generally accept other full platform-dependent directory paths that haven't been dragged and dropped onto the window. See Also -------- * [love](love "love") * [love.filedropped](love.filedropped "love.filedropped") love Canvas:getImageData Canvas:getImageData =================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** It has been renamed to [Canvas:newImageData](canvas-newimagedata "Canvas:newImageData"). Generates [ImageData](imagedata "ImageData") from the contents of the Canvas. Think of it as taking a screenshot of the hidden screen that is the Canvas. Function -------- ### Synopsis ``` data = Canvas:getImageData( ) ``` ### Arguments None. ### Returns `[ImageData](imagedata "ImageData") data` The new ImageData made from the Canvas' image. See Also -------- * [Canvas](canvas "Canvas") * [love.graphics.newScreenshot](love.graphics.newscreenshot "love.graphics.newScreenshot") love love.graphics.getStencilTest love.graphics.getStencilTest ============================ **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. 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](love.graphics.stencil "love.graphics.stencil"). Each [Canvas](canvas "Canvas") has its own per-pixel stencil values. Function -------- ### Synopsis ``` comparemode, comparevalue = love.graphics.getStencilTest( ) ``` ### Arguments None. ### Returns `[CompareMode](comparemode "CompareMode") comparemode` The type of comparison that is made for each pixel. Will be "always" if stencil testing is disabled. `[number](number "number") comparevalue` The value used when comparing with the stencil value of each pixel. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setStencilTest](love.graphics.setstenciltest "love.graphics.setStencilTest") * [love.graphics.stencil](love.graphics.stencil "love.graphics.stencil") love VideoStream:getFilename VideoStream:getFilename ======================= **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets filename of video stream. Function -------- ### Synopsis ``` filename = VideoStream:getFilename( ) ``` ### Arguments None. ### Returns `[string](string "string") filename` The filename of video stream See Also -------- * [VideoStream](videostream "VideoStream") love Transform:shear Transform:shear =============== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Applies a [shear factor](https://en.wikipedia.org/wiki/Shear_mapping) (skew) to the Transform's coordinate system. This method does not reset any previously applied transformations. Function -------- ### Synopsis ``` transform = Transform:shear( kx, ky ) ``` ### Arguments `[number](number "number") kx` The shear factor along the x-axis. `[number](number "number") ky` The shear factor along the y-axis. ### Returns `[Transform](transform "Transform") transform` The Transform object the method was called on. Allows easily chaining Transform methods. See Also -------- * [Transform](transform "Transform") * [Transform:reset](transform-reset "Transform:reset") * [Transform:translate](transform-translate "Transform:translate") * [Transform:rotate](transform-rotate "Transform:rotate") * [Transform:scale](transform-scale "Transform:scale") * [Transform:setTransformation](transform-settransformation "Transform:setTransformation") love love.graphics.setFrontFaceWinding love.graphics.setFrontFaceWinding ================================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Sets whether triangles with clockwise- or counterclockwise-ordered vertices are considered front-facing. This is designed for use in combination with [Mesh face culling](love.graphics.setmeshcullmode "love.graphics.setMeshCullMode"). Other love.graphics shapes, lines, and sprites are not guaranteed to have a specific winding order to their internal vertices. Function -------- ### Synopsis ``` love.graphics.setFrontFaceWinding( winding ) ``` ### Arguments `[VertexWinding](vertexwinding "VertexWinding") winding` The winding mode to use. The default winding is counterclockwise ("ccw"). ### Returns Nothing. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getFrontFaceWinding](love.graphics.getfrontfacewinding "love.graphics.getFrontFaceWinding") * [love.graphics.setMeshCullMode](love.graphics.setmeshcullmode "love.graphics.setMeshCullMode") * [Mesh](mesh "Mesh") love MotorJoint:getLinearOffset MotorJoint:getLinearOffset ========================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This method is not supported in earlier versions. Gets the target linear offset between the two Bodies the Joint is attached to. Function -------- ### Synopsis ``` x, y = MotorJoint:getLinearOffset( ) ``` ### Arguments None. ### Returns `[number](number "number") x` The x component of the target linear offset, relative to the first Body. `[number](number "number") y` The y component of the target linear offset, relative to the first Body. See Also -------- * [MotorJoint](motorjoint "MotorJoint") * [MotorJoint:setLinearOffset](motorjoint-setlinearoffset "MotorJoint:setLinearOffset") love love.joystick.getHat love.joystick.getHat ==================== **Available since LÖVE [0.5.0](https://love2d.org/wiki/0.5.0 "0.5.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been moved to [Joystick:getHat](joystick-gethat "Joystick:getHat"). Returns the direction of a hat. Function -------- ### Synopsis ``` direction = love.joystick.getHat( joystick, hat ) ``` ### Arguments `[number](number "number") joystick` The joystick to be checked `[number](number "number") hat` The hat to be checked ### Returns `[JoystickConstant](joystickconstant "JoystickConstant") direction` The direction the hat is pushed See Also -------- * [love.joystick](love.joystick "love.joystick") love Thread:wait Thread:wait =========== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Wait for a thread to finish. This call will block until the thread finishes. Function -------- ### Synopsis ``` Thread:wait( ) ``` ### Arguments None. ### Returns None. See Also -------- * [Thread](thread "Thread") love love.window.setDisplaySleepEnabled love.window.setDisplaySleepEnabled ================================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Sets whether the display is allowed to sleep while the program is running. Display sleep is disabled by default. Some types of input (e.g. joystick button presses) might not prevent the display from sleeping, if display sleep is allowed. Function -------- ### Synopsis ``` love.window.setDisplaySleepEnabled( enable ) ``` ### Arguments `[boolean](boolean "boolean") enable` True to enable system display sleep, false to disable it. ### Returns Nothing. See Also -------- * [love.window](love.window "love.window") * [love.window.isDisplaySleepEnabled](love.window.isdisplaysleepenabled "love.window.isDisplaySleepEnabled") love Object:typeOf Object:typeOf ============= Checks whether an object is of a certain type. If the object has the type with the specified name in its hierarchy, this function will return true. Function -------- ### Synopsis ``` b = Object:typeOf( name ) ``` ### Arguments `[string](string "string") name` The name of the type to check for. ### Returns `[boolean](boolean "boolean") b` True if the object is of the specified type, false otherwise. Examples -------- ### Checking the type of an object ``` image = love.graphics.newImage("test.png") print(image:typeOf("Object")) -- outputs: true print(image:typeOf("Drawable")) -- outputs: true print(image:typeOf("Image")) -- outputs: true print(image:typeOf("MouseJoint")) -- outputs: false ``` See Also -------- * [Object](object "Object") love love.filesystem.remove love.filesystem.remove ====================== Removes a file or empty directory. Function -------- ### Synopsis ``` success = love.filesystem.remove( name ) ``` ### Arguments `[string](string "string") name` The file or directory to remove. ### Returns `[boolean](boolean "boolean") success` True if the file/directory was removed, false otherwise. Notes ----- The directory must be empty before removal or else it will fail. Simply remove all files and folders in the directory beforehand. If the file exists in the .love but not in the save directory, it returns `false` as well. An opened [File](file "File") prevents removal of the underlying file. Simply close the [File](file "File") to remove it. Examples -------- Create a bunch of folders in the save folder and remove them and any file they may contain as soon as the game is quit. ``` function love.load() local dir = 'a' for _ = 1, 10 do dir = dir .. '/a' end love.filesystem.createDirectory( dir ) end   function love.quit() local function recursivelyDelete( item ) if love.filesystem.getInfo( item , "directory" ) then for _, child in pairs( love.filesystem.getDirectoryItems( item )) do recursivelyDelete( item .. '/' .. child ) love.filesystem.remove( item .. '/' .. child ) end elseif love.filesystem.getInfo( item ) then love.filesystem.remove( item ) end love.filesystem.remove( item ) end recursivelyDelete( 'a' ) end ``` See Also -------- * [love.filesystem](love.filesystem "love.filesystem") love Video:getSource Video:getSource =============== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets the audio [Source](source "Source") used for playing back the video's audio. May return nil if the video has no audio, or if [Video:setSource](video-setsource "Video:setSource") is called with a nil argument. Function -------- ### Synopsis ``` source = Video:getSource( ) ``` ### Arguments None. ### Returns `[Source](source "Source") source` The audio Source used for audio playback, or nil if the video has no audio. See Also -------- * [Video](video "Video") * [Video:setSource](video-setsource "Video:setSource") * [Source](source "Source") love love.physics.setMeter love.physics.setMeter ===================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Sets the pixels to meter scale factor. All coordinates in the physics module are divided by this number and converted to meters, and it creates a convenient way to draw the objects directly to the screen without the need for graphics transformations. It is recommended to create shapes no larger than 10 times the scale. This is important because Box2D is tuned to work well with shape sizes from 0.1 to 10 meters. The default meter scale is 30. love.physics.setMeter does not apply retroactively to created objects. Created objects retain their meter coordinates but the scale factor will affect their pixel coordinates. It is recommended to call this function before any further use of the [love.physics](love.physics "love.physics") module Function -------- ### Synopsis ``` love.physics.setMeter( scale ) ``` ### Arguments `[number](number "number") scale` The scale factor as an integer. ### Returns Nothing. Examples -------- ### Note that the body's coordinates in meters remain unchanged ``` love.physics.setMeter(30) -- set 30 pixels/meter body = love.physics.newBody(world, 300, 300, "dynamic") -- place the body at pixel coordinates (300,300) or in meter coordinates (10,10) love.physics.setMeter(10) -- set 10 pixels/meter body:getPosition() -- returns pixel coordinates (100,100) ``` See Also -------- * [love.physics](love.physics "love.physics") * [love.physics.getMeter](love.physics.getmeter "love.physics.getMeter") love Joystick:getHat Joystick:getHat =============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been moved from [love.joystick.getHat](love.joystick.gethat "love.joystick.getHat"). Gets the direction of the Joystick's [hat](https://en.wikipedia.org/wiki/Joystick#Hat_switch). Function -------- ### Synopsis ``` direction = Joystick:getHat( hat ) ``` ### Arguments `[number](number "number") hat` The index of the hat to be checked. ### Returns `[JoystickHat](joystickhat "JoystickHat") direction` The direction the hat is pushed. See Also -------- * [Joystick](joystick "Joystick") * [Joystick:getHatCount](joystick-gethatcount "Joystick:getHatCount") love EdgeShape:getPoints EdgeShape:getPoints =================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the local coordinates of the edge points. Function -------- ### Synopsis ``` x1, y1, x2, y2 = EdgeShape:getPoints( ) ``` ### Arguments None. ### Returns `[number](number "number") x1` The x-component of the first vertex. `[number](number "number") y1` The y-component of the first vertex. `[number](number "number") x2` The x-component of the second vertex. `[number](number "number") y2` The y-component of the second vertex. See Also -------- * [EdgeShape](edgeshape "EdgeShape")
programming_docs
love Mesh:flush Mesh:flush ========== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Immediately sends all modified vertex data in the Mesh to the graphics card. Normally it isn't necessary to call this method as [love.graphics.draw](love.graphics.draw "love.graphics.draw")(mesh, ...) will do it automatically if needed, but explicitly using **Mesh:flush** gives more control over when the work happens. If this method is used, it generally shouldn't be called more than once (at most) between love.graphics.draw(mesh, ...) calls. Function -------- ### Synopsis ``` Mesh:flush( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Mesh](mesh "Mesh") love Shape:setData Shape:setData ============= **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** Use [Fixture:setUserData](fixture-setuserdata "Fixture:setUserData") instead. Set data to be passed to the collision callback. When a shape collides, the value set here will be passed to the collision callback as one of the parameters. Typically, you would want to store a table reference here, but any value can be used. Function -------- ### Synopsis ``` Shape:setData( v ) ``` ### Arguments `[any](https://love2d.org/w/index.php?title=any&action=edit&redlink=1 "any (page does not exist)") v` Any Lua value. ### Returns Nothing. See Also -------- * [Shape](shape "Shape") * [Shape:getData](shape-getdata "Shape:getData") love Body:setMassFromShapes Body:setMassFromShapes ====================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in that and later versions. Sets mass properties from attatched shapes. If you feel that finding the correct mass properties is tricky, then this function may be able to help you. After creating the needed shapes on the Body, a call to this function will set the mass properties based on those shapes. Remember to call this function after adding the shapes. Setting the mass properties this way always results in a realistic (or at least good-looking) simulation, so using it is highly recommended. Function -------- ### Synopsis ``` Body:setMassFromShapes( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Body](body "Body") love DrawMode DrawMode ======== Controls whether shapes are drawn as an outline, or filled. Constants --------- fill Draw filled shape. line Draw outlined shape. See Also -------- * [love.graphics](love.graphics "love.graphics") love love.filesystem love.filesystem =============== Provides an interface to the user's filesystem. This module provides access to files in specific places: * The root folder of the .love archive (or source directory) * The root folder of the game's *save directory*. * The folder *containing* the game's .love archive (or source directory), but only if [specific conditions](love.filesystem.getsourcebasedirectory "love.filesystem.getSourceBaseDirectory") are met. Each game is granted a single directory on the system where files can be saved through love.filesystem. This is the **only directory** where love.filesystem can write files. These directories will typically be found in something like: | OS | Path | Alternative | Notes | | --- | --- | --- | --- | | Windows XP | `C:\Documents and Settings\user\Application Data\LOVE\` | `%appdata%\LOVE\` | When fused, save directory will be created directly inside `Application Data`, rather than as a sub-directory of `LOVE`. | | Windows Vista, 7, 8 and 10 | `C:\Users\user\AppData\Roaming\LOVE` | `%appdata%\LOVE\` | When fused, save directory will be created directly inside `AppData`, rather than as a sub-directory of `LOVE`. | | Mac | `/Users/user/Library/Application Support/LOVE/` | - | - | | Linux | `$XDG_DATA_HOME/love/` | `~/.local/share/love/` | - | | Android | `/data/user/0/org.love2d.android/files/save/` | `/data/data/org.love2d.android/files/save/` | On Android there are various save locations. If these don't work then you can use `love.filesystem.getSaveDirectory()` to check. | Files that are opened for write or append will always be created in the save directory. The same goes for other operations that involve writing to the filesystem, like createDirectory. Files that are opened for read will be looked for in the save directory, and then in the .love archive (in that order). So if a file with a certain filename (and path) exist in both the .love archive and the save folder, the one in the save directory takes precedence. Note: **All** paths are relative to the .love archive and save directory. (except for the get\*Directory() calls) It is recommended to set your game's identity first in your [conf.lua](love.conf "Config Files"). You can set it with [love.filesystem.setIdentity](love.filesystem.setidentity "love.filesystem.setIdentity") as well. Types ----- | | | | | | --- | --- | --- | --- | | [DroppedFile](droppedfile "DroppedFile") | Represents a file dropped from the window. | 0.10.0 | | | [File](file "File") | Represents a file on the filesystem. | | | | [FileData](filedata "FileData") | [Data](data "Data") representing the contents of a file. | | | Functions --------- | | | | | | --- | --- | --- | --- | | [love.filesystem.append](love.filesystem.append "love.filesystem.append") | Append data to an existing file. | 0.9.0 | | | [love.filesystem.areSymlinksEnabled](love.filesystem.aresymlinksenabled "love.filesystem.areSymlinksEnabled") | Gets whether love.filesystem follows symbolic links. | 0.9.2 | | | [love.filesystem.createDirectory](love.filesystem.createdirectory "love.filesystem.createDirectory") | Creates a directory. | 0.9.0 | | | [love.filesystem.enumerate](love.filesystem.enumerate "love.filesystem.enumerate") | Returns all the files and subdirectories in the directory. | 0.3.0 | 0.9.0 | | [love.filesystem.exists](love.filesystem.exists "love.filesystem.exists") | Check whether a file or directory exists. | | 11.0 | | [love.filesystem.getAppdataDirectory](love.filesystem.getappdatadirectory "love.filesystem.getAppdataDirectory") | Returns the application data directory (could be the same as getUserDirectory) | | | | [love.filesystem.getCRequirePath](love.filesystem.getcrequirepath "love.filesystem.getCRequirePath") | Gets the filesystem paths that will be searched for c libraries when [require](https://www.lua.org/manual/5.1/manual.html#pdf-require) is called. | 11.0 | | | [love.filesystem.getDirectoryItems](love.filesystem.getdirectoryitems "love.filesystem.getDirectoryItems") | Returns all the files and subdirectories in the directory. | 0.9.0 | | | [love.filesystem.getIdentity](love.filesystem.getidentity "love.filesystem.getIdentity") | Gets the write directory name for your game. | 0.9.0 | | | [love.filesystem.getInfo](love.filesystem.getinfo "love.filesystem.getInfo") | Gets information about the specified file or directory. | 11.0 | | | [love.filesystem.getLastModified](love.filesystem.getlastmodified "love.filesystem.getLastModified") | Gets the last modification time of a file. | 0.7.1 | 11.0 | | [love.filesystem.getRealDirectory](love.filesystem.getrealdirectory "love.filesystem.getRealDirectory") | Gets the absolute path of the directory containing a filepath. | 0.9.2 | | | [love.filesystem.getRequirePath](love.filesystem.getrequirepath "love.filesystem.getRequirePath") | Gets the filesystem paths that will be searched when [require](https://www.lua.org/manual/5.1/manual.html#pdf-require) is called. | 0.10.0 | | | [love.filesystem.getSaveDirectory](love.filesystem.getsavedirectory "love.filesystem.getSaveDirectory") | Gets the full path to the designated save directory. | 0.5.0 | | | [love.filesystem.getSize](love.filesystem.getsize "love.filesystem.getSize") | Gets the size in bytes of a file. | 0.9.0 | 11.0 | | [love.filesystem.getSource](love.filesystem.getsource "love.filesystem.getSource") | Returns the full path to the .love file or directory. | 0.9.0 | | | [love.filesystem.getSourceBaseDirectory](love.filesystem.getsourcebasedirectory "love.filesystem.getSourceBaseDirectory") | Returns the full path to the directory containing the .love file. | 0.9.0 | | | [love.filesystem.getUserDirectory](love.filesystem.getuserdirectory "love.filesystem.getUserDirectory") | Returns the path of the user's directory | | | | [love.filesystem.getWorkingDirectory](love.filesystem.getworkingdirectory "love.filesystem.getWorkingDirectory") | Gets the current working directory. | 0.5.0 | | | [love.filesystem.init](love.filesystem.init "love.filesystem.init") | Initializes love.filesystem, will be called internally, so should not be used explictly. | | | | [love.filesystem.isDirectory](love.filesystem.isdirectory "love.filesystem.isDirectory") | Check whether something is a directory. | | 11.0 | | [love.filesystem.isFile](love.filesystem.isfile "love.filesystem.isFile") | Check whether something is a file. | | 11.0 | | [love.filesystem.isFused](love.filesystem.isfused "love.filesystem.isFused") | Gets whether the game is in fused mode or not. | 0.9.0 | | | [love.filesystem.isSymlink](love.filesystem.issymlink "love.filesystem.isSymlink") | Gets whether a filepath is actually a symbolic link. | 0.9.2 | 11.0 | | [love.filesystem.lines](love.filesystem.lines "love.filesystem.lines") | Iterate over the lines in a file. | | | | [love.filesystem.load](love.filesystem.load "love.filesystem.load") | Loads a Lua file (but does not run it). | 0.5.0 | | | [love.filesystem.mkdir](love.filesystem.mkdir "love.filesystem.mkdir") | Creates a directory. | | 0.9.0 | | [love.filesystem.mount](love.filesystem.mount "love.filesystem.mount") | Mounts a zip file or folder in the game's save directory for reading. | 0.9.0 | | | [love.filesystem.newFile](love.filesystem.newfile "love.filesystem.newFile") | Creates a new [File](file "File") object. | | | | [love.filesystem.newFileData](love.filesystem.newfiledata "love.filesystem.newFileData") | Creates a new [FileData](filedata "FileData") object from a file on disk, or from a string in memory. | 0.7.0 | | | [love.filesystem.read](love.filesystem.read "love.filesystem.read") | Read the contents of a file. | | | | [love.filesystem.remove](love.filesystem.remove "love.filesystem.remove") | Removes a file (or directory). | | | | [love.filesystem.setCRequirePath](love.filesystem.setcrequirepath "love.filesystem.setCRequirePath") | Sets the filesystem paths that will be searched for c libraries when [require](https://www.lua.org/manual/5.1/manual.html#pdf-require) is called. | 11.0 | | | [love.filesystem.setIdentity](love.filesystem.setidentity "love.filesystem.setIdentity") | Sets the write directory for your game. | | | | [love.filesystem.setRequirePath](love.filesystem.setrequirepath "love.filesystem.setRequirePath") | Sets the filesystem paths that will be searched when [require](https://www.lua.org/manual/5.1/manual.html#pdf-require) is called. | 0.10.0 | | | [love.filesystem.setSource](love.filesystem.setsource "love.filesystem.setSource") | Sets the source of the game, where the code is present. Used internally. | | | | [love.filesystem.setSymlinksEnabled](love.filesystem.setsymlinksenabled "love.filesystem.setSymlinksEnabled") | Sets whether love.filesystem follows symbolic links. | 0.9.2 | | | [love.filesystem.unmount](love.filesystem.unmount "love.filesystem.unmount") | Unmounts a zip file or folder previously mounted with [love.filesystem.mount](love.filesystem.mount "love.filesystem.mount"). | 0.9.0 | | | [love.filesystem.write](love.filesystem.write "love.filesystem.write") | Write data to a file. | | | Enums ----- | | | | | | --- | --- | --- | --- | | [FileDecoder](filedecoder "FileDecoder") | How to decode a given [FileData](filedata "FileData"). | 0.7.0 | 11.0 | | [FileMode](filemode "FileMode") | The different modes you can open a [File](file "File") in. | | | | [FileType](filetype "FileType") | The type of a file. | 11.0 | | See Also -------- * [love](love "love") love World:getContactCount World:getContactCount ===================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the number of contacts in the world. Function -------- ### Synopsis ``` n = World:getContactCount( ) ``` ### Arguments None. ### Returns `[number](number "number") n` The number of contacts in the world. See Also -------- * [World](world "World") love ParticleSystem:getAreaSpread ParticleSystem:getAreaSpread ============================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | This function has been renamed to [ParticleSystem:getEmissionArea](particlesystem-getemissionarea "ParticleSystem:getEmissionArea"). | Gets the area-based spawn parameters for the particles. Function -------- ### Synopsis ``` distribution, dx, dy = ParticleSystem:getAreaSpread( ) ``` ### Arguments None. ### Returns `[AreaSpreadDistribution](areaspreaddistribution "AreaSpreadDistribution") distribution` The type of distribution for new particles. `[number](number "number") dx` The maximum spawn distance from the emitter along the x-axis for uniform distribution, or the standard deviation along the x-axis for normal distribution. `[number](number "number") dy` The maximum spawn distance from the emitter along the y-axis for uniform distribution, or the standard deviation along the y-axis for normal distribution. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setAreaSpread](particlesystem-setareaspread "ParticleSystem:setAreaSpread") love Joint:isDestroyed Joint:isDestroyed ================= **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Gets whether the Joint is destroyed. Destroyed joints cannot be used. Function -------- ### Synopsis ``` destroyed = Joint:isDestroyed( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") destroyed` Whether the Joint is destroyed. See Also -------- * [Joint](joint "Joint") * [Joint:destroy](joint-destroy "Joint:destroy") love Body:setY Body:setY ========= Set the y position of the body. This function cannot wake up the body. Function -------- ### Synopsis ``` Body:setY( y ) ``` ### Arguments `[number](number "number") y` The y position. ### Returns Nothing. See Also -------- * [Body](body "Body") love Body:getWorldVector Body:getWorldVector =================== Transform a vector from local coordinates to world coordinates. Function -------- ### Synopsis ``` worldX, worldY = Body:getWorldVector( localX, localY ) ``` ### Arguments `[number](number "number") localX` The vector x component in local coordinates. `[number](number "number") localY` The vector y component in local coordinates. ### Returns `[number](number "number") worldX` The vector x component in world coordinates. `[number](number "number") worldY` The vector y component in world coordinates. See Also -------- * [Body](body "Body") love Body:getJoints Body:getJoints ============== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** It has been renamed from [Body:getJointList](body-getjointlist "Body:getJointList"). Returns a table containing the Joints attached to this Body. Function -------- ### Synopsis ``` joints = Body:getJoints( ) ``` ### Arguments None. ### Returns `[table](table "table") joints` A [sequence](sequence "sequence") with the [Joints](joint "Joint") attached to the Body. See Also -------- * [Body](body "Body") love love.graphics.getCanvasFormats love.graphics.getCanvasFormats ============================== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Gets the available [Canvas formats](canvasformat "CanvasFormat"), and whether each is supported. Function -------- ### Synopsis ``` formats = love.graphics.getCanvasFormats( ) ``` ### Arguments None. ### Returns `[table](table "table") formats` A table containing [CanvasFormats](canvasformat "CanvasFormat") as keys, and a boolean indicating whether the format is supported as values. Not all systems support all formats. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` formats = love.graphics.getCanvasFormats( readable ) ``` ### Arguments `[boolean](boolean "boolean") readable` If true, the returned formats will only be indicated as supported if [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") will work with the [readable](texture-isreadable "Texture:isReadable") flag set to true for that format, and vice versa if the parameter is false. ### Returns `[table](table "table") formats` A table containing [CanvasFormats](canvasformat "CanvasFormat") 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. Examples -------- ### Create a canvas with the format 'rgba16f' if it is supported ``` local formats = love.graphics.getCanvasFormats() if formats.rgba16f then canvas = love.graphics.newCanvas(800, 600, "rgba16f") else -- The 'rgba16f' format isn't supported. We could have some fallback code, or trigger a message telling the user their system is unsupported. end ``` ### Display a list of the canvas formats on the screen ``` canvasformats = love.graphics.getCanvasFormats()   function love.draw() local y = 0 for formatname, formatsupported in pairs(canvasformats) do local str = string.format("Supports format '%s': %s", formatname, tostring(formatsupported)) love.graphics.print(str, 10, y) y = y + 20 end end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [CanvasFormat](canvasformat "CanvasFormat") * [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") * [Canvas](canvas "Canvas") love love.filesystem.append love.filesystem.append ====================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Append data to an existing file. Function -------- ### Synopsis ``` success, errormsg = love.filesystem.append( name, data, size ) ``` ### Arguments `[string](string "string") name` The name (and path) of the file. `[string](string "string") data` The string data to append to the file. `[number](number "number") size (all)` How many bytes to write. ### Returns `[boolean](boolean "boolean") success` True if the operation was successful, or nil if there was an error. `[string](string "string") errormsg` The error message on failure. Function -------- ### Synopsis ``` success, errormsg = love.filesystem.append( name, data, size ) ``` ### Arguments `[string](string "string") name` The name (and path) of the file. `[Data](data "Data") data` The Data object to append to the file. `[number](number "number") size (all)` How many bytes to write. ### Returns `[boolean](boolean "boolean") success` True if the operation was successful, or nil if there was an error. `[string](string "string") errormsg` The error message on failure. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [love.filesystem.write](love.filesystem.write "love.filesystem.write")
programming_docs
love Joint Joint ===== Attach multiple bodies together to interact in unique ways. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.physics.newDistanceJoint](love.physics.newdistancejoint "love.physics.newDistanceJoint") | Creates a [DistanceJoint](distancejoint "DistanceJoint") between two bodies. | | | | [love.physics.newFrictionJoint](love.physics.newfrictionjoint "love.physics.newFrictionJoint") | A [FrictionJoint](frictionjoint "FrictionJoint") applies friction to a body. | 0.8.0 | | | [love.physics.newGearJoint](love.physics.newgearjoint "love.physics.newGearJoint") | Create a [GearJoint](gearjoint "GearJoint") connecting two Joints. | | | | [love.physics.newMotorJoint](love.physics.newmotorjoint "love.physics.newMotorJoint") | Creates a joint between two bodies which controls the relative motion between them. | 0.9.0 | | | [love.physics.newMouseJoint](love.physics.newmousejoint "love.physics.newMouseJoint") | Create a joint between a body and the mouse. | | | | [love.physics.newPrismaticJoint](love.physics.newprismaticjoint "love.physics.newPrismaticJoint") | Creates a [PrismaticJoint](prismaticjoint "PrismaticJoint") between two bodies. | | | | [love.physics.newPulleyJoint](love.physics.newpulleyjoint "love.physics.newPulleyJoint") | Creates a [PulleyJoint](pulleyjoint "PulleyJoint") to join two bodies to each other and the ground. | | | | [love.physics.newRevoluteJoint](love.physics.newrevolutejoint "love.physics.newRevoluteJoint") | Creates a pivot joint between two bodies. | | | | [love.physics.newRopeJoint](love.physics.newropejoint "love.physics.newRopeJoint") | Creates a joint between two bodies that enforces a max distance between them. | 0.8.0 | | | [love.physics.newWeldJoint](love.physics.newweldjoint "love.physics.newWeldJoint") | A [WeldJoint](weldjoint "WeldJoint") essentially glues two bodies together. | 0.8.0 | | | [love.physics.newWheelJoint](love.physics.newwheeljoint "love.physics.newWheelJoint") | Creates a wheel joint. | 0.8.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Joint:destroy](joint-destroy "Joint:destroy") | Explicitly destroys the Joint. | | | | [Joint:getAnchors](joint-getanchors "Joint:getAnchors") | Get the anchor points of the joint. | | | | [Joint:getBodies](joint-getbodies "Joint:getBodies") | Gets the [bodies](body "Body") that the Joint is attached to. | 0.9.2 | | | [Joint:getCollideConnected](joint-getcollideconnected "Joint:getCollideConnected") | Gets whether the connected Bodies collide. | | | | [Joint:getReactionForce](joint-getreactionforce "Joint:getReactionForce") | Returns the reaction force on the second body. | | | | [Joint:getReactionTorque](joint-getreactiontorque "Joint:getReactionTorque") | Returns the reaction torque on the second body. | | | | [Joint:getType](joint-gettype "Joint:getType") | Gets a string representing the type. | | | | [Joint:getUserData](joint-getuserdata "Joint:getUserData") | Returns the Lua value associated with this Joint. | 0.9.2 | | | [Joint:isDestroyed](joint-isdestroyed "Joint:isDestroyed") | Gets whether the Joint is destroyed. | 0.9.2 | | | [Joint:setCollideConnected](joint-setcollideconnected "Joint:setCollideConnected") | Sets whether the connected Bodies should collide with each other. | | 0.8.0 | | [Joint:setUserData](joint-setuserdata "Joint:setUserData") | Associates a Lua value with the Joint. | 0.9.2 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Supertypes ---------- * [Object](object "Object") Subtypes -------- | | | | | | --- | --- | --- | --- | | [DistanceJoint](distancejoint "DistanceJoint") | Keeps two bodies at the same distance. | | | | [FrictionJoint](frictionjoint "FrictionJoint") | A FrictionJoint applies friction to a body. | 0.8.0 | | | [GearJoint](gearjoint "GearJoint") | Keeps bodies together in such a way that they act like gears. | | | | [MotorJoint](motorjoint "MotorJoint") | Controls the relative motion between two [Bodies](body "Body") | 0.9.0 | | | [MouseJoint](mousejoint "MouseJoint") | For controlling objects with the mouse. | | | | [PrismaticJoint](prismaticjoint "PrismaticJoint") | Restricts relative motion between Bodies to one shared axis. | | | | [PulleyJoint](pulleyjoint "PulleyJoint") | Allows you to simulate bodies connected through pulleys. | | | | [RevoluteJoint](revolutejoint "RevoluteJoint") | Allow two Bodies to revolve around a shared point. | | | | [RopeJoint](ropejoint "RopeJoint") | Enforces a maximum distance between two points on two bodies. | 0.8.0 | | | [WeldJoint](weldjoint "WeldJoint") | A WeldJoint essentially glues two bodies together. | 0.8.0 | | | [WheelJoint](wheeljoint "WheelJoint") | Restricts a point on the second body to a line on the first body. | | | Enums ----- | | | | | | --- | --- | --- | --- | | [JointType](jointtype "JointType") | Different types of joints. | | | See Also -------- * [love.physics](love.physics "love.physics") love love.joystick.getBall love.joystick.getBall ===================== **Available since LÖVE [0.5.0](https://love2d.org/wiki/0.5.0 "0.5.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier or later versions. Returns the change in ball position. Function -------- ### Synopsis ``` dx, dy = love.joystick.getBall( joystick, ball ) ``` ### Arguments `[number](number "number") joystick` The joystick to be checked `[number](number "number") ball` The ball to be checked ### Returns `[number](number "number") dx` Change in x of the ball position. `[number](number "number") dy` Change in y of the ball position. See Also -------- * [love.joystick](love.joystick "love.joystick") love Video:play Video:play ========== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Starts playing the Video. In order for the video to appear onscreen it must be drawn with [love.graphics.draw](love.graphics.draw "love.graphics.draw"). Function -------- ### Synopsis ``` Video:play( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Video](video "Video") * [Video:pause](video-pause "Video:pause") * [Video:isPlaying](video-isplaying "Video:isPlaying") love Texture:setWrap Texture:setWrap =============== Sets the wrapping properties of a Texture. This function sets the way a Texture is repeated when it is drawn with a [Quad](quad "Quad") that is larger than the texture's extent, or when a custom [Shader](shader "Shader") is used which uses texture coordinates outside of [0, 1]. A texture may be clamped or set to repeat in both horizontal and vertical directions. Clamped textures appear only once (with the edges of the texture stretching to fill the extent of the Quad), whereas repeated ones repeat as many times as there is room in the Quad. Function -------- ### Synopsis ``` Texture:setWrap( horiz, vert, depth ) ``` ### Arguments `[WrapMode](wrapmode "WrapMode") horiz` Horizontal wrapping mode of the texture. `[WrapMode](wrapmode "WrapMode") vert (horiz)` Vertical wrapping mode of the texture. `[WrapMode](wrapmode "WrapMode") depth (horiz)` Available since 11.0 Wrapping mode for the z-axis of a [Volume texture](texturetype "TextureType"). ### Returns Nothing. See Also -------- * [Texture](texture "Texture") * [Texture:getWrap](texture-getwrap "Texture:getWrap") * [WrapMode](wrapmode "WrapMode") love love.window.setPosition love.window.setPosition ======================= **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Sets the position of the window on the screen. The window position is in the coordinate space of the specified display. Function -------- ### Synopsis ``` love.window.setPosition( x, y, display ) ``` ### Arguments `[number](number "number") x` The x-coordinate of the window's position. `[number](number "number") y` The y-coordinate of the window's position. `[number](number "number") display (1)` The index of the display that the new window position is relative to. ### Returns Nothing. See Also -------- * [love.window](love.window "love.window") * [love.window.getPosition](love.window.getposition "love.window.getPosition") love Font:setFallbacks Font:setFallbacks ================= **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Sets the fallback fonts. When the Font doesn't contain a glyph, it will substitute the glyph from the next subsequent fallback Fonts. This is akin to setting a "font stack" in Cascading Style Sheets (CSS). Function -------- ### Synopsis ``` Font:setFallbacks( fallbackfont1, ... ) ``` ### Arguments `[Font](font "Font") fallbackfont1` The first fallback Font to use. `[Font](font "Font") ...` Additional fallback Fonts. ### Returns Nothing. Notes ----- If this is called it should be before [love.graphics.print](love.graphics.print "love.graphics.print"), [Font:getWrap](font-getwrap "Font:getWrap"), and other Font methods which use glyph positioning information are called. Every fallback Font must be created from the same file type as the primary Font. For example, a Font created from a .ttf file can only use fallback Fonts that were created from .ttf files. See Also -------- * [Font](font "Font") love love.graphics.drawLayer love.graphics.drawLayer ======================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Draws a layer of an [Array Texture](love.graphics.newarrayimage "love.graphics.newArrayImage"). Function -------- Draws a layer of an Array Texture. ### Synopsis ``` love.graphics.drawLayer( texture, layerindex, x, y, r, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[Texture](texture "Texture") texture` The Array Texture to draw. `[number](number "number") layerindex` The index of the layer to use when drawing. `[number](number "number") x (0)` The position to draw the texture (x-axis). `[number](number "number") y (0)` The position to draw the texture (y-axis). `[number](number "number") r (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Shearing factor (x-axis). `[number](number "number") ky (0)` Shearing factor (y-axis). ### Returns Nothing. Function -------- Draws a layer of an Array Texture using the specified [Quad](quad "Quad"). ### Synopsis ``` love.graphics.drawLayer( texture, layerindex, quad, x, y, r, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[Texture](texture "Texture") texture` The Array Texture to draw. `[number](number "number") layerindex` The index of the layer to use when drawing. `[Quad](quad "Quad") quad` The subsection of the texture's layer to use when drawing. `[number](number "number") x (0)` The position to draw the texture (x-axis). `[number](number "number") y (0)` The position to draw the texture (y-axis). `[number](number "number") r (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Shearing factor (x-axis). `[number](number "number") ky (0)` Shearing factor (y-axis). ### Returns Nothing. ### Notes The specified layer index overrides any layer index set on the Quad via [Quad:setLayer](https://love2d.org/w/index.php?title=Quad:setLayer&action=edit&redlink=1 "Quad:setLayer (page does not exist)"). Function -------- Draws a layer of an Array Texture using the specified [Transform](transform "Transform"). ### Synopsis ``` love.graphics.drawLayer( texture, layerindex, transform ) ``` ### Arguments `[Texture](texture "Texture") texture` The Array Texture to draw. `[number](number "number") layerindex` The index of the layer to use when drawing. `[Transform](transform "Transform") transform` A transform object. ### Returns Nothing. Function -------- Draws a layer of an Array Texture using the specified [Quad](quad "Quad") and [Transform](transform "Transform"). ### Synopsis ``` love.graphics.drawLayer( texture, layerindex, quad, transform ) ``` ### Arguments `[Texture](texture "Texture") texture` The Array Texture to draw. `[number](number "number") layerindex` The index of the layer to use when drawing. `[Quad](quad "Quad") quad` The subsection of the texture's layer to use when drawing. `[Transform](transform "Transform") transform` A transform object. ### Returns Nothing. ### Notes The specified layer index overrides any layer index set on the Quad via [Quad:setLayer](https://love2d.org/w/index.php?title=Quad:setLayer&action=edit&redlink=1 "Quad:setLayer (page does not exist)"). Notes ----- In order to use an Array Texture or other non-2D texture types as the main texture in a custom [Shader](shader "Shader"), the [void effect()](love.graphics.newshader "love.graphics.newShader") variant must be used in the pixel shader, and MainTex must be declared as an ArrayImage or sampler2DArray like so: `uniform ArrayImage MainTex;`. Examples -------- ### Draw multiple layers of an Array Image ``` function love.load() local sprites = {"sprite1.png", "sprite2.png"} image = love.graphics.newArrayImage(sprites) end   function love.draw() love.graphics.drawLayer(image, 1, 50, 50) love.graphics.drawLayer(image, 2, 250, 50) end ``` ### Use a custom shader with love.graphics.drawLayer ``` shader = love.graphics.newShader[[ uniform ArrayImage MainTex;   void effect() { // Texel uses a third component of the texture coordinate for the layer index, when an Array Texture is passed in. // love sets up the texture coordinates to contain the layer index specified in love.graphics.drawLayer, when // rendering the Array Texture. love_PixelColor = Texel(MainTex, VaryingTexCoord.xyz) * VaryingColor; } ]]   function love.load() local sprites = {"sprite1.png", "sprite2.png"} image = love.graphics.newArrayImage(sprites) end   function love.draw() love.graphics.setShader(shader) love.graphics.drawLayer(image, 1, 50, 50) love.graphics.drawLayer(image, 2, 250, 50) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.newArrayImage](love.graphics.newarrayimage "love.graphics.newArrayImage") * [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") * [love.graphics.newShader](love.graphics.newshader "love.graphics.newShader") * [TextureType](texturetype "TextureType") love Source:getVolume Source:getVolume ================ Gets the current volume of the Source. Function -------- ### Synopsis ``` volume = Source:getVolume( ) ``` ### Arguments None. ### Returns `[number](number "number") volume` The volume of the Source, where 1.0 is normal volume. See Also -------- * [Source](source "Source") love ParticleSystem:pause ParticleSystem:pause ==================== Pauses the particle emitter. Function -------- ### Synopsis ``` ParticleSystem:pause( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love CompareMode CompareMode =========== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This enum is not supported in earlier versions. Different types of per-pixel [stencil test](love.graphics.setstenciltest "love.graphics.setStencilTest") and [depth test](love.graphics.setdepthmode "love.graphics.setDepthMode") comparisons. The pixels of an object will be drawn if the comparison succeeds, for each pixel that the object touches. Constants --------- equal * stencil tests: the stencil value of the pixel must be equal to the [supplied value](love.graphics.setstenciltest "love.graphics.setStencilTest"). * depth tests: the depth value of the drawn object at that pixel must be equal to the existing depth value of that pixel. notequal * stencil tests: the stencil value of the pixel must **not** be equal to the [supplied value](love.graphics.setstenciltest "love.graphics.setStencilTest"). * depth tests: the depth value of the drawn object at that pixel must **not** be equal to the existing depth value of that pixel. less * stencil tests: the stencil value of the pixel must be less than the [supplied value](love.graphics.setstenciltest "love.graphics.setStencilTest"). * depth tests: the depth value of the drawn object at that pixel must be less than the existing depth value of that pixel. lequal * stencil tests: the stencil value of the pixel must be less than or equal to the [supplied value](love.graphics.setstenciltest "love.graphics.setStencilTest"). * depth tests: the depth value of the drawn object at that pixel must be less than or equal to the existing depth value of that pixel. gequal * stencil tests: the stencil value of the pixel must be greater than or equal to the [supplied value](love.graphics.setstenciltest "love.graphics.setStencilTest"). * depth tests: the depth value of the drawn object at that pixel must be greater than or equal to the existing depth value of that pixel. greater * stencil tests: the stencil value of the pixel must be greater than the [supplied value](love.graphics.setstenciltest "love.graphics.setStencilTest"). * depth tests: the depth value of the drawn object at that pixel must be greater than the existing depth value of that pixel. never Objects will never be drawn. always Objects will always be drawn. Effectively disables the depth or stencil test. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setStencilTest](love.graphics.setstenciltest "love.graphics.setStencilTest") * [love.graphics.stencil](love.graphics.stencil "love.graphics.stencil") * [love.graphics.setDepthMode](love.graphics.setdepthmode "love.graphics.setDepthMode") love Font:getWrap Font:getWrap ============ **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Gets formatting information for text, given a wrap limit. This function accounts for newlines correctly (i.e. '\n'). Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. ### Synopsis ``` width, wrappedtext = Font:getWrap( text, wraplimit ) ``` ### Arguments `[string](string "string") text` The text that will be wrapped. `[number](number "number") wraplimit` The maximum width in pixels of each line that *text* is allowed before wrapping. ### Returns `[number](number "number") width` The maximum width of the wrapped text. `[table](table "table") wrappedtext` A [sequence](sequence "sequence") containing each line of text that was wrapped. Function -------- **Removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in that and later versions. ### Synopsis ``` width, lines = Font:getWrap( text, wraplimit ) ``` ### Arguments `[string](string "string") text` The text that would be wrapped. `[number](number "number") wraplimit` The maximum width in pixels of each line that *text* is allowed before wrapping. ### Returns `[number](number "number") width` The maximum width of the wrapped text. `[number](number "number") lines` The number of lines that the wrapped text will have. See Also -------- * [Font](font "Font") * [love.graphics.printf](love.graphics.printf "love.graphics.printf") * [Text:setf](text-setf "Text:setf")
programming_docs
love Body:resetMassData Body:resetMassData ================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Resets the mass of the body by recalculating it from the mass properties of the fixtures. Function -------- ### Synopsis ``` Body:resetMassData( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Body](body "Body") love love.physics love.physics ============ **Available since LÖVE [0.4.0](https://love2d.org/wiki/0.4.0 "0.4.0")** This module is not supported in earlier versions. Can simulate 2D rigid bodies in a realistic manner. This module is essentially just a binding to [Box2D](http://box2d.org/about/) (version 2.3.0 - [manual](https://box2d.org/documentation/)). For simpler (and more common) use cases, a small number of libraries exist, which are usually more popularly used than love.physics and can be found here: <https://github.com/love2d-community/awesome-love2d#physics> Types ----- | | | | | | --- | --- | --- | --- | | [Body](body "Body") | Bodies are objects with velocity and position. | | | | [Contact](contact "Contact") | Contacts are objects created to manage collisions in worlds. | | | | [Fixture](fixture "Fixture") | Fixtures attach shapes to bodies. | 0.8.0 | | | [Joint](joint "Joint") | Attach multiple bodies together to interact in unique ways. | | | | [Shape](shape "Shape") | [Shapes](shape "Shape") are objects used to control mass and collisions. | | | | [World](world "World") | A world is an object that contains all bodies and joints. | | | Functions --------- | | | | | | --- | --- | --- | --- | | [love.physics.getDistance](love.physics.getdistance "love.physics.getDistance") | Returns the two closest points between two fixtures and their distance. | 0.8.0 | | | [love.physics.getMeter](love.physics.getmeter "love.physics.getMeter") | Returns the meter scale factor. | 0.8.0 | | | [love.physics.newBody](love.physics.newbody "love.physics.newBody") | Creates a new body. | | | | [love.physics.newChainShape](love.physics.newchainshape "love.physics.newChainShape") | Creates a new [ChainShape](chainshape "ChainShape"). | 0.8.0 | | | [love.physics.newCircleShape](love.physics.newcircleshape "love.physics.newCircleShape") | Creates a new [CircleShape](circleshape "CircleShape"). | | | | [love.physics.newDistanceJoint](love.physics.newdistancejoint "love.physics.newDistanceJoint") | Creates a [DistanceJoint](distancejoint "DistanceJoint") between two bodies. | | | | [love.physics.newEdgeShape](love.physics.newedgeshape "love.physics.newEdgeShape") | Creates a new [EdgeShape](edgeshape "EdgeShape"). | 0.8.0 | | | [love.physics.newFixture](love.physics.newfixture "love.physics.newFixture") | Creates and attaches a fixture. | 0.8.0 | | | [love.physics.newFrictionJoint](love.physics.newfrictionjoint "love.physics.newFrictionJoint") | A [FrictionJoint](frictionjoint "FrictionJoint") applies friction to a body. | 0.8.0 | | | [love.physics.newGearJoint](love.physics.newgearjoint "love.physics.newGearJoint") | Create a [GearJoint](gearjoint "GearJoint") connecting two Joints. | | | | [love.physics.newMotorJoint](love.physics.newmotorjoint "love.physics.newMotorJoint") | Creates a joint between two bodies which controls the relative motion between them. | 0.9.0 | | | [love.physics.newMouseJoint](love.physics.newmousejoint "love.physics.newMouseJoint") | Create a joint between a body and the mouse. | | | | [love.physics.newPolygonShape](love.physics.newpolygonshape "love.physics.newPolygonShape") | Creates a new [PolygonShape](polygonshape "PolygonShape"). | | | | [love.physics.newPrismaticJoint](love.physics.newprismaticjoint "love.physics.newPrismaticJoint") | Creates a [PrismaticJoint](prismaticjoint "PrismaticJoint") between two bodies. | | | | [love.physics.newPulleyJoint](love.physics.newpulleyjoint "love.physics.newPulleyJoint") | Creates a [PulleyJoint](pulleyjoint "PulleyJoint") to join two bodies to each other and the ground. | | | | [love.physics.newRectangleShape](love.physics.newrectangleshape "love.physics.newRectangleShape") | Shorthand for creating rectangular [PolygonShapes](polygonshape "PolygonShape"). | | | | [love.physics.newRevoluteJoint](love.physics.newrevolutejoint "love.physics.newRevoluteJoint") | Creates a pivot joint between two bodies. | | | | [love.physics.newRopeJoint](love.physics.newropejoint "love.physics.newRopeJoint") | Creates a joint between two bodies that enforces a max distance between them. | 0.8.0 | | | [love.physics.newWeldJoint](love.physics.newweldjoint "love.physics.newWeldJoint") | A [WeldJoint](weldjoint "WeldJoint") essentially glues two bodies together. | 0.8.0 | | | [love.physics.newWheelJoint](love.physics.newwheeljoint "love.physics.newWheelJoint") | Creates a wheel joint. | 0.8.0 | | | [love.physics.newWorld](love.physics.newworld "love.physics.newWorld") | Creates a new World. | | | | [love.physics.setMeter](love.physics.setmeter "love.physics.setMeter") | Sets the meter scale factor. | 0.8.0 | | Enums ----- | | | | | | --- | --- | --- | --- | | [BodyType](bodytype "BodyType") | The types of a [Body](body "Body"). | | | | [JointType](jointtype "JointType") | Different types of joints. | | | | [ShapeType](shapetype "ShapeType") | The different types of [Shapes](shape "Shape"), as returned by [Shape:getType](shape-gettype "Shape:getType"). | | | Notes ----- ### Box2D's architecture, concepts, and terminologies. [![Box2D basic overview.png](https://love2d.org/w/images/thumb/2/29/Box2D_basic_overview.png/880px-Box2D_basic_overview.png)](https://love2d.org/wiki/File:Box2D_basic_overview.png) See Also -------- * [love](love "love") * [Tutorial:Physics](https://love2d.org/wiki/Tutorial:Physics "Tutorial:Physics") * [Tutorial:PhysicsCollisionCallbacks](https://love2d.org/wiki/Tutorial:PhysicsCollisionCallbacks "Tutorial:PhysicsCollisionCallbacks") * [Box2D Gotchas](http://www.iforce2d.net/b2dtut/gotchas) (recommended reading) love love.graphics.hasFocus love.graphics.hasFocus ====================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** Moved to the [love.window](love.window "love.window") module as [love.window.hasFocus](love.window.hasfocus "love.window.hasFocus"). Checks if the game window has keyboard focus. Function -------- ### Synopsis ``` focus = love.graphics.hasFocus( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") focus` True if the window has the focus or false if not. See Also -------- * [love.graphics](love.graphics "love.graphics") love PrismaticJoint:enableMotor PrismaticJoint:enableMotor ========================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [PrismaticJoint:setMotorEnabled](prismaticjoint-setmotorenabled "PrismaticJoint:setMotorEnabled"). Starts or stops the joint motor. Function -------- ### Synopsis ``` PrismaticJoint:enableMotor( enable ) ``` ### Arguments `[boolean](boolean "boolean") enable` True to enable, false to disable. ### Returns Nothing. See Also -------- * [PrismaticJoint](prismaticjoint "PrismaticJoint") love WheelJoint:getSpringDampingRatio WheelJoint:getSpringDampingRatio ================================ **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the damping ratio. Function -------- ### Synopsis ``` ratio = WheelJoint:getSpringDampingRatio( ) ``` ### Arguments None. ### Returns `[number](number "number") ratio` The damping ratio. See Also -------- * [WheelJoint](wheeljoint "WheelJoint") * [WheelJoint:setSpringDampingRatio](wheeljoint-setspringdampingratio "WheelJoint:setSpringDampingRatio") love love.textinput love.textinput ============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Called when text has been entered by the user. For example if shift-2 is pressed on an American keyboard layout, the text "@" will be generated. Function -------- ### Synopsis ``` love.textinput( text ) ``` ### Arguments `[string](string "string") text` The UTF-8 encoded unicode text. ### Returns Nothing. Notes ----- Although Lua strings can store UTF-8 encoded unicode text just fine, many functions in Lua's string library will not treat the text as you might expect. For example, `#text` (and `string.len(text)`) will give the number of *bytes* in the string, rather than the number of unicode characters. The [Lua wiki](http://lua-users.org/wiki/LuaUnicode) and a [presentation by one of Lua's creators](https://www.lua.org/wshop12/Ierusalimschy.pdf) give more in-depth explanations, with some tips. The [utf8](utf8 "utf8") library can be used to operate on UTF-8 encoded unicode text (such as the text argument given in this function.) On Android and iOS, textinput is disabled by default; call [love.keyboard.setTextInput](love.keyboard.settextinput "love.keyboard.setTextInput") to enable it. Examples -------- Record and print text the user writes. ``` function love.load() text = "Type away! -- " end   function love.textinput(t) text = text .. t end   function love.draw() love.graphics.printf(text, 0, 0, love.graphics.getWidth()) end ``` Print text the user writes, and erase text when backspace is pressed. ``` local utf8 = require("utf8")   function love.load() text = "Type away! -- "   -- enable key repeat so backspace can be held down to trigger love.keypressed multiple times. love.keyboard.setKeyRepeat(true) end   function love.textinput(t) text = text .. t end   function love.keypressed(key) if key == "backspace" then -- get the byte offset to the last UTF-8 character in the string. local byteoffset = utf8.offset(text, -1)   if byteoffset then -- remove the last UTF-8 character. -- string.sub operates on bytes rather than UTF-8 characters, so we couldn't do string.sub(text, 1, -2). text = string.sub(text, 1, byteoffset - 1) end end end   function love.draw() love.graphics.printf(text, 0, 0, love.graphics.getWidth()) end ``` See Also -------- * [love](love "love") * [love.keypressed](love.keypressed "love.keypressed") * [love.keyboard.setTextInput](love.keyboard.settextinput "love.keyboard.setTextInput") * [love.keyboard.hasTextInput](love.keyboard.hastextinput "love.keyboard.hasTextInput") * [utf8](utf8 "utf8") * [textinput vs keypressed](https://wiki.libsdl.org/Tutorials/TextInput) love love.window.minimize love.window.minimize ==================== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Minimizes the window to the system's task bar / dock. Function -------- ### Synopsis ``` love.window.minimize( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [love.window](love.window "love.window") love love.graphics.getRendererInfo love.graphics.getRendererInfo ============================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets information about the system's video card and drivers. Almost everything returned by this function is highly dependent on the system running the code and should probably not be used to make run-time decisions. Function -------- ### Synopsis ``` name, version, vendor, device = love.graphics.getRendererInfo( ) ``` ### Arguments None. ### Returns `[string](string "string") name` The name of the renderer, e.g. "OpenGL" or "OpenGL ES". `[string](string "string") version` The version of the renderer with some extra driver-dependent version info, e.g. "2.1 INTEL-8.10.44". `[string](string "string") vendor` The name of the graphics card vendor, e.g. "Intel Inc". `[string](string "string") device` The name of the graphics card, e.g. "Intel HD Graphics 3000 OpenGL Engine". See Also -------- * [love.graphics](love.graphics "love.graphics") love ParticleSystem:getTangentialAcceleration ParticleSystem:getTangentialAcceleration ======================================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the tangential acceleration (acceleration perpendicular to the particle's direction). Function -------- ### Synopsis ``` min, max = ParticleSystem:getTangentialAcceleration( ) ``` ### Arguments Nothing. ### Returns `[number](number "number") min` The minimum acceleration. `[number](number "number") max` The maximum acceleration. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setTangentialAcceleration](particlesystem-settangentialacceleration "ParticleSystem:setTangentialAcceleration") love love.graphics.setLineStyle love.graphics.setLineStyle ========================== **Available since LÖVE [0.3.2](https://love2d.org/wiki/0.3.2 "0.3.2")** This function is not supported in earlier versions. Sets the line style. Function -------- ### Synopsis ``` love.graphics.setLineStyle( style ) ``` ### Arguments `[LineStyle](linestyle "LineStyle") style` The LineStyle to use. Line styles include `smooth` and `rough`. ### Returns Nothing. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getLineStyle](love.graphics.getlinestyle "love.graphics.getLineStyle") * [love.graphics.setLineWidth](love.graphics.setlinewidth "love.graphics.setLineWidth") love Body:getWorldCenter Body:getWorldCenter =================== Get the center of mass position in world coordinates. Use [Body:getLocalCenter](body-getlocalcenter "Body:getLocalCenter") to get the center of mass in local coordinates. Function -------- ### Synopsis ``` x, y = Body:getWorldCenter( ) ``` ### Arguments None. ### Returns `[number](number "number") x` The x coordinate of the center of mass. `[number](number "number") y` The y coordinate of the center of mass. See Also -------- * [Body](body "Body") love Fixture:isSensor Fixture:isSensor ================ **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns whether the fixture is a sensor. Function -------- ### Synopsis ``` sensor = Fixture:isSensor( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") sensor` If the fixture is a sensor. See Also -------- * [Fixture](fixture "Fixture") * [Fixture:setSensor](fixture-setsensor "Fixture:setSensor") love BezierCurve:scale BezierCurve:scale ================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Scale the Bézier curve by a factor. Function -------- ### Synopsis ``` BezierCurve:scale(s, ox, oy) ``` ### Arguments `[number](number "number") s` Scale factor. `[number](number "number") ox (0)` X coordinate of the scaling center. `[number](number "number") oy (0)` Y coordinate of the scaling center. ### Returns Nothing. See Also -------- * [BezierCurve:translate](beziercurve-translate "BezierCurve:translate") * [BezierCurve:rotate](beziercurve-rotate "BezierCurve:rotate") * [BezierCurve](beziercurve "BezierCurve") * [love.math](love.math "love.math") love love.filesystem.read love.filesystem.read ==================== Read the contents of a file. Function -------- ### Synopsis ``` contents, size = love.filesystem.read( name, size ) ``` ### Arguments `[string](string "string") name` The name (and path) of the file. `[number](number "number") size (all)` How many bytes to read. ### Returns `[string](string "string") contents` The file contents. `[number](number "number") size` How many bytes have been read. ### Returns (if error on reading) `[nil](nil "nil") contents` returns nil as content. `[string](string "string") error` returns an error message. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. Reads the contents of a file into either a string or a [FileData](filedata "FileData") object. ### Synopsis ``` contents, size = love.filesystem.read( container, name, size ) ``` ### Arguments `[ContainerType](containertype "ContainerType") container` What type to return the file's contents as. `[string](string "string") name` The name (and path) of the file `[number](number "number") size (all)` How many bytes to read ### Returns `[value](value "value") contents` [FileData](filedata "FileData") or string containing the file contents. `[number](number "number") size` How many bytes have been read. ### Returns (if error on reading) `[nil](nil "nil") contents` returns nil as content. `[string](string "string") error` returns an error message. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") love love.audio.setOrientation love.audio.setOrientation ========================= Sets the orientation of the listener. Function -------- ### Synopsis ``` love.audio.setOrientation( fx, fy, fz, ux, uy, uz ) ``` ### Arguments `[number](number "number") fx, fy, fz` Forward vector of the listener orientation. `[number](number "number") ux, uy, uz` Up vector of the listener orientation. ### Returns Nothing. See Also -------- * [love.audio](love.audio "love.audio") love love.touchpressed love.touchpressed ================= **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Callback function triggered when the touch screen is touched. Function -------- ### Synopsis ``` love.touchpressed( id, x, y, dx, dy, pressure ) ``` ### Arguments `[light userdata](light_userdata "light userdata") id` The identifier for the touch press. `[number](number "number") x` The x-axis position of the touch press inside the window, in pixels. `[number](number "number") y` The y-axis position of the touch press inside the window, in pixels. `[number](number "number") dx` The x-axis movement of the touch press inside the window, in pixels. This should always be zero. `[number](number "number") dy` The y-axis movement of the touch press inside the window, in pixels. This should always be zero. `[number](number "number") pressure` The amount of pressure being applied. Most touch screens aren't pressure sensitive, in which case the pressure will be 1. ### Returns Nothing. Notes ----- The identifier is only guaranteed to be unique for the specific touch press until [love.touchreleased](love.touchreleased "love.touchreleased") is called with that identifier, at which point it may be reused for new touch presses. The unofficial Android and iOS ports of LÖVE 0.9.2 reported touch positions as normalized values in the range of [0, 1], whereas this API reports positions in pixels. See Also -------- * [love](love "love") * [love.touchreleased](love.touchreleased "love.touchreleased") * [love.touchmoved](love.touchmoved "love.touchmoved") * [love.touch](love.touch "love.touch") love love.graphics.getScissor love.graphics.getScissor ======================== **Available since LÖVE [0.4.0](https://love2d.org/wiki/0.4.0 "0.4.0")** This function is not supported in earlier versions. Gets the current scissor box. Function -------- ### Synopsis ``` x, y, width, height = love.graphics.getScissor( ) ``` ### Arguments None. ### Returns `[number](number "number") x` The x-component of the top-left point of the box. `[number](number "number") y` The y-component of the top-left point of the box. `[number](number "number") width` The width of the box. `[number](number "number") height` The height of the box. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setScissor](love.graphics.setscissor "love.graphics.setScissor") * [love.graphics.intersectScissor](love.graphics.intersectscissor "love.graphics.intersectScissor")
programming_docs
love MouseConstant MouseConstant ============= **Removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** Mouse button constants have been replaced with button index numbers. Mouse buttons. Constants --------- l Left Mouse Button. m Middle Mouse Button. r Right Mouse Button. wd Mouse Wheel Down. wu Mouse Wheel Up. x1 Mouse X1 (also known as button 4). x2 Mouse X2 (also known as button 5). See Also -------- * [love.mouse](love.mouse "love.mouse") * [love.mouse.isDown](love.mouse.isdown "love.mouse.isDown") * [love.mousepressed](love.mousepressed "love.mousepressed") * [love.mousereleased](love.mousereleased "love.mousereleased") love (File):flush (File):flush ============ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Flushes any buffered written data in the file to the disk. Function -------- ### Synopsis ``` success, err = File:flush( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") success` Whether the file successfully flushed any buffered data to the disk. `[string](string "string") err (nil)` The error string, if an error occurred and the file could not be flushed. See Also -------- * [File](file "File") * [File:write]((file)-write "(File):write") * [File:setBuffer]((file)-setbuffer "(File):setBuffer") love TimeUnit TimeUnit ======== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This enum is not supported in earlier versions. Units that represent time. Constants --------- seconds Regular seconds. samples Audio samples. See Also -------- * [love.audio](love.audio "love.audio") love RevoluteJoint:setMaxMotorTorque RevoluteJoint:setMaxMotorTorque =============================== Set the maximum motor force. Function -------- ### Synopsis ``` RevoluteJoint:setMaxMotorTorque( f ) ``` ### Arguments `[number](number "number") f` The maximum motor force, in Nm. ### Returns Nothing. See Also -------- * [RevoluteJoint](revolutejoint "RevoluteJoint") love Thread:start Thread:start ============ **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Starts the thread. Beginning with version [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0"), threads can be restarted after they have completed their execution. Function -------- ### Synopsis ``` Thread:start( ) ``` ### Arguments None. ### Returns Nothing. Function -------- **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in earlier versions. ### Synopsis ``` Thread:start( arg1, arg2, ... ) ``` ### Arguments `[Variant](variant "Variant") arg1` A string, number, boolean, LÖVE object, or simple table. `[Variant](variant "Variant") arg2` A string, number, boolean, LÖVE object, or simple table. `[Variant](variant "Variant") ...` You can continue passing values to the thread. ### Returns Nothing. ### Notes Arguments passed to Thread:start are accessible in the thread's main file via **...** (the vararg expression.) See Also -------- * [Thread](thread "Thread") * [Thread:wait](thread-wait "Thread:wait") * [Thread:isRunning](thread-isrunning "Thread:isRunning") love JointType JointType ========= Different types of joints. Constants --------- distance A [DistanceJoint](distancejoint "DistanceJoint"). friction A [FrictionJoint](frictionjoint "FrictionJoint"). gear A [GearJoint](gearjoint "GearJoint"). mouse A [MouseJoint](mousejoint "MouseJoint"). prismatic A [PrismaticJoint](prismaticjoint "PrismaticJoint"). pulley A [PulleyJoint](pulleyjoint "PulleyJoint"). revolute A [RevoluteJoint](revolutejoint "RevoluteJoint"). rope A [RopeJoint](ropejoint "RopeJoint"). weld A [WeldJoint](weldjoint "WeldJoint"). See Also -------- * [Joint](joint "Joint") * [love.physics](love.physics "love.physics") love Body:getPosition Body:getPosition ================ Get the position of the body. Note that this may not be the center of mass of the body. Function -------- ### Synopsis ``` x, y = Body:getPosition( ) ``` ### Arguments None. ### Returns `[number](number "number") x` The x position. `[number](number "number") y` The y position. See Also -------- * [Body](body "Body") love SoundData:getSampleCount SoundData:getSampleCount ======================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Returns the number of samples per channel of the SoundData. Function -------- ### Synopsis ``` count = SoundData:getSampleCount( ) ``` ### Arguments None. ### Returns `[number](number "number") count` Total number of samples. See Also -------- * [SoundData](sounddata "SoundData") love love.keypressed love.keypressed =============== Callback function triggered when a key is pressed. Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.keypressed( key, scancode, isrepeat ) ``` ### Arguments `[KeyConstant](keyconstant "KeyConstant") key` Character of the pressed key. `[Scancode](scancode "Scancode") scancode` The scancode representing the pressed key. `[boolean](boolean "boolean") isrepeat` Whether this keypress event is a repeat. The delay between key repeats depends on the user's system settings. ### Returns Nothing. ### Notes [Scancodes](scancode "Scancode") are keyboard layout-independent, so the scancode "w" will be generated if the key in the same place as the "w" key on an [American keyboard](https://en.wikipedia.org/wiki/British_and_American_keyboards#/media/File:KB_United_States-NoAltGr.svg) is pressed, no matter what the key is labelled or what the user's operating system settings are. Key repeat needs to be enabled with [love.keyboard.setKeyRepeat](love.keyboard.setkeyrepeat "love.keyboard.setKeyRepeat") for repeat keypress events to be received. This does not affect [love.textinput](love.textinput "love.textinput"). Function -------- **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier or later versions. ### Synopsis ``` love.keypressed( key, isrepeat ) ``` ### Arguments `[KeyConstant](keyconstant "KeyConstant") key` Character of the key pressed. `[boolean](boolean "boolean") isrepeat` Whether this keypress event is a repeat. The delay between key repeats depends on the user's system settings. ### Returns Nothing. ### Notes Key repeat needs to be enabled with [love.keyboard.setKeyRepeat](love.keyboard.setkeyrepeat "love.keyboard.setKeyRepeat") for repeat keypress events to be received. Function -------- **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** Unicode text input is now handled separately via [love.textinput](love.textinput "love.textinput"). ### Synopsis ``` love.keypressed( key, unicode ) ``` ### Arguments `[KeyConstant](keyconstant "KeyConstant") key` Character of the key pressed. `[number](number "number") unicode` The unicode number of the key pressed. ### Returns Nothing. Examples -------- Exit the game when the player presses the Escape key, using [love.event.quit](love.event.quit "love.event.quit"). ``` function love.keypressed(key, scancode, isrepeat) if key == "escape" then love.event.quit() end end ``` **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** Text input is now handled separately via [love.textinput](love.textinput "love.textinput"). Record and print text the user writes (0.8.0 and below.) ``` function love.load() text = "Type away! -- " end   function love.keypressed(key, unicode) -- ignore non-printable characters (see http://www.ascii-code.com/) if unicode > 31 and unicode < 127 then text = text .. string.char(unicode) end end   function love.draw() love.graphics.printf(text, 0, 0, 800) end ``` See Also -------- * [love](love "love") * [love.keyreleased](love.keyreleased "love.keyreleased") * [love.keyboard.isDown](love.keyboard.isdown "love.keyboard.isDown") * [love.keyboard.isScancodeDown](love.keyboard.isscancodedown "love.keyboard.isScancodeDown") * [love.textinput](love.textinput "love.textinput") love love.graphics.getLineJoin love.graphics.getLineJoin ========================= Gets the line join style. Function -------- ### Synopsis ``` join = love.graphics.getLineJoin( ) ``` ### Arguments Nothing. ### Returns `[LineJoin](linejoin "LineJoin") join` The LineJoin style. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setLineJoin](love.graphics.setlinejoin "love.graphics.setLineJoin") love BezierCurve:getSegment BezierCurve:getSegment ====================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets a BezierCurve that corresponds to the specified segment of this BezierCurve. Function -------- ### Synopsis ``` curve = BezierCurve:getSegment( startpoint, endpoint ) ``` ### Arguments `[number](number "number") startpoint` The starting point along the curve. Must be between 0 and 1. `[number](number "number") endpoint` The end of the segment. Must be between 0 and 1. ### Returns `[BezierCurve](beziercurve "BezierCurve") curve` A BezierCurve that corresponds to the specified segment. See Also -------- * [BezierCurve](beziercurve "BezierCurve") * [BezierCurve:renderSegment](beziercurve-rendersegment "BezierCurve:renderSegment") * [love.math](love.math "love.math") love love.graphics.toggleFullscreen love.graphics.toggleFullscreen ============================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** Moved to the [love.window](love.window "love.window") module as [love.window.toggleFullscreen](love.window.togglefullscreen "love.window.toggleFullscreen"). Toggles fullscreen. Function -------- ### Synopsis ``` success = love.graphics.toggleFullscreen( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") success` True if successful, false otherwise. See Also -------- * [love.graphics](love.graphics "love.graphics") love love.joystick.getName love.joystick.getName ===================== **Available since LÖVE [0.5.0](https://love2d.org/wiki/0.5.0 "0.5.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been moved to [Joystick:getName](joystick-getname "Joystick:getName"). Returns the name of a joystick. Function -------- ### Synopsis ``` name = love.joystick.getName( joystick ) ``` ### Arguments `[number](number "number") joystick` The joystick to be checked ### Returns `[string](string "string") name` The name See Also -------- * [love.joystick](love.joystick "love.joystick") love love.audio.isEffectsSupported love.audio.isEffectsSupported ============================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets whether audio effects are supported in the system. Function -------- ### Synopsis ``` supported = love.audio.isEffectsSupported( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") supported` True if effects are supported, false otherwise. Notes ----- Older Linux distributions that ship with older OpenAL library may not support audio effects. Furthermore, iOS doesn't support audio effects at all. See Also -------- * [love.audio](love.audio "love.audio") * [love.audio.getMaxSceneEffects](love.audio.getmaxsceneeffects "love.audio.getMaxSceneEffects") * [love.audio.getMaxSourceEffects](love.audio.getmaxsourceeffects "love.audio.getMaxSourceEffects") * [love.audio.setEffect](love.audio.seteffect "love.audio.setEffect") love Transform:rotate Transform:rotate ================ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Applies a rotation to the Transform's coordinate system. This method does not reset any previously applied transformations. Function -------- ### Synopsis ``` transform = Transform:rotate( angle ) ``` ### Arguments `[number](number "number") angle` The relative angle in radians to rotate this Transform by. ### Returns `[Transform](transform "Transform") transform` The Transform object the method was called on. Allows easily chaining Transform methods. See Also -------- * [Transform](transform "Transform") * [Transform:reset](transform-reset "Transform:reset") * [Transform:translate](transform-translate "Transform:translate") * [Transform:scale](transform-scale "Transform:scale") * [Transform:shear](transform-shear "Transform:shear") * [Transform:setTransformation](transform-settransformation "Transform:setTransformation") love love.math.compress love.math.compress ================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | This function is deprecated and is replaced by [love.data.compress](love.data.compress "love.data.compress"). | Compresses a string or data using a specific compression algorithm. This function, depending on the compression format and level, can be slow if called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). Some benchmarks are available [here](https://github.com/Cyan4973/lz4#user-content-benchmarks). Function -------- ### Synopsis ``` compressedData = love.math.compress( rawstring, format, level ) ``` ### Arguments `[string](string "string") rawstring` The raw (un-compressed) string to compress. `[CompressedDataFormat](compresseddataformat "CompressedDataFormat") format ("lz4")` The format to use when compressing the string. `[number](number "number") level (-1)` The level of compression to use, between 0 and 9. -1 indicates the default level. The meaning of this argument depends on the compression format being used. ### Returns `[CompressedData](compresseddata "CompressedData") compressedData` A new Data object containing the compressed version of the string. Function -------- ### Synopsis ``` compressedData = love.math.compress( data, format, level ) ``` ### Arguments `[Data](data "Data") data` A Data object containing the raw (un-compressed) data to compress. `[CompressedDataFormat](compresseddataformat "CompressedDataFormat") format ("lz4")` The format to use when compressing the data. `[number](number "number") level (-1)` The level of compression to use, between 0 and 9. -1 indicates the default level. The meaning of this argument depends on the compression format being used. ### Returns `[CompressedData](compresseddata "CompressedData") compressedData` A new Data object containing the compressed version of the raw data. See Also -------- * [love.math](love.math "love.math") * [love.math.decompress](love.math.decompress "love.math.decompress") * [CompressedData](compresseddata "CompressedData") love Texture:getDPIScale Texture:getDPIScale =================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This method is not supported in earlier versions. Gets the DPI scale factor of the Texture. The DPI scale factor represents relative pixel density. A DPI scale factor of 2 means the texture has twice the pixel density in each dimension (4 times as many pixels in the same area) compared to a texture with a DPI scale factor of 1. For example, a texture with pixel dimensions of 100x100 with a DPI scale factor of 2 will be drawn as if it was 50x50. This is useful with high-dpi / retina displays to easily allow swapping out higher or lower pixel density Images and Canvases without needing any extra manual scaling logic. Function -------- ### Synopsis ``` dpiscale = Texture:getDPIScale( ) ``` ### Arguments None. ### Returns `[number](number "number") dpiscale` The DPI scale factor of the Texture. See Also -------- * [Texture](texture "Texture") * [Texture:getDimensions](texture-getdimensions "Texture:getDimensions") * [Texture:getPixelDimensions](texture-getpixeldimensions "Texture:getPixelDimensions") * [love.graphics.newImage](love.graphics.newimage "love.graphics.newImage") * [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") * [Config Files](love.conf "Config Files") love Body:getX Body:getX ========= Get the x position of the body in world coordinates. Function -------- ### Synopsis ``` x = Body:getX( ) ``` ### Arguments None. ### Returns `[number](number "number") x` The x position in world coordinates. See Also -------- * [Body](body "Body") love Source:setDistance Source:setDistance ================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [Source:setAttenuationDistances](source-setattenuationdistances "Source:setAttenuationDistances"). Sets the reference and maximum distance of the source. Function -------- ### Synopsis ``` Source:setDistance( ref, max ) ``` ### Arguments `[number](number "number") ref` The new reference distance. `[number](number "number") max` The new maximum distance. ### Returns Nothing. See Also -------- * [Source](source "Source") love World:rayCast World:rayCast ============= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Casts a ray and calls a function for each fixtures it intersects. Function -------- ### Synopsis ``` World:rayCast( x1, y1, x2, y2, callback ) ``` ### Arguments `[number](number "number") x1` The x position of the starting point of the ray. `[number](number "number") y1` The y position of the starting point of the ray. `[number](number "number") x2` The x position of the end point of the ray. `[number](number "number") y2` The y position of the end point of the ray. `[function](function "function") callback` A function called for each fixture intersected by the ray. The function gets six arguments and should return a number as a control value. The intersection points fed into the function will be in an arbitrary order. If you wish to find the closest point of intersection, you'll need to do that yourself within the function. The easiest way to do that is by using the fraction value. ### Returns Nothing. Callback -------- ### Synopsis ``` control = callback( fixture, x, y, xn, yn, fraction ) ``` ### Arguments `[Fixture](fixture "Fixture") fixture` The fixture intersecting the ray. `[number](number "number") x` The x position of the intersection point. `[number](number "number") y` The y position of the intersection point. `[number](number "number") xn` The x value of the surface normal vector of the shape edge. `[number](number "number") yn` The y value of the surface normal vector of the shape edge. `[number](number "number") fraction` The position of the intersection on the ray as a number from 0 to 1 (or even higher if the ray length was changed with the return value). ### Returns `[number](number "number") control` The ray can be controlled with the return value. A positive value sets a new ray length where 1 is the default value. A value of 0 terminates the ray. If the callback function returns -1, the intersection gets ignored as if it didn't happen. Notes ----- There is a bug in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") where the normal vector passed to the callback function gets scaled by [love.physics.getMeter](love.physics.getmeter "love.physics.getMeter"). Examples -------- ### Casting a ray over some random shapes. ``` function worldRayCastCallback(fixture, x, y, xn, yn, fraction) local hit = {} hit.fixture = fixture hit.x, hit.y = x, y hit.xn, hit.yn = xn, yn hit.fraction = fraction   table.insert(Ray.hitList, hit)   return 1 -- Continues with ray cast through all shapes. end   function createStuff() -- Cleaning up the previous stuff. for i = #Terrain.Stuff, 1, -1 do Terrain.Stuff[i].Fixture:destroy() Terrain.Stuff[i] = nil end   -- Generates some random shapes. for i = 1, 30 do local p = {}   p.x, p.y = math.random(100, 700), math.random(100, 500) local shapetype = math.random(3) if shapetype == 1 then local w, h, r = math.random() * 10 + 40, math.random() * 10 + 40, math.random() * math.pi * 2 p.Shape = love.physics.newRectangleShape(p.x, p.y, w, h, r) elseif shapetype == 2 then local a = math.random() * math.pi * 2 local x2, y2 = p.x + math.cos(a) * (math.random() * 30 + 20), p.y + math.sin(a) * (math.random() * 30 + 20) p.Shape = love.physics.newEdgeShape(p.x, p.y, x2, y2) else local r = math.random() * 40 + 10 p.Shape = love.physics.newCircleShape(p.x, p.y, r) end   p.Fixture = love.physics.newFixture(Terrain.Body, p.Shape)   Terrain.Stuff[i] = p end end   function love.keypressed() createStuff() end   function love.load() -- Setting this to 1 to avoid all current scaling bugs. love.physics.setMeter(1)   -- Start out with the same random stuff each start. math.randomseed(0xfacef00d)   World = love.physics.newWorld()   Terrain = {} Terrain.Body = love.physics.newBody(World, 0, 0, "static") Terrain.Stuff = {} createStuff()   Ray = { x1 = 0, y1 = 0, x2 = 0, y2 = 0, hitList = {} } end   function love.update(dt) local now = love.timer.getTime()   World:update(dt)   -- Clear fixture hit list. Ray.hitList = {}   -- Calculate ray position. local pos = (math.sin(now/4) + 1.2) * 0.4 Ray.x2, Ray.y2 = math.cos(pos * (math.pi/2)) * 1000, math.sin(pos * (math.pi/2)) * 1000   -- Cast the ray and populate the hitList table. World:rayCast(Ray.x1, Ray.y1, Ray.x2, Ray.y2, worldRayCastCallback) end   function love.draw() -- Drawing the terrain. love.graphics.setColor(255, 255, 255) for i, v in ipairs(Terrain.Stuff) do if v.Shape:getType() == "polygon" then love.graphics.polygon("line", Terrain.Body:getWorldPoints( v.Shape:getPoints() )) elseif v.Shape:getType() == "edge" then love.graphics.line(Terrain.Body:getWorldPoints( v.Shape:getPoints() )) else local x, y = Terrain.Body:getWorldPoints(v.x, v.y) love.graphics.circle("line", x, y, v.Shape:getRadius()) end end   -- Drawing the ray. love.graphics.setLineWidth(3) love.graphics.setColor(255, 255, 255, 100) love.graphics.line(Ray.x1, Ray.y1, Ray.x2, Ray.y2) love.graphics.setLineWidth(1)   -- Drawing the intersection points and normal vectors if there were any. for i, hit in ipairs(Ray.hitList) do love.graphics.setColor(255, 0, 0) love.graphics.print(i, hit.x, hit.y) -- Prints the hit order besides the point. love.graphics.circle("line", hit.x, hit.y, 3) love.graphics.setColor(0, 255, 0) love.graphics.line(hit.x, hit.y, hit.x + hit.xn * 25, hit.y + hit.yn * 25) end end ``` Screenshot of the example. See Also -------- * [World](world "World")
programming_docs
love love.window.isVisible love.window.isVisible ===================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Checks if the game window is visible. The window is considered visible if it's not minimized and the program isn't hidden. Function -------- ### Synopsis ``` visible = love.window.isVisible( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") visible` True if the window is visible or false if not. See Also -------- * [love.window](love.window "love.window") * [love.visible](love.visible "love.visible") love ParticleSystem:getImage ParticleSystem:getImage ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. **Removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** Use [ParticleSystem:getTexture](particlesystem-gettexture "ParticleSystem:getTexture") instead. Gets the image used for the particles. Function -------- ### Synopsis ``` image = ParticleSystem:getImage( ) ``` ### Arguments Nothing. ### Returns `[Image](image "Image") image` An Image to use for the particles. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setImage](particlesystem-setimage "ParticleSystem:setImage") love love.audio.getVolume love.audio.getVolume ==================== Returns the master volume. Function -------- ### Synopsis ``` volume = love.audio.getVolume( ) ``` ### Arguments None. ### Returns `[number](number "number") volume` The current master volume See Also -------- * [love.audio](love.audio "love.audio") love LineJoin LineJoin ======== Line join style. Constants --------- miter The ends of the line segments beveled in an angle so that they join seamlessly. none No cap applied to the ends of the line segments. bevel Flattens the point where line segments join together. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setLineJoin](love.graphics.setlinejoin "love.graphics.setLineJoin") love CanvasFormat CanvasFormat ============ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This enum is not supported in earlier versions. | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | It has been superseded by [PixelFormat](pixelformat "PixelFormat").. | [Canvas](canvas "Canvas") formats. Constants --------- normal The default Canvas format - usually an alias for the `rgba8` format, or the `srgb` format if [gamma-correct rendering](love.graphics.isgammacorrect "love.graphics.isGammaCorrect") is enabled in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0") and newer. hdr A format suitable for high dynamic range content - an alias for the `rgba16f` format, normally. rgba8 Available since 0.9.2 8 bits per channel (32 bpp) RGBA. Color channel values range from 0-255 (0-1 in shaders). rgba4 Available since 0.9.2 4 bits per channel (16 bpp) RGBA. rgb5a1 Available since 0.9.2 RGB with 5 bits each, and a 1-bit alpha channel (16 bpp). rgb565 Available since 0.9.2 RGB with 5, 6, and 5 bits each, respectively (16 bpp). There is no alpha channel in this format. rgb10a2 Available since 0.9.2 RGB with 10 bits per channel, and a 2-bit alpha channel (32 bpp). rgba16f Available since 0.9.2 Floating point RGBA with 16 bits per channel (64 bpp). Color values can range from [-65504, +65504]. rgba32f Available since 0.9.2 Floating point RGBA with 32 bits per channel (128 bpp). rg11b10f Available since 0.9.2 Floating point RGB with 11 bits in the red and green channels, and 10 bits in the blue channel (32 bpp). There is no alpha channel. Color values can range from [0, +65024]. srgb Available since 0.9.2 The same as `rgba8`, but the Canvas is *interpreted* as being in the sRGB color space. Everything drawn to the Canvas will be converted from linear RGB to sRGB. When the Canvas is drawn (or used in a shader), it will be decoded from sRGB to linear RGB. This reduces color banding when doing gamma-correct rendering, since sRGB encoding has more precision than linear RGB for darker colors. r8 Available since 0.10.0 Single-channel (red component) format (8 bpp). rg8 Available since 0.10.0 Two channels (red and green components) with 8 bits per channel (16 bpp). r16f Available since 0.10.0 Floating point single-channel format (16 bpp). Color values can range from [-65504, +65504]. rg16f Available since 0.10.0 Floating point two-channel format with 16 bits per channel (32 bpp). Color values can range from [-65504, +65504]. r32f Available since 0.10.0 Floating point single-channel format (32 bpp). rg32f Available since 0.10.0 Floating point two-channel format with 32 bits per channel (64 bpp). Notes ----- The 16 bpp RGB and RGBA formats use half as much VRAM as the 32 bpp RGBA formats, but they have significantly lower quality. The HDR / floating point formats are most useful when combined with pixel shaders. Effects such as tonemapped HDR with bloom can be accomplished, or the canvas can be used to store arbitrary non-color data such as positions which can then be used in a custom shader. The sRGB format should only be used when doing gamma-correct rendering, which is an advanced topic and it's easy to get color-spaces mixed up. If you're not sure whether you need this, you might want to avoid it. Read more about gamma-correct rendering [here](http://http.developer.nvidia.com/GPUGems3/gpugems3_ch24.html), [here](http://filmicgames.com/archives/299), and [here](http://renderwonk.com/blog/index.php/archive/adventures-with-gamma-correct-rendering/). Not all systems support every format. Use [love.graphics.getCanvasFormats](love.graphics.getcanvasformats "love.graphics.getCanvasFormats") to check before creating the Canvas. In general, `rgba8`, `rgba4`, and `rgb5a1` are supported everywhere. `rgb10a2` is also supported everywhere on desktop platforms. The regular single- and two-channel formats (`r8` and `rg8`), as well as the `srgb` format, are supported on desktop graphics cards capable of OpenGL 3+ / DirectX 10+ (nvidia GeForce 8000 series and up, ATI/AMD HD 2000 series and up, and the Intel HD 2000 and up), and mobile GPUs capable of OpenGL ES 3. The floating-point formats (`rgba16f`, `rgba32f`, `rg11b10f`, `r16f`, `rg16f`, `r32f`, and `rg32f`) are supported on OpenGL 3-capable desktop graphics cards, and some OpenGL ES 3 mobile GPUs. The 32-bit-per-channel floating point formats are rarely supported on mobile devices. `rgb565` is often only supported on OpenGL ES / mobile devices, or with very new desktop OpenGL drivers. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getCanvasFormats](love.graphics.getcanvasformats "love.graphics.getCanvasFormats") * [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") * [Canvas:getFormat](canvas-getformat "Canvas:getFormat") love love.graphics.getLineWidth love.graphics.getLineWidth ========================== **Available since LÖVE [0.3.2](https://love2d.org/wiki/0.3.2 "0.3.2")** This function is not supported in earlier versions. Gets the current line width. Function -------- ### Synopsis ``` width = love.graphics.getLineWidth( ) ``` ### Arguments None. ### Returns `[number](number "number") width` The current line width. Notes ----- 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 ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setLineWidth](love.graphics.setlinewidth "love.graphics.setLineWidth") love Body:setActive Body:setActive ============== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Sets whether the body is active in the world. An inactive body does not take part in the simulation. It will not move or cause any collisions. Function -------- ### Synopsis ``` Body:setActive( active ) ``` ### Arguments `[boolean](boolean "boolean") active` If the body is active or not. ### Returns Nothing. See Also -------- * [Body](body "Body") love ParticleSystem:getDirection ParticleSystem:getDirection =========================== Gets the direction of the particle emitter (in radians). Function -------- ### Synopsis ``` direction = ParticleSystem:getDirection( ) ``` ### Arguments None. ### Returns `[number](number "number") direction` The direction of the emitter (radians). See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love GraphicsFeature GraphicsFeature =============== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This enum is not supported in earlier versions. Graphics features that can be checked for with [love.graphics.getSupported](love.graphics.getsupported "love.graphics.getSupported"). Constants --------- clampzero Available since 0.10.0 Whether the "clampzero" [WrapMode](wrapmode "WrapMode") is supported. lighten Available since 0.10.0 Whether the "lighten" and "darken" [BlendModes](blendmode "BlendMode") are supported. multicanvasformats Available since 0.10.0 Whether multiple [Canvases](canvas "Canvas") with different [formats](canvasformat "CanvasFormat") can be used in the same [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas") call. ### Notes `clampzero` is supported on all desktop systems, but only some mobile devices. If it's not supported and it's attempted to be set, the "clamp" wrap mode will automatically be used instead. `lighten` is supported on all desktop systems, and OpenGL ES 3-capable mobile devices. `multicanvasformats` is supported on OpenGL 3-capable desktop systems, and OpenGL ES 3-capable mobile devices. glsl3 Available since 11.0 Whether GLSL 3 [Shaders](shader "Shader") can be used. instancing Available since 11.0 Whether [mesh instancing](love.graphics.drawinstanced "love.graphics.drawInstanced") is supported. fullnpot Available since 11.0 Whether textures with non-power-of-two dimensions can use [mipmapping](texture-setmipmapfilter "Texture:setMipmapFilter") and the 'repeat' [WrapMode](wrapmode "WrapMode"). pixelshaderhighp Available since 11.0 Whether pixel shaders can use "highp" 32 bit floating point numbers (as opposed to just 16 bit or lower precision). shaderderivatives Available since 11.0 Whether shaders can use the `dFdx`, `dFdy`, and `fwidth` functions for computing derivatives. ### Notes `glsl3` and `instancing` are supported on OpenGL 3 and OpenGL ES 3-capable systems. `instancing` is also supported on some older systems that don't support GLSL 3, but [vertex attribute-based](mesh-attachattribute "Mesh:attachAttribute") instancing must be used in that case (instead of `love_InstanceID` in a GLSL 3 shader). `fullnpot`, `pixelshaderhighp`, and `shaderderivatives` are supported on all desktop systems and most mobile systems, except for some older OpenGL ES 2 devices. canvas Removed in 0.10.0 Support for [Canvas](canvas "Canvas"). npot Removed in 0.10.0 Support for textures with non-power-of-two sizes. See [PO2 Syndrome](https://love2d.org/wiki/PO2_Syndrome "PO2 Syndrome"). subtractive Removed in 0.10.0 Support for the subtractive [blend mode](blendmode "BlendMode"). shader Available since 0.9.0 and removed in LÖVE 0.10.0 Support for [Shaders](shader "Shader"). hdrcanvas Available since 0.9.0 and removed in LÖVE 0.10.0 Support for HDR [Canvases](canvas "Canvas"). Use [love.graphics.getCanvasFormats](love.graphics.getcanvasformats "love.graphics.getCanvasFormats") instead. multicanvas Available since 0.9.0 and removed in LÖVE 0.10.0 Support for simultaneous rendering to at least 4 [canvases](canvas "Canvas") at once, with [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas"). Use [love.graphics.getSystemLimits](love.graphics.getsystemlimits "love.graphics.getSystemLimits") instead. mipmap Available since 0.9.0 and removed in LÖVE 0.10.0 Support for Mipmaps. dxt Available since 0.9.0 and removed in LÖVE 0.10.0 Support for DXT compressed images (see [CompressedFormat](compressedformat "CompressedFormat").) Use [love.graphics.getCompressedImageFormats](love.graphics.getcompressedimageformats "love.graphics.getCompressedImageFormats") instead. bc5 Available since 0.9.0 and removed in LÖVE 0.10.0 Support for BC4 and BC5 compressed images. Use [love.graphics.getCompressedImageFormats](love.graphics.getcompressedimageformats "love.graphics.getCompressedImageFormats") instead. Use [love.graphics.isGammaCorrect](love.graphics.isgammacorrect "love.graphics.isGammaCorrect") or [love.graphics.getCanvasFormats](love.graphics.getcanvasformats "love.graphics.getCanvasFormats") instead srgb Available since 0.9.1 and removed in LÖVE 0.10.0 Support for gamma-correct rendering with the `srgb` window flag in [love.window.setMode](love.window.setmode "love.window.setMode"), and the "srgb" [TextureFormat](textureformat "TextureFormat") for [Canvases](love.graphics.newcanvas "love.graphics.newCanvas") and [Images](love.graphics.newimage "love.graphics.newImage"). pixeleffect Removed in 0.9.0 Support for [PixelEffects](pixeleffect "PixelEffect"). ### Notes [Canvases](canvas "Canvas"), [Shaders](shader "Shader"), mipmaps, npot textures, and the subtract [BlendMode](blendmode "BlendMode") are always supported in version [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0") and newer (due to its system requirements.) For previous versions: `subtractive`, `mipmap`, and `dxt` are supported on nearly every system. `canvas`, `multicanvas`, `npot`, and `shader` have roughly the same minimum requirements for support: a DirectX 9.0c+ capable graphics card with drivers that support ~OpenGL 2.1+. `hdrcanvas`, `bc5`, and `srgb` all share mostly the same minimum requirements for support as well: a DirectX 10+ capable graphics card with drivers that support ~OpenGL 3+. DirectX 9.0c+ capable graphics cards include the nvidia GeForce 5000-series (2003) and newer, the ATI Radeon 9000-series and newer, and the Intel GMA x3100 GPU and newer. DirectX 10+ capable graphics cards include the nvidia GeForce 8000-series (2006) and newer, the ATI/AMD HD 2000-series and newer, and the Intel HD 2000/3000 GPUs and newer. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getSupported](love.graphics.getsupported "love.graphics.getSupported") love (File):tell (File):tell =========== Returns the position in the file. Function -------- ### Synopsis ``` pos = File:tell( ) ``` ### Arguments None. ### Returns `[number](number "number") pos` The current position. See Also -------- * [File](file "File") love love.quit love.quit ========= **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This callback is not supported in earlier versions. Callback function triggered when the game is closed. Function -------- ### Synopsis ``` r = love.quit( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") r` Abort quitting. If true, do not close the game. Example ------- This example shows how the return value of **love.quit** can be used to stop the closing of the game. ``` local quit = true function love.quit() if quit then print("We are not ready to quit yet!") quit = not quit else print("Thanks for playing. Please play again soon!") return quit end return true end ``` See Also -------- * [love](love "love") * [love.event.quit](love.event.quit "love.event.quit") love love.graphics.getMaxImageSize love.graphics.getMaxImageSize ============================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** Use [love.graphics.getSystemLimits](love.graphics.getsystemlimits "love.graphics.getSystemLimits") instead. Gets the max supported width or height of [Images](image "Image") and [Canvases](canvas "Canvas"). Attempting to create an Image with a width \*or\* height greater than this number will create a checkerboard-patterned image instead. Doing the same for a canvas will result in an error. The returned number depends on the system running the code. It is safe to assume it will never be less than 1024 and will almost always be 2048 or greater. Function -------- ### Synopsis ``` size = love.graphics.getMaxImageSize( ) ``` ### Arguments None. ### Returns `[number](number "number") size` The max supported width or height of Images and Canvases. Notes ----- There is an [online database](http://feedback.wildfiregames.com/report/opengl/feature/GL_MAX_TEXTURE_SIZE) which has collected info about the max image size for various systems. See Also -------- * [love.graphics](love.graphics "love.graphics") * [Image](image "Image") * [Canvas](canvas "Canvas") love enet.peer:reset enet.peer:reset =============== Forcefully disconnects [peer](enet.peer "enet.peer"). The [peer](enet.peer "enet.peer") is not notified of the disconnection. Function -------- ### Synopsis ``` peer:reset() ``` ### Arguments None. ### Returns Nothing. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.peer](enet.peer "enet.peer") love Shape:getCategory Shape:getCategory ================= **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** Use [Fixture:setCategory](fixture-setcategory "Fixture:setCategory") instead. Gets the categories this shape is a member of. The number of categories the shape is a member of is the number of return values. Categories are used for allowing/disallowing certain collision. Function -------- ### Synopsis ``` ... = Shape:getCategory( ) ``` ### Arguments None. ### Returns `[numbers](https://love2d.org/w/index.php?title=numbers&action=edit&redlink=1 "numbers (page does not exist)") ...` Numbers from 1-16. See Also -------- * [Shape](shape "Shape") love love.math.getRandomState love.math.getRandomState ======================== **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. Gets the current state of the random number generator. This returns an opaque implementation-dependent string which is only useful for later use with [love.math.setRandomState](love.math.setrandomstate "love.math.setRandomState") or [RandomGenerator:setState](randomgenerator-setstate "RandomGenerator:setState"). This is different from [love.math.getRandomSeed](love.math.getrandomseed "love.math.getRandomSeed") in that getRandomState gets the random number generator's current state, whereas getRandomSeed gets the previously set seed number. Function -------- ### Synopsis ``` state = love.math.getRandomState( ) ``` ### Arguments None. ### Returns `[string](string "string") state` The current state of the random number generator, represented as a string. Notes ----- The value of the state string does not depend on the current operating system. See Also -------- * [love.math](love.math "love.math") * [love.math.setRandomState](love.math.setrandomstate "love.math.setRandomState")
programming_docs
love Source:getChannels Source:getChannels ================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | This function has been renamed to [Source:getChannelCount](source-getchannelcount "Source:getChannelCount"). | Gets the number of channels in the Source. Only 1-channel (mono) Sources can use directional and positional effects. Function -------- ### Synopsis ``` channels = Source:getChannels( ) ``` ### Arguments None. ### Returns `[number](number "number") channels` 1 for mono, 2 for stereo. See Also -------- * [Source](source "Source") love Data:clone Data:clone ========== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Creates a new copy of the Data object. Function -------- ### Synopsis ``` clone = Data:clone( ) ``` ### Arguments None. ### Returns `[Data](data "Data") clone` The new copy. See Also -------- * [Data](data "Data") love love.window.isMinimized love.window.isMinimized ======================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets whether the Window is currently [minimized](love.window.minimize "love.window.minimize"). Function -------- ### Synopsis ``` minimized = love.window.isMinimized( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") minimized` True if the window is currently minimized, false otherwise. See Also -------- * [love.window](love.window "love.window") * [love.window.minimize](love.window.minimize "love.window.minimize") * [love.window.restore](love.window.restore "love.window.restore") love Source:getPitch Source:getPitch =============== Gets the current pitch of the Source. Function -------- ### Synopsis ``` pitch = Source:getPitch( ) ``` ### Arguments None. ### Returns `[number](number "number") pitch` The pitch, where 1.0 is normal. See Also -------- * [Source](source "Source") love WheelJoint:setMaxMotorTorque WheelJoint:setMaxMotorTorque ============================ **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Sets a new maximum motor torque. Function -------- ### Synopsis ``` WheelJoint:setMaxMotorTorque( maxTorque ) ``` ### Arguments `[number](number "number") maxTorque` The new maximum torque for the joint motor in newton meters. ### Returns Nothing See Also -------- * [WheelJoint](wheeljoint "WheelJoint") * [WheelJoint:getMaxMotorTorque](wheeljoint-getmaxmotortorque "WheelJoint:getMaxMotorTorque") love love.graphics.line love.graphics.line ================== Draws lines between points. Function -------- ### Synopsis ``` love.graphics.line( x1, y1, x2, y2, ... ) ``` ### Arguments `[number](number "number") x1` The position of first point on the x-axis. `[number](number "number") y1` The position of first point on the y-axis. `[number](number "number") x2` The position of second point on the x-axis. `[number](number "number") y2` The position of second point on the y-axis. `[number](number "number") ...` You can continue passing point positions to draw a polyline. ### Returns Nothing. Function -------- ### Synopsis ``` love.graphics.line( points ) ``` ### Arguments `[table](table "table") points` A table of point positions, as described above. ### Returns Nothing. Examples -------- Draw the outline of a simple trapezoid. ``` function love.draw() love.graphics.line(200,50, 400,50, 500,300, 100,300, 200,50) -- last pair is a repeat to complete the trapezoid end ``` Draw a line from the center of the screen to the mouse pointer. ``` w = love.graphics.getWidth() / 2 -- half the window width h = love.graphics.getHeight() / 2 -- half the window height function love.draw() local mx, my = love.mouse.getPosition() -- current position of the mouse love.graphics.line(w, h, mx, my) end ``` Draw a zigzag line from a single table. ``` sometable = { 100, 100, 200, 200, 300, 100, 400, 200, } function love.draw() love.graphics.line(sometable) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setLine](love.graphics.setline "love.graphics.setLine") * [love.graphics.setLineWidth](love.graphics.setlinewidth "love.graphics.setLineWidth") * [love.graphics.setLineStyle](love.graphics.setlinestyle "love.graphics.setLineStyle") love Contact:setRestitution Contact:setRestitution ====================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Sets the contact restitution. Function -------- ### Synopsis ``` Contact:setRestitution( restitution ) ``` ### Arguments `[number](number "number") restitution` The contact restitution. ### Returns Nothing. See Also -------- * [Contact](contact "Contact") love EffectWaveform EffectWaveform ============== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This enum is not supported in earlier versions. The different types of waveforms that can be used with the **ringmodulator** [EffectType](effecttype "EffectType"). Constants --------- sawtooth A sawtooth wave, also known as a ramp wave. Named for its linear rise, and (near-)instantaneous fall along time. sine A sine wave. Follows a trigonometric sine function. square A square wave. Switches between high and low states (near-)instantaneously. triangle A triangle wave. Follows a linear rise and fall that repeats periodically. See Also -------- * [love.audio](love.audio "love.audio") * [EffectType](effecttype "EffectType") love love.physics.newDistanceJoint love.physics.newDistanceJoint ============================= Creates a [DistanceJoint](distancejoint "DistanceJoint") between two bodies. This joint constrains the distance between two points on two bodies to be constant. These two points are specified in world coordinates and the two bodies are assumed to be in place when this joint is created. The first anchor point is connected to the first body and the second to the second body, and the points define the length of the distance joint. Making changes to a [World](world "World") is not allowed inside of the [beginContact](https://love2d.org/w/index.php?title=beginContact&action=edit&redlink=1 "beginContact (page does not exist)"), [endContact](https://love2d.org/w/index.php?title=endContact&action=edit&redlink=1 "endContact (page does not exist)"), [preSolve](https://love2d.org/w/index.php?title=preSolve&action=edit&redlink=1 "preSolve (page does not exist)"), and [postSolve](https://love2d.org/w/index.php?title=postSolve&action=edit&redlink=1 "postSolve (page does not exist)") callback functions, as BOX2D locks the world during these callbacks. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in earlier versions. ### Synopsis ``` joint = love.physics.newDistanceJoint( body1, body2, x1, y1, x2, y2, collideConnected ) ``` ### Arguments `[Body](body "Body") body1` The first body to attach to the joint. `[Body](body "Body") body2` The second body to attach to the joint. `[number](number "number") x1` The x position of the first anchor point (world space). `[number](number "number") y1` The y position of the first anchor point (world space). `[number](number "number") x2` The x position of the second anchor point (world space). `[number](number "number") y2` The y position of the second anchor point (world space). `[boolean](boolean "boolean") collideConnected (false)` Specifies whether the two bodies should collide with each other. ### Returns `[DistanceJoint](distancejoint "DistanceJoint") joint` The new distance joint. Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. ### Synopsis ``` joint = love.physics.newDistanceJoint( body1, body2, x1, y1, x2, y2 ) ``` ### Arguments `[Body](body "Body") body1` The first body to attach to the joint. `[Body](body "Body") body2` The second body to attach to the joint. `[number](number "number") x1` The x position of the first anchor point (world space). `[number](number "number") y1` The y position of the first anchor point (world space). `[number](number "number") x2` The x position of the second anchor point (world space). `[number](number "number") y2` The y position of the second anchor point (world space). ### Returns `[DistanceJoint](distancejoint "DistanceJoint") joint` The new distance joint. See Also -------- * [love.physics](love.physics "love.physics") * [DistanceJoint](distancejoint "DistanceJoint") * [Joint](joint "Joint") love ParticleSystem:getColors ParticleSystem:getColors ======================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the series of colors applied to the particle sprite. In versions prior to [11.0](https://love2d.org/wiki/11.0 "11.0"), color component values were within the range of 0 to 255 instead of 0 to 1. Function -------- ### Synopsis ``` rgba1, rgba2, ..., rgba8 = ParticleSystem:getColors( ) ``` ### Arguments Nothing. ### Returns `[table](table "table") rgba1` First color, a numerical indexed table with the red, green, blue and alpha values as numbers (0-1). `[table](table "table") rgba2` Second color, a numerical indexed table with the red, green, blue and alpha values as numbers (0-1). `[table](table "table") rgba8` Eighth color, a numerical indexed table with the red, green, blue and alpha values as numbers (0-1). See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setColors](particlesystem-setcolors "ParticleSystem:setColors") love love.graphics.getSupported love.graphics.getSupported ========================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** It has replaced [love.graphics.isSupported](love.graphics.issupported "love.graphics.isSupported"). 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. Function -------- ### Synopsis ``` features = love.graphics.getSupported( ) ``` ### Arguments None. ### Returns `[table](table "table") features` A table containing [GraphicsFeature](graphicsfeature "GraphicsFeature") keys, and boolean values indicating whether each feature is supported. See Also -------- * [love.graphics](love.graphics "love.graphics") * [GraphicsFeature](graphicsfeature "GraphicsFeature") love (Image):getData (Image):getData =============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0") and removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** Create an [ImageData](imagedata "ImageData") from a file, create the Image from that, and keep a reference to the ImageData, instead of using this function. Gets the original [ImageData](imagedata "ImageData") or [CompressedData](compresseddata "CompressedData") used to create the Image. All Images keep a reference to the Data that was used to create the Image. The Data is used to refresh the Image when [love.window.setMode](love.window.setmode "love.window.setMode") or [Image:refresh]((image)-refresh "(Image):refresh") is called. Function -------- ### Synopsis ``` data = Image:getData( ) ``` ### Arguments None. ### Returns `[ImageData](imagedata "ImageData") data` The original ImageData used to create the Image, if the image is not compressed. Function -------- ### Synopsis ``` data = Image:getData( ) ``` ### Arguments None. ### Returns `[CompressedData](compresseddata "CompressedData") data` The original CompressedData used to create the Image, if the image is compressed. Examples -------- Edit the Image's ImageData and refresh the Image using the edited ImageData. ``` function love.load() image = love.graphics.newImage("pig.png") end   function love.draw() love.graphics.draw(image) end   function love.keypressed(key) -- If the image is compressed, it will return CompressedData which doesn't have a mapPixel method. -- Currently only dds files can become compressed images. if key == "e" and not image:isCompressed() then local data = image:getData() data:mapPixel(function(x, y, r, g, b, a) return r/2, g/2, b/2, a/2 end) image:refresh() end end ``` See Also -------- * [Image](image "Image") * [Image:refresh]((image)-refresh "(Image):refresh") * [Image:isCompressed]((image)-iscompressed "(Image):isCompressed") love love.graphics.getDPIScale love.graphics.getDPIScale ========================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. 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](love.window.setmode "love.window.setMode") 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](love.window.frompixels "love.window.fromPixels") and [love.window.toPixels](love.window.topixels "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. Function -------- ### Synopsis ``` scale = love.graphics.getDPIScale( ) ``` ### Arguments None. ### Returns `[number](number "number") scale` The pixel scale factor associated with the window. Notes ----- The units of [love.graphics.getWidth](love.graphics.getwidth "love.graphics.getWidth"), [love.graphics.getHeight](love.graphics.getheight "love.graphics.getHeight"), [love.mouse.getPosition](love.mouse.getposition "love.mouse.getPosition"), mouse events, [love.touch.getPosition](love.touch.getposition "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. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getDimensions](love.graphics.getdimensions "love.graphics.getDimensions") * [love.graphics.getPixelDimensions](love.graphics.getpixeldimensions "love.graphics.getPixelDimensions") * [love.window.toPixels](love.window.topixels "love.window.toPixels") * [love.window.fromPixels](love.window.frompixels "love.window.fromPixels") * [love.window.setMode](love.window.setmode "love.window.setMode") * [Config Files](love.conf "Config Files") love love.filesystem.isSymlink love.filesystem.isSymlink ========================= **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | This function is deprecated and is replaced by [love.filesystem.getInfo](love.filesystem.getinfo "love.filesystem.getInfo"). | Gets whether a filepath is actually a symbolic link. If symbolic links are not enabled (via [love.filesystem.setSymlinksEnabled](love.filesystem.setsymlinksenabled "love.filesystem.setSymlinksEnabled")), this function will always return false. Function -------- ### Synopsis ``` symlink = love.filesystem.isSymlink( path ) ``` ### Arguments `[string](string "string") path` The file or directory path to check. ### Returns `[boolean](boolean "boolean") symlink` True if the path is a symbolic link, false otherwise. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [love.filesystem.setSymlinksEnabled](love.filesystem.setsymlinksenabled "love.filesystem.setSymlinksEnabled") * [love.filesystem.areSymlinksEnabled](love.filesystem.aresymlinksenabled "love.filesystem.areSymlinksEnabled") love Transform:isAffine2DTransform Transform:isAffine2DTransform ============================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Checks whether the Transform is an affine transformation. Function -------- ### Synopsis ``` affine = Transform:isAffine2DTransform() ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") affine` `true` if the transform object is an affine transformation, `false` otherwise. See Also -------- * [Transform](transform "Transform") love Font:getDescent Font:getDescent =============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the descent of the Font. The descent spans the distance between the baseline and the lowest descending glyph in a typeface. Function -------- ### Synopsis ``` descent = Font:getDescent( ) ``` ### Arguments None. ### Returns `[number](number "number") descent` The descent of the Font in pixels. See Also -------- * [Font](font "Font") * [Font:getAscent](font-getascent "Font:getAscent") * [Font:getBaseline](font-getbaseline "Font:getBaseline") love love.physics.newMotorJoint love.physics.newMotorJoint ========================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Creates a joint between two bodies which controls the relative motion between them. Position and rotation offsets can be specified once the MotorJoint has been created, as well as the maximum motor force and torque that will be be applied to reach the target offsets. Function -------- ### Synopsis ``` joint = love.physics.newMotorJoint( body1, body2, correctionFactor ) ``` ### Arguments `[Body](body "Body") body1` The first body to attach to the joint. `[Body](body "Body") body2` The second body to attach to the joint. `[number](number "number") correctionFactor (0.3)` The joint's initial position correction factor, in the range of [0, 1]. ### Returns `[MotorJoint](motorjoint "MotorJoint") joint` The new MotorJoint. Function -------- **Available since LÖVE [0.10.1](https://love2d.org/wiki/0.10.1 "0.10.1")** This variant is not supported in earlier versions. ### Synopsis ``` joint = love.physics.newMotorJoint( body1, body2, correctionFactor, collideConnected ) ``` ### Arguments `[Body](body "Body") body1` The first body to attach to the joint. `[Body](body "Body") body2` The second body to attach to the joint. `[number](number "number") correctionFactor (0.3)` The joint's initial position correction factor, in the range of [0, 1]. `[boolean](boolean "boolean") collideConnected (false)` Specifies whether the two bodies should collide with each other. ### Returns `[MotorJoint](motorjoint "MotorJoint") joint` The new MotorJoint. See Also -------- * [love.physics](love.physics "love.physics") * [MotorJoint](motorjoint "MotorJoint") * [Joint](joint "Joint") love love.graphics.shear love.graphics.shear =================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Shears the coordinate system. In version 0.9.2, a bug caused this function to reset all transformations. It was fixed in [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0"). A workaround for 0.9.2 would be to use a combination of rotating and scaling to imitate shearing. Function -------- ### Synopsis ``` love.graphics.shear( kx, ky ) ``` ### Arguments `[number](number "number") kx` The shear factor on the x-axis. `[number](number "number") ky` The shear factor on the y-axis. ### Returns Nothing. Examples -------- ### Squish a rectangle ``` function love.draw() love.graphics.translate(100, 100) local t = love.timer.getTime() love.graphics.shear(math.cos(t), math.cos(t * 1.3)) love.graphics.rectangle('fill', 0, 0, 100, 50) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.pop](love.graphics.pop "love.graphics.pop") * [love.graphics.push](love.graphics.push "love.graphics.push") * [love.graphics.rotate](love.graphics.rotate "love.graphics.rotate") * [love.graphics.scale](love.graphics.scale "love.graphics.scale") * [love.graphics.translate](love.graphics.translate "love.graphics.translate") * [love.graphics.origin](love.graphics.origin "love.graphics.origin")
programming_docs
love ParticleSystem:setOffset ParticleSystem:setOffset ======================== Set the offset position which the particle sprite is rotated around. If this function is not used, the particles rotate around their center. Function -------- ### Synopsis ``` ParticleSystem:setOffset( x, y ) ``` ### Arguments `[number](number "number") x` The x coordinate of the rotation offset. `[number](number "number") y` The y coordinate of the rotation offset. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love love.window.isOpen love.window.isOpen ================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function has been renamed from [love.window.isCreated](love.window.iscreated "love.window.isCreated"). Checks if the window is open. Function -------- ### Synopsis ``` open = love.window.isOpen( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") open` True if the window is open, false otherwise. See Also -------- * [love.window](love.window "love.window") * [love.window.isCreated](love.window.iscreated "love.window.isCreated") love love.filesystem.setRequirePath love.filesystem.setRequirePath ============================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Sets the filesystem paths that will be searched when [require](https://www.lua.org/manual/5.1/manual.html#pdf-require) is called. The paths string given to this function is a sequence of path templates separated by semicolons. The argument passed to *require* will be inserted in place of any question mark ("?") character in each template (after the dot characters in the argument passed to *require* are replaced by directory separators.) The paths are relative to the game's source and save directories, as well as any paths mounted with [love.filesystem.mount](love.filesystem.mount "love.filesystem.mount"). Function -------- ### Synopsis ``` love.filesystem.setRequirePath( paths ) ``` ### Arguments `[string](string "string") paths` The paths that the *require* function will check in love's filesystem. ### Returns Nothing. Notes ----- The default paths string is `"?.lua;?/init.lua"`, which makes `require("cool")` try to load `cool.lua` and then try `cool/init.lua` if cool.lua doesn't exist. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [love.filesystem.getRequirePath](love.filesystem.getrequirepath "love.filesystem.getRequirePath") love love.thread.newThread love.thread.newThread ===================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Creates a new Thread from a filename, string or [FileData](filedata "FileData") object containing Lua code. Function -------- **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in earlier versions. ### Synopsis ``` thread = love.thread.newThread( filename ) ``` ### Arguments `[string](string "string") filename` The name of the Lua file to use as the source. ### Returns `[Thread](thread "Thread") thread` A new Thread that has yet to be started. Function -------- **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in earlier versions. ### Synopsis ``` thread = love.thread.newThread( fileData ) ``` ### Arguments `[FileData](filedata "FileData") fileData` The FileData containing the Lua code to use as the source. ### Returns `[Thread](thread "Thread") thread` A new Thread that has yet to be started. Function -------- **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This variant is not supported in earlier versions. ### Synopsis ``` thread = love.thread.newThread( codestring ) ``` ### Arguments `[string](string "string") codestring` A string containing the Lua code to use as the source. It needs to either be at least 1024 characters long, or contain at least one newline. ### Returns `[Thread](thread "Thread") thread` A new Thread that has yet to be started. Function -------- **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in that and later versions. ### Synopsis ``` thread = love.thread.newThread( name, filename ) ``` ### Arguments `[string](string "string") name` The name of the thread. `[string](string "string") filename` The name of the File to use as source. ### Returns `[Thread](thread "Thread") thread` A new Thread that has yet to be started. Function -------- **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in that and later versions. ### Synopsis ``` thread = love.thread.newThread( name, file ) ``` ### Arguments `[string](string "string") name` The name of the thread. `[File](file "File") file` The file to use as source. ### Returns `[Thread](thread "Thread") thread` A new Thread that has yet to be started. Function -------- **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in that and later versions. ### Synopsis ``` thread = love.thread.newThread( name, data ) ``` ### Arguments `[string](string "string") name` The name of the thread. `[Data](data "Data") data` The data to use as source. ### Returns `[Thread](thread "Thread") thread` A new Thread that has yet to be started. See Also -------- * [love.thread](love.thread "love.thread") * [Thread](thread "Thread") love love.filesystem.setIdentity love.filesystem.setIdentity =========================== Sets the write directory for your game. Note that you can only set the name of the folder to store your files in, not the location. Function -------- ### Synopsis ``` love.filesystem.setIdentity( name ) ``` ### Arguments `[string](string "string") name` The new identity that will be used as write directory. ### Returns Nothing. Function -------- **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.filesystem.setIdentity( name, appendToPath ) ``` ### Arguments `[string](string "string") name` The new identity that will be used as write directory. `[boolean](boolean "boolean") appendToPath (false)` Whether the identity directory will be searched when reading a filepath before or after the game's source directory and any currently. TRUE: results in searching source before searching save directory; FALSE: results in searching game save directory before searching source directory[mounted](love.filesystem.mount "love.filesystem.mount") archives. ### Returns Nothing. Examples -------- ### Setting the game folder name ``` -- Yes: love.filesystem.setIdentity("monkey_doom_2") -- No: love.filesystem.setIdentity("c:/Users/bob/monkey_doom_2") ``` ### Setting which to search first ``` --Search Source, then the save directory love.filesystem.setIdentity(love.filesystem.getIdentity(),true) --Search Save directory, then the Source Directory love.filesystem.setIdentity(love.filesystem.getIdentity(),false) ``` See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [love.filesystem.getIdentity](love.filesystem.getidentity "love.filesystem.getIdentity") love love.mouse love.mouse ========== Provides an interface to the user's mouse. Types ----- | | | | | | --- | --- | --- | --- | | [Cursor](cursor "Cursor") | Represents a hardware cursor. | 0.9.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [love.mouse.getCursor](love.mouse.getcursor "love.mouse.getCursor") | Gets the current Cursor. | 0.9.0 | | | [love.mouse.getPosition](love.mouse.getposition "love.mouse.getPosition") | Returns the current position of the mouse. | 0.3.2 | | | [love.mouse.getRelativeMode](love.mouse.getrelativemode "love.mouse.getRelativeMode") | Gets whether relative mode is enabled for the mouse. | 0.9.2 | | | [love.mouse.getSystemCursor](love.mouse.getsystemcursor "love.mouse.getSystemCursor") | Gets a [Cursor](cursor "Cursor") object representing a system-native hardware cursor. | 0.9.0 | | | [love.mouse.getX](love.mouse.getx "love.mouse.getX") | Returns the current x-position of the mouse. | | | | [love.mouse.getY](love.mouse.gety "love.mouse.getY") | Returns the current y-position of the mouse. | | | | [love.mouse.hasCursor](love.mouse.hascursor "love.mouse.hasCursor") | Gets whether cursor functionality is supported. | 0.10.0 | 11.0 | | [love.mouse.isCursorSupported](love.mouse.iscursorsupported "love.mouse.isCursorSupported") | Gets whether cursor functionality is supported. | 11.0 | | | [love.mouse.isDown](love.mouse.isdown "love.mouse.isDown") | Checks whether a certain button is down. | | | | [love.mouse.isGrabbed](love.mouse.isgrabbed "love.mouse.isGrabbed") | Checks if the mouse is grabbed. | | | | [love.mouse.isVisible](love.mouse.isvisible "love.mouse.isVisible") | Checks if the cursor is visible. | | | | [love.mouse.newCursor](love.mouse.newcursor "love.mouse.newCursor") | Creates a new hardware [Cursor](cursor "Cursor") object from an image. | 0.9.0 | | | [love.mouse.setCursor](love.mouse.setcursor "love.mouse.setCursor") | Sets the current mouse cursor. | 0.9.0 | | | [love.mouse.setGrab](love.mouse.setgrab "love.mouse.setGrab") | Grabs the mouse and confines it to the window. | | 0.9.0 | | [love.mouse.setGrabbed](love.mouse.setgrabbed "love.mouse.setGrabbed") | Grabs the mouse and confines it to the window. | 0.9.0 | | | [love.mouse.setPosition](love.mouse.setposition "love.mouse.setPosition") | Sets the current position of the mouse. | | | | [love.mouse.setRelativeMode](love.mouse.setrelativemode "love.mouse.setRelativeMode") | Sets whether relative mode is enabled for the mouse. | 0.9.2 | | | [love.mouse.setVisible](love.mouse.setvisible "love.mouse.setVisible") | Sets the current visibility of the cursor. | | | | [love.mouse.setX](love.mouse.setx "love.mouse.setX") | Sets the current X position of the mouse. | 0.9.0 | | | [love.mouse.setY](love.mouse.sety "love.mouse.setY") | Sets the current Y position of the mouse. | 0.9.0 | | Enums ----- | | | | | | --- | --- | --- | --- | | [CursorType](cursortype "CursorType") | Types of hardware cursors. | 0.9.0 | | | [MouseConstant](mouseconstant "MouseConstant") | Mouse buttons. | | 0.10.0 | See Also -------- * [love](love "love") * [love.mousepressed](love.mousepressed "love.mousepressed") * [love.mousereleased](love.mousereleased "love.mousereleased") * [love.mousemoved](love.mousemoved "love.mousemoved") * [love.wheelmoved](love.wheelmoved "love.wheelmoved") love CircleShape:setRadius CircleShape:setRadius ===================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Sets the radius of the circle. Function -------- ### Synopsis ``` CircleShape:setRadius( radius ) ``` ### Arguments `[number](number "number") radius` The radius of the circle ### Returns Nothing. See Also -------- * [CircleShape](circleshape "CircleShape") love GlyphData GlyphData ========= **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This type is not supported in earlier versions. A GlyphData represents a drawable symbol of a font Rasterizer. Constructors ------------ | | | | | | --- | --- | --- | --- | | [Rasterizer:getGlyphData](rasterizer-getglyphdata "Rasterizer:getGlyphData") | Gets glyph data of a specified glyph. | 0.7.0 | | | [love.font.newGlyphData](love.font.newglyphdata "love.font.newGlyphData") | Creates a new GlyphData. | 0.7.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Data:clone](data-clone "Data:clone") | Creates a new copy of the Data object. | 11.0 | | | [Data:getFFIPointer](data-getffipointer "Data:getFFIPointer") | Gets an FFI pointer to the Data. | 11.3 | | | [Data:getPointer](data-getpointer "Data:getPointer") | Gets a pointer to the Data. | | | | [Data:getSize](data-getsize "Data:getSize") | Gets the [Data](data "Data")'s size in bytes. | | | | [Data:getString](data-getstring "Data:getString") | Gets the full Data as a string. | 0.9.0 | | | [GlyphData:getAdvance](glyphdata-getadvance "GlyphData:getAdvance") | Gets glyph advance. | 0.7.0 | | | [GlyphData:getBearing](glyphdata-getbearing "GlyphData:getBearing") | Gets glyph bearing. | 0.7.0 | | | [GlyphData:getBoundingBox](glyphdata-getboundingbox "GlyphData:getBoundingBox") | Gets glyph bounding box. | 0.7.0 | | | [GlyphData:getDimensions](glyphdata-getdimensions "GlyphData:getDimensions") | Gets glyph dimensions. | 0.7.0 | | | [GlyphData:getFormat](glyphdata-getformat "GlyphData:getFormat") | Gets glyph pixel format. | 11.0 | | | [GlyphData:getGlyph](glyphdata-getglyph "GlyphData:getGlyph") | Gets glyph number. | 0.7.0 | | | [GlyphData:getGlyphString](glyphdata-getglyphstring "GlyphData:getGlyphString") | Gets glyph string. | 0.7.0 | | | [GlyphData:getHeight](glyphdata-getheight "GlyphData:getHeight") | Gets glyph height. | 0.7.0 | | | [GlyphData:getWidth](glyphdata-getwidth "GlyphData:getWidth") | Gets glyph width. | 0.7.0 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Supertypes ---------- * [Data](data "Data") * [Object](object "Object") See Also -------- * [love.font](love.font "love.font") love Fixture:setRestitution Fixture:setRestitution ====================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Sets the restitution of the fixture. Function -------- ### Synopsis ``` Fixture:setRestitution( restitution ) ``` ### Arguments `[number](number "number") restitution` The fixture restitution. ### Returns Nothing. See Also -------- * [Fixture](fixture "Fixture") * [Fixture:getRestitution](fixture-getrestitution "Fixture:getRestitution") love ParticleSystem:getPosition ParticleSystem:getPosition ========================== Gets the position of the emitter. Function -------- ### Synopsis ``` x, y = ParticleSystem:getPosition( ) ``` ### Arguments None. ### Returns `[number](number "number") x` Position along x-axis. `[number](number "number") y` Position along y-axis. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love Shape:setSensor Shape:setSensor =============== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in that and later versions. Sets whether this shape should act as a sensor. Set the shape as a sensor if you want to be notified when collision between shapes occur, but don't want a physical response (for instance, maybe you want enemies to appear when the player "touches" a certain point). Function -------- ### Synopsis ``` Shape:setSensor( sensor ) ``` ### Arguments `[boolean](boolean "boolean") sensor` True for sensor, false otherwise. ### Returns Nothing. See Also -------- * [Shape](shape "Shape") love Source:getFilter Source:getFilter ================ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the [filter](source-setfilter "Source:setFilter") settings currently applied to the Source. Function -------- ### Synopsis ``` settings = Source:getFilter( ) ``` ### Arguments None. ### Returns `[table](table "table") settings (nil)` The filter settings to use for this Source, or nil if the Source has no active filter. The table has the following fields: `[FilterType](filtertype "FilterType") type` The type of filter to use. `[number](number "number") volume` The overall volume of the audio. `[number](number "number") highgain` Volume of high-frequency audio. Only applies to low-pass and band-pass filters. `[number](number "number") lowgain` Volume of low-frequency audio. Only applies to high-pass and band-pass filters. See Also -------- * [Source](source "Source") * [Source:setFilter](source-setfilter "Source:setFilter") * [Source:setEffect](source-seteffect "Source:setEffect") love love.joystick.isOpen love.joystick.isOpen ==================== **Available since LÖVE [0.5.0](https://love2d.org/wiki/0.5.0 "0.5.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier or later versions. Checks if the joystick is open. Function -------- ### Synopsis ``` open = love.joystick.isOpen( joystick ) ``` ### Arguments `[number](number "number") joystick` The joystick to be checked ### Returns `[boolean](boolean "boolean") open` True if the joystick is open, false if it is closed. See Also -------- * [love.joystick](love.joystick "love.joystick") love (File):getBuffer (File):getBuffer ================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the buffer mode of a file. Function -------- ### Synopsis ``` mode, size = File:getBuffer( ) ``` ### Arguments None. ### Returns `[BufferMode](buffermode "BufferMode") mode` The current buffer mode of the file. `[number](number "number") size` The maximum size in bytes of the file's buffer. See Also -------- * [File](file "File") * [File:setBuffer]((file)-setbuffer "(File):setBuffer") * [File:write]((file)-write "(File):write") love Texture:setDepthSampleMode Texture:setDepthSampleMode ========================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Sets the comparison mode used when sampling from a [depth texture](pixelformat "PixelFormat") in a shader. Depth texture comparison modes are advanced low-level functionality typically used with shadow mapping in 3D. When using a depth texture with a comparison mode set in a shader, it must be declared as a `sampler2DShadow` and used in a GLSL 3 [Shader](shader "Shader"). The result of accessing the texture in the shader will return a float between 0 and 1, proportional to the number of samples (up to 4 samples will be used if bilinear filtering is enabled) that passed the test set by the [comparison](comparemode "CompareMode") operation. Depth texture comparison can only be used with [readable](texture-isreadable "Texture:isReadable") depth-formatted [Canvases](canvas "Canvas"). Function -------- ### Synopsis ``` Texture:setDepthSampleMode( compare ) ``` ### Arguments `[CompareMode](comparemode "CompareMode") compare` The comparison mode used when sampling from this texture in a shader. ### Returns Nothing. Function -------- Disables depth texture comparison functionality for this texture. ### Synopsis ``` Texture:setDepthSampleMode( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Texture](texture "Texture") * [Texture:getDepthSampleMode](texture-getdepthsamplemode "Texture:getDepthSampleMode") * [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") love MatrixLayout MatrixLayout ============ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This enum is not supported in earlier versions. The layout of matrix elements (row-major or column-major). Constants --------- row The matrix is row-major: ``` matrix = { {a, b, c, d}, -- row 1 {e, f, g, h}, -- row 2 -- etc. } -- or matrix = { a, b, c, d, -- row 1 e, f, g, h, -- row 2 -- etc. } ``` column The matrix is column-major: ``` matrix = { {a, b, c, d}, -- column 1 {e, f, g, h}, -- column 2 -- etc. } -- or matrix = { a, b, c, d, -- column 1 e, f, g, h, -- column 2 -- etc. } ``` See Also -------- * [Transform](transform "Transform") * [Shader](shader "Shader") * [Transform:setMatrix](transform-setmatrix "Transform:setMatrix") * [Shader:send](shader-send "Shader:send")
programming_docs
love Body:isTouching Body:isTouching =============== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets whether the Body is touching the given other Body. Using this in [love.update](love.update "love.update") may miss collisions, since [World:update](world-update "World:update") can begin and end a collision within a single call. The [collision callbacks](world-setcallbacks "World:setCallbacks") are recommended instead, when feasible. Function -------- ### Synopsis ``` touching = Body:isTouching( otherbody ) ``` ### Arguments `[Body](body "Body") otherbody` The other body to check. ### Returns `[boolean](boolean "boolean") touching` True if this body is touching the other body, false otherwise. See Also -------- * [Body](body "Body") love Cursor:getType Cursor:getType ============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the type of the Cursor. Function -------- ### Synopsis ``` ctype = Cursor:getType( ) ``` ### Arguments None. ### Returns `[CursorType](cursortype "CursorType") ctype` The type of the Cursor. See Also -------- * [Cursor](cursor "Cursor") love love.update love.update =========== Callback function used to update the state of the game every frame. Function -------- ### Synopsis ``` love.update( dt ) ``` ### Arguments `[number](number "number") dt` Time since the last update in seconds. ### Returns Nothing. Examples -------- Run a function called *think* inside a table called *npc* once per second. ``` dtotal = 0 -- this keeps track of how much time has passed function love.update(dt) dtotal = dtotal + dt -- we add the time passed since the last update, probably a very small number like 0.01 if dtotal >= 1 then dtotal = dtotal - 1 -- reduce our timer by a second, but don't discard the change... what if our framerate is 2/3 of a second? npc.think() end end ``` Change a variable *var* at a constant rate (+/- 3 per second in this example). ``` var = 10 -- arbitrary starting value rate = 3 -- change to change the rate at which the var is changed function love.update(dt) if love.keyboard.isDown("down") then -- reduce the value var = var - (dt * rate) end if love.keyboard.isDown("up") then -- increase the value var = var + (dt * rate) end end ``` See Also -------- * [love](love "love") * [World:update](world-update "World:update") * [variable](variable "variable") love Shader:getExternVariable Shader:getExternVariable ======================== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2") and removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** It has been replaced by [Shader:hasUniform](shader-hasuniform "Shader:hasUniform"). Gets information about an 'extern' ('uniform') variable in the shader. Returns nil if the variable name doesn't exist in the shader, or if the video driver's shader compiler has determined that the variable doesn't affect the final output of the shader. Function -------- ### Synopsis ``` type, components, arrayelements = Shader:getExternVariable( name ) ``` ### Arguments `[string](string "string") name` The name of the extern variable. ### Returns `[ShaderVariableType](https://love2d.org/w/index.php?title=ShaderVariableType&action=edit&redlink=1 "ShaderVariableType (page does not exist)") type (nil)` The base type of the variable. `[number](number "number") components (nil)` The number of components in the variable (e.g. 2 for a vec2 or mat2.) `[number](number "number") arrayelements (nil)` The number of elements in the array if the variable is an array, or 1 if not. See Also -------- * [Shader](shader "Shader") * [Shader:send](shader-send "Shader:send") love love.physics.getDistance love.physics.getDistance ======================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Returns the two closest points between two fixtures and their distance. This function does not work correctly in [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and may terminate LÖVE without errors. Function -------- ### Synopsis ``` distance, x1, y1, x2, y2 = love.physics.getDistance( fixture1, fixture2 ) ``` ### Arguments `[Fixture](fixture "Fixture") fixture1` The first fixture. `[Fixture](fixture "Fixture") fixture2` The second fixture. ### Returns `[number](number "number") distance` The distance of the two points. `[number](number "number") x1` The x-coordinate of the first point. `[number](number "number") y1` The y-coordinate of the first point. `[number](number "number") x2` The x-coordinate of the second point. `[number](number "number") y2` The y-coordinate of the second point. See Also -------- * [love.physics](love.physics "love.physics") love Joystick:getConnectedIndex Joystick:getConnectedIndex ========================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. **This is only raw "documentation" of function, that I found, but was not documented. Please update it and then remove this notice!** Gets joystick connected index. Function -------- ### Synopsis ``` index = Joystick:getConnectedIndex( ) ``` ### Arguments None. ### Returns `[number](number "number") index (nil)` Gets joystick connected index. See Also -------- * [Joystick](joystick "Joystick") * [Joystick:isConnected](joystick-isconnected "Joystick:isConnected") * [Joystick:getGUID](joystick-getguid "Joystick:getGUID") love VideoStream:seek VideoStream:seek ================ **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Sets the current playback position of the Video. Function -------- ### Synopsis ``` VideoStream:seek( offset ) ``` ### Arguments `[number](number "number") offset` The time in seconds since the beginning of the Video. ### Returns None. See Also -------- * [VideoStream](videostream "VideoStream") * [VideoStream:rewind](videostream-rewind "VideoStream:rewind") * [VideoStream:tell](videostream-tell "VideoStream:tell") love love.window.getDisplayName love.window.getDisplayName ========================== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Gets the name of a display. Function -------- ### Synopsis ``` name = love.window.getDisplayName( displayindex ) ``` ### Arguments `[number](number "number") displayindex (1)` The index of the display to get the name of. ### Returns `[string](string "string") name` The name of the specified display. See Also -------- * [love.window](love.window "love.window") * [love.window.getDisplayCount](love.window.getdisplaycount "love.window.getDisplayCount") love World:getBodyCount World:getBodyCount ================== Returns the number of bodies in the world. Function -------- ### Synopsis ``` n = World:getBodyCount( ) ``` ### Arguments None. ### Returns `[number](number "number") n` The number of bodies in the world. See Also -------- * [World](world "World") love RopeJoint:setMaxLength RopeJoint:setMaxLength ====================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Sets the maximum length of a RopeJoint. Function -------- ### Synopsis ``` RopeJoint:setMaxLength( maxlength ) ``` ### Arguments `[number](number "number") maxLength` The new maximum length of the RopeJoint. ### Returns Nothing. See Also -------- * [RopeJoint](ropejoint "RopeJoint") * [RopeJoint:getMaxLength](ropejoint-getmaxlength "RopeJoint:getMaxLength") love love.graphics.setStencil love.graphics.setStencil ======================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** It has been replaced by [love.graphics.stencil](love.graphics.stencil "love.graphics.stencil") and [love.graphics.setStencilTest](love.graphics.setstenciltest "love.graphics.setStencilTest"). Defines or releases a stencil for the drawing operations. The passed function draws to the stencil instead of the screen, creating an image with transparent and opaque pixels. While active, it is used to test where pixels will be drawn or discarded. Image contents do not directly affect the stencil, but see below for a workaround. Calling the function without arguments releases the active stencil. Function -------- ### Synopsis ``` love.graphics.setStencil( stencilFunction ) ``` ### Arguments `[function](function "function") stencilFunction` Function that draws the stencil. ### Returns Nothing. Function -------- Releases the active stencil. ### Synopsis ``` love.graphics.setStencil( ) ``` ### Arguments None. ### Returns Nothing. Examples -------- ### Drawing circles masked by a rectangle ``` myStencilFunction = function() love.graphics.rectangle("fill", 225, 200, 350, 300) end   love.graphics.setStencil(myStencilFunction)   love.graphics.setColor(255, 0, 0, 120) love.graphics.circle("fill", 300, 300, 150, 50) love.graphics.setColor(0, 255, 0, 120) love.graphics.circle("fill", 500, 300, 150, 50) love.graphics.setColor(0, 0, 255, 120) love.graphics.circle("fill", 400, 400, 150, 50) ``` ### Drawing a circle with a hole ``` myStencilFunction = function() love.graphics.circle("fill", 400, 300, 50) end   love.graphics.setInvertedStencil(myStencilFunction) love.graphics.circle("fill", 400, 300, 150) ``` ### Drawing two masked triangles with different colors ``` myStencilFunction = function() love.graphics.circle("fill", 400, 300, 60, 25) end   love.graphics.setStencil(myStencilFunction) love.graphics.setColor(155, 0, 128) love.graphics.polygon("fill", 400, 200, 486, 350, 314, 350)     love.graphics.setInvertedStencil(myStencilFunction) love.graphics.setColor(144, 214, 128) love.graphics.polygon("fill", 400, 200, 486, 350, 314, 350) ``` ### Using an Image as a stencil mask ``` -- a black/white mask image: black pixels will mask, white pixels will pass. local mask = love.graphics.newImage("mymask.png")   local mask_effect = love.graphics.newShader[[ vec4 effect (vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) { if (Texel(texture, texture_coords).rgb == vec3(0.0)) { // a discarded pixel wont be applied as the stencil. discard; } return vec4(1.0); } ]]   function myStencilFunction() love.graphics.setShader(mask_effect) love.graphics.draw(mask, 0, 0) love.graphics.setShader() end   love.graphics.setStencil(myStencilFunction) love.graphics.rectangle("fill", 0, 0, 256, 256) love.graphics.setStencil() ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setInvertedStencil](love.graphics.setinvertedstencil "love.graphics.setInvertedStencil") love ParticleSystem:getRotation ParticleSystem:getRotation ========================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the rotation of the image upon particle creation (in radians). Function -------- ### Synopsis ``` min, max = ParticleSystem:getRotation( ) ``` ### Arguments Nothing. ### Returns `[number](number "number") min` The minimum initial angle (radians). `[number](number "number") max` The maximum initial angle (radians). See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setRotation](particlesystem-setrotation "ParticleSystem:setRotation") love love.graphics.newImageFont love.graphics.newImageFont ========================== Creates a new [Font](font "Font") by loading a [specifically formatted](imagefontformat "ImageFontFormat") image. In versions prior to [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0"), LÖVE expects ISO 8859-1 encoding for the glyphs string. This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- ### Synopsis ``` font = love.graphics.newImageFont( filename, glyphs ) ``` ### Arguments `[string](string "string") filename` The filepath to the image file. `[string](string "string") glyphs` A string of the characters in the image in order from left to right. ### Returns `[Font](font "Font") font` A Font object which can be used to draw text on screen. Function -------- ### Synopsis ``` font = love.graphics.newImageFont( imagedata, glyphs ) ``` ### Arguments `[ImageData](imagedata "ImageData") imageData` The ImageData object to create the font from. `[string](string "string") glyphs` A string of the characters in the image in order from left to right. ### Returns `[Font](font "Font") font` A Font object which can be used to draw text on screen. Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. ### Synopsis ``` font = love.graphics.newImageFont( filename, glyphs, extraspacing ) ``` ### Arguments `[string](string "string") filename` The filepath to the image file. `[string](string "string") glyphs` A string of the characters in the image in order from left to right. `[number](number "number") extraspacing` Additional spacing (positive or negative) to apply to each glyph in the Font. ### Returns `[Font](font "Font") font` A Font object which can be used to draw text on screen. Notes ----- Instead of using this function, consider using a BMFont generator such as [bmfont](http://www.angelcode.com/products/bmfont/), [littera](http://kvazars.com/littera/), or [bmGlyph](https://www.bmglyph.com/) with [love.graphics.newFont](love.graphics.newfont "love.graphics.newFont"). Because slime said it was better. Examples -------- Creating a simple image font. Download this [image file](https://love2d.org/wiki/File:font_example.png "File:font example.png") which will be used by LÖVE to create the font. Obviously when you want to create a font for your game you want to make the background transparent. ``` local font = love.graphics.newImageFont( 'font_example.png', ' ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' ) function love.draw() love.graphics.setFont( font ) love.graphics.print( 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', 16, 16 ) love.graphics.print( 'Text is now drawn using the font', 16, 32 ) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [Font](font "Font") * [Image Font Format](imagefontformat "ImageFontFormat") love Channel:pop Channel:pop =========== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Retrieves the value of a Channel message and removes it from the message queue. It returns nil if there are no messages in the queue. This function doesn't free up the memory used by a Channel, it needs to be garbage collected to release the memory. Function -------- ### Synopsis ``` value = Channel:pop( ) ``` ### Arguments None. ### Returns `[Variant](variant "Variant") value` The contents of the message. See Also -------- * [Channel](channel "Channel") * [Channel:push](channel-push "Channel:push") * [Channel:demand](channel-demand "Channel:demand") love FileDecoder FileDecoder =========== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0") and removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This enum is not supported in earlier or later versions. How to decode a given [FileData](filedata "FileData"). Constants --------- file The data is unencoded. base64 The data is base64-encoded. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") love love.joystick.getAxes love.joystick.getAxes ===================== **Available since LÖVE [0.5.0](https://love2d.org/wiki/0.5.0 "0.5.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been moved to [Joystick:getAxes](joystick-getaxes "Joystick:getAxes"). Returns the position of each axis. Function -------- ### Synopsis ``` axisDir1, axisDir2, axisDirN = love.joystick.getAxes( joystick ) ``` ### Arguments `[number](number "number") joystick` The joystick to be checked ### Returns `[number](number "number") axisDir1` Direction of axis1 `[number](number "number") axisDir2` Direction of axis2 `[number](number "number") axisDirN` Direction of axisN See Also -------- * [love.joystick](love.joystick "love.joystick") love Body:setFixedRotation Body:setFixedRotation ===================== Set whether a body has fixed rotation. Bodies with fixed rotation don't vary the speed at which they rotate. Calling this function causes the mass to be reset. LÖVE [0.6.2](https://love2d.org/wiki/0.6.2 "0.6.2") does not contain the fix for a bug with this function when it is called with a false argument. Function -------- ### Synopsis ``` Body:setFixedRotation( isFixed ) ``` ### Arguments `[boolean](boolean "boolean") isFixed` Whether the body should have fixed rotation. ### Returns Nothing. See Also -------- * [Body](body "Body") love love.graphics.setInvertedStencil love.graphics.setInvertedStencil ================================ **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** It has been replaced by [love.graphics.stencil](love.graphics.stencil "love.graphics.stencil") and [love.graphics.setStencilTest](love.graphics.setstenciltest "love.graphics.setStencilTest"). Defines an inverted stencil for the drawing operations or releases the active one. It's the same as [love.graphics.setStencil](love.graphics.setstencil "love.graphics.setStencil") with the mask inverted. Function -------- ### Synopsis ``` love.graphics.setInvertedStencil( stencilFunction ) ``` ### Arguments `[function](function "function") stencilFunction` Function that draws the stencil. ### Returns Nothing. Function -------- Releases the active stencil. ### Synopsis ``` love.graphics.setInvertedStencil( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.newStencil](love.graphics.newstencil "love.graphics.newStencil") * [love.graphics.setStencil](love.graphics.setstencil "love.graphics.setStencil") love ParticleSystem:reset ParticleSystem:reset ==================== Resets the particle emitter, removing any existing particles and resetting the lifetime counter. Function -------- ### Synopsis ``` ParticleSystem:reset( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love CircleShape:getLocalCenter CircleShape:getLocalCenter ========================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in that and later versions. Get the center of the circle in local coordinates. Function -------- ### Synopsis ``` lx, ly = CircleShape:getLocalCenter( ) ``` ### Arguments None. ### Returns `[number](number "number") lx` The x position of the circle in local coordinates. `[number](number "number") ly` The y position of the circle in local coordinates. See Also -------- * [CircleShape](circleshape "CircleShape")
programming_docs
love socket socket ====== Since [11.0](https://love2d.org/wiki/11.0 "11.0"), LÖVE does fully support non-blocking TCP connections on Windows **Available since LÖVE [0.5.0](https://love2d.org/wiki/0.5.0 "0.5.0")** This module is not supported in earlier versions. Implements a [luasocket](http://w3.impa.br/~diego/software/luasocket/) module for TCP/UDP networking. The luasocket module is bundled with love binary, but in order to use it, you need to require the module like this: ``` require("socket") ``` or even better: ``` local socket = require("socket") ``` **Note:** Since ~~lua 5.2~~ LÖVE 11.0, the latter method is ~~preferred~~ recommended, as modules will no longer register themselves in the global space, instead they will return a table. **Note:** When using blocking operations (network connect/read/write, or socket.sleep), the whole LÖVE main loop will be blocked, and it is usually a bad idea. So use only non-blocking operations if possible, or use it in a thread. Reference Manual ---------------- For detailed usage, see the [reference manual](http://w3.impa.br/~diego/software/luasocket/reference.html). See Also -------- * [love](love "love") * [Tutorial:Networking with UDP](https://love2d.org/wiki/Tutorial:Networking_with_UDP "Tutorial:Networking with UDP") * [enet](lua-enet "enet") * [LUBE](https://love2d.org/forums/viewtopic.php?f=5&t=230) love WeldJoint:getFrequency WeldJoint:getFrequency ====================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the frequency. Function -------- ### Synopsis ``` freq = WeldJoint:getFrequency( ) ``` ### Arguments None. ### Returns `[number](number "number") freq` The frequency in hertz. See Also -------- * [WeldJoint](weldjoint "WeldJoint") * [WeldJoint:setFrequency](weldjoint-setfrequency "WeldJoint:setFrequency") love love.graphics.discard love.graphics.discard ===================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Discards (trashes) the contents of the screen or active [Canvas](canvas "Canvas"). This is a performance optimization function with niche use cases. If the active Canvas has just been changed and the "replace" [BlendMode](blendmode "BlendMode") is about to be used to draw something which covers the entire screen, calling **love.graphics.discard** rather than calling [love.graphics.clear](love.graphics.clear "love.graphics.clear") or doing nothing may improve performance on mobile devices. On some desktop systems this function may do nothing. This function effectively replaces the contents of the screen or active Canvas with garbage. Most [BlendModes](blendmode "BlendMode"), including the default "alpha" blend mode, blend what's drawn with the contents of the screen - which would cause unexpected glitches if this function is used inappropriately. Function -------- ### Synopsis ``` love.graphics.discard( discardcolor, discardstencil ) ``` ### Arguments `[boolean](boolean "boolean") discardcolor (true)` Whether to discard the texture(s) of the active Canvas(es) (the contents of the screen if no Canvas is active.) `[boolean](boolean "boolean") discardstencil (true)` Whether to discard the contents of the [stencil buffer](love.graphics.stencil "love.graphics.stencil") of the screen / active Canvas. ### Returns Nothing. Function -------- ### Synopsis ``` love.graphics.discard( discardcolors, discardstencil ) ``` ### Arguments `[table](table "table") discardcolors` An array containing boolean values indicating whether to discard the texture of each active Canvas, when multiple simultaneous Canvases are active. `[boolean](boolean "boolean") discardstencil (true)` Whether to discard the contents of the [stencil buffer](love.graphics.stencil "love.graphics.stencil") of the screen / active Canvas. ### Returns Nothing. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.clear](love.graphics.clear "love.graphics.clear") * [Canvas](canvas "Canvas") * [love.graphics.setBlendMode](love.graphics.setblendmode "love.graphics.setBlendMode") love love.graphics.applyTransform love.graphics.applyTransform ============================ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Applies the given [Transform](transform "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. Function -------- ### Synopsis ``` love.graphics.applyTransform( transform ) ``` ### Arguments `[Transform](transform "Transform") transform` The Transform object to apply to the current graphics coordinate transform. ### Returns Nothing. Examples -------- ``` local transform = love.math.newTransform() transform:translate(200, 0)   function love.draw() love.graphics.translate(100, 100) love.graphics.rectangle("fill", 0, 0, 50, 50)   love.graphics.applyTransform(transform) love.graphics.rectangle("fill", 0, 0, 50, 50) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.math.newTransform](love.math.newtransform "love.math.newTransform") * [love.graphics.replaceTransform](love.graphics.replacetransform "love.graphics.replaceTransform") * [love.graphics.push](love.graphics.push "love.graphics.push") * [love.graphics.pop](love.graphics.pop "love.graphics.pop") love enet.peer:last round trip time enet.peer:last round trip time ============================== Returns or sets the round trip time of the previous round trip time computation. If value is [nil](nil "nil") the current value of the [peer](enet.peer "enet.peer") is returned. Otherwise the the previous round trip time computation is set to the specified value and returned. ENet performs some filtering on the round trip times and it takes some time until the parameters are accurate. To speed it up you can set the value of the last round trip time to a more accurate guess. Function -------- ### Synopsis ``` peer:last_round_trip_time() ``` ### Arguments None. ### Returns `[number](number "number") lastroundtriptime` The [peer's](enet.peer "enet.peer") last round trip time computation in milliseconds. ### Synopsis ``` peer:last_round_trip_time(value) ``` ### Arguments `[number](number "number") value` Integer value to be used as the last round trip time. ### Returns Nothing. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.peer](enet.peer "enet.peer") * [enet.peer:round\_trip\_time](enet.peer-round_trip_time "enet.peer:round trip time") love love.image love.image ========== Provides an interface to decode encoded image data. Types ----- | | | | | | --- | --- | --- | --- | | [CompressedImageData](compressedimagedata "CompressedImageData") | Compressed image data designed to stay compressed in RAM and on the GPU. | 0.9.0 | | | [ImageData](imagedata "ImageData") | Raw (decoded) image data. | | | Functions --------- | | | | | | --- | --- | --- | --- | | [love.image.isCompressed](love.image.iscompressed "love.image.isCompressed") | Determines whether a file can be loaded as [CompressedImageData](compressedimagedata "CompressedImageData"). | 0.9.0 | | | [love.image.newCompressedData](love.image.newcompresseddata "love.image.newCompressedData") | Create a new [CompressedImageData](compressedimagedata "CompressedImageData") object from a compressed image file. | 0.9.0 | | | [love.image.newEncodedImageData](love.image.newencodedimagedata "love.image.newEncodedImageData") | Encodes ImageData. | | 0.8.0 | | [love.image.newImageData](love.image.newimagedata "love.image.newImageData") | Creates a new ImageData object. | | | Enums ----- | | | | | | --- | --- | --- | --- | | [CompressedImageFormat](compressedimageformat "CompressedImageFormat") | Compressed image data formats. | 0.9.0 | | | [ImageEncodeFormat](imageencodeformat "ImageEncodeFormat") | Image file formats supported by [ImageData:encode](imagedata-encode "ImageData:encode"). | | | | [PixelFormat](pixelformat "PixelFormat") | Pixel formats for [Textures](texture "Texture"), [ImageData](imagedata "ImageData"), and [CompressedImageData](compressedimagedata "CompressedImageData"). | 11.0 | | See Also -------- * [love](love "love") * [Image](image "Image") - the love.graphics data type * [Image Formats](image_formats "Image Formats") love Text:setFont Text:setFont ============ **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Replaces the [Font](font "Font") used with the text. This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). Create multiple Text objects with different Fonts if you need to rapidly switch fonts. Function -------- ### Synopsis ``` Text:setFont( font ) ``` ### Arguments `[Font](font "Font") font` The new font to use with this Text object. ### Returns Nothing. See Also -------- * [Text](text "Text") * [Text:getFont](text-getfont "Text:getFont") love World:getBodies World:getBodies =============== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** It has renamed from [World:getBodyList](world-getbodylist "World:getBodyList"). Returns a table with all bodies. Function -------- ### Synopsis ``` bodies = World:getBodies( ) ``` ### Arguments None. ### Returns `[table](table "table") bodies` A [sequence](sequence "sequence") with all bodies. See Also -------- * [World](world "World") love love.window love.window =========== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This module is not supported in earlier versions. Provides an interface for modifying and retrieving information about the program's window. Functions --------- | | | | | | --- | --- | --- | --- | | [love.window.close](love.window.close "love.window.close") | Closes the window. | 0.10.0 | | | [love.window.fromPixels](love.window.frompixels "love.window.fromPixels") | Converts a number from pixels to density-independent units. | 0.9.2 | | | [love.window.getDPIScale](love.window.getdpiscale "love.window.getDPIScale") | Gets the DPI scale factor associated with the window. | 11.0 | | | [love.window.getDesktopDimensions](love.window.getdesktopdimensions "love.window.getDesktopDimensions") | Gets the width and height of the desktop. | 0.9.0 | | | [love.window.getDimensions](love.window.getdimensions "love.window.getDimensions") | Gets the width and height of the window. | 0.9.0 | 0.10.0 | | [love.window.getDisplayCount](love.window.getdisplaycount "love.window.getDisplayCount") | Gets the number of connected monitors. | 0.9.0 | | | [love.window.getDisplayName](love.window.getdisplayname "love.window.getDisplayName") | Gets the name of a display. | 0.9.2 | | | [love.window.getDisplayOrientation](love.window.getdisplayorientation "love.window.getDisplayOrientation") | Gets current device display orientation. | 11.3 | | | [love.window.getFullscreen](love.window.getfullscreen "love.window.getFullscreen") | Gets whether the window is fullscreen. | 0.9.0 | | | [love.window.getFullscreenModes](love.window.getfullscreenmodes "love.window.getFullscreenModes") | Gets a list of supported fullscreen modes. | 0.9.0 | | | [love.window.getHeight](love.window.getheight "love.window.getHeight") | Gets the height of the window. | 0.9.0 | 0.10.0 | | [love.window.getIcon](love.window.geticon "love.window.getIcon") | Gets the window icon. | 0.9.0 | | | [love.window.getMode](love.window.getmode "love.window.getMode") | Gets the display mode and properties of the window. | 0.9.0 | | | [love.window.getPixelScale](love.window.getpixelscale "love.window.getPixelScale") | Gets the DPI scale factor associated with the window. | 0.9.1 | 11.0 | | [love.window.getPosition](love.window.getposition "love.window.getPosition") | Gets the position of the window on the screen. | 0.9.2 | | | [love.window.getSafeArea](love.window.getsafearea "love.window.getSafeArea") | Gets unobstructed area inside the window. | 11.3 | | | [love.window.getTitle](love.window.gettitle "love.window.getTitle") | Gets the window title. | 0.9.0 | | | [love.window.getVSync](love.window.getvsync "love.window.getVSync") | Gets current vsync value. | 11.3 | | | [love.window.getWidth](love.window.getwidth "love.window.getWidth") | Gets the width of the window. | 0.9.0 | 0.10.0 | | [love.window.hasFocus](love.window.hasfocus "love.window.hasFocus") | Checks if the game window has keyboard focus. | 0.9.0 | | | [love.window.hasMouseFocus](love.window.hasmousefocus "love.window.hasMouseFocus") | Checks if the game window has mouse focus. | 0.9.0 | | | [love.window.isCreated](love.window.iscreated "love.window.isCreated") | Checks if the window has been created. | 0.9.0 | 0.10.0 | | [love.window.isDisplaySleepEnabled](love.window.isdisplaysleepenabled "love.window.isDisplaySleepEnabled") | Gets whether the display is allowed to sleep while the program is running. | 0.10.0 | | | [love.window.isMaximized](love.window.ismaximized "love.window.isMaximized") | Gets whether the Window is currently [maximized](love.window.maximize "love.window.maximize"). | 0.10.2 | | | [love.window.isMinimized](love.window.isminimized "love.window.isMinimized") | Gets whether the Window is currently [minimized](love.window.minimize "love.window.minimize"). | 11.0 | | | [love.window.isOpen](love.window.isopen "love.window.isOpen") | Checks if the window is open. | 0.10.0 | | | [love.window.isVisible](love.window.isvisible "love.window.isVisible") | Checks if the game window is visible. | 0.9.0 | | | [love.window.maximize](love.window.maximize "love.window.maximize") | Makes the window as large as possible. | 0.10.0 | | | [love.window.minimize](love.window.minimize "love.window.minimize") | Minimizes the window to the system's task bar / dock. | 0.9.2 | | | [love.window.requestAttention](love.window.requestattention "love.window.requestAttention") | Causes the window to request the attention of the user if it is not in the foreground. | 0.10.0 | | | [love.window.restore](love.window.restore "love.window.restore") | Restores the size and position of the window if it was [minimized](love.window.minimize "love.window.minimize") or [maximized](love.window.maximize "love.window.maximize"). | 11.0 | | | [love.window.setDisplaySleepEnabled](love.window.setdisplaysleepenabled "love.window.setDisplaySleepEnabled") | Sets whether the display is allowed to sleep while the program is running. | 0.10.0 | | | [love.window.setFullscreen](love.window.setfullscreen "love.window.setFullscreen") | Enters or exits fullscreen. | 0.9.0 | | | [love.window.setIcon](love.window.seticon "love.window.setIcon") | Sets the window icon. | 0.9.0 | | | [love.window.setMode](love.window.setmode "love.window.setMode") | Sets the display mode and properties of the window. | 0.9.0 | | | [love.window.setPosition](love.window.setposition "love.window.setPosition") | Sets the position of the window on the screen. | 0.9.2 | | | [love.window.setTitle](love.window.settitle "love.window.setTitle") | Sets the window title. | 0.9.0 | | | [love.window.setVSync](love.window.setvsync "love.window.setVSync") | Sets vertical synchronization mode. | 11.3 | | | [love.window.showMessageBox](love.window.showmessagebox "love.window.showMessageBox") | Displays a message box above the love window. | 0.9.2 | | | [love.window.toPixels](love.window.topixels "love.window.toPixels") | Converts a number from density-independent units to pixels. | 0.9.2 | | | [love.window.updateMode](love.window.updatemode "love.window.updateMode") | Sets the display mode and properties of the window, without modifying unspecified properties. | 11.0 | | Enums ----- | | | | | | --- | --- | --- | --- | | [DisplayOrientation](displayorientation "DisplayOrientation") | Types of device display orientation. | 11.3 | | | [FullscreenType](fullscreentype "FullscreenType") | Types of fullscreen modes. | 0.9.0 | | | [MessageBoxType](messageboxtype "MessageBoxType") | Types of message box dialogs. | 0.9.2 | | See Also -------- * [love](love "love") * [love.resize](love.resize "love.resize") * [love.focus](love.focus "love.focus") * [love.mousefocus](love.mousefocus "love.mousefocus") * [love.visible](love.visible "love.visible") love Transform:clone Transform:clone =============== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Creates a new copy of this Transform. Function -------- ### Synopsis ``` clone = Transform:clone( ) ``` ### Arguments None. ### Returns `[Transform](transform "Transform") clone` The copy of this Transform. See Also -------- * [Transform](transform "Transform") * [love.math.newTransform](love.math.newtransform "love.math.newTransform") love love.graphics.inverseTransformPoint love.graphics.inverseTransformPoint =================================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. 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](transform-inversetransformpoint "Transform:inverseTransformPoint") method exists for [Transform](transform "Transform") objects. Function -------- ### Synopsis ``` globalX, globalY = love.graphics.inverseTransformPoint( screenX, screenY ) ``` ### Arguments `[number](number "number") screenX` The x component of the screen-space position. `[number](number "number") screenY` The y component of the screen-space position. ### Returns `[number](number "number") globalX` The x component of the position in global coordinates. `[number](number "number") globalY` The y component of the position in global coordinates. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.transformPoint](love.graphics.transformpoint "love.graphics.transformPoint") * [Transform](transform "Transform") love Body:destroy Body:destroy ============ Explicitly destroys the Body and all fixtures and joints attached to it. An error will occur if you attempt to use the object after calling this function. In 0.7.2, when you don't have time to wait for garbage collection, this function may be used to free the object immediately. Function -------- ### Synopsis ``` Body:destroy( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Body](body "Body") love love.audio.getVelocity love.audio.getVelocity ====================== Returns the velocity of the listener. Function -------- ### Synopsis ``` x, y, z = love.audio.getVelocity( ) ``` ### Arguments None. ### Returns `[number](number "number") x` The X velocity of the listener. `[number](number "number") y` The Y velocity of the listener. `[number](number "number") z` The Z velocity of the listener. See Also -------- * [love.audio](love.audio "love.audio") love SoundData:getDuration SoundData:getDuration ===================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the duration of the sound data. Function -------- ### Synopsis ``` duration = SoundData:getDuration( ) ``` ### Arguments None. ### Returns `[number](number "number") duration` The duration of the sound data in seconds. See Also -------- * [SoundData](sounddata "SoundData")
programming_docs
love AlignMode AlignMode ========= Text alignment. Constants --------- center Align text center. left Align text left. right Align text right. justify Available since 0.9.0 Align text both left and right. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.printf](love.graphics.printf "love.graphics.printf") love CompressedImageData:getMipmapCount CompressedImageData:getMipmapCount ================================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the number of [mipmap](https://en.wikipedia.org/wiki/Mipmap) levels in the CompressedImageData. The base mipmap level (original image) is included in the count. Function -------- ### Synopsis ``` mipmaps = CompressedImageData:getMipmapCount( ) ``` ### Arguments None. ### Returns `[number](number "number") mipmaps` The number of mipmap levels stored in the CompressedImageData. Notes ----- Mipmap filtering cannot be activated for an [Image](image "Image") created from a CompressedImageData which does not have enough mipmap levels to go down to 1x1. For example, a 256x256 image created from a CompressedImageData should have 8 mipmap levels or [Image:setMipmapFilter]((image)-setmipmapfilter "(Image):setMipmapFilter") will error. Most tools which can create compressed textures are able to automatically generate mipmaps for them in the same file. See Also -------- * [CompressedImageData](compressedimagedata "CompressedImageData") * [Image:setMipmapFilter]((image)-setmipmapfilter "(Image):setMipmapFilter") love love.sound.newSoundData love.sound.newSoundData ======================= Creates new [SoundData](sounddata "SoundData") from a filepath, [File](file "File"), or [Decoder](decoder "Decoder"). It's also possible to create SoundData with a custom sample rate, channel and bit depth. The sound data will be decoded to the memory in a raw format. It is recommended to create only short sounds like effects, as a 3 minute song uses 30 MB of memory this way. Function -------- ### Synopsis ``` soundData = love.sound.newSoundData( filename ) ``` ### Arguments `[string](string "string") filename` The file name of the file to load. ### Returns `[SoundData](sounddata "SoundData") soundData` A new SoundData object. Function -------- ### Synopsis ``` soundData = love.sound.newSoundData( file ) ``` ### Arguments `[File](file "File") file` A File pointing to an audio file. ### Returns `[SoundData](sounddata "SoundData") soundData` A new SoundData object. Function -------- ### Synopsis ``` soundData = love.sound.newSoundData( decoder ) ``` ### Arguments `[Decoder](decoder "Decoder") decoder` Decode data from this Decoder until EOF. ### Returns `[SoundData](sounddata "SoundData") soundData` A new SoundData object. Function -------- ### Synopsis ``` soundData = love.sound.newSoundData( samples, rate, bits, channels ) ``` ### Arguments `[number](number "number") samples` Total number of samples. `[number](number "number") rate (44100)` Number of samples per second `[number](number "number") bits (16)` Bits per sample (8 or 16). `[number](number "number") channels (2)` Either 1 for mono or 2 for stereo. ### Returns `[SoundData](sounddata "SoundData") soundData` A new SoundData object. Examples -------- ### Loading SoundData from files ``` wav = love.sound.newSoundData("doom.wav") -- Beware: if doom.mp3 is a huge file, it will take -- ages to decode. mp3 = love.sound.newSoundData("doom.mp3") ``` See Also -------- * [love.sound](love.sound "love.sound") * [SoundData](sounddata "SoundData") love love.graphics.setColor love.graphics.setColor ====================== Sets the color used for drawing. In versions prior to [11.0](https://love2d.org/wiki/11.0 "11.0"), color component values were within the range of 0 to 255 instead of 0 to 1. Function -------- ### Synopsis ``` love.graphics.setColor( red, green, blue, alpha ) ``` ### Arguments `[number](number "number") red` The amount of red. `[number](number "number") green` The amount of green. `[number](number "number") blue` The amount of blue. `[number](number "number") alpha (1)` The amount of alpha. The alpha value will be applied to all subsequent draw operations, even the drawing of an image. ### Returns Nothing. Function -------- **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.setColor( rgba ) ``` ### Arguments `[table](table "table") rgba` A numerical indexed table with the red, green, blue and alpha values as [numbers](number "number"). The alpha is optional and defaults to 1 if it is left out. ### Returns Nothing. Examples -------- ### Draw a red, blue and green circle ``` function love.draw() love.graphics.setColor(1, 0, 0) love.graphics.circle("fill", 50, 50, 20)   love.graphics.setColor(0, 0, 1) love.graphics.circle("fill", 50, 100, 20)   myColor = {0, 1, 0, 1} love.graphics.setColor(myColor) love.graphics.circle("fill", 50, 150, 20) end ``` ### Display a Venn diagram ``` function love.load() baseX = 300 baseY = 400 radius = 100 offsetY = radius*.5*math.sqrt(3) love.graphics.setBackgroundColor(1, 1, 1) end   function love.draw() love.graphics.setColor(1, 0, 0, 0.4) love.graphics.circle('fill', baseX, baseY, radius) love.graphics.setColor(0, 1, 0, 0.4) love.graphics.circle('fill', baseX + radius / 2, baseY - offsetY, radius) love.graphics.setColor(0, 0, 1, 0.4) love.graphics.circle('fill', baseX + radius, baseY, radius) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [HSL color](https://love2d.org/wiki/HSL_color "HSL color") (an alternate color space, based on human perception) love World:destroy World:destroy ============= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Destroys the world, taking all bodies, joints, fixtures and their shapes with it. An error will occur if you attempt to use any of the destroyed objects after calling this function. Function -------- ### Synopsis ``` World:destroy( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [World](world "World") love value value ===== The **Variant** type is not a real lua type, but instead indicates what lua values LÖVE can store internally. It is used in [love.thread](love.thread "love.thread") and [love.event](love.event "love.event"). Indeed, as it is a "virtual" type, it has no specific representation in lua, and no methods. Types ----- A **Variant** can be a [table](table "table"), a [boolean](boolean "boolean"), a [string](string "string"), a [number](number "number") or LÖVE [Objects](object "Object"). Notes ----- Foreign userdata (Lua's files, LuaSocket, ENet, ...), and functions are not supported. Nested tables are not officially supported in versions prior to [11.0](https://love2d.org/wiki/11.0 "11.0"). See Also -------- * [love](love "love") love love.mousefocus love.mousefocus =============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This callback is not supported in earlier versions. Callback function triggered when window receives or loses mouse focus. Function -------- ### Synopsis ``` love.mousefocus( focus ) ``` ### Arguments `[boolean](boolean "boolean") focus` Whether the window has mouse focus or not. ### Returns Nothing. Example ------- ``` function love.load() text = "Mouse is in the window!" end   function love.draw() love.graphics.print(text,0,0) end   function love.mousefocus(f) if not f then text = "Mouse is not in the window!" print("LOST MOUSE FOCUS") else text = "Mouse is in the window!" print("GAINED MOUSE FOCUS") end end ``` See Also -------- * [love](love "love") love Texture:getWrap Texture:getWrap =============== Gets the wrapping properties of a Texture. This function returns the currently set horizontal and vertical [wrapping modes](wrapmode "WrapMode") for the texture. Function -------- ### Synopsis ``` horiz, vert, depth = Texture:getWrap( ) ``` ### Arguments None. ### Returns `[WrapMode](wrapmode "WrapMode") horiz` Horizontal wrapping mode of the texture. `[WrapMode](wrapmode "WrapMode") vert` Vertical wrapping mode of the texture. `[WrapMode](wrapmode "WrapMode") depth` Available since 11.0 Wrapping mode for the z-axis of a [Volume texture](texturetype "TextureType"). See Also -------- * [Texture](texture "Texture") * [Texture:setWrap](texture-setwrap "Texture:setWrap") * [WrapMode](wrapmode "WrapMode") love love.graphics.scale love.graphics.scale =================== 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](love.draw "love.draw")() exits. Function -------- ### Synopsis ``` love.graphics.scale( sx, sy ) ``` ### Arguments `[number](number "number") sx` The scaling in the direction of the x-axis. `[number](number "number") sy (sx)` The scaling in the direction of the y-axis. If omitted, it defaults to same as parameter sx. ### Returns Nothing. Examples -------- Draw two lines of text, one scaled and one normal. Uses [love.graphics.push](love.graphics.push "love.graphics.push") and [love.graphics.pop](love.graphics.pop "love.graphics.pop") to return to normal render scale. ``` function love.draw() love.graphics.push() love.graphics.scale(0.5, 0.5) -- reduce everything by 50% in both X and Y coordinates love.graphics.print("Scaled text", 50, 50) love.graphics.pop() love.graphics.print("Normal text", 50, 50) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.pop](love.graphics.pop "love.graphics.pop") * [love.graphics.push](love.graphics.push "love.graphics.push") * [love.graphics.rotate](love.graphics.rotate "love.graphics.rotate") * [love.graphics.shear](love.graphics.shear "love.graphics.shear") * [love.graphics.translate](love.graphics.translate "love.graphics.translate") * [love.graphics.origin](love.graphics.origin "love.graphics.origin") love Texture:getDepth Texture:getDepth ================ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the depth of a [Volume Texture](texturetype "TextureType"). Returns 1 for 2D, Cubemap, and Array textures. Function -------- ### Synopsis ``` depth = Texture:getDepth( ) ``` ### Arguments None. ### Returns `[number](number "number") depth` The depth of the volume Texture. See Also -------- * [Texture](texture "Texture") * [love.graphics.newVolumeImage](love.graphics.newvolumeimage "love.graphics.newVolumeImage") * [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") love Mesh Mesh ==== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This type is not supported in earlier versions. A 2D [polygon mesh](https://en.wikipedia.org/wiki/Polygon_mesh) used for drawing arbitrary textured shapes. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.graphics.newMesh](love.graphics.newmesh "love.graphics.newMesh") | Creates a new **Mesh**. | 0.9.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Mesh:attachAttribute](mesh-attachattribute "Mesh:attachAttribute") | Attaches a vertex attribute from a different Mesh onto this Mesh, for use when drawing. Optionally allows per-[instance](love.graphics.drawinstanced "love.graphics.drawInstanced") attributes. | 0.10.0 | | | [Mesh:detachAttribute](mesh-detachattribute "Mesh:detachAttribute") | Removes a previously [attached](mesh-attachattribute "Mesh:attachAttribute") vertex attribute from this Mesh. | 11.0 | | | [Mesh:flush](mesh-flush "Mesh:flush") | Immediately sends all modified vertex data in the Mesh to the graphics card. | 0.10.0 | | | [Mesh:getDrawMode](mesh-getdrawmode "Mesh:getDrawMode") | Gets the mode used when drawing the Mesh. | 0.9.0 | | | [Mesh:getDrawRange](mesh-getdrawrange "Mesh:getDrawRange") | Gets the range of vertices used when drawing the Mesh. | 0.9.1 | | | [Mesh:getImage](mesh-getimage "Mesh:getImage") | Gets the [Image](image "Image") used when drawing the Mesh. | 0.9.0 | 0.10.0 | | [Mesh:getTexture](mesh-gettexture "Mesh:getTexture") | Gets the texture ([Image](image "Image") or [Canvas](canvas "Canvas")) used when drawing the Mesh. | 0.9.1 | | | [Mesh:getVertex](mesh-getvertex "Mesh:getVertex") | Gets the properties of a vertex in the Mesh. | 0.9.0 | | | [Mesh:getVertexAttribute](mesh-getvertexattribute "Mesh:getVertexAttribute") | Gets the properties of a specific attribute within a vertex in the Mesh. | 0.10.0 | | | [Mesh:getVertexCount](mesh-getvertexcount "Mesh:getVertexCount") | Gets the total number of vertices in the Mesh. | 0.9.0 | | | [Mesh:getVertexFormat](mesh-getvertexformat "Mesh:getVertexFormat") | Gets the vertex format that the Mesh was [created](love.graphics.newmesh "love.graphics.newMesh") with. | 0.10.0 | | | [Mesh:getVertexMap](mesh-getvertexmap "Mesh:getVertexMap") | Gets the vertex map for the Mesh. | 0.9.0 | | | [Mesh:getVertices](mesh-getvertices "Mesh:getVertices") | Gets all the vertices in the Mesh. | 0.9.0 | 0.10.0 | | [Mesh:hasVertexColors](mesh-hasvertexcolors "Mesh:hasVertexColors") | Gets whether per-vertex colors are used when drawing the Mesh. | 0.9.0 | 0.10.0 | | [Mesh:isAttributeEnabled](mesh-isattributeenabled "Mesh:isAttributeEnabled") | Gets whether a specific vertex attribute in the Mesh is enabled. | 0.10.0 | | | [Mesh:setAttributeEnabled](mesh-setattributeenabled "Mesh:setAttributeEnabled") | Enables or disables a specific vertex attribute in the Mesh. | 0.10.0 | | | [Mesh:setDrawMode](mesh-setdrawmode "Mesh:setDrawMode") | Sets the mode used when drawing the Mesh. | 0.9.0 | | | [Mesh:setDrawRange](mesh-setdrawrange "Mesh:setDrawRange") | Restricts the drawn vertices of the Mesh to a subset of the total. | 0.9.1 | | | [Mesh:setImage](mesh-setimage "Mesh:setImage") | Sets the [Image](image "Image") used when drawing the Mesh. | 0.9.0 | 0.10.0 | | [Mesh:setTexture](mesh-settexture "Mesh:setTexture") | Sets the texture ([Image](image "Image") or [Canvas](canvas "Canvas")) used when drawing the Mesh. | 0.9.1 | | | [Mesh:setVertex](mesh-setvertex "Mesh:setVertex") | Sets the properties of a vertex in the Mesh. | 0.9.0 | | | [Mesh:setVertexAttribute](mesh-setvertexattribute "Mesh:setVertexAttribute") | Sets the properties of a specific attribute within a vertex in the Mesh. | 0.10.0 | | | [Mesh:setVertexColors](mesh-setvertexcolors "Mesh:setVertexColors") | Sets whether per-vertex colors are used instead of the constant color when drawing the Mesh. | 0.9.0 | 0.10.0 | | [Mesh:setVertexMap](mesh-setvertexmap "Mesh:setVertexMap") | Sets the vertex map for the Mesh. | 0.9.0 | | | [Mesh:setVertices](mesh-setvertices "Mesh:setVertices") | Replaces a range of vertices in the Mesh with new ones. | 0.9.0 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Enums ----- | | | | | | --- | --- | --- | --- | | [IndexDataType](indexdatatype "IndexDataType") | Vertex map datatype. | 11.0 | | | [MeshDrawMode](meshdrawmode "MeshDrawMode") | How a Mesh's vertices are used when drawing. | 0.9.0 | | | [VertexAttributeStep](vertexattributestep "VertexAttributeStep") | The frequency at which a vertex shader fetches the vertex attribute's data from the Mesh when it's drawn. | 11.0 | | Supertypes ---------- * [Drawable](drawable "Drawable") * [Object](object "Object") See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.draw](love.graphics.draw "love.graphics.draw") * [SpriteBatch:attachAttribute](spritebatch-attachattribute "SpriteBatch:attachAttribute") love HashFunction HashFunction ============ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This enum is not supported in earlier versions. Hash algorithm of [love.data.hash](love.data.hash "love.data.hash"). Constants --------- md5 MD5 hash algorithm (16 bytes). sha1 SHA1 hash algorithm (20 bytes). sha224 SHA2 hash algorithm with message digest size of 224 bits (28 bytes). sha256 SHA2 hash algorithm with message digest size of 256 bits (32 bytes). sha384 SHA2 hash algorithm with message digest size of 384 bits (48 bytes). sha512 SHA2 hash algorithm with message digest size of 512 bits (64 bytes). See Also -------- * [love.data](love.data "love.data") * [love.data.hash](love.data.hash "love.data.hash") love Text:set Text:set ======== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Replaces the contents of the Text object with a new unformatted string. Function -------- ### Synopsis ``` Text:set( textstring ) ``` ### Arguments `[string](string "string") textstring` The new string of text to use. ### Returns Nothing. Function -------- ### Synopsis ``` Text:set( coloredtext ) ``` ### Arguments `[table](table "table") coloredtext` A table containing colors and strings to use as the new text, in the form of `{color1, string1, color2, string2, ...}`. `[table](table "table") 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}`. `[string](string "string") string1` A string of text which has a color specified by the previous color. `[table](table "table") 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}`. `[string](string "string") string2` A string of text which has a color specified by the previous color. `[tables and strings](https://love2d.org/w/index.php?title=tables_and_strings&action=edit&redlink=1 "tables and strings (page does not exist)") ...` Additional colors and strings. ### Returns Nothing. ### Notes The color set by [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor") will be combined (multiplied) with the colors of the text, when drawing the Text object. Function -------- **Removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** Use [Text:clear](text-clear "Text:clear") instead. Clears the contents of the Text object. ### Synopsis ``` Text:set( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Text](text "Text") * [Text:setf](text-setf "Text:setf") * [Text:add](text-add "Text:add") * [Text:addf](text-addf "Text:addf") * [Text:clear](text-clear "Text:clear")
programming_docs
love Mesh:setImage Mesh:setImage ============= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. **Removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** Use [Mesh:setTexture](mesh-settexture "Mesh:setTexture") instead. [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0") (bug) [Images](image "Image") are not released from memory automatically when nil-ing meshes. Call Mesh:setImage() to manually clear. Sets the [Image](image "Image") used when drawing the Mesh. Function -------- ### Synopsis ``` Mesh:setImage( image ) ``` ### Arguments `[Image](image "Image") image` The Image to texture the Mesh with when drawing. ### Returns Nothing. Function -------- ### Synopsis ``` Mesh:setImage( ) ``` ### Arguments None. ### Returns Nothing. ### Notes Disables any Image from being used when drawing the Mesh. Untextured meshes have a white color by default. See Also -------- * [Mesh](mesh "Mesh") * [Mesh:getImage](mesh-getimage "Mesh:getImage") love GlyphData:getHeight GlyphData:getHeight =================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Gets glyph height. Function -------- ### Synopsis ``` height = GlyphData:getHeight() ``` ### Arguments None. ### Returns `[number](number "number") height` Glyph height. See Also -------- * [GlyphData](glyphdata "GlyphData") love Thread:demand Thread:demand ============= **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been moved to the [Channel](channel "Channel") API. Receive a message from a thread. Wait for the message to exist before returning. (Can return nil in case of an error in the thread.) Function -------- ### Synopsis ``` value = Thread:demand( name ) ``` ### Arguments `[string](string "string") name` The name of the message. ### Returns `[Variant](variant "Variant") value` The contents of the message. See Also -------- * [Thread](thread "Thread") love (Image):refresh (Image):refresh =============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0") and removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** It has been replaced by [Image:replacePixels]((image)-replacepixels "(Image):replacePixels"). Reloads the Image's contents from the [ImageData](imagedata "ImageData") or [CompressedData](compresseddata "CompressedData") used to create the image. Function -------- ### Synopsis ``` Image:refresh( ) ``` ### Arguments None. ### Returns Nothing. Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0") and removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** It has been replaced by [Image:replacePixels]((image)-replacepixels "(Image):replacePixels"). ### Synopsis ``` Image:refresh( x, y, width, height ) ``` ### Arguments `[number](number "number") x` The x-axis of the top-left corner of the area within the Image to reload. `[number](number "number") y` The y-axis of the top-left corner of the area within the Image to reload. `[number](number "number") width` The width of the area within the Image to reload. `[number](number "number") height` The height of the area within the Image to reload. ### Returns Nothing. Examples -------- ``` function love.load() imagedata = love.image.newImageData("pig.png") image = love.graphics.newImage(imagedata) end   function love.draw() love.graphics.draw(image) end   function love.keypressed(key) if key == "e" then -- Modify the original ImageData and apply the changes to the Image. imagedata:mapPixel(function(x, y, r, g, b, a) return r/2, g/2, b/2, a/2 end) image:refresh() end end ``` See Also -------- * [Image](image "Image") * [Image:getData]((image)-getdata "(Image):getData") love lua-enet lua-enet ======== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This module is not supported in earlier versions. Official documentation for lua-enet is available [here](http://leafo.net/lua-enet/). ENet's features are listed on its [homepage](http://enet.bespin.org/Features.html). The official documentation may have typos. The documentation on this wiki reflects Löve's implementation, meaning it should be safe to follow what's written here. lua-enet is simply some Lua bindings for ENet. ENet's purpose is to provide a relatively thin, simple and robust network communication layer for games on top of UDP (User Datagram Protocol).The primary feature it provides is optional reliable, in-order delivery of packets. ENet omits certain higher level networking features such as authentication, lobbying, server discovery, encryption, or other similar tasks that are particularly application specific so that the library remains flexible, portable, and easily embeddable. Types ----- | Type | Description | | --- | --- | | [host](enet.host "enet.host") | An ENet host for communicating with peers. | | [peer](enet.peer "enet.peer") | An ENet peer which data packets may be sent or received from. | | [event](enet.event "enet.event") | A simple table containing information on an event. | Functions --------- | Function | Description | | --- | --- | | [host\_create](enet.host_create "enet.host create") | Returns a new host. | | [linked\_version](enet.linked_version "enet.linked version") | Returns the included ENet's version string. | Examples -------- **server.lua** ``` -- server.lua local enet = require "enet" local host = enet.host_create("localhost:6789") while true do local event = host:service(100) while event do if event.type == "receive" then print("Got message: ", event.data, event.peer) event.peer:send( "pong" ) elseif event.type == "connect" then print(event.peer, "connected.") elseif event.type == "disconnect" then print(event.peer, "disconnected.") end event = host:service() end end ``` **client.lua** ``` -- client.lua local enet = require "enet" local host = enet.host_create() local server = host:connect("localhost:6789") while true do local event = host:service(100) while event do if event.type == "receive" then print("Got message: ", event.data, event.peer) event.peer:send( "ping" ) elseif event.type == "connect" then print(event.peer, "connected.") event.peer:send( "ping" ) elseif event.type == "disconnect" then print(event.peer, "disconnected.") end event = host:service() end end ``` See Also -------- * [love](love "love") * [socket](socket "socket") love love.timer.getMicroTime love.timer.getMicroTime ======================= **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** [love.timer.getTime](love.timer.gettime "love.timer.getTime") is now microsecond-accurate. Returns the value of a timer with an unspecified starting time. The time is accurate to the microsecond. Function -------- ### Synopsis ``` t = love.timer.getMicroTime( ) ``` ### Arguments None. ### Returns `[number](number "number") t` The time passed in seconds. See Also -------- * [love.timer](love.timer "love.timer") * [love.timer.getTime](love.timer.gettime "love.timer.getTime") love SpriteBatch:getColor SpriteBatch:getColor ==================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This method is not supported in earlier versions. Gets the color that will be used for the next add and set operations. If no color has been set with [SpriteBatch:setColor](spritebatch-setcolor "SpriteBatch:setColor") or the current SpriteBatch color has been cleared, this method will return nil. In versions prior to [11.0](https://love2d.org/wiki/11.0 "11.0"), color component values were within the range of 0 to 255 instead of 0 to 1. Function -------- ### Synopsis ``` r, g, b, a = SpriteBatch:getColor( ) ``` ### Arguments None. ### Returns `[number](number "number") r` The red component (0-1). `[number](number "number") g` The green component (0-1). `[number](number "number") b` The blue component (0-1). `[number](number "number") a` The alpha component (0-1). See Also -------- * [SpriteBatch](spritebatch "SpriteBatch") * [SpriteBatch:setColor](spritebatch-setcolor "SpriteBatch:setColor") love love.graphics.getLineStyle love.graphics.getLineStyle ========================== **Available since LÖVE [0.3.2](https://love2d.org/wiki/0.3.2 "0.3.2")** This function is not supported in earlier versions. Gets the line style. Function -------- ### Synopsis ``` style = love.graphics.getLineStyle( ) ``` ### Arguments None. ### Returns `[LineStyle](linestyle "LineStyle") style` The current line style. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setLineStyle](love.graphics.setlinestyle "love.graphics.setLineStyle") love enet.host:bandwidth limit enet.host:bandwidth limit ========================= Sets the bandwidth limits of the [host](enet.peer "enet.peer") in bytes/sec. Set to 0 for unlimited. Function -------- ### Synopsis ``` host:bandwidth_limit(incoming, outgoing) ``` ### Arguments `[number](number "number") incoming` Download speed limit in bytes/sec. `[number](number "number") outgoing` Upload speed limit in bytes/sec. ### Returns Nothing. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.host](enet.host "enet.host") love love.audio.getDopplerScale love.audio.getDopplerScale ========================== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Gets the current global scale factor for velocity-based doppler effects. Function -------- ### Synopsis ``` scale = love.audio.getDopplerScale( ) ``` ### Arguments None. ### Returns `[number](number "number") scale` The current doppler scale factor. See Also -------- * [love.audio](love.audio "love.audio") * [love.audio.setDopplerScale](love.audio.setdopplerscale "love.audio.setDopplerScale") love Contact:resetFriction Contact:resetFriction ===================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Resets the contact friction to the mixture value of both fixtures. Function -------- ### Synopsis ``` Contact:resetFriction( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Contact](contact "Contact") love love.graphics.setShader love.graphics.setShader ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [love.graphics.setPixelEffect](love.graphics.setpixeleffect "love.graphics.setPixelEffect"). Sets or resets a [Shader](shader "Shader") as the current pixel effect or vertex shaders. All drawing operations until the next *love.graphics.setShader* will be drawn using the [Shader](shader "Shader") object specified. Function -------- ### Synopsis ``` love.graphics.setShader( shader ) ``` ### Arguments `[Shader](shader "Shader") shader` The new shader. ### Returns Nothing. ### Notes Sets the current shader to a specified [Shader](shader "Shader"). All drawing operations until the next *love.graphics.setShader* will be drawn using the [Shader](shader "Shader") object specified. Function -------- ### Synopsis ``` love.graphics.setShader( ) ``` ### Arguments None. ### Returns Nothing. ### Notes Disables shaders, allowing unfiltered drawing operations. Examples -------- ### Drawing a rectangle using a pixel effect shader ``` function love.load() effect = love.graphics.newShader [[ extern number time; vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) { return vec4((1.0+sin(time))/2.0, abs(cos(time)), abs(sin(time)), 1.0); } ]] end   function love.draw() -- boring white love.graphics.setShader() love.graphics.rectangle('fill', 10,10,780,285)   -- LOOK AT THE PRETTY COLORS! love.graphics.setShader(effect) love.graphics.rectangle('fill', 10,305,780,285) end   local t = 0 function love.update(dt) t = t + dt effect:send("time", t) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [Shader](shader "Shader") love Source:stop Source:stop =========== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Stops a Source. Function -------- ### Synopsis ``` Source:stop() ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Source](source "Source") love ParticleSystem:getTexture ParticleSystem:getTexture ========================= **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** It has been renamed from [ParticleSystem:getImage](particlesystem-getimage "ParticleSystem:getImage"). Gets the texture ([Image](image "Image") or [Canvas](canvas "Canvas")) used for the particles. Function -------- ### Synopsis ``` texture = ParticleSystem:getTexture( ) ``` ### Arguments None. ### Returns `[Texture](texture "Texture") texture` The [Image](image "Image") or [Canvas](canvas "Canvas") used for the particles. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setTexture](particlesystem-settexture "ParticleSystem:setTexture") love love.graphics.setLineWidth love.graphics.setLineWidth ========================== **Available since LÖVE [0.3.2](https://love2d.org/wiki/0.3.2 "0.3.2")** This function is not supported in earlier versions. Sets the line width. Function -------- ### Synopsis ``` love.graphics.setLineWidth( width ) ``` ### Arguments `[number](number "number") width` The width of the line. ### Returns Nothing. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getLineWidth](love.graphics.getlinewidth "love.graphics.getLineWidth") * [love.graphics.setLineStyle](love.graphics.setlinestyle "love.graphics.setLineStyle") love PrismaticJoint:getAxis PrismaticJoint:getAxis ====================== **Available since LÖVE [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2")** This function is not supported in earlier versions. Gets the world-space axis vector of the Prismatic Joint. Function -------- ### Synopsis ``` x, y = PrismaticJoint:getAxis( ) ``` ### Arguments None. ### Returns `[number](number "number") x` The x-axis coordinate of the world-space axis vector. `[number](number "number") y` The y-axis coordinate of the world-space axis vector. See Also -------- * [PrismaticJoint](prismaticjoint "PrismaticJoint") * [love.physics.newPrismaticJoint](love.physics.newprismaticjoint "love.physics.newPrismaticJoint") love Shape:getData Shape:getData ============= **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** Use [Fixture:getUserData](fixture-getuserdata "Fixture:getUserData") instead. Get the data set with setData. Function -------- ### Synopsis ``` v = Shape:getData( ) ``` ### Arguments None. ### Returns `[any](https://love2d.org/w/index.php?title=any&action=edit&redlink=1 "any (page does not exist)") v` The data previously set, or nil if none. See Also -------- * [Shape](shape "Shape") * [Shape:setData](shape-setdata "Shape:setData") love Source:isPaused Source:isPaused =============== **Removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** It has been replaced by [Source:isPlaying](source-isplaying "Source:isPlaying"). Returns whether the Source is paused. Function -------- ### Synopsis ``` paused = Source:isPaused( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") paused` True if the Source is paused, false otherwise. See Also -------- * [Source](source "Source") love Body:applyImpulse Body:applyImpulse ================= **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been renamed to [Body:applyLinearImpulse](body-applylinearimpulse "Body:applyLinearImpulse"). Applies an impulse to a body. This makes a single, instantaneous addition to the body momentum. An impulse pushes a body in a direction. A body with with a larger mass will react less. The reaction does **not** depend on the timestep, and is equivalent to applying a force continuously for 1 second. Impulses are best used to give a single push to a body. For a continuous push to a body it is better to use [Body:applyForce](body-applyforce "Body:applyForce"). If the position to apply the impulse is not given, it will act on the center of mass of the body. The part of the impulse not directed towards the center of mass will cause the body to spin (and depends on the rotational inertia). Note that the impulse components and position must be given in world coordinates. Function -------- ### Synopsis ``` Body:applyImpulse( ix, iy, x, y ) ``` ### Arguments `[number](number "number") ix` The x component of the impulse. `[number](number "number") iy` The y component of the impulse. `[number](number "number") x` The x position to apply the impulse. `[number](number "number") y` The y position to apply the impulse. ### Returns Nothing. See Also -------- * [Body](body "Body") love ParticleSystem:isEmpty ParticleSystem:isEmpty ====================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** Use [ParticleSystem:getCount](particlesystem-getcount "ParticleSystem:getCount") and [ParticleSystem:getBufferSize](particlesystem-getbuffersize "ParticleSystem:getBufferSize"). Checks whether the particle system is empty of particles. Function -------- ### Synopsis ``` empty = ParticleSystem:isEmpty( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") empty` True if there are no live particles, false otherwise. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love World:setAllowSleep World:setAllowSleep =================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in that and later versions. Set the sleep behaviour of the world. A sleeping body is much more efficient to simulate than when awake. If sleeping is allowed, any body that has come to rest will sleep. Function -------- ### Synopsis ``` World:setAllowSleep( permission ) ``` ### Arguments `[boolean](boolean "boolean") permission` Permission for any body to sleep. ### Returns Nothing. See Also -------- * [World](world "World") love nil nil === From the Lua 5.1 [reference manual §2.2](https://www.lua.org/manual/5.1/manual.html#2.2): Nil is the type of the value nil, whose main property is to be different from any other value; it usually represents the absence of a useful value. love love.filesystem.getDirectoryItems love.filesystem.getDirectoryItems ================================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [love.filesystem.enumerate](love.filesystem.enumerate "love.filesystem.enumerate"). Returns a table with the names of files and subdirectories in the specified path. The table is not sorted in any way; the order is undefined. If the path passed to the function exists in the game and the save directory, it will list the files and directories from both places. Function -------- ### Synopsis ``` files = love.filesystem.getDirectoryItems( dir ) ``` ### Arguments `[string](string "string") dir` The directory. ### Returns `[table](table "table") files` A [sequence](sequence "sequence") with the names of all files and subdirectories as strings. Function -------- **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier or later versions. ### Synopsis ``` files = love.filesystem.getDirectoryItems( dir, callback ) ``` ### Arguments `[string](string "string") dir` The directory. `[function](function "function") callback` A function which is called for each file and folder in the directory. The filename is passed to the function as an argument. ### Returns `[table](table "table") files` A [sequence](sequence "sequence") with the names of all files and subdirectories as strings. Examples -------- ### Simple Example ``` local dir = "" --assuming that our path is full of lovely files (it should at least contain main.lua in this case) local files = love.filesystem.getDirectoryItems(dir) for k, file in ipairs(files) do print(k .. ". " .. file) --outputs something like "1. main.lua" end ``` ### Recursively find and display all files and folders in a folder and its subfolders. ``` function love.load() filesString = recursiveEnumerate("", "") end   -- This function will return a string filetree of all files -- in the folder and files in all subfolders function recursiveEnumerate(folder, fileTree) local lfs = love.filesystem local filesTable = lfs.getDirectoryItems(folder) for i,v in ipairs(filesTable) do local file = folder.."/"..v if lfs.isFile(file) then fileTree = fileTree.."\n"..file elseif lfs.isDirectory(file) then fileTree = fileTree.."\n"..file.." (DIR)" fileTree = recursiveEnumerate(file, fileTree) end end return fileTree end   function love.draw() love.graphics.print(filesString, 0, 0) end ``` See Also -------- * [love.filesystem](love.filesystem "love.filesystem")
programming_docs
love Texture:getPixelDimensions Texture:getPixelDimensions ========================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This method is not supported in earlier versions. Gets the width and height in pixels of the Texture. [Texture:getDimensions](texture-getdimensions "Texture:getDimensions") gets the dimensions of the texture in units scaled by the texture's [DPI scale factor](texture-getdpiscale "Texture:getDPIScale"), rather than pixels. Use getDimensions for calculations related to drawing the texture (calculating an origin offset, for example), and getPixelDimensions only when dealing specifically with pixels, for example when using [Canvas:newImageData](canvas-newimagedata "Canvas:newImageData"). Function -------- ### Synopsis ``` pixelwidth, pixelheight = Texture:getPixelDimensions( ) ``` ### Arguments None. ### Returns `[number](number "number") pixelwidth` The width of the Texture, in pixels. `[number](number "number") pixelheight` The height of the Texture, in pixels. See Also -------- * [Texture](texture "Texture") * [Texture:getDPIScale](texture-getdpiscale "Texture:getDPIScale") * [Texture:getPixelWidth](texture-getpixelwidth "Texture:getPixelWidth") * [Texture:getPixelHeight](texture-getpixelheight "Texture:getPixelHeight") love MouseJoint:setTarget MouseJoint:setTarget ==================== Sets the target point. Function -------- ### Synopsis ``` MouseJoint:setTarget( x, y ) ``` ### Arguments `[number](number "number") x` The x-component of the target. `[number](number "number") y` The y-component of the target. ### Returns Nothing. See Also -------- * [MouseJoint](mousejoint "MouseJoint") love love.physics.newPolygonShape love.physics.newPolygonShape ============================ Creates a new [PolygonShape](polygonshape "PolygonShape"). This shape can have 8 vertices at most, and must form a convex shape. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in earlier versions. ### Synopsis ``` shape = love.physics.newPolygonShape( x1, y1, x2, y2, x3, y3, ... ) ``` ### Arguments `[number](number "number") x1` The x position of the first point. `[number](number "number") y1` The y position of the first point. `[number](number "number") x2` The x position of the second point. `[number](number "number") y2` The y position of the second point. `[number](number "number") x3` The x position of the third point. `[number](number "number") y3` The y position of the third point. `[number](number "number") ...` You can continue passing more point positions to create the PolygonShape. ### Returns `[PolygonShape](polygonshape "PolygonShape") shape` A new PolygonShape. Function -------- **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This variant is not supported in earlier versions. ### Synopsis ``` shape = love.physics.newPolygonShape( vertices ) ``` ### Arguments `[table](table "table") vertices` A list of vertices to construct the polygon, in the form of `{x1, y1, x2, y2, x3, y3, ...}`. ### Returns `[PolygonShape](polygonshape "PolygonShape") shape` A new PolygonShape. Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. ### Synopsis ``` shape = love.physics.newPolygonShape( body, ... ) ``` ### Arguments `[Body](body "Body") body` The body to attach the shape to. `[numbers](https://love2d.org/w/index.php?title=numbers&action=edit&redlink=1 "numbers (page does not exist)") ...` Vertices of the polygon. ### Returns `[PolygonShape](polygonshape "PolygonShape") shape` A new PolygonShape. See Also -------- * [love.physics](love.physics "love.physics") * [PolygonShape](polygonshape "PolygonShape") * [Shape](shape "Shape") love ParticleSystem:setDirection ParticleSystem:setDirection =========================== Sets the direction the particles will be emitted in. Function -------- ### Synopsis ``` ParticleSystem:setDirection( direction ) ``` ### Arguments `[number](number "number") direction` The direction of the particles (in radians). ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love SpriteBatch:addLayer SpriteBatch:addLayer ==================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Adds a sprite to a batch created with an [Array Texture](texturetype "TextureType"). Function -------- Adds a layer of the SpriteBatch's Array Texture. ### Synopsis ``` spriteindex = SpriteBatch:addLayer( layerindex, x, y, r, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[number](number "number") layerindex` The index of the layer to use for this sprite. `[number](number "number") x (0)` The position to draw the sprite (x-axis). `[number](number "number") y (0)` The position to draw the sprite (y-axis). `[number](number "number") r (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Shearing factor (x-axis). `[number](number "number") ky (0)` Shearing factor (y-axis). ### Returns `[number](number "number") spriteindex` The index of the added sprite, for use with [SpriteBatch:set](spritebatch-set "SpriteBatch:set") or [SpriteBatch:setLayer](spritebatch-setlayer "SpriteBatch:setLayer"). Function -------- Adds a layer of the SpriteBatch's Array Texture using the specified [Quad](quad "Quad"). ### Synopsis ``` spriteindex = SpriteBatch:addLayer( layerindex, quad, x, y, r, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[number](number "number") layerindex` The index of the layer to use for this sprite. `[Quad](quad "Quad") quad` The subsection of the texture's layer to use when drawing the sprite. `[number](number "number") x (0)` The position to draw the sprite (x-axis). `[number](number "number") y (0)` The position to draw the sprite (y-axis). `[number](number "number") r (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Shearing factor (x-axis). `[number](number "number") ky (0)` Shearing factor (y-axis). ### Returns `[number](number "number") spriteindex` The index of the added sprite, for use with [SpriteBatch:set](spritebatch-set "SpriteBatch:set") or [SpriteBatch:setLayer](spritebatch-setlayer "SpriteBatch:setLayer"). ### Notes The specified layer index overrides any layer index set on the Quad via [Quad:setLayer](https://love2d.org/w/index.php?title=Quad:setLayer&action=edit&redlink=1 "Quad:setLayer (page does not exist)"). Function -------- Adds a layer of the SpriteBatch's Array Texture using the specified [Transform](transform "Transform"). ### Synopsis ``` spriteindex = SpriteBatch:addLayer( layerindex, transform ) ``` ### Arguments `[number](number "number") layerindex` The index of the layer to use for this sprite. `[Transform](transform "Transform") transform` A transform object. ### Returns `[number](number "number") spriteindex` The index of the added sprite, for use with [SpriteBatch:set](spritebatch-set "SpriteBatch:set") or [SpriteBatch:setLayer](spritebatch-setlayer "SpriteBatch:setLayer"). Function -------- Adds a layer of the SpriteBatch's Array Texture using the specified [Quad](quad "Quad") and [Transform](transform "Transform"). ### Synopsis ``` spriteindex = SpriteBatch:addLayer( layerindex, quad, transform ) ``` ### Arguments `[number](number "number") layerindex` The index of the layer to use for this sprite. `[Quad](quad "Quad") quad` The subsection of the texture's layer to use when drawing the sprite. `[Transform](transform "Transform") transform` A transform object. ### Returns `[number](number "number") spriteindex` The index of the added sprite, for use with [SpriteBatch:set](spritebatch-set "SpriteBatch:set") or [SpriteBatch:setLayer](spritebatch-setlayer "SpriteBatch:setLayer"). ### Notes The specified layer index overrides any layer index set on the Quad via [Quad:setLayer](https://love2d.org/w/index.php?title=Quad:setLayer&action=edit&redlink=1 "Quad:setLayer (page does not exist)"). Notes ----- In order to use an Array Texture or other non-2D texture types as the main texture in a custom [Shader](shader "Shader"), the [void effect()](love.graphics.newshader "love.graphics.newShader") variant must be used in the pixel shader, and MainTex must be declared as an ArrayImage or sampler2DArray like so: `uniform ArrayImage MainTex;`. Examples -------- ### Draw multiple layers of an Array Image in a SpriteBatch ``` function love.load() local sprites = {"sprite1.png", "sprite2.png"} image = love.graphics.newArrayImage(sprites)   batch = love.graphics.newSpriteBatch(image) batch:addLayer(1, 50, 50) batch:addLayer(2, 250, 50) end   function love.draw() love.graphics.draw(batch) end ``` ### Use a custom shader ``` shader = love.graphics.newShader[[ uniform ArrayImage MainTex;   void effect() { // Texel uses a third component of the texture coordinate for the layer index, when an Array Texture is passed in. // love sets up the texture coordinates to contain the layer index specified in love.graphics.drawLayer, when // rendering the Array Texture. love_PixelColor = Texel(MainTex, VaryingTexCoord.xyz) * VaryingColor; } ]]   function love.load() local sprites = {"sprite1.png", "sprite2.png"} image = love.graphics.newArrayImage(sprites)   batch = love.graphics.newSpriteBatch(image) batch:addLayer(1, 50, 50) batch:addLayer(2, 250, 50) end   function love.draw() love.graphics.setShader(shader) love.graphics.draw(batch) end ``` See Also -------- * [SpriteBatch](spritebatch "SpriteBatch") * [SpriteBatch:setLayer](spritebatch-setlayer "SpriteBatch:setLayer") * [love.graphics.newArrayImage](love.graphics.newarrayimage "love.graphics.newArrayImage") * [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") * [love.graphics.newShader](love.graphics.newshader "love.graphics.newShader") * [TextureType](texturetype "TextureType") love Data:getSize Data:getSize ============ Gets the [Data](data "Data")'s size in bytes. Function -------- ### Synopsis ``` size = Data:getSize( ) ``` ### Arguments None. ### Returns `[number](number "number") size` The size of the Data in bytes. See Also -------- * [Data](data "Data") love love.graphics.replaceTransform love.graphics.replaceTransform ============================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Replaces the current coordinate transformation with the given [Transform](transform "Transform") object. Function -------- ### Synopsis ``` love.graphics.replaceTransform( transform ) ``` ### Arguments `[Transform](transform "Transform") transform` The Transform object to replace the current graphics coordinate transform with. ### Returns Nothing. Examples -------- ``` local transform = love.math.newTransform() transform:translate(200, 0)   function love.draw() love.graphics.translate(100, 100) love.graphics.rectangle("fill", 0, 0, 50, 50)   love.graphics.replaceTransform(transform) love.graphics.rectangle("fill", 0, 0, 50, 50) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.math.newTransform](love.math.newtransform "love.math.newTransform") * [love.graphics.applyTransform](love.graphics.applytransform "love.graphics.applyTransform") * [love.graphics.push](love.graphics.push "love.graphics.push") * [love.graphics.pop](love.graphics.pop "love.graphics.pop") love love.graphics.getDimensions love.graphics.getDimensions =========================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the width and height in pixels of the window. Function -------- ### Synopsis ``` width, height = love.graphics.getDimensions( ) ``` ### Arguments None. ### Returns `[number](number "number") width` The width of the window. `[number](number "number") height` The height of the window. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getWidth](love.graphics.getwidth "love.graphics.getWidth") * [love.graphics.getHeight](love.graphics.getheight "love.graphics.getHeight") love ParticleSystem:setTangentialAcceleration ParticleSystem:setTangentialAcceleration ======================================== Sets the tangential acceleration (acceleration perpendicular to the particle's direction). Function -------- ### Synopsis ``` ParticleSystem:setTangentialAcceleration( min, max ) ``` ### Arguments `[number](number "number") min` The minimum acceleration. `[number](number "number") max (min)` The maximum acceleration. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love enet.host:broadcast enet.host:broadcast =================== Queues a packet to be sent to all connected [peers](enet.peer "enet.peer"). Function -------- ### Synopsis ``` host:broadcast(data, channel, flag) ``` ### Arguments `[string](string "string") data` The data to send. `[number](number "number") channel` The channel to send the packet on. Defaults to 0. `[string](string "string") flag` flag is one of "reliable", "unsequenced", or "unreliable". Reliable packets are guaranteed to arrive, and arrive in the order in which they are sent. Unreliable packets arrive in the order in which they are sent, but they aren't guaranteed to arrive. Unsequenced packets are neither guaranteed to arrive, nor do they have any guarantee on the order they arrive. Optional. Defaults to reliable. ### Returns Nothing. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.peer](enet.peer "enet.peer") love love.joystick.getNumAxes love.joystick.getNumAxes ======================== **Available since LÖVE [0.5.0](https://love2d.org/wiki/0.5.0 "0.5.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been moved to [Joystick:getAxisCount](joystick-getaxiscount "Joystick:getAxisCount"). Returns the number of axes on the joystick. Function -------- ### Synopsis ``` axes = love.joystick.getNumAxes( joystick ) ``` ### Arguments `[number](number "number") joystick` The joystick to be checked ### Returns `[number](number "number") axes` The number of axes available See Also -------- * [love.joystick](love.joystick "love.joystick") love SoundData:getSampleRate SoundData:getSampleRate ======================= Returns the sample rate of the SoundData. Function -------- ### Synopsis ``` rate = SoundData:getSampleRate( ) ``` ### Arguments None. ### Returns `[number](number "number") rate` Number of samples per second. See Also -------- * [SoundData](sounddata "SoundData") love RevoluteJoint:setLimitsEnabled RevoluteJoint:setLimitsEnabled ============================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [RevoluteJoint:enableLimits](revolutejoint-enablelimits "RevoluteJoint:enableLimits"). Enables/disables the joint limit. Function -------- ### Synopsis ``` RevoluteJoint:setLimitsEnabled( enable ) ``` ### Arguments `[boolean](boolean "boolean") enable` True to enable, false to disable. ### Returns Nothing. See Also -------- * [RevoluteJoint](revolutejoint "RevoluteJoint") love love.physics.newMouseJoint love.physics.newMouseJoint ========================== Create a joint between a body and the mouse. This joint actually connects the body to a fixed point in the world. To make it follow the mouse, the fixed point must be updated every timestep (example below). The advantage of using a MouseJoint instead of just changing a body position directly is that collisions and reactions to other joints are handled by the physics engine. Function -------- ### Synopsis ``` joint = love.physics.newMouseJoint( body, x, y ) ``` ### Arguments `[Body](body "Body") body` The body to attach to the mouse. `[number](number "number") x` The x position of the connecting point. `[number](number "number") y` The y position of the connecting point. ### Returns `[MouseJoint](mousejoint "MouseJoint") joint` The new mouse joint. Examples -------- ``` function love.load() world = love.physics.newWorld(0, 0) body = love.physics.newBody(world, love.mouse.getX(), love.mouse.getY(), "dynamic") shape = love.physics.newCircleShape(20) fixture = love.physics.newFixture(body, shape) joint = love.physics.newMouseJoint(body, love.mouse.getPosition()) end   function love.draw() love.graphics.circle("fill", body:getX(), body:getY(), shape:getRadius()) end   function love.update(dt) joint:setTarget(love.mouse.getPosition()) world:update(dt) end ``` See Also -------- * [love.physics](love.physics "love.physics") * [MouseJoint](mousejoint "MouseJoint") * [Joint](joint "Joint") love Channel:push Channel:push ============ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Send a message to the thread Channel. See [Variant](variant "Variant") for the list of supported types. Function -------- ### Synopsis ``` id = Channel:push( value ) ``` ### Arguments `[Variant](variant "Variant") value` The contents of the message. ### Returns `[number](number "number") id` Available since 11.0 Identifier which can be supplied to [Channel:hasRead](channel-hasread "Channel:hasRead") See Also -------- * [Channel](channel "Channel") * [Channel:pop](channel-pop "Channel:pop") * [Channel:supply](channel-supply "Channel:supply") love Contact:isTouching Contact:isTouching ================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Returns whether the two colliding fixtures are touching each other. Function -------- ### Synopsis ``` touching = Contact:isTouching( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") touching` True if they touch or false if not. See Also -------- * [Contact](contact "Contact") love Body:applyLinearImpulse Body:applyLinearImpulse ======================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Applies an impulse to a body. This makes a single, instantaneous addition to the body momentum. An impulse pushes a body in a direction. A body with with a larger mass will react less. The reaction does **not** depend on the timestep, and is equivalent to applying a force continuously for 1 second. Impulses are best used to give a single push to a body. For a continuous push to a body it is better to use [Body:applyForce](body-applyforce "Body:applyForce"). If the position to apply the impulse is not given, it will act on the center of mass of the body. The part of the impulse not directed towards the center of mass will cause the body to spin (and depends on the rotational inertia). Note that the impulse components and position must be given in world coordinates. Function -------- ### Synopsis ``` Body:applyLinearImpulse( ix, iy ) ``` ### Arguments `[number](number "number") ix` The x component of the impulse applied to the center of mass. `[number](number "number") iy` The y component of the impulse applied to the center of mass. ### Returns Nothing. Function -------- ### Synopsis ``` Body:applyLinearImpulse( ix, iy, x, y ) ``` ### Arguments `[number](number "number") ix` The x component of the impulse. `[number](number "number") iy` The y component of the impulse. `[number](number "number") x` The x position to apply the impulse. `[number](number "number") y` The y position to apply the impulse. ### Returns Nothing. See Also -------- * [Body](body "Body") * [Body:applyAngularImpulse](body-applyangularimpulse "Body:applyAngularImpulse") * [Body:getLinearVelocity](body-getlinearvelocity "Body:getLinearVelocity") * [Body:setLinearVelocity](body-setlinearvelocity "Body:setLinearVelocity")
programming_docs
love love.keyboard.isDown love.keyboard.isDown ==================== Checks whether a certain key is down. Not to be confused with [love.keypressed](love.keypressed "love.keypressed") or [love.keyreleased](love.keyreleased "love.keyreleased"). Function -------- ### Synopsis ``` down = love.keyboard.isDown( key ) ``` ### Arguments `[KeyConstant](keyconstant "KeyConstant") key` The key to check. ### Returns `[boolean](boolean "boolean") down` True if the key is down, false if not. Function -------- **Available since LÖVE [0.7.2](https://love2d.org/wiki/0.7.2 "0.7.2")** This variant is not supported in earlier versions. ### Synopsis ``` anyDown = love.keyboard.isDown( key, ... ) ``` ### Arguments `[KeyConstant](keyconstant "KeyConstant") key` A key to check. `[KeyConstant](keyconstant "KeyConstant") ...` Additional keys to check. ### Returns `[boolean](boolean "boolean") anyDown` True if any supplied key is down, false if not. Examples -------- ### Increase a value while a key is held down ``` local val = 0; function love.update(dt) -- We will increase the variable by 1 for every second the key is held down. if love.keyboard.isDown("up") then val = val + dt print(val) end   -- We will decrease the variable by 1/s if any of the wasd keys is pressed. if love.keyboard.isDown('w', 'a', 's', 'd') then val = val - dt print(val) end end ``` See Also -------- * [love.keyboard](love.keyboard "love.keyboard") * [love.keypressed](love.keypressed "love.keypressed") * [love.keyreleased](love.keyreleased "love.keyreleased") * [love.keyboard.isScancodeDown](love.keyboard.isscancodedown "love.keyboard.isScancodeDown") love WheelJoint:setSpringFrequency WheelJoint:setSpringFrequency ============================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Sets a new spring frequency. Function -------- ### Synopsis ``` WheelJoint:setSpringFrequency( freq ) ``` ### Arguments `[number](number "number") freq` The new frequency in hertz. ### Returns Nothing. See Also -------- * [WheelJoint](wheeljoint "WheelJoint") * [WheelJoint:getSpringFrequency](wheeljoint-getspringfrequency "WheelJoint:getSpringFrequency") love PulleyJoint:setRatio PulleyJoint:setRatio ==================== Set the pulley ratio. Function -------- ### Synopsis ``` PulleyJoint:setRatio( ratio ) ``` ### Arguments `[number](number "number") ratio` The new pulley ratio of the joint. ### Returns Nothing. See Also -------- * [PulleyJoint](pulleyjoint "PulleyJoint") love love.window.hasMouseFocus love.window.hasMouseFocus ========================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Checks if the game window has mouse focus. Function -------- ### Synopsis ``` focus = love.window.hasMouseFocus( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") focus` True if the window has mouse focus or false if not. See Also -------- * [love.window](love.window "love.window") love CompressedData CompressedData ============== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** In versions prior to [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0") the CompressedData name was used for [CompressedImageData](compressedimagedata "CompressedImageData") objects. Represents byte data compressed using a specific algorithm. [love.data.decompress](love.data.decompress "love.data.decompress") can be used to de-compress the data (or [love.math.decompress](love.math.decompress "love.math.decompress") in [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2") or earlier). Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.data.compress](love.data.compress "love.data.compress") | Compresses a string or data using a specific compression algorithm. | 11.0 | | | [love.math.compress](love.math.compress "love.math.compress") | Compresses a string or data using a specific compression algorithm. | 0.10.0 | 11.0 | Functions --------- | | | | | | --- | --- | --- | --- | | [CompressedData:getFormat](compresseddata-getformat "CompressedData:getFormat") | Gets the compression format of the CompressedData. | 0.10.0 | | | [Data:clone](data-clone "Data:clone") | Creates a new copy of the Data object. | 11.0 | | | [Data:getFFIPointer](data-getffipointer "Data:getFFIPointer") | Gets an FFI pointer to the Data. | 11.3 | | | [Data:getPointer](data-getpointer "Data:getPointer") | Gets a pointer to the Data. | | | | [Data:getSize](data-getsize "Data:getSize") | Gets the [Data](data "Data")'s size in bytes. | | | | [Data:getString](data-getstring "Data:getString") | Gets the full Data as a string. | 0.9.0 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Enums ----- | | | | | | --- | --- | --- | --- | | [CompressedDataFormat](compresseddataformat "CompressedDataFormat") | Compressed data formats. | 0.10.0 | | Supertypes ---------- * [Data](data "Data") * [Object](object "Object") See Also -------- * [love.data](love.data "love.data") * [love.data.decompress](love.data.decompress "love.data.decompress") * [love.math](love.math "love.math") (deprecated since 11.0) * [love.math.decompress](love.math.decompress "love.math.decompress") (deprecated since 11.0) love MouseJoint:setMaxForce MouseJoint:setMaxForce ====================== Sets the highest allowed force. Function -------- ### Synopsis ``` MouseJoint:setMaxForce( f ) ``` ### Arguments `[number](number "number") f` The max allowed force. ### Returns Nothing. See Also -------- * [MouseJoint](mousejoint "MouseJoint") love TextureFormat TextureFormat ============= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This enum is not supported in earlier or later versions. [Image](image "Image") texture formats. As of LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2"), [Canvases](canvas "Canvas") use [CanvasFormats](canvasformat "CanvasFormat") rather than TextureFormats. Constants --------- normal The default texture format: 8 bits per channel (32 bpp) RGBA. Color channel values range from 0-255 (0-1 in shaders.) hdr Only usable in Canvases. The high dynamic range texture format: floating point 16 bits per channel (64 bpp) RGBA. Color channel values inside the Canvas range from -infinity to +infinity. srgb Available since 0.9.1 The same as `normal`, but the texture is *interpreted* as being in the sRGB color space. It will be decoded from sRGB to linear RGB when drawn or sampled from in a shader. For Canvases, this will also convert everything drawn *to* the Canvas from linear RGB to sRGB. Notes ----- The HDR format is most useful when combined with pixel shaders. Effects such as tonemapped HDR with bloom can be accomplished, or the canvas can be used to store arbitrary non-color data such as positions which are then interpreted and used in a shader, as long as you draw the right things to the canvas. The sRGB format should only be used when doing gamma-correct rendering, which is an advanced topic and it's easy to get color-spaces mixed up. If you're not sure whether you need this, you might want to avoid it. Read more about gamma-correct rendering [here](http://http.developer.nvidia.com/GPUGems3/gpugems3_ch24.html), [here](http://filmicgames.com/archives/299), and [here](http://renderwonk.com/blog/index.php/archive/adventures-with-gamma-correct-rendering/). Not all systems support the HDR and sRGB formats. Use [love.graphics.isSupported](love.graphics.issupported "love.graphics.isSupported") to check before creating the Canvas or Image. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.newImage](love.graphics.newimage "love.graphics.newImage") * [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") * [love.graphics.isSupported](love.graphics.issupported "love.graphics.isSupported") love love.filesystem.getCRequirePath love.filesystem.getCRequirePath =============================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the filesystem paths that will be searched for c libraries when [require](https://www.lua.org/manual/5.1/manual.html#pdf-require) is called. The paths string returned by this function is a sequence of path templates separated by semicolons. The argument passed to *require* will be inserted in place of any question mark ("?") character in each template (after the dot characters in the argument passed to *require* are replaced by directory separators.) Additionally, any occurrence of a double question mark ("??") will be replaced by the name passed to require and the default library extension for the platform. The paths are relative to the game's source and save directories, as well as any paths mounted with [love.filesystem.mount](love.filesystem.mount "love.filesystem.mount"). Function -------- ### Synopsis ``` paths = love.filesystem.getCRequirePath( ) ``` ### Arguments None. ### Returns `[string](string "string") paths` The paths that the *require* function will check for c libraries in love's filesystem. Notes ----- The default paths string is `"??"`, which makes `require("cool")` try to load `cool.dll`, or `cool.so` depending on the platform. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [love.filesystem.setCRequirePath](love.filesystem.setcrequirepath "love.filesystem.setCRequirePath") love ParticleSystem:getLinearAcceleration ParticleSystem:getLinearAcceleration ==================================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the linear acceleration (acceleration along the x and y axes) for particles. Every particle created will accelerate along the x and y axes between xmin,ymin and xmax,ymax. Function -------- ### Synopsis ``` xmin, ymin, xmax, ymax = ParticleSystem:getLinearAcceleration( ) ``` ### Arguments Nothing. ### Returns `[number](number "number") xmin` The minimum acceleration along the x axis. `[number](number "number") ymin` The minimum acceleration along the y axis. `[number](number "number") xmax (xmin)` The maximum acceleration along the x axis. `[number](number "number") ymax (ymin)` The maximum acceleration along the y axis. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setLinearAcceleration](particlesystem-setlinearacceleration "ParticleSystem:setLinearAcceleration") love love.graphics.push love.graphics.push ================== Copies and pushes the current coordinate transformation to the transformation stack. This function is always used to prepare for a corresponding [pop](love.graphics.pop "love.graphics.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. Function -------- Pushes the current transformation to the transformation stack. ### Synopsis ``` love.graphics.push( ) ``` ### Arguments None. ### Returns Nothing. Function -------- **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This variant is not supported in earlier versions. Pushes a specific type of state to the stack. ### Synopsis ``` love.graphics.push( stack ) ``` ### Arguments `[StackType](stacktype "StackType") stack` The type of stack to push (e.g. just transformation state, or all love.graphics state). ### Returns Nothing. Examples -------- Modify and restore the coordinate system. ``` function love.draw() love.graphics.push() -- stores the default coordinate system love.graphics.translate(...) -- move the camera position love.graphics.scale(...) -- zoom the camera -- use the new coordinate system to draw the viewed scene love.graphics.pop() -- return to the default coordinates -- draw the status display using the screen coordinates end ``` **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This example is not supported in earlier versions. Modify love.graphics state in a function, and restore it easily so other code isn't disturbed. ``` function DrawCoolThing() love.graphics.push("all") -- save all love.graphics state so any changes can be restored   love.graphics.setColor(0, 0, 255) love.graphics.setBlendMode("subtract")   love.graphics.circle("fill", 400, 300, 80)   love.graphics.pop() -- restore the saved love.graphics state end   function love.draw() love.graphics.setColor(255, 128, 128) love.graphics.circle("fill", 400, 300, 100)   DrawCoolThing()   love.graphics.rectangle("fill", 600, 200, 200, 200) -- still uses the color set at the top of love.draw end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.pop](love.graphics.pop "love.graphics.pop") * [love.graphics.translate](love.graphics.translate "love.graphics.translate") * [love.graphics.rotate](love.graphics.rotate "love.graphics.rotate") * [love.graphics.scale](love.graphics.scale "love.graphics.scale") * [love.graphics.shear](love.graphics.shear "love.graphics.shear") * [love.graphics.origin](love.graphics.origin "love.graphics.origin") * [StackType](stacktype "StackType") love love.graphics.getPixelDimensions love.graphics.getPixelDimensions ================================ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the width and height in pixels of the window. [love.graphics.getDimensions](love.graphics.getdimensions "love.graphics.getDimensions") gets the dimensions of the window in units scaled by the screen's [DPI scale factor](love.graphics.getdpiscale "love.graphics.getDPIScale"), 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](shader "Shader"), for example). Function -------- ### Synopsis ``` pixelwidth, pixelheight = love.graphics.getPixelDimensions( ) ``` ### Arguments None. ### Returns `[number](number "number") pixelwidth` The width of the window in pixels. `[number](number "number") pixelheight` The width of the window in pixels. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getPixelWidth](love.graphics.getpixelwidth "love.graphics.getPixelWidth") * [love.graphics.getPixelHeight](love.graphics.getpixelheight "love.graphics.getPixelHeight") love ParticleSystem ParticleSystem ============== A ParticleSystem can be used to create particle effects like fire or smoke. The particle system has to be created using [love.graphics.newParticleSystem](love.graphics.newparticlesystem "love.graphics.newParticleSystem"). Just like any other [Drawable](drawable "Drawable") it can be drawn to the screen using [love.graphics.draw](love.graphics.draw "love.graphics.draw"). You also have to [update](particlesystem-update "ParticleSystem:update") it in the [update callback](love.update "love.update") to see any changes in the particles emitted. The particle system won't create any particles unless you call [setParticleLifetime](particlesystem-setparticlelifetime "ParticleSystem:setParticleLifetime") and [setEmissionRate](particlesystem-setemissionrate "ParticleSystem:setEmissionRate"). Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.graphics.newParticleSystem](love.graphics.newparticlesystem "love.graphics.newParticleSystem") | Creates a new **ParticleSystem**. | | | Functions --------- | | | | | | --- | --- | --- | --- | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | | [ParticleSystem:clone](particlesystem-clone "ParticleSystem:clone") | Creates an identical copy of the ParticleSystem in the stopped state. | 0.9.1 | | | [ParticleSystem:count](particlesystem-count "ParticleSystem:count") | Gets the amount of particles that are currently in the system. | | 0.9.0 | | [ParticleSystem:emit](particlesystem-emit "ParticleSystem:emit") | Emits a burst of particles from the particle emitter. | 0.9.0 | | | [ParticleSystem:getAreaSpread](particlesystem-getareaspread "ParticleSystem:getAreaSpread") | Gets the area-based spawn parameters for the particles. | 0.9.0 | 11.0 | | [ParticleSystem:getBufferSize](particlesystem-getbuffersize "ParticleSystem:getBufferSize") | Gets the maximum number of particles the ParticleSystem can have at once. | 0.9.0 | | | [ParticleSystem:getColors](particlesystem-getcolors "ParticleSystem:getColors") | Gets the colors to apply to the particle sprite. | 0.9.0 | | | [ParticleSystem:getCount](particlesystem-getcount "ParticleSystem:getCount") | Gets the number of particles that are currently in the system. | 0.9.0 | | | [ParticleSystem:getDirection](particlesystem-getdirection "ParticleSystem:getDirection") | Gets the direction of the particle emitter (in radians). | | | | [ParticleSystem:getEmissionArea](particlesystem-getemissionarea "ParticleSystem:getEmissionArea") | Gets the area-based spawn parameters for the particles. | 11.0 | | | [ParticleSystem:getEmissionRate](particlesystem-getemissionrate "ParticleSystem:getEmissionRate") | Gets the amount of particles emitted per second. | 0.9.0 | | | [ParticleSystem:getEmitterLifetime](particlesystem-getemitterlifetime "ParticleSystem:getEmitterLifetime") | Gets how long the particle system will emit particles | 0.9.0 | | | [ParticleSystem:getImage](particlesystem-getimage "ParticleSystem:getImage") | Gets the image used for the particles. | 0.9.0 | 0.10.0 | | [ParticleSystem:getInsertMode](particlesystem-getinsertmode "ParticleSystem:getInsertMode") | Gets the mode used when the ParticleSystem adds new particles. | 0.9.0 | | | [ParticleSystem:getLinearAcceleration](particlesystem-getlinearacceleration "ParticleSystem:getLinearAcceleration") | Gets the linear acceleration (acceleration along the x and y axes) for particles. | 0.9.0 | | | [ParticleSystem:getLinearDamping](particlesystem-getlineardamping "ParticleSystem:getLinearDamping") | Gets the amount of linear damping (constant deceleration) for particles. | 0.9.2 | | | [ParticleSystem:getOffset](particlesystem-getoffset "ParticleSystem:getOffset") | Gets the particle image's draw offset. | 0.9.0 | | | [ParticleSystem:getOffsetX](particlesystem-getoffsetx "ParticleSystem:getOffsetX") | Get the x coordinate of the particle rotation offset. | | 0.9.0 | | [ParticleSystem:getOffsetY](particlesystem-getoffsety "ParticleSystem:getOffsetY") | Get the y coordinate of the particle rotation offset. | | 0.9.0 | | [ParticleSystem:getParticleLifetime](particlesystem-getparticlelifetime "ParticleSystem:getParticleLifetime") | Gets the lifetime of the particles. | 0.9.0 | | | [ParticleSystem:getPosition](particlesystem-getposition "ParticleSystem:getPosition") | Gets the position of the emitter. | | | | [ParticleSystem:getQuads](particlesystem-getquads "ParticleSystem:getQuads") | Gets a series of [Quads](quad "Quad") used for the particle sprites. | 0.9.2 | | | [ParticleSystem:getRadialAcceleration](particlesystem-getradialacceleration "ParticleSystem:getRadialAcceleration") | Gets the radial acceleration (away from the emitter). | 0.9.0 | | | [ParticleSystem:getRotation](particlesystem-getrotation "ParticleSystem:getRotation") | Gets the rotation of the image upon particle creation (in radians). | 0.9.0 | | | [ParticleSystem:getSizeVariation](particlesystem-getsizevariation "ParticleSystem:getSizeVariation") | Gets the amount of size variation. | 0.9.0 | | | [ParticleSystem:getSizes](particlesystem-getsizes "ParticleSystem:getSizes") | Gets the sizes of the particle over its lifetime. | 0.9.0 | | | [ParticleSystem:getSpeed](particlesystem-getspeed "ParticleSystem:getSpeed") | Gets the speed of the particles. | 0.9.0 | | | [ParticleSystem:getSpin](particlesystem-getspin "ParticleSystem:getSpin") | Gets the spin of the sprite. | 0.9.0 | | | [ParticleSystem:getSpinVariation](particlesystem-getspinvariation "ParticleSystem:getSpinVariation") | Gets the amount of spin variation. | 0.9.0 | | | [ParticleSystem:getSpread](particlesystem-getspread "ParticleSystem:getSpread") | Gets the amount of directional spread of the particle emitter (in radians). | | | | [ParticleSystem:getTangentialAcceleration](particlesystem-gettangentialacceleration "ParticleSystem:getTangentialAcceleration") | Gets the tangential acceleration (acceleration perpendicular to the particle's direction). | 0.9.0 | | | [ParticleSystem:getTexture](particlesystem-gettexture "ParticleSystem:getTexture") | Gets the texture ([Image](image "Image") or [Canvas](canvas "Canvas")) used for the particles. | 0.9.1 | | | [ParticleSystem:getX](particlesystem-getx "ParticleSystem:getX") | Gets the x-coordinate of the particle emitter's position. | | 0.9.0 | | [ParticleSystem:getY](particlesystem-gety "ParticleSystem:getY") | Gets the y-coordinate of the particle emitter's position. | | 0.9.0 | | [ParticleSystem:hasRelativeRotation](particlesystem-hasrelativerotation "ParticleSystem:hasRelativeRotation") | Gets whether particle angles and rotations are relative to their velocities. | 0.9.1 | | | [ParticleSystem:isActive](particlesystem-isactive "ParticleSystem:isActive") | Checks whether the particle system is actively emitting particles. | | | | [ParticleSystem:isEmpty](particlesystem-isempty "ParticleSystem:isEmpty") | Checks whether the particle system is empty of particles. | | 0.9.0 | | [ParticleSystem:isFull](particlesystem-isfull "ParticleSystem:isFull") | Checks whether the particle system is full of particles. | | 0.9.0 | | [ParticleSystem:isPaused](particlesystem-ispaused "ParticleSystem:isPaused") | Checks whether the particle system is paused. | 0.9.0 | | | [ParticleSystem:isStopped](particlesystem-isstopped "ParticleSystem:isStopped") | Checks whether the particle system is stopped. | 0.9.0 | | | [ParticleSystem:moveTo](particlesystem-moveto "ParticleSystem:moveTo") | Moves the position of the emitter. | 0.9.1 | | | [ParticleSystem:pause](particlesystem-pause "ParticleSystem:pause") | Pauses the particle emitter. | | | | [ParticleSystem:reset](particlesystem-reset "ParticleSystem:reset") | Resets the particle emitter, removing existing particles and resetting the lifetime counter. | | | | [ParticleSystem:setAreaSpread](particlesystem-setareaspread "ParticleSystem:setAreaSpread") | Sets area-based spawn parameters for the particles. | 0.9.0 | 11.0 | | [ParticleSystem:setBufferSize](particlesystem-setbuffersize "ParticleSystem:setBufferSize") | Sets the size of the buffer (the max allowed amount of particles in the system). | | | | [ParticleSystem:setColor](particlesystem-setcolor "ParticleSystem:setColor") | Sets the color of the image. | | 0.8.0 | | [ParticleSystem:setColors](particlesystem-setcolors "ParticleSystem:setColors") | Sets the colors to apply to the particle sprite. | 0.8.0 | | | [ParticleSystem:setDirection](particlesystem-setdirection "ParticleSystem:setDirection") | Sets the direction the particles will be emitted in. | | | | [ParticleSystem:setEmissionArea](particlesystem-setemissionarea "ParticleSystem:setEmissionArea") | Sets area-based spawn parameters for the particles. | 11.0 | | | [ParticleSystem:setEmissionRate](particlesystem-setemissionrate "ParticleSystem:setEmissionRate") | Sets the amount of particles emitted per second. | | | | [ParticleSystem:setEmitterLifetime](particlesystem-setemitterlifetime "ParticleSystem:setEmitterLifetime") | Sets how long the particle system should emit particles | 0.9.0 | | | [ParticleSystem:setGravity](particlesystem-setgravity "ParticleSystem:setGravity") | Sets the gravity affecting the particles (acceleration along the y-axis). | | 0.9.0 | | [ParticleSystem:setImage](particlesystem-setimage "ParticleSystem:setImage") | Sets the image to be used for the particles. | 0.9.0 | 0.10.0 | | [ParticleSystem:setInsertMode](particlesystem-setinsertmode "ParticleSystem:setInsertMode") | Sets the mode to use when the ParticleSystem adds new particles. | 0.9.0 | | | [ParticleSystem:setLifetime](particlesystem-setlifetime "ParticleSystem:setLifetime") | Sets how long the particle system should emit particles (if -1 then it emits particles forever). | | 0.9.0 | | [ParticleSystem:setLinearAcceleration](particlesystem-setlinearacceleration "ParticleSystem:setLinearAcceleration") | Sets the linear acceleration (acceleration along the x and y axes) for particles. | 0.9.0 | | | [ParticleSystem:setLinearDamping](particlesystem-setlineardamping "ParticleSystem:setLinearDamping") | Sets the amount of linear damping (constant deceleration) for particles. | 0.9.2 | | | [ParticleSystem:setOffset](particlesystem-setoffset "ParticleSystem:setOffset") | Set the offset position which the particle sprite is rotated around. | | | | [ParticleSystem:setParticleLife](particlesystem-setparticlelife "ParticleSystem:setParticleLife") | Sets the life of the particles. | | 0.9.0 | | [ParticleSystem:setParticleLifetime](particlesystem-setparticlelifetime "ParticleSystem:setParticleLifetime") | Sets the lifetime of the particles. | 0.9.0 | | | [ParticleSystem:setPosition](particlesystem-setposition "ParticleSystem:setPosition") | Sets the position of the emitter. | | | | [ParticleSystem:setQuads](particlesystem-setquads "ParticleSystem:setQuads") | Sets a series of [Quads](quad "Quad") to use for the particle sprites. | 0.9.2 | | | [ParticleSystem:setRadialAcceleration](particlesystem-setradialacceleration "ParticleSystem:setRadialAcceleration") | Set the radial acceleration (away from the emitter). | | | | [ParticleSystem:setRelativeRotation](particlesystem-setrelativerotation "ParticleSystem:setRelativeRotation") | Sets whether particle angles and rotations are relative to their velocities. | 0.9.1 | | | [ParticleSystem:setRotation](particlesystem-setrotation "ParticleSystem:setRotation") | Sets the rotation of the image upon particle creation (in radians). | | | | [ParticleSystem:setSize](particlesystem-setsize "ParticleSystem:setSize") | Sets the size of the particle (1.0 being normal size). | | 0.8.0 | | [ParticleSystem:setSizeVariation](particlesystem-setsizevariation "ParticleSystem:setSizeVariation") | Sets the amount of size variation. | | | | [ParticleSystem:setSizes](particlesystem-setsizes "ParticleSystem:setSizes") | Sets the sizes of the particle over its lifetime. | 0.8.0 | | | [ParticleSystem:setSpeed](particlesystem-setspeed "ParticleSystem:setSpeed") | Sets the speed of the particles. | | | | [ParticleSystem:setSpin](particlesystem-setspin "ParticleSystem:setSpin") | Sets the spin of the sprite. | | | | [ParticleSystem:setSpinVariation](particlesystem-setspinvariation "ParticleSystem:setSpinVariation") | Sets the amount of spin variation. | | | | [ParticleSystem:setSpread](particlesystem-setspread "ParticleSystem:setSpread") | Sets the amount of spread for the system. | | | | [ParticleSystem:setSprite](particlesystem-setsprite "ParticleSystem:setSprite") | Sets the image which is to be emitted. | | 0.9.0 | | [ParticleSystem:setTangentialAcceleration](particlesystem-settangentialacceleration "ParticleSystem:setTangentialAcceleration") | Sets the tangential acceleration (acceleration perpendicular to the particle's direction). | | | | [ParticleSystem:setTexture](particlesystem-settexture "ParticleSystem:setTexture") | Sets the texture ([Image](image "Image") or [Canvas](canvas "Canvas")) to be used for the particles. | 0.9.1 | | | [ParticleSystem:start](particlesystem-start "ParticleSystem:start") | Starts the particle emitter. | | | | [ParticleSystem:stop](particlesystem-stop "ParticleSystem:stop") | Stops the particle emitter, resetting the lifetime counter. | | | | [ParticleSystem:update](particlesystem-update "ParticleSystem:update") | Updates the particle system; moving, creating and killing particles. | | | Enums ----- | | | | | | --- | --- | --- | --- | | [AreaSpreadDistribution](areaspreaddistribution "AreaSpreadDistribution") | Types of particle area spread distribution. | 0.9.0 | | | [ParticleInsertMode](particleinsertmode "ParticleInsertMode") | How newly created particles are added to the ParticleSystem. | 0.9.0 | | Supertypes ---------- * [Drawable](drawable "Drawable") * [Object](object "Object") See Also -------- * [love.graphics](love.graphics "love.graphics") Particle editors: * <https://love2d.org/forums/viewtopic.php?f=4&t=2110> * <https://love2d.org/forums/viewtopic.php?f=5&t=32954> * <https://love2d.org/forums/viewtopic.php?f=5&t=76986>
programming_docs
love (File):eof (File):eof ========== **Removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** It has been renamed to [File:isEOF]((file)-iseof "(File):isEOF"). If the end-of-file has been reached Function -------- ### Synopsis ``` eof = File:eof( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") eof` Whether EOF has been reached See Also -------- * [File](file "File") love ImageData:getPixel ImageData:getPixel ================== Gets the color of a pixel at a specific position in the image. Valid x and y values start at 0 and go up to image width and height minus 1. Non-integer values are floored. In versions prior to [11.0](https://love2d.org/wiki/11.0 "11.0"), color component values were within the range of 0 to 255 instead of 0 to 1. Prior to [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2"), this function does not properly handle non-integer coordinates, and may produce an invalid result when non-integer values are passed. Function -------- ### Synopsis ``` r, g, b, a = ImageData:getPixel( x, y ) ``` ### Arguments `[number](number "number") x` The position of the pixel on the x-axis. `[number](number "number") y` The position of the pixel on the y-axis. ### Returns `[number](number "number") r` The red component (0-1). `[number](number "number") g` The green component (0-1). `[number](number "number") b` The blue component (0-1). `[number](number "number") a` The alpha component (0-1). Examples -------- When the mouse is clicked, reads the red, green, and blue value of the pixel under the mouse and uses it as the background color. ``` local imagedata = love.image.newImageData('path/to/Image.png') local image = love.graphics.newImage(imagedata)   function love.mousepressed(mx, my) if 0 <= mx and mx < image:getWidth() and 0 <= my and my < image:getHeight() then local r, g, b = imagedata:getPixel(mx, my) love.graphics.setBackgroundColor(r, g, b) end end   function love.draw() love.graphics.draw(image, 0, 0) end ``` See Also -------- * [ImageData](imagedata "ImageData") * [ImageData:setPixel](imagedata-setpixel "ImageData:setPixel") love love.system.getClipboardText love.system.getClipboardText ============================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets text from the clipboard. Function -------- ### Synopsis ``` text = love.system.getClipboardText( ) ``` ### Arguments None. ### Returns `[string](string "string") text` The text currently held in the system's clipboard. See Also -------- * [love.system](love.system "love.system") * [love.system.setClipboardText](love.system.setclipboardtext "love.system.setClipboardText") love love.physics.newGearJoint love.physics.newGearJoint ========================= Create a [GearJoint](gearjoint "GearJoint") connecting two Joints. The gear joint connects two joints that must be either [prismatic](prismaticjoint "PrismaticJoint") or [revolute](revolutejoint "RevoluteJoint") joints. Using this joint requires that the joints it uses connect their respective bodies to the ground and have the ground as the first body. When destroying the bodies and joints you must make sure you destroy the gear joint before the other joints. The gear joint has a ratio the determines how the angular or distance values of the connected joints relate to each other. The formula coordinate1 + ratio \* coordinate2 always has a constant value that is set when the gear joint is created. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in earlier versions. ### Synopsis ``` joint = love.physics.newGearJoint( joint1, joint2, ratio, collideConnected ) ``` ### Arguments `[Joint](joint "Joint") joint1` The first joint to connect with a gear joint. `[Joint](joint "Joint") joint2` The second joint to connect with a gear joint. `[number](number "number") ratio (1)` The gear ratio. `[boolean](boolean "boolean") collideConnected (false)` Specifies whether the two bodies should collide with each other. ### Returns `[GearJoint](gearjoint "GearJoint") joint` The new gear joint. Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. ### Synopsis ``` joint = love.physics.newGearJoint( joint1, joint2, ratio ) ``` ### Arguments `[Joint](joint "Joint") joint1` The first joint to connect with a gear joint. `[Joint](joint "Joint") joint2` The second joint to connect with a gear joint. `[number](number "number") ratio (1)` The gear ratio. ### Returns `[GearJoint](gearjoint "GearJoint") joint` The new gear joint. See Also -------- * [love.physics](love.physics "love.physics") * [GearJoint](gearjoint "GearJoint") * [Joint](joint "Joint") love Body:setLinearVelocity Body:setLinearVelocity ====================== Sets a new linear velocity for the Body. This function will not accumulate anything; any impulses previously applied since the last call to World:update will be lost. Function -------- ### Synopsis ``` Body:setLinearVelocity( x, y ) ``` ### Arguments `[number](number "number") x` The x-component of the velocity vector. `[number](number "number") y` The y-component of the velocity vector. ### Returns Nothing. See Also -------- * [Body](body "Body") love love.graphics.setNewFont love.graphics.setNewFont ======================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Creates and sets a new [Font](font "Font"). This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- ### Synopsis ``` font = love.graphics.setNewFont( size ) ``` ### Arguments `[number](number "number") size (12)` The size of the font. ### Returns `[Font](font "Font") font` The new font. Function -------- ### Synopsis ``` font = love.graphics.setNewFont( filename, size ) ``` ### Arguments `[string](string "string") filename` The path and name of the file with the font. `[number](number "number") size (12)` The size of the font. ### Returns `[Font](font "Font") font` The new font. Function -------- ### Synopsis ``` font = love.graphics.setNewFont( file, size ) ``` ### Arguments `[File](file "File") file` A [File](file "File") with the font. `[number](number "number") size (12)` The size of the font. ### Returns `[Font](font "Font") font` The new font. Function -------- ### Synopsis ``` font = love.graphics.setNewFont( data, size ) ``` ### Arguments `[Data](data "Data") data` A [Data](data "Data") with the font. `[number](number "number") size (12)` The size of the font. ### Returns `[Font](font "Font") font` The new font. Function -------- ### Synopsis ``` font = love.graphics.setNewFont( rasterizer ) ``` ### Arguments `[Rasterizer](rasterizer "Rasterizer") rasterizer` A rasterizer. ### Returns `[Font](font "Font") font` The new font. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.newFont](love.graphics.newfont "love.graphics.newFont") * [love.graphics.setFont](love.graphics.setfont "love.graphics.setFont") love (File):seek (File):seek =========== Seek to a position in a file Function -------- ### Synopsis ``` success = File:seek( pos ) ``` ### Arguments `[number](number "number") pos` The position to seek to, relative to start of file. ### Returns `[boolean](boolean "boolean") success` Whether the operation was successful See Also -------- * [File](file "File") love love.graphics.getStats love.graphics.getStats ====================== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Gets performance-related rendering statistics. The per-frame metrics (drawcalls, canvasswitches, shaderswitches) are reset by [love.graphics.present](love.graphics.present "love.graphics.present"), which for the default implementation of [love.run](love.run "love.run") is called right after the execution of [love.draw](love.draw "love.draw"). Therefore this function should probably be called at the end of [love.draw](love.draw "love.draw"). Function -------- ### Synopsis ``` stats = love.graphics.getStats( ) ``` ### Arguments None. ### Returns `[table](table "table") stats` A table with the following fields: `[number](number "number") drawcalls` The number of draw calls made so far during the current frame. `[number](number "number") canvasswitches` The number of times the active [Canvas](canvas "Canvas") has been switched so far during the current frame. `[number](number "number") texturememory` The estimated total size in bytes of video memory used by all loaded [Images](image "Image"), [Canvases](canvas "Canvas"), and [Fonts](font "Font"). `[number](number "number") images` The number of [Image](image "Image") objects currently loaded. `[number](number "number") canvases` The number of [Canvas](canvas "Canvas") objects currently loaded. `[number](number "number") fonts` The number of [Font](font "Font") objects currently loaded. `[number](number "number") shaderswitches` Available since 0.10.2 The number of times the active [Shader](shader "Shader") has been changed so far during the current frame. `[number](number "number") drawcallsbatched` Available since 11.0 The number of draw calls that were saved by LÖVE's automatic batching, since the start of the frame. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. This variant accepts an existing table to fill in, instead of creating a new one. ### Synopsis ``` stats = love.graphics.getStats( stats ) ``` ### Arguments `[table](table "table") stats` A table which will be filled in with the stat fields below. ### Returns `[table](table "table") stats` The table that was passed in above, now containing the following fields: `[number](number "number") drawcalls` The number of draw calls made so far during the current frame. `[number](number "number") canvasswitches` The number of times the active [Canvas](canvas "Canvas") has been switched so far during the current frame. `[number](number "number") texturememory` The estimated total size in bytes of video memory used by all loaded [Images](image "Image"), [Canvases](canvas "Canvas"), and [Fonts](font "Font"). `[number](number "number") images` The number of [Image](image "Image") objects currently loaded. `[number](number "number") canvases` The number of [Canvas](canvas "Canvas") objects currently loaded. `[number](number "number") fonts` The number of [Font](font "Font") objects currently loaded. `[number](number "number") shaderswitches` The number of times the active [Shader](shader "Shader") has been changed so far during the current frame. `[number](number "number") drawcallsbatched` The number of draw calls that were saved by LÖVE's automatic batching, since the start of the frame. Examples -------- ### display the estimated amount of video memory used for textures ``` function love.load() love.graphics.setNewFont(24) end   function love.draw() -- some drawing code here --   local stats = love.graphics.getStats()   local str = string.format("Estimated amount of texture memory used: %.2f MB", stats.texturememory / 1024 / 1024) love.graphics.print(str, 10, 10) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") love Source Source ====== A Source represents audio you can play back. You can do interesting things with Sources, like set the volume, pitch, and its position relative to the listener. Please note that positional audio only works for mono (i.e. non-stereo) sources. The Source controls (play/pause/stop) act according to the following state table. | | Playing | Paused | | --- | --- | --- | | play() | No change | Play | | stop() | Pause + Rewind | Rewind | | pause() | Pause | No change | And for fans of flowcharts (note: omitted calls have no effect, stopping always rewinds). Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.audio.newQueueableSource](love.audio.newqueueablesource "love.audio.newQueueableSource") | Creates a new Source usable for real-time generated sound playback with [Source:queue](source-queue "Source:queue"). | 11.0 | | | [love.audio.newSource](love.audio.newsource "love.audio.newSource") | Creates a new **Source** from a file, [SoundData](sounddata "SoundData"), or [Decoder](decoder "Decoder"). | | | Functions --------- | | | | | | --- | --- | --- | --- | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | | [Source:clone](source-clone "Source:clone") | Creates an identical copy of the Source in the stopped state. | 0.9.1 | | | [Source:getActiveEffects](source-getactiveeffects "Source:getActiveEffects") | Gets a list of the Source's active effect names. | 11.0 | | | [Source:getAirAbsorption](source-getairabsorption "Source:getAirAbsorption") | Gets the amount of air absorption applied to the Source. | 11.2 | | | [Source:getAttenuationDistances](source-getattenuationdistances "Source:getAttenuationDistances") | Gets the reference and maximum attenuation distances of the Source. | 0.9.0 | | | [Source:getChannelCount](source-getchannelcount "Source:getChannelCount") | Gets the number of channels in the Source. | 11.0 | | | [Source:getChannels](source-getchannels "Source:getChannels") | Gets the number of channels in the Source. | 0.9.0 | | | [Source:getCone](source-getcone "Source:getCone") | Gets the Source's directional volume cones. | 0.9.0 | | | [Source:getDirection](source-getdirection "Source:getDirection") | Gets the direction of the Source. | 0.7.0 | | | [Source:getDistance](source-getdistance "Source:getDistance") | Returns the reference and maximum distance of the source. | 0.8.0 | 0.9.0 | | [Source:getDuration](source-getduration "Source:getDuration") | Gets the duration of the Source. | 0.10.0 | | | [Source:getEffect](source-geteffect "Source:getEffect") | Retrieve filter settings associated to a specific effect. | 11.0 | | | [Source:getFilter](source-getfilter "Source:getFilter") | Gets the [filter](source-setfilter "Source:setFilter") settings currently applied to the Source. | 11.0 | | | [Source:getFreeBufferCount](source-getfreebuffercount "Source:getFreeBufferCount") | Gets the number of free buffer slots of a queueable Source. | 11.0 | | | [Source:getPitch](source-getpitch "Source:getPitch") | Gets the current pitch of the Source. | | | | [Source:getPosition](source-getposition "Source:getPosition") | Gets the position of the Source. | 0.7.0 | | | [Source:getRolloff](source-getrolloff "Source:getRolloff") | Returns the rolloff factor of the source. | 0.8.0 | | | [Source:getType](source-gettype "Source:getType") | Gets the type of the Source. | 0.10.0 | | | [Source:getVelocity](source-getvelocity "Source:getVelocity") | Gets the velocity of the Source. | 0.7.0 | | | [Source:getVolume](source-getvolume "Source:getVolume") | Gets the current volume of the Source. | | | | [Source:getVolumeLimits](source-getvolumelimits "Source:getVolumeLimits") | Returns the volume limits of the source. | 0.8.0 | | | [Source:isLooping](source-islooping "Source:isLooping") | Returns whether the Source will loop. | | | | [Source:isPaused](source-ispaused "Source:isPaused") | Returns whether the Source is paused. | | 11.0 | | [Source:isPlaying](source-isplaying "Source:isPlaying") | Returns whether the Source is playing. | 0.9.0 | | | [Source:isRelative](source-isrelative "Source:isRelative") | Gets whether the Source's position and direction are relative to the listener. | 0.9.0 | | | [Source:isStatic](source-isstatic "Source:isStatic") | Returns whether the Source is static. | 0.7.0 | 0.10.0 | | [Source:isStopped](source-isstopped "Source:isStopped") | Returns whether the Source is stopped. | | 11.0 | | [Source:pause](source-pause "Source:pause") | Pauses a source. | 0.7.0 | | | [Source:play](source-play "Source:play") | Plays a source. | 0.7.0 | | | [Source:queue](source-queue "Source:queue") | Queues SoundData for playback in a [queueable Source](love.audio.newqueueablesource "love.audio.newQueueableSource"). | 11.0 | | | [Source:resume](source-resume "Source:resume") | Resumes a paused source. | 0.7.0 | 11.0 | | [Source:rewind](source-rewind "Source:rewind") | Rewinds a source. | 0.7.0 | 11.0 | | [Source:seek](source-seek "Source:seek") | Sets the currently playing position of the Source. | 0.8.0 | | | [Source:setAirAbsorption](source-setairabsorption "Source:setAirAbsorption") | Sets the amount of air absorption applied to the Source. | 11.2 | | | [Source:setAttenuationDistances](source-setattenuationdistances "Source:setAttenuationDistances") | Sets the reference and maximum attenuation distances of the Source. | 0.9.0 | | | [Source:setCone](source-setcone "Source:setCone") | Sets the Source's directional volume cones. | 0.9.0 | | | [Source:setDirection](source-setdirection "Source:setDirection") | Sets the direction of the Source. | 0.7.0 | | | [Source:setDistance](source-setdistance "Source:setDistance") | Sets the reference and maximum distance of the source. | 0.8.0 | 0.9.0 | | [Source:setEffect](source-seteffect "Source:setEffect") | Applies an audio [effect](effecttype "EffectType") to the Source. | 11.0 | | | [Source:setFilter](source-setfilter "Source:setFilter") | Sets a low-pass, high-pass, or band-pass filter to apply when playing the Source. | 11.0 | | | [Source:setLooping](source-setlooping "Source:setLooping") | Sets whether the Source should loop. | | | | [Source:setPitch](source-setpitch "Source:setPitch") | Sets the pitch of the Source. | | | | [Source:setPosition](source-setposition "Source:setPosition") | Sets the position of the Source. | 0.7.0 | | | [Source:setRelative](source-setrelative "Source:setRelative") | Sets whether the Source's position and direction are relative to the listener. | 0.9.0 | | | [Source:setRolloff](source-setrolloff "Source:setRolloff") | Sets the rolloff factor. | 0.8.0 | | | [Source:setVelocity](source-setvelocity "Source:setVelocity") | Sets the velocity of the Source. | 0.7.0 | | | [Source:setVolume](source-setvolume "Source:setVolume") | Sets the current volume of the Source. | | | | [Source:setVolumeLimits](source-setvolumelimits "Source:setVolumeLimits") | Sets the volume limits of the source. | 0.8.0 | | | [Source:stop](source-stop "Source:stop") | Stops a source. | 0.7.0 | | | [Source:tell](source-tell "Source:tell") | Gets the currently playing position of the Source. | 0.8.0 | | Enums ----- | | | | | | --- | --- | --- | --- | | [FilterType](filtertype "FilterType") | Types of filters for Sources. | 11.0 | | | [SourceType](sourcetype "SourceType") | Types of audio sources. | | | Supertypes ---------- * [Object](object "Object") See Also -------- * [love.audio](love.audio "love.audio")
programming_docs
love ParticleSystem:getSizes ParticleSystem:getSizes ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the series of sizes by which the sprite is scaled. 1.0 is normal size. The particle system will interpolate between each size evenly over the particle's lifetime. Function -------- ### Synopsis ``` size1, size1, ..., size8 = ParticleSystem:getSizes( ) ``` ### Arguments Nothing. ### Returns `[number](number "number") size1` The first size. `[number](number "number") size2` The second size. `[number](number "number") size8` The eighth size. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setSizes](particlesystem-setsizes "ParticleSystem:setSizes") love Source:play Source:play =========== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Starts playing the Source. Function -------- **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This variant is not supported in earlier versions. ### Synopsis ``` success = Source:play() ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") success` Whether the Source was able to successfully start playing. Function -------- **Removed in LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This variant is not supported in that and later versions. ### Synopsis ``` Source:play() ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Source](source "Source") love Channel:hasRead Channel:hasRead =============== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets whether a pushed value has been popped or otherwise removed from the Channel. Function -------- ### Synopsis ``` hasread = Channel:hasRead( id ) ``` ### Arguments `[number](number "number") id` An id value previously returned by [Channel:push](channel-push "Channel:push"). ### Returns `[boolean](boolean "boolean") hasread` Whether the value represented by the id has been removed from the Channel via [Channel:pop](channel-pop "Channel:pop"), [Channel:demand](channel-demand "Channel:demand"), or [Channel:clear](channel-clear "Channel:clear"). See Also -------- * [Channel](channel "Channel") * [Channel:push](channel-push "Channel:push") * [Channel:pop](channel-pop "Channel:pop") * [Channel:demand](channel-demand "Channel:demand") * [Channel:clear](channel-clear "Channel:clear") love love.thread.newChannel love.thread.newChannel ====================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Create a new unnamed thread channel. One use for them is to pass new unnamed channels to other threads via [Channel:push](channel-push "Channel:push") on a named channel. Function -------- ### Synopsis ``` channel = love.thread.newChannel( ) ``` ### Arguments None. ### Returns `[Channel](channel "Channel") channel` The new Channel object. See Also -------- * [love.thread](love.thread "love.thread") * [Channel](channel "Channel") love Texture:getPixelWidth Texture:getPixelWidth ===================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This method is not supported in earlier versions. Gets the width in pixels of the Texture. [Texture:getWidth](texture-getwidth "Texture:getWidth") gets the width of the texture in units scaled by the texture's [DPI scale factor](texture-getdpiscale "Texture:getDPIScale"), rather than pixels. Use getWidth for calculations related to drawing the texture (calculating an origin offset, for example), and getPixelWidth only when dealing specifically with pixels, for example when using [Canvas:newImageData](canvas-newimagedata "Canvas:newImageData"). Function -------- ### Synopsis ``` pixelwidth = Texture:getPixelWidth( ) ``` ### Arguments None. ### Returns `[number](number "number") pixelwidth` The width of the Texture, in pixels. See Also -------- * [Texture](texture "Texture") * [Texture:getDPIScale](texture-getdpiscale "Texture:getDPIScale") * [Texture:getPixelHeight](texture-getpixelheight "Texture:getPixelHeight") * [Texture:getPixelDimensions](texture-getpixeldimensions "Texture:getPixelDimensions") love ParticleSystem:isPaused ParticleSystem:isPaused ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Checks whether the particle system is paused. Function -------- ### Synopsis ``` paused = ParticleSystem:isPaused( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") paused` True if system is paused, false otherwise. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:isActive](particlesystem-isactive "ParticleSystem:isActive") * [ParticleSystem:isStopped](particlesystem-isstopped "ParticleSystem:isStopped") love Mesh:getVertexCount Mesh:getVertexCount =================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the total number of vertices in the Mesh. Function -------- ### Synopsis ``` count = Mesh:getVertexCount( ) ``` ### Arguments None. ### Returns `[number](number "number") count` The total number of vertices in the mesh. See Also -------- * [Mesh](mesh "Mesh") * [Mesh:getVertex](mesh-getvertex "Mesh:getVertex") * [Mesh:setVertex](mesh-setvertex "Mesh:setVertex") love SpriteBatch:getTexture SpriteBatch:getTexture ====================== **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. Gets the texture ([Image](image "Image") or [Canvas](canvas "Canvas")) used by the SpriteBatch. Function -------- ### Synopsis ``` texture = SpriteBatch:getTexture( ) ``` ### Arguments None. ### Returns `[Texture](texture "Texture") texture` The Image or Canvas used by the SpriteBatch. See Also -------- * [SpriteBatch](spritebatch "SpriteBatch") * [SpriteBatch:setTexture](spritebatch-settexture "SpriteBatch:setTexture") love Joystick:getID Joystick:getID ============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the joystick's unique identifier. The identifier will remain the same for the life of the game, even when the Joystick is disconnected and reconnected, but it **will** change when the game is re-launched. Function -------- ### Synopsis ``` id, instanceid = Joystick:getID( ) ``` ### Arguments None. ### Returns `[number](number "number") id` The Joystick's unique identifier. Remains the same as long as the game is running. `[number](number "number") instanceid (nil)` Unique instance identifier. Changes every time the Joystick is reconnected. nil if the Joystick is not connected. See Also -------- * [Joystick](joystick "Joystick") * [Joystick:isConnected](joystick-isconnected "Joystick:isConnected") * [Joystick:getGUID](joystick-getguid "Joystick:getGUID") love love.keyboard.setTextInput love.keyboard.setTextInput ========================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Enables or disables [text input](love.textinput "love.textinput") events. It is enabled by default on Windows, Mac, and Linux, and disabled by default on iOS and Android. On touch devices, this shows the system's native on-screen keyboard when it's enabled. Function -------- ### Synopsis ``` love.keyboard.setTextInput( enable ) ``` ### Arguments `[boolean](boolean "boolean") enable` Whether text input events should be enabled. ### Returns Nothing. Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. On iOS and Android this variant tells the OS that the specified rectangle is where text will show up in the game, which prevents the system on-screen keyboard from covering the text. ### Synopsis ``` love.keyboard.setTextInput( enable, x, y, w, h ) ``` ### Arguments `[boolean](boolean "boolean") enable` Whether text input events should be enabled. `[number](number "number") x` Text rectangle x position. `[number](number "number") y` Text rectangle y position. `[number](number "number") w` Text rectangle width. `[number](number "number") h` Text rectangle height. ### Returns Nothing. See Also -------- * [love.keyboard](love.keyboard "love.keyboard") * [love.keyboard.hasTextInput](love.keyboard.hastextinput "love.keyboard.hasTextInput") * [love.textinput](love.textinput "love.textinput") love love.keyboard love.keyboard ============= Provides an interface to the user's keyboard. Functions --------- | | | | | | --- | --- | --- | --- | | [love.keyboard.getKeyFromScancode](love.keyboard.getkeyfromscancode "love.keyboard.getKeyFromScancode") | Gets the key corresponding to the given hardware scancode. | 0.9.2 | | | [love.keyboard.getKeyRepeat](love.keyboard.getkeyrepeat "love.keyboard.getKeyRepeat") | Returns the delay and interval of key repeating. | | 0.9.0 | | [love.keyboard.getScancodeFromKey](love.keyboard.getscancodefromkey "love.keyboard.getScancodeFromKey") | Gets the hardware scancode corresponding to the given key. | 0.9.2 | | | [love.keyboard.hasKeyRepeat](love.keyboard.haskeyrepeat "love.keyboard.hasKeyRepeat") | Gets whether key repeat is enabled. | 0.9.0 | | | [love.keyboard.hasScreenKeyboard](love.keyboard.hasscreenkeyboard "love.keyboard.hasScreenKeyboard") | Gets whether screen keyboard is supported. | 0.10.0 | | | [love.keyboard.hasTextInput](love.keyboard.hastextinput "love.keyboard.hasTextInput") | Gets whether [text input](love.textinput "love.textinput") events are enabled. | 0.9.0 | | | [love.keyboard.isDown](love.keyboard.isdown "love.keyboard.isDown") | Checks whether a certain key is down. | | | | [love.keyboard.isScancodeDown](love.keyboard.isscancodedown "love.keyboard.isScancodeDown") | Checks whether the specified [Scancodes](scancode "Scancode") are pressed. | 0.10.0 | | | [love.keyboard.setKeyRepeat](love.keyboard.setkeyrepeat "love.keyboard.setKeyRepeat") | Enables or disables key repeat for [love.keypressed](love.keypressed "love.keypressed"). | | | | [love.keyboard.setTextInput](love.keyboard.settextinput "love.keyboard.setTextInput") | Enables or disables [text input](love.textinput "love.textinput") events. | 0.9.0 | | Enums ----- | | | | | | --- | --- | --- | --- | | [KeyConstant](keyconstant "KeyConstant") | All the keys you can press. | | | | [Scancode](scancode "Scancode") | Keyboard scancodes. | 0.9.2 | | See Also -------- * [love](love "love") * [love.keypressed](love.keypressed "love.keypressed") * [love.keyreleased](love.keyreleased "love.keyreleased") love love.window.getHeight love.window.getHeight ===================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** Use [love.graphics.getHeight](love.graphics.getheight "love.graphics.getHeight") or [love.window.getMode](love.window.getmode "love.window.getMode") instead. Gets the height of the window. Function -------- ### Synopsis ``` height = love.window.getHeight( ) ``` ### Arguments None. ### Returns `[number](number "number") height` The height of the window. See Also -------- * [love.window](love.window "love.window") * [love.window.getWidth](love.window.getwidth "love.window.getWidth") * [love.window.getDimensions](love.window.getdimensions "love.window.getDimensions") * [love.window.setMode](love.window.setmode "love.window.setMode") love Joint:getCollideConnected Joint:getCollideConnected ========================= Gets whether the connected Bodies collide. Function -------- ### Synopsis ``` c = Joint:getCollideConnected( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") c` True if they collide, false otherwise. See Also -------- * [Joint](joint "Joint") love VideoStream VideoStream =========== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This type is not supported in earlier versions. An object which decodes, streams, and controls [Videos](video "Video"). Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.video.newVideoStream](love.video.newvideostream "love.video.newVideoStream") | Creates a new **VideoStream**. | 0.10.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | | [VideoStream:getFilename](videostream-getfilename "VideoStream:getFilename") | Gets filename of video stream. | 0.10.0 | | | [VideoStream:isPlaying](videostream-isplaying "VideoStream:isPlaying") | Gets whatever the video stream is playing. | 0.10.0 | | | [VideoStream:pause](videostream-pause "VideoStream:pause") | Pauses video stream. | 0.10.0 | | | [VideoStream:play](videostream-play "VideoStream:play") | Plays video stream. | 0.10.0 | | | [VideoStream:rewind](videostream-rewind "VideoStream:rewind") | Rewinds video stream. | 0.10.0 | | | [VideoStream:seek](videostream-seek "VideoStream:seek") | Sets the current playback position of the Video. | 0.10.0 | | | [VideoStream:setSync](videostream-setsync "VideoStream:setSync") | TODO | 0.10.0 | | | [VideoStream:tell](videostream-tell "VideoStream:tell") | Gets the current playback position of video stream. | 0.10.0 | | Supertypes ---------- * [Object](object "Object") See Also -------- * [love.video](love.video "love.video") * [Video](video "Video") love love.graphics.getStackDepth love.graphics.getStackDepth =========================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the current depth of the transform / state stack (the number of [pushes](love.graphics.push "love.graphics.push") without corresponding [pops](love.graphics.pop "love.graphics.pop")). Function -------- ### Synopsis ``` depth = love.graphics.getStackDepth( ) ``` ### Arguments None. ### Returns `[number](number "number") depth` The current depth of the transform and state love.graphics stack. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.push](love.graphics.push "love.graphics.push") * [love.graphics.pop](love.graphics.pop "love.graphics.pop") love Fixture:setUserData Fixture:setUserData =================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Associates a Lua value with the fixture. To delete the reference, explicitly pass nil. Use this function in one thread and one thread only. Using it in more threads will make Lua cry and most likely crash. Function -------- ### Synopsis ``` Fixture:setUserData( value ) ``` ### Arguments `[any](https://love2d.org/w/index.php?title=any&action=edit&redlink=1 "any (page does not exist)") value` The Lua value to associate with the fixture. ### Returns Nothing. See Also -------- * [Fixture](fixture "Fixture") * [Fixture:getUserData](fixture-getuserdata "Fixture:getUserData") love love.graphics.getSystemLimits love.graphics.getSystemLimits ============================= **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** It has replaced [love.graphics.getSystemLimit](love.graphics.getsystemlimit "love.graphics.getSystemLimit"). Gets the system-dependent maximum values for love.graphics features. Function -------- ### Synopsis ``` limits = love.graphics.getSystemLimits( ) ``` ### Arguments None. ### Returns `[table](table "table") limits` A table containing [GraphicsLimit](graphicslimit "GraphicsLimit") keys, and number values. See Also -------- * [love.graphics](love.graphics "love.graphics") * [GraphicsLimit](graphicslimit "GraphicsLimit") love RopeJoint:getMaxLength RopeJoint:getMaxLength ====================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Gets the maximum length of a RopeJoint. Function -------- ### Synopsis ``` maxLength = RopeJoint:getMaxLength( ) ``` ### Arguments None. ### Returns `[number](number "number") maxLength` The maximum length of the RopeJoint. See Also -------- * [RopeJoint](ropejoint "RopeJoint") * [RopeJoint:setMaxLength](ropejoint-setmaxlength "RopeJoint:setMaxLength") love Fixture:getCategory Fixture:getCategory =================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the categories the fixture belongs to. Function -------- ### Synopsis ``` category1, category2, ... = Fixture:getCategory( ) ``` ### Arguments None. ### Returns `[number](number "number") category1` The first category. `[number](number "number") category2` The second category. See Also -------- * [Fixture](fixture "Fixture") * [Fixture:setCategory](fixture-setcategory "Fixture:setCategory") love ContainerType ContainerType ============= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This enum is not supported in earlier versions. Return type of various data-returning functions. Constants --------- data Return type is [ByteData](bytedata "ByteData"). string Return type is [string](string "string"). Notes ----- Use **data** return type if you want to pass a reference to the data to another thread or LÖVE function, and use **string** return type if you want to use it immediately, like sending it to network. See Also -------- * [love.data](love.data "love.data") * [love.data.compress](love.data.compress "love.data.compress") * [love.data.decompress](love.data.decompress "love.data.decompress") * [love.data.encode](love.data.encode "love.data.encode") * [love.data.decode](love.data.decode "love.data.decode") * [love.data.pack](love.data.pack "love.data.pack") * [love.filesystem.read](love.filesystem.read "love.filesystem.read") * [File:read]((file)-read "(File):read") love DroppedFile DroppedFile =========== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This type is not supported in earlier versions. Represents a file dropped onto the window. Note that the DroppedFile type can only be obtained from [love.filedropped](love.filedropped "love.filedropped") callback, and can't be constructed manually by the user. Functions --------- These functions have parentheses in odd places. This is because the *File:* namespace is reserved in Mediawiki. | | | | | | --- | --- | --- | --- | | [(File):close]((file)-close "(File):close") | Closes a [File](file "File"). | | | | [(File):eof]((file)-eof "(File):eof") | If the end-of-file has been reached | | 0.10.0 | | [(File):flush]((file)-flush "(File):flush") | Flushes any buffered written data in the file to disk. | 0.9.0 | | | [(File):getBuffer]((file)-getbuffer "(File):getBuffer") | Gets the buffer mode of a file. | 0.9.0 | | | [(File):getFilename]((file)-getfilename "(File):getFilename") | Gets the filename that the File object was created with. | 0.10.0 | | | [(File):getMode]((file)-getmode "(File):getMode") | Gets the [FileMode](filemode "FileMode") the file has been opened with. | 0.9.0 | | | [(File):getSize]((file)-getsize "(File):getSize") | Returns the [file](file "File") size. | | | | [(File):isEOF]((file)-iseof "(File):isEOF") | Gets whether end-of-file has been reached. | 0.10.0 | | | [(File):isOpen]((file)-isopen "(File):isOpen") | Gets whether the file is open. | 0.9.0 | | | [(File):lines]((file)-lines "(File):lines") | Iterate over all the lines in a file. | | | | [(File):open]((file)-open "(File):open") | Open the file for write, read or append. | | | | [(File):read]((file)-read "(File):read") | Read a number of bytes from a file | | | | [(File):seek]((file)-seek "(File):seek") | Seek to a position in a file | | | | [(File):setBuffer]((file)-setbuffer "(File):setBuffer") | Sets the buffer mode for a file opened for writing or appending. | 0.9.0 | | | [(File):tell]((file)-tell "(File):tell") | Returns the position in the file. | | | | [(File):write]((file)-write "(File):write") | Write data to a file. | | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Supertypes ---------- * [File](file "File") * [Object](object "Object") See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [love.filedropped](love.filedropped "love.filedropped")
programming_docs
love love.math.newTransform love.math.newTransform ====================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Creates a new [Transform](transform "Transform") object. Function -------- Creates a Transform with no transformations applied. Call methods on the returned object to apply transformations. ### Synopsis ``` transform = love.math.newTransform( ) ``` ### Arguments None. ### Returns `[Transform](transform "Transform") transform` The new Transform object. Function -------- Creates a Transform with the specified transformation applied on creation. ### Synopsis ``` transform = love.math.newTransform( x, y, angle, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[number](number "number") x` The position of the new Transform on the x-axis. `[number](number "number") y` The position of the new Transform on the y-axis. `[number](number "number") angle (0)` The orientation of the new Transform in radians. `[number](number "number") sx (1)` Scale factor on the x-axis. `[number](number "number") sy (sx)` Scale factor on the y-axis. `[number](number "number") ox (0)` Origin offset on the x-axis. `[number](number "number") oy (0)` Origin offset on the y-axis. `[number](number "number") kx (0)` Shearing / skew factor on the x-axis. `[number](number "number") ky (0)` Shearing / skew factor on the y-axis. ### Returns `[Transform](transform "Transform") transform` The new Transform object. Examples -------- Creates a new Transform object and uses it to position and rotate a rectangle around its center. ``` function love.load() rectwidth = 100 rectheight = 100   -- arguments are: x, y, angle, scalex, scaley, offsetx, offsety transform = love.math.newTransform(100, 100, math.pi/4, 1, 1, rectwidth / 2, rectheight / 2) end   function love.draw() love.graphics.applyTransform(transform) love.graphics.rectangle("fill", 0, 0, rectwidth, rectheight) end ``` See Also -------- * [love.math](love.math "love.math") * [Transform](transform "Transform") love Framebuffer:renderTo Framebuffer:renderTo ==================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been renamed to [Canvas:renderTo](canvas-renderto "Canvas:renderTo"). Render to the [Framebuffer](framebuffer "Framebuffer") using a function. Function -------- ### Synopsis ``` Framebuffer:renderTo( func ) ``` ### Arguments `[function](function "function") func` A function performing drawing operations. ### Returns Nothing. Notes ----- This function will clear the target framebuffer. This is a shortcut to [love.graphics.setRenderTarget](love.graphics.setrendertarget "love.graphics.setRenderTarget"): ``` framebuffer:renderTo( func ) ``` is the same as ``` love.graphics.setRenderTarget( framebuffer ) func() love.graphics.setRenderTarget() ``` Examples -------- ### Using an anonymous function for drawing to a Framebuffer ``` framebuffer:renderTo(function() love.graphics.draw(image1, 0,0) love.graphics.draw(image2, 100,100) end) ``` See Also -------- * [Framebuffer](framebuffer "Framebuffer") * [love.graphics.setRenderTarget](love.graphics.setrendertarget "love.graphics.setRenderTarget") love love.joystick.close love.joystick.close =================== **Available since LÖVE [0.5.0](https://love2d.org/wiki/0.5.0 "0.5.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier or later versions. Closes a joystick, i.e. stop using it for generating events and in query functions. Function -------- ### Synopsis ``` love.joystick.close( joystick ) ``` ### Arguments `[number](number "number") joystick` The joystick to be closed ### Returns Nothing. See Also -------- * [love.joystick](love.joystick "love.joystick") love Thread:getKeys Thread:getKeys ============== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This method is not supported in earlier or later versions. Returns a table with the names of all messages in the message box. Function -------- ### Synopsis ``` msgNames = Thread:getKeys() ``` ### Arguments None. ### Returns `[table](table "table") msgNames` A [sequence](sequence "sequence") with all the message names. See Also -------- * [Thread](thread "Thread") love love.audio.getRecordingDevices love.audio.getRecordingDevices ============================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets a list of [RecordingDevices](recordingdevice "RecordingDevice") on the system. The first device in the list is the user's default recording device. The list may be empty if there are no microphones connected to the system. Audio recording is currently not supported on iOS. Function -------- ### Synopsis ``` devices = love.audio.getRecordingDevices( ) ``` ### Arguments None. ### Returns `[table](table "table") devices` The list of connected [recording devices](recordingdevice "RecordingDevice"). Notes ----- Audio recording for Android is supported since [11.3](https://love2d.org/wiki/11.3 "11.3"). However, it's not supported when APK from Play Store is used. See Also -------- * [love.audio](love.audio "love.audio") * [RecordingDevice](recordingdevice "RecordingDevice") love Mesh:detachAttribute Mesh:detachAttribute ==================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Removes a previously [attached](mesh-attachattribute "Mesh:attachAttribute") vertex attribute from this Mesh. Function -------- ### Synopsis ``` success = Mesh:detachAttribute( name ) ``` ### Arguments `[string](string "string") name` The name of the attached vertex attribute to detach. ### Returns `[boolean](boolean "boolean") success` Whether the attribute was successfully detached. See Also -------- * [Mesh](mesh "Mesh") * [Mesh:attachAttribute](mesh-attachattribute "Mesh:attachAttribute") love ImageFlag ImageFlag ========= Image flags. This needs more documentation! Constants --------- linear mipmaps See Also -------- * [love.graphics](love.graphics "love.graphics") * [Image:getFlags]((image)-getflags "(Image):getFlags") love ParticleSystem:setSizeVariation ParticleSystem:setSizeVariation =============================== Sets the amount of size variation (0 meaning no variation and 1 meaning full variation between start and end). Function -------- ### Synopsis ``` ParticleSystem:setSizeVariation( variation ) ``` ### Arguments `[number](number "number") variation` The amount of variation (0 meaning no variation and 1 meaning full variation between start and end). ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love World:getContactFilter World:getContactFilter ====================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the function for collision filtering. Function -------- ### Synopsis ``` contactFilter = World:getContactFilter( ) ``` ### Arguments None. ### Returns `[function](function "function") contactFilter` The function that handles the contact filtering. See Also -------- * [World](world "World") * [World:setContactFilter](world-setcontactfilter "World:setContactFilter") love love.graphics.getImageFormats love.graphics.getImageFormats ============================= **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the raw and compressed [pixel formats](pixelformat "PixelFormat") usable for [Images](image "Image"), and whether each is supported. Function -------- ### Synopsis ``` formats = love.graphics.getImageFormats( ) ``` ### Arguments None. ### Returns `[table](table "table") formats` A table containing [PixelFormats](pixelformat "PixelFormat") as keys, and a boolean indicating whether the format is supported as values. Not all systems support all formats. Examples -------- ### Display a list of the raw and compressed pixel formats usable with Images on the screen ``` formats = love.graphics.getImageFormats()   function love.draw() local y = 0 for formatname, formatsupported in pairs(formats) do local str = string.format("Supports format '%s': %s", formatname, tostring(formatsupported)) love.graphics.print(str, 10, y) y = y + 20 end end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [PixelFormat](pixelformat "PixelFormat") * [love.graphics.newImage](love.graphics.newimage "love.graphics.newImage") * [love.image.newImageData](love.image.newimagedata "love.image.newImageData") * [love.image.newCompressedData](love.image.newcompresseddata "love.image.newCompressedData") love WeldJoint:setDampingRatio WeldJoint:setDampingRatio ========================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Sets a new damping ratio. Function -------- ### Synopsis ``` WeldJoint:setDampingRatio( ratio ) ``` ### Arguments `[number](number "number") ratio` The new damping ratio. ### Returns Nothing. See Also -------- * [WeldJoint](weldjoint "WeldJoint") * [WeldJoint:getDampingRatio](weldjoint-getdampingratio "WeldJoint:getDampingRatio") love Body:isBullet Body:isBullet ============= Get the bullet status of a body. There are two methods to check for body collisions: * at their location when the world is updated (default) * using continuous collision detection (CCD) The default method is efficient, but a body moving very quickly may sometimes jump over another body without producing a collision. A body that is set as a bullet will use CCD. This is less efficient, but is guaranteed not to jump when moving quickly. Note that static bodies (with zero mass) always use CCD, so your walls will not let a fast moving body pass through even if it is not a bullet. Function -------- ### Synopsis ``` status = Body:isBullet( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") status` The bullet status of the body. See Also -------- * [Body](body "Body") love Texture:setFilter Texture:setFilter ================= Sets the [filter mode](filtermode "FilterMode") of the Texture. Function -------- ### Synopsis ``` Texture:setFilter( min, mag ) ``` ### Arguments `[FilterMode](filtermode "FilterMode") min` Filter mode to use when minifying the texture (rendering it at a smaller size on-screen than its size in pixels). `[FilterMode](filtermode "FilterMode") mag` Filter mode to use when magnifying the texture (rendering it at a larger size on-screen than its size in pixels). ### Returns Nothing. Function -------- **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in earlier versions. ### Synopsis ``` Texture:setFilter( min, mag, anisotropy ) ``` ### Arguments `[FilterMode](filtermode "FilterMode") min` Filter mode to use when minifying the texture (rendering it at a smaller size on-screen than its size in pixels). `[FilterMode](filtermode "FilterMode") mag` Filter mode to use when magnifying the texture (rendering it at a larger size on-screen than its size in pixels). `[number](number "number") anisotropy (1)` Maximum amount of anisotropic filtering to use. ### Returns Nothing. ### Notes When mipmapping is used, higher anisotropic filtering values increase the quality of the texture when rendering it with a non-uniform scale, at the expense of a bit of performance. Most systems support up to 8x or 16x anisotropic filtering. See Also -------- * [Texture](texture "Texture") * [Texture:getFilter](texture-getfilter "Texture:getFilter") love Canvas:newImageData Canvas:newImageData =================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** It has been renamed from [Canvas:getImageData](canvas-getimagedata "Canvas:getImageData"). Generates [ImageData](imagedata "ImageData") from the contents of the Canvas. This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- ### Synopsis ``` data = Canvas:newImageData( ) ``` ### Arguments None. ### Returns `[ImageData](imagedata "ImageData") data` The new ImageData made from the Canvas' contents. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` data = Canvas:newImageData( slice, mipmap, x, y, width, height ) ``` ### Arguments `[number](number "number") slice` The cubemap face index, array index, or depth layer for [cubemap, array, or volume](texturetype "TextureType") type Canvases, respectively. This argument is ignored for regular 2D canvases. `[number](number "number") mipmap (1)` The mipmap index to use, for Canvases with [mipmaps](mipmapmode "MipmapMode"). `[number](number "number") x` The x-axis of the top-left corner (in pixels) of the area within the Canvas to capture. `[number](number "number") y` The y-axis of the top-left corner (in pixels) of the area within the Canvas to capture. `[number](number "number") width` The width in pixels of the area within the Canvas to capture. `[number](number "number") height` The height in pixels of the area within the Canvas to capture. ### Returns `[ImageData](imagedata "ImageData") data` The new ImageData made from the Canvas' contents. Function -------- **Removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in that and later versions. ### Synopsis ``` data = Canvas:newImageData( x, y, width, height ) ``` ### Arguments `[number](number "number") x` The x-axis of the top-left corner (in pixels) of the area within the Canvas to capture. `[number](number "number") y` The y-axis of the top-left corner (in pixels) of the area within the Canvas to capture. `[number](number "number") width` The width in pixels of the area within the Canvas to capture. `[number](number "number") height` The height in pixels of the area within the Canvas to capture. ### Returns `[ImageData](imagedata "ImageData") data` The new ImageData made from the Canvas' contents. See Also -------- * [Canvas](canvas "Canvas") * [love.graphics.captureScreenshot](love.graphics.capturescreenshot "love.graphics.captureScreenshot") * [ImageData](imagedata "ImageData") love love.event.poll love.event.poll =============== **Available since LÖVE [0.6.0](https://love2d.org/wiki/0.6.0 "0.6.0")** This function is not supported in earlier versions. Returns an iterator for messages in the event queue. Function -------- ### Synopsis ``` i = love.event.poll( ) ``` ### Arguments None. ### Returns `[function](function "function") i` Iterator function usable in a for loop. Examples -------- ### Checking for events in 0.10.0 ``` for n, a, b, c, d, e, f in love.event.poll() do if n == "quit" then -- Quit! end end ``` ### Checking for events in 0.8.0 ``` for e, a, b, c, d in love.event.poll() do if e == "quit" then -- Quit! end end ``` ### Checking for events in 0.7.2 ``` for e, a, b, c in love.event.poll() do if e == "q" then -- Quit! end end ``` See Also -------- * [love.event](love.event "love.event") * [love.event.wait](love.event.wait "love.event.wait") love Mesh:setVertex Mesh:setVertex ============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Sets the properties of a vertex in the Mesh. In versions prior to [11.0](https://love2d.org/wiki/11.0 "11.0"), color and byte component values were within the range of 0 to 255 instead of 0 to 1. Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. ### Synopsis ``` Mesh:setVertex( index, attributecomponent, ... ) ``` ### Arguments `[number](number "number") index` The index of the the vertex you want to modify (one-based). `[number](number "number") attributecomponent` The first component of the first vertex attribute in the specified vertex. `[number](number "number") ...` Additional components of all vertex attributes in the specified vertex. ### Returns Nothing. ### Notes The arguments are in the same order as the vertex attributes in the Mesh's [vertex format](mesh-getvertexformat "Mesh:getVertexFormat"). A standard Mesh that wasn't [created](love.graphics.newmesh "love.graphics.newMesh") with a custom vertex format will use two position numbers, two texture coordinate numbers, and four color components per vertex: x, y, u, v, r, g, b, a. If no value is supplied for a specific vertex attribute component, it will be set to a default value of 0 if its [data type](attributedatatype "AttributeDataType") is "float", or 1 if its data type is "byte". Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. ### Synopsis ``` Mesh:setVertex( index, vertex ) ``` ### Arguments `[number](number "number") index` The index of the the vertex you want to modify (one-based). `[table](table "table") vertex` A table with vertex information, in the form of `{attributecomponent, ...}`. `[number](number "number") attributecomponent` The first component of the first vertex attribute in the specified vertex. `[number](number "number") ...` Additional components of all vertex attributes in the specified vertex. ### Returns Nothing. ### Notes The table indices are in the same order as the vertex attributes in the Mesh's [vertex format](mesh-getvertexformat "Mesh:getVertexFormat"). A standard Mesh that wasn't [created](love.graphics.newmesh "love.graphics.newMesh") with a custom vertex format will use two position numbers, two texture coordinate numbers, and four color components per vertex: x, y, u, v, r, g, b, a. If no value is supplied for a specific vertex attribute component, it will be set to a default value of 0 if its [data type](attributedatatype "AttributeDataType") is "float", or 1 if its data type is "byte". Function -------- Sets the vertex components of a Mesh that wasn't [created](love.graphics.newmesh "love.graphics.newMesh") with a custom vertex format. ### Synopsis ``` Mesh:setVertex( index, x, y, u, v, r, g, b, a ) ``` ### Arguments `[number](number "number") index` The index of the the vertex you want to modify (one-based). `[number](number "number") x` The position of the vertex on the x-axis. `[number](number "number") y` The position of the vertex on the y-axis. `[number](number "number") u` The horizontal component of the texture coordinate. `[number](number "number") v` The vertical component of the texture coordinate. `[number](number "number") r (1)` The red component of the vertex's color. `[number](number "number") g (1)` The green component of the vertex's color. `[number](number "number") b (1)` The blue component of the vertex's color. `[number](number "number") a (1)` The alpha component of the vertex's color. ### Returns Nothing. Function -------- Sets the vertex components of a Mesh that wasn't [created](love.graphics.newmesh "love.graphics.newMesh") with a custom vertex format. ### Synopsis ``` Mesh:setVertex( index, vertex ) ``` ### Arguments `[number](number "number") index` The index of the the vertex you want to modify (one-based). `[table](table "table") vertex` A table with vertex information. `[number](number "number") [1]` The position of the vertex on the x-axis. `[number](number "number") [2]` The position of the vertex on the y-axis. `[number](number "number") [3]` The u texture coordinate. Texture coordinates are normally in the range of [0, 1], but can be greater or less (see [WrapMode](wrapmode "WrapMode").) `[number](number "number") [4]` The v texture coordinate. Texture coordinates are normally in the range of [0, 1], but can be greater or less (see [WrapMode](wrapmode "WrapMode").) `[number](number "number") [5] (1)` The red color component. `[number](number "number") [6] (1)` The green color component. `[number](number "number") [7] (1)` The blue color component. `[number](number "number") [8] (1)` The alpha color component. ### Returns Nothing. See Also -------- * [Mesh](mesh "Mesh") * [Mesh:getVertex](mesh-getvertex "Mesh:getVertex") * [Mesh:getVertexCount](mesh-getvertexcount "Mesh:getVertexCount") * [Mesh:getVertexFormat](mesh-getvertexformat "Mesh:getVertexFormat")
programming_docs
love Contact:getNormal Contact:getNormal ================= Get the normal vector between two shapes that are in contact. This function returns the coordinates of a unit vector that points from the first shape to the second. Function -------- ### Synopsis ``` nx, ny = Contact:getNormal( ) ``` ### Arguments None. ### Returns `[number](number "number") nx` The x component of the normal vector. `[number](number "number") ny` The y component of the normal vector. See Also -------- * [Contact](contact "Contact") love Source:setVolumeLimits Source:setVolumeLimits ====================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Sets the volume limits of the source. The limits have to be numbers from 0 to 1. Function -------- ### Synopsis ``` Source:setVolumeLimits( min, max ) ``` ### Arguments `[number](number "number") min` The minimum volume. `[number](number "number") max` The maximum volume. ### Returns Nothing. See Also -------- * [Source](source "Source") love love.graphics.setDefaultFilter love.graphics.setDefaultFilter ============================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [love.graphics.setDefaultImageFilter](love.graphics.setdefaultimagefilter "love.graphics.setDefaultImageFilter"). Sets the default scaling filters used with [Images](image "Image"), [Canvases](canvas "Canvas"), and [Fonts](font "Font"). This function does not apply retroactively to loaded images. Existing objects retain their current scaling filters. Function -------- ### Synopsis ``` love.graphics.setDefaultFilter( min, mag, anisotropy ) ``` ### Arguments `[FilterMode](filtermode "FilterMode") min` Filter mode used when scaling the image down. `[FilterMode](filtermode "FilterMode") mag` Filter mode used when scaling the image up. `[number](number "number") anisotropy (1)` Maximum amount of Anisotropic Filtering used. ### Returns Nothing. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getDefaultFilter](love.graphics.getdefaultfilter "love.graphics.getDefaultFilter") * [FilterMode](filtermode "FilterMode") love love.joystick.setGamepadMapping love.joystick.setGamepadMapping =============================== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Due to a bug, any mapping that is a suffix of another (for example "x" is a suffix to "leftx") needs to be mapped first Binds a virtual gamepad input to a button, axis or hat for all Joysticks of a certain type. For example, if this function is used with a [GUID](joystick-getguid "Joystick:getGUID") returned by a Dualshock 3 controller in OS X, the binding will affect [Joystick:getGamepadAxis](joystick-getgamepadaxis "Joystick:getGamepadAxis") and [Joystick:isGamepadDown](joystick-isgamepaddown "Joystick:isGamepadDown") for *all* Dualshock 3 controllers used with the game when run in OS X. LÖVE includes built-in gamepad bindings for many common controllers. This function lets you change the bindings or add new ones for types of Joysticks which aren't recognized as gamepads by default. The virtual gamepad buttons and axes are designed around the Xbox 360 controller layout. Function -------- ### Synopsis ``` success = love.joystick.setGamepadMapping( guid, button, inputtype, inputindex, hatdir ) ``` ### Arguments `[string](string "string") guid` The OS-dependent [GUID](joystick-getguid "Joystick:getGUID") for the type of Joystick the binding will affect. `[GamepadButton](gamepadbutton "GamepadButton") button` The virtual gamepad button to bind. `[JoystickInputType](joystickinputtype "JoystickInputType") inputtype` The type of input to bind the virtual gamepad button to. `[number](number "number") inputindex` The index of the axis, button, or hat to bind the virtual gamepad button to. `[JoystickHat](joystickhat "JoystickHat") hatdir (nil)` The direction of the hat, if the virtual gamepad button will be bound to a hat. nil otherwise. ### Returns `[boolean](boolean "boolean") success` Whether the virtual gamepad button was successfully bound. Function -------- ### Synopsis ``` success = love.joystick.setGamepadMapping( guid, axis, inputtype, inputindex, hatdir ) ``` ### Arguments `[string](string "string") guid` The OS-dependent [GUID](joystick-getguid "Joystick:getGUID") for the type of Joystick the binding will affect. `[GamepadAxis](gamepadaxis "GamepadAxis") axis` The virtual gamepad axis to bind. `[JoystickInputType](joystickinputtype "JoystickInputType") inputtype` The type of input to bind the virtual gamepad axis to. `[number](number "number") inputindex` The index of the axis, button, or hat to bind the virtual gamepad axis to. `[JoystickHat](joystickhat "JoystickHat") hatdir (nil)` The direction of the hat, if the virtual gamepad axis will be bound to a hat. nil otherwise. ### Returns `[boolean](boolean "boolean") success` Whether the virtual gamepad axis was successfully bound. Notes ----- The physical locations for the bound gamepad axes and buttons should correspond as closely as possible to the layout of a standard Xbox 360 controller. See Also -------- * [love.joystick](love.joystick "love.joystick") * [Joystick:getGUID](joystick-getguid "Joystick:getGUID") * [Joystick:isGamepad](joystick-isgamepad "Joystick:isGamepad") * [Joystick:getGamepadMapping](joystick-getgamepadmapping "Joystick:getGamepadMapping") love CullMode CullMode ======== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This enum is not supported in earlier versions. How [Mesh](mesh "Mesh") geometry is culled when rendering. Constants --------- back Back-facing triangles in Meshes are culled (not rendered). The [vertex order](love.graphics.setfrontfacewinding "love.graphics.setFrontFaceWinding") of a triangle determines whether it is back- or front-facing. front Front-facing triangles in Meshes are culled. none Both back- and front-facing triangles in Meshes are rendered. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setMeshCullMode](love.graphics.setmeshcullmode "love.graphics.setMeshCullMode") * [Mesh](mesh "Mesh") love DistanceJoint:setDampingRatio DistanceJoint:setDampingRatio ============================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been renamed from [DistanceJoint:setDamping](distancejoint-setdamping "DistanceJoint:setDamping"). Sets the damping ratio. Function -------- ### Synopsis ``` DistanceJoint:setDampingRatio( ratio ) ``` ### Arguments `[number](number "number") ratio` The damping ratio. ### Returns Nothing. See Also -------- * [DistanceJoint](distancejoint "DistanceJoint") love Transform:scale Transform:scale =============== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Scales the Transform's coordinate system. This method does not reset any previously applied transformations. Function -------- ### Synopsis ``` transform = Transform:scale( sx, sy ) ``` ### Arguments `[number](number "number") sx` The relative scale factor along the x-axis. `[number](number "number") sy (sx)` The relative scale factor along the y-axis. ### Returns `[Transform](transform "Transform") transform` The Transform object the method was called on. Allows easily chaining Transform methods. See Also -------- * [Transform](transform "Transform") * [Transform:reset](transform-reset "Transform:reset") * [Transform:translate](transform-translate "Transform:translate") * [Transform:rotate](transform-rotate "Transform:rotate") * [Transform:shear](transform-shear "Transform:shear") * [Transform:setTransformation](transform-settransformation "Transform:setTransformation") love love.filesystem.setSource love.filesystem.setSource ========================= Sets the source of the game, where the code is present. This function can only be called once, and is normally automatically done by LÖVE. Function -------- ### Synopsis ``` love.filesystem.setSource( path ) ``` ### Arguments `[string](string "string") path` Absolute path to the game's source folder. ### Returns Nothing. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") love ParticleSystem:setSprite ParticleSystem:setSprite ======================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [ParticleSystem:setImage](particlesystem-setimage "ParticleSystem:setImage"). Sets the image which is to be emitted. Function -------- ### Synopsis ``` ParticleSystem:setSprite( sprite ) ``` ### Arguments `[Image](image "Image") sprite` An Image to use for the particle. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love Text:getDimensions Text:getDimensions ================== **Available since LÖVE [0.10.1](https://love2d.org/wiki/0.10.1 "0.10.1")** This function is not supported in earlier versions. Gets the width and height of the text in pixels. Function -------- ### Synopsis ``` width, height = Text:getDimensions( ) ``` ### Arguments None. ### Returns `[number](number "number") width` The width of the text. If multiple sub-strings have been added with [Text:add](text-add "Text:add"), the width of the last sub-string is returned. `[number](number "number") height` The height of the text. If multiple sub-strings have been added with [Text:add](text-add "Text:add"), the height of the last sub-string is returned. Function -------- Gets the width and height of a specific sub-string that was previously added to the Text object. ### Synopsis ``` width, height = Text:getDimensions( index ) ``` ### Arguments `[number](number "number") index` An index number returned by [Text:add](text-add "Text:add") or [Text:addf](text-addf "Text:addf"). ### Returns `[number](number "number") width` The width of the sub-string (before scaling and other transformations). `[number](number "number") height` The height of the sub-string (before scaling and other transformations). See Also -------- * [Text](text "Text") * [Text:set](text-set "Text:set") * [Text:setf](text-setf "Text:setf") * [Text:add](text-add "Text:add") * [Text:addf](text-addf "Text:addf") love ParticleSystem:getCount ParticleSystem:getCount ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [ParticleSystem:count](particlesystem-count "ParticleSystem:count"). Gets the number of particles that are currently in the system. Function -------- ### Synopsis ``` count = ParticleSystem:getCount( ) ``` ### Arguments None. ### Returns `[number](number "number") count` The current number of live particles. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:getBufferSize](particlesystem-getbuffersize "ParticleSystem:getBufferSize") love ParticleSystem:count ParticleSystem:count ==================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [ParticleSystem:getCount](particlesystem-getcount "ParticleSystem:getCount"). Gets the amount of particles that are currently in the system. Function -------- ### Synopsis ``` count = ParticleSystem:count( ) ``` ### Arguments None. ### Returns `[number](number "number") count` The current number of live particles. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love enet.host:connect enet.host:connect ================= Connects a [host](enet.host "enet.host") to a remote [host](enet.host "enet.host"). Returns [peer](enet.peer "enet.peer") object associated with the remote [host](enet.host "enet.host"). The actual connection will not take place until the next [host:service()](enet.host-service "enet.host:service") is called, in which a "connect" [event](enet.event "enet.event") will be generated. Function -------- ### Synopsis ``` peer = host:connect(address, channel_count, data) ``` ### Arguments `[string](string "string") address` The address to connect to in the format "ip:port". `[number](number "number") channel_count` The number of channels to allocate. It should be the same as the channel count on the server. Defaults to 1. `[number](number "number") data` An integer value that can be associated with the connect [event](enet.event "enet.event"). Defaults to 0. ### Returns `[enet.peer](enet.peer "enet.peer") peer` A [peer](enet.peer "enet.peer"). See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.event](enet.event "enet.event") * [enet.peer](enet.peer "enet.peer") * [enet.host:channel\_limit](enet.host-channel_limit "enet.host:channel limit") love love.gamepadreleased love.gamepadreleased ==================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Called when a Joystick's virtual gamepad button is released. Function -------- ### Synopsis ``` love.gamepadreleased( joystick, button ) ``` ### Arguments `[Joystick](joystick "Joystick") joystick` The joystick object. `[GamepadButton](gamepadbutton "GamepadButton") button` The virtual gamepad button. ### Returns Nothing. See Also -------- * [love](love "love") * [love.gamepadpressed](love.gamepadpressed "love.gamepadpressed") * [Joystick:isGamepad](joystick-isgamepad "Joystick:isGamepad") love WeldJoint:setFrequency WeldJoint:setFrequency ====================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Sets a new frequency. Function -------- ### Synopsis ``` WeldJoint:setFrequency( freq ) ``` ### Arguments `[number](number "number") freq` The new frequency in hertz. ### Returns Nothing. See Also -------- * [WeldJoint](weldjoint "WeldJoint") * [WeldJoint:getFrequency](weldjoint-getfrequency "WeldJoint:getFrequency") love love.window.restore love.window.restore =================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Restores the size and position of the window if it was [minimized](love.window.minimize "love.window.minimize") or [maximized](love.window.maximize "love.window.maximize"). Function -------- ### Synopsis ``` love.window.restore( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [love.window](love.window "love.window") * [love.window.minimize](love.window.minimize "love.window.minimize") * [love.window.maximize](love.window.maximize "love.window.maximize") * [love.window.isMinimized](love.window.isminimized "love.window.isMinimized") * [love.window.isMaximized](love.window.ismaximized "love.window.isMaximized") love enet.host create enet.host create ================ Returns a new [host](enet.host "enet.host"). All arguments are optional. A bind\_address of [nil](nil "nil") makes a [host](enet.host "enet.host") that can not be connected to (typically a client). Otherwise the address can either be of the form <ipaddress>:<port>, <hostname>:<port>, or \*:<port>. Example addresses include "127.0.0.1:8888", "localhost:2232", and "\*:6767". If port is 0, the system automatically chooses an ephemeral port and you can get port number by [host:get\_socket\_address](enet.host-get_socket_address "enet.host:get socket address")(). Function -------- ### Synopsis ``` host = enet.host_create(bind_address, peer_count, channel_count, in_bandwidth, out_bandwidth) ``` ### Arguments `[string](string "string") bind_address` The address to connect to in the format "ip:port". `[number](number "number") peer_count` The max number of peers. Defaults to 64. `[number](number "number") channel_count` The max number of channels. Defaults to 1. `[number](number "number") in_bandwidth` Downstream bandwidth in bytes/sec. Defaults to 0 (unlimited). `[number](number "number") out_bandwidth` Upstream bandwidth in bytes/sec. Defaults to 0 (unlimited). ### Returns `[enet.host](enet.host "enet.host") host` The requested [host](enet.host "enet.host"). See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.host](enet.host "enet.host") * [enet.host:channel\_limit](enet.host-channel_limit "enet.host:channel limit") * [enet.host:bandwidth\_limit](enet.host-bandwidth_limit "enet.host:bandwidth limit") love love.timer.getDelta love.timer.getDelta =================== Returns the time between the last two frames. Function -------- ### Synopsis ``` dt = love.timer.getDelta( ) ``` ### Arguments None. ### Returns `[number](number "number") dt` The time passed (in seconds). See Also -------- * [love.timer](love.timer "love.timer") * [love.timer.getAverageDelta](love.timer.getaveragedelta "love.timer.getAverageDelta") love Canvas:getPixel Canvas:getPixel =============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** Use [Canvas:newImageData](canvas-newimagedata "Canvas:newImageData") instead. Gets the pixel at the specified position from a Canvas. Valid x and y values start at 0 and go up to canvas width and height minus 1. This function can be very slow: it can cause the CPU to wait for the GPU to finish all the work currently in its queue, which can be a whole frame's worth (or more.) Function -------- ### Synopsis ``` r, g, b, a = Canvas:getPixel( x, y ) ``` ### Arguments `[number](number "number") x` The position of the pixel on the x-axis. `[number](number "number") y` The position of the pixel on the y-axis. ### Returns `[number](number "number") r` The red component (0-255). `[number](number "number") g` The green component (0-255). `[number](number "number") b` The blue component (0-255). `[number](number "number") a` The alpha component (0-255). See Also -------- * [Canvas](canvas "Canvas") love Contact:resetRestitution Contact:resetRestitution ======================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Resets the contact restitution to the mixture value of both fixtures. Function -------- ### Synopsis ``` Contact:resetRestitution( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Contact](contact "Contact") love Body:getContactList Body:getContactList =================== | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | It has been renamed to [Body:getContacts](body-getcontacts "Body:getContacts"). | **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This method is not supported in earlier versions. Gets a list of all [Contacts](contact "Contact") attached to the Body. The list can change multiple times during a [World:update](world-update "World:update") call, so some collisions may be missed if the World collide callbacks are not used at all. Function -------- ### Synopsis ``` contacts = Body:getContactList( ) ``` ### Arguments None. ### Returns `[table](table "table") contacts` A list with all contacts associated with the Body. See Also -------- * [Body](body "Body") love Contact:getFixtures Contact:getFixtures =================== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Gets the two [Fixtures](fixture "Fixture") that hold the shapes that are in contact. Function -------- ### Synopsis ``` fixtureA, fixtureB = Contact:getFixtures( ) ``` ### Arguments None. ### Returns `[Fixture](fixture "Fixture") fixtureA` The first Fixture. `[Fixture](fixture "Fixture") fixtureB` The second Fixture. See Also -------- * [Contact](contact "Contact")
programming_docs
love ImageData:getDimensions ImageData:getDimensions ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the width and height of the ImageData in pixels. Function -------- ### Synopsis ``` width, height = ImageData:getDimensions( ) ``` ### Arguments None. ### Returns `[number](number "number") width` The width of the [ImageData](imagedata "ImageData") in pixels. `[number](number "number") height` The height of the [ImageData](imagedata "ImageData") in pixels. See Also -------- * [ImageData](imagedata "ImageData") love Body:getGravityScale Body:getGravityScale ==================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the gravity scale factor. Function -------- ### Synopsis ``` scale = Body:getGravityScale( ) ``` ### Arguments None. ### Returns `[number](number "number") scale` The gravity scale factor. See Also -------- * [Body](body "Body") * [Body:setGravityScale](body-setgravityscale "Body:setGravityScale") * [World:setGravity](world-setgravity "World:setGravity") love RandomGenerator:random RandomGenerator:random ====================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Generates a pseudo-random number in a platform independent manner. Function -------- Get uniformly distributed pseudo-random real number within [0, 1]. ### Synopsis ``` number = RandomGenerator:random( ) ``` ### Arguments None. ### Returns `[number](number "number") number` The pseudo-random number. Function -------- Get uniformly distributed pseudo-random **integer** number within [1, max]. ### Synopsis ``` number = RandomGenerator:random( max ) ``` ### Arguments `[number](number "number") max` The maximum possible value it should return. ### Returns `[number](number "number") number` The pseudo-random integer number. Function -------- Get uniformly distributed pseudo-random **integer** number within [min, max]. ### Synopsis ``` number = RandomGenerator:random( min, max ) ``` ### Arguments `[number](number "number") min` The minimum possible value it should return. `[number](number "number") max` The maximum possible value it should return. ### Returns `[number](number "number") number` The pseudo-random integer number. Notes ----- When using the 2nd and 3rd variant, numbers passed will be rounded, thus, `RandomGenerator:random(0, 76.767)` may return 77 See Also -------- * [RandomGenerator](randomgenerator "RandomGenerator") * [love.math.random](love.math.random "love.math.random") * [love.math](love.math "love.math") love Thread:send Thread:send =========== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0") and removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been renamed to [Thread:set](thread-set "Thread:set"). Send a message (put it in the message box). Function -------- ### Synopsis ``` Thread:send(name, value) ``` ### Arguments `[string](string "string") name` The name of the message. `[Variant](variant "Variant") value` The contents of the message. ### Returns None. See Also -------- * [Thread](thread "Thread") love VideoStream:tell VideoStream:tell ================ **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets the current playback position of video stream. Function -------- ### Synopsis ``` seconds = VideoStream:tell( ) ``` ### Arguments None. ### Returns `[number](number "number") seconds` The seconds since the beginning of the video. See Also -------- * [VideoStream](videostream "VideoStream") * [VideoStream:seek](videostream-seek "VideoStream:seek") * [VideoStream:rewind](videostream-rewind "VideoStream:rewind") love love.font.newImageRasterizer love.font.newImageRasterizer ============================ **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Creates a new Image Rasterizer. Function -------- Create an ImageRasterizer from the image data. ### Synopsis ``` rasterizer = love.font.newImageRasterizer( imageData, glyphs, extraSpacing, dpiscale ) ``` ### Arguments `[ImageData](imagedata "ImageData") imageData` Font image data. `[string](string "string") glyphs` String containing font glyphs. `[number](number "number") extraSpacing (0)` Font extra spacing. `[number](number "number") dpiscale (1)` Available since 11.0 Font DPI scale. ### Returns `[Rasterizer](rasterizer "Rasterizer") rasterizer` The rasterizer. See Also -------- * [love.font](love.font "love.font") * [love.font.newRasterizer](love.font.newrasterizer "love.font.newRasterizer") * [love.font.newBMFontRasterizer](love.font.newbmfontrasterizer "love.font.newBMFontRasterizer") * [love.font.newTrueTypeRasterizer](love.font.newtruetyperasterizer "love.font.newTrueTypeRasterizer") * [Rasterizer](rasterizer "Rasterizer") love boolean boolean ======= From the Lua 5.1 [reference manual §2.2](https://www.lua.org/manual/5.1/manual.html#2.2): Boolean is the type of the values false and true. Both [nil](nil "nil") and false make a condition false; *any* other value makes it true. love MotorJoint:getAngularOffset MotorJoint:getAngularOffset =========================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This method is not supported in earlier versions. Gets the target angular offset between the two Bodies the Joint is attached to. Function -------- ### Synopsis ``` angleoffset = MotorJoint:getAngularOffset( ) ``` ### Arguments None. ### Returns `[number](number "number") angleoffset` The target angular offset in radians: the second body's angle minus the first body's angle. See Also -------- * [MotorJoint](motorjoint "MotorJoint") * [MotorJoint:setAngularOffset](motorjoint-setangularoffset "MotorJoint:setAngularOffset") love love.isVersionCompatible love.isVersionCompatible ======================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets whatever the version is compatible with current running version of LÖVE. Function -------- ### Synopsis ``` compatible = love.isVersionCompatible( version ) ``` ### Arguments `[string](string "string") version` The version (for example: "0.10.1"). ### Returns `[boolean](boolean "boolean") compatible` Whatever is the version compatible. Function -------- ### Synopsis ``` compatible = love.isVersionCompatible( major, minor, revision ) ``` ### Arguments `[number](number "number") major` The major version, i.e. 0 for version 0.10.1. `[number](number "number") minor` The minor version, i.e. 10 for version 0.10.1. `[number](number "number") revision` The revision version, i.e. 1 for version 0.10.1. ### Returns `[boolean](boolean "boolean") compatible` Whatever is the version compatible. See Also -------- * [love](love "love") * [love.getVersion](love.getversion "love.getVersion") love love.audio.setPosition love.audio.setPosition ====================== Sets the position of the listener, which determines how sounds play. Function -------- ### Synopsis ``` love.audio.setPosition( x, y, z ) ``` ### Arguments `[number](number "number") x` The x position of the listener. `[number](number "number") y` The y position of the listener. `[number](number "number") z` The z position of the listener. ### Returns Nothing. See Also -------- * [love.audio](love.audio "love.audio") * [Source:setPosition](source-setposition "Source:setPosition") love love.graphics.newShader love.graphics.newShader ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [love.graphics.newPixelEffect](love.graphics.newpixeleffect "love.graphics.newPixelEffect"). This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! 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](mesh "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. Function -------- ### Synopsis ``` shader = love.graphics.newShader( code ) ``` ### Arguments `[string](string "string") code` The pixel shader or vertex shader code, or a filename pointing to a file with the code. ### Returns `[Shader](shader "Shader") shader` A Shader object for use in drawing operations. Function -------- ### Synopsis ``` shader = love.graphics.newShader( pixelcode, vertexcode ) ``` ### Arguments `[string](string "string") pixelcode` The pixel shader code, or a filename pointing to a file with the code. `[string](string "string") vertexcode` The vertex shader code, or a filename pointing to a file with the code. ### Returns `[Shader](shader "Shader") shader` A Shader object for use in drawing operations. ### Notes The pixelcode and vertexcode arguments can be in any order. Shader Language --------------- Shaders are not programmed in Lua, but by using a special shader language – GLSL, with a few aliases and a different entry point for convenience – instead. GLSL has very similar syntax to C. None of the aliases LÖVE provides are mandatory, but using `Texel` instead of `texture2D` is recommended since `Texel` works in all glsl versions, whereas `texture2D` does not work in GLSL 3. | GLSL | LÖVE shader language | | --- | --- | | sampler2D | Image | | sampler2DArray | ArrayImage | | samplerCube | CubeImage | | sampler3D | VolumeImage | | texture2D(tex, uv) (in GLSL 1) | Texel(tex, uv) | | texture(tex, uv) (in GLSL 3) | Texel(tex, uv) | | float | number (deprecated) | | uniform | extern (deprecated) | The version of GLSL used depends on whether the `#pragma language glsl3` line is added to the top of a shader file, as well as whether LÖVE is running on a desktop or mobile device: | LÖVE shader language | desktop GLSL version | mobile GLSL version | | --- | --- | --- | | glsl1 (default) | [GLSL 1.20](https://www.opengl.org/registry/doc/GLSLangSpec.Full.1.20.8.pdf) | [GLSL ES 1.00](https://www.khronos.org/files/opengles_shading_language.pdf) | | glsl3 | [GLSL 3.30](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.3.30.pdf) | [GLSL ES 3.00](https://www.khronos.org/registry/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf) | GLSL 3 is [not supported](graphicsfeature "GraphicsFeature") on some older systems. Use [love.graphics.getSupported](love.graphics.getsupported "love.graphics.getSupported") to check at run-time. Vertex shader code must contain at least one function, named `position`, which is the function that will produce transformed vertex positions of drawn objects in screen-space. Pixel shader code must contain at least one function, named `effect`, which is the function that will produce the color which is blended onto the screen for each pixel a drawn object touches. LÖVE provides several useful [Shader Variables](shader_variables "Shader Variables") by default. Additionally, LÖVE exposes a function `VideoTexel(uv)` which yields the color value of the currently drawn video at that position. Since Videos are drawn as YUV data in multiple textures, and then converted in the shader, the Texel function cannot be used. Pixel Shader Function --------------------- When an object is drawn, the pixel shader `effect` function is called hundreds or thousands of times: once for each pixel on the screen that the object touches. The pixel shader is run after the vertex shader, if there is one. ### Synopsis ``` vec4 effect( vec4 color, Image tex, vec2 texture_coords, vec2 screen_coords ) ``` ### Arguments `[vec4](https://love2d.org/w/index.php?title=vec4&action=edit&redlink=1 "vec4 (page does not exist)") color` The drawing color set with [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor") or the per-vertex [Mesh](mesh "Mesh") color. `[Image](image "Image") tex` The texture of the image or canvas being drawn. `[vec2](https://love2d.org/w/index.php?title=vec2&action=edit&redlink=1 "vec2 (page does not exist)") texture_coords` The location inside the texture to get pixel data from. Texture coordinates are usually normalized to the range of (0, 0) to (1, 1), with the top-left corner being (0, 0). `[vec2](https://love2d.org/w/index.php?title=vec2&action=edit&redlink=1 "vec2 (page does not exist)") screen_coords` Coordinates of the pixel on the screen. Pixel coordinates are not normalized (unlike texture coordinates). (0.5, 0.5) represents the top left of the screen (bottom left in LÖVE versions prior to [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")). ### Returns `[vec4](https://love2d.org/w/index.php?title=vec4&action=edit&redlink=1 "vec4 (page does not exist)") output_color` The color of the pixel. ### Notes On mobile devices, variables in pixel shaders use `mediump` (16 bit float) precision by default instead of 32 bit float, for performance reasons. This may cause numeric instability or visual artifacts for larger numbers. Use the `highp` qualifier when declaring a variable (for example `highp float pos;`) to make it use always 32 bit float precision. Furthermore, `highp` precision is not supported on all devices, particularly GLES2 devices. Use [love.graphics.getSupported](love.graphics.getsupported "love.graphics.getSupported") to check! If no pixel shader is used, LÖVE internally uses a default. This is its code: ``` vec4 effect(vec4 color, Image tex, vec2 texture_coords, vec2 screen_coords) { vec4 texturecolor = Texel(tex, texture_coords); return texturecolor * color; } ``` Or for Video ``` vec4 effect(vec4 color, Image tex, vec2 texture_coords, vec2 screen_coords) { vec4 texturecolor = VideoTexel(texture_coords); return texturecolor * color; } ``` If multiple canvases are being rendered to simultaneously (by giving multiple Canvas parameters to [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas")), you can use the **void effect** (no arguments!) function instead of **vec4 effect** in order to output a separate color to each Canvas. It has the following prototype: ``` void effect() { // love_Canvases is a writable array of vec4 colors. Each index corresponds to a Canvas. // IMPORTANT: If you don't assign a value to all active canvases, bad things will happen. love_Canvases[0] = color; love_Canvases[1] = color + vec4(0.5); // etc. } ``` If you wish to get the arguments that are passed to the single-canvas version (`vec4 effect`), see the built-in [Shader Variables](shader_variables "Shader Variables"). `color` will be in `VaryingColor`, `texture_coords` will be in `VaryingTexCoord` and `screen_coords` is in `love_PixelCoord`. And if you wish to access the texture used in the drawing operation, you can do that by defining a uniform texture (of the appropriate type) named `MainTex` or by sending it yourself via [Shader:send](shader-send "Shader:send"). Vertex Shader Function ---------------------- ### Synopsis ``` vec4 position( mat4 transform_projection, vec4 vertex_position ) ``` ### Arguments `[mat4](https://love2d.org/w/index.php?title=mat4&action=edit&redlink=1 "mat4 (page does not exist)") transform_projection` The transformation matrix affected by [love.graphics.translate](love.graphics.translate "love.graphics.translate") and friends combined with the orthographic projection matrix. `[vec4](https://love2d.org/w/index.php?title=vec4&action=edit&redlink=1 "vec4 (page does not exist)") vertex_position` The raw un-transformed position of the current vertex. ### Returns `[vec4](https://love2d.org/w/index.php?title=vec4&action=edit&redlink=1 "vec4 (page does not exist)") output_pos` The final transformed position of the current vertex. ### Notes If no vertex shader code is used, LÖVE uses a default. This is its code: ``` vec4 position(mat4 transform_projection, vec4 vertex_position) { // The order of operations matters when doing matrix multiplication. return transform_projection * vertex_position; } ``` Notes ----- Vertex shader code is run for every vertex drawn to the screen (for example, love.graphics.rectangle will produce 4 vertices) and is used to transform the vertex positions from their original coordinates into screen-space, as well as to send information such as per-vertex color and texture coordinate values to the pixel shader. Pixel shader code is run for every pixel on the screen that a drawn object touches, and is used to produce the color that will be blended onto the screen at that pixel, often by reading from an image. Pixel shaders are sometimes called fragment shaders. The `varying` keyword can be used to set a value in the vertex shader and have it interpolated in between vertices and passed down to the pixel shader. Vertex and Pixel shader code can be combined into one file or string if you wrap the vertex-specific code in `#ifdef VERTEX .. #endif` and the pixel-specific code in `#ifdef PIXEL .. #endif`. Built-in variables ------------------ LÖVE provides several built-in variables for both pixel and vertex shaders. The full list can be found here: [Shader Variables](shader_variables "Shader Variables"). Examples -------- ### Create a shader using vertex and pixel shader code which behaves as if no shader is set. ``` local pixelcode = [[ vec4 effect( vec4 color, Image tex, vec2 texture_coords, vec2 screen_coords ) { vec4 texcolor = Texel(tex, texture_coords); return texcolor * color; } ]]   local vertexcode = [[ vec4 position( mat4 transform_projection, vec4 vertex_position ) { return transform_projection * vertex_position; } ]]   shader = love.graphics.newShader(pixelcode, vertexcode)   function love.draw() love.graphics.setShader(shader) -- draw things love.graphics.setShader() -- draw more things end ``` ### Access the pre-transformed vertex position in the pixel shader with the **varying** keyword. #### vertex shader code ``` varying vec4 vpos;   vec4 position( mat4 transform_projection, vec4 vertex_position ) { vpos = vertex_position; return transform_projection * vertex_position; } ``` #### pixel shader code ``` varying vec4 vpos;   vec4 effect( vec4 color, Image tex, vec2 texture_coords, vec2 screen_coords ) { texture_coords += vec2(cos(vpos.x), sin(vpos.y)); vec4 texcolor = Texel(tex, texture_coords); return texcolor * color; } ``` ### Combine the above example into one string or file with the help of **#ifdef**. ``` varying vec4 vpos;   #ifdef VERTEX vec4 position( mat4 transform_projection, vec4 vertex_position ) { vpos = vertex_position; return transform_projection * vertex_position; } #endif   #ifdef PIXEL vec4 effect( vec4 color, Image tex, vec2 texture_coords, vec2 screen_coords ) { texture_coords += vec2(cos(vpos.x), sin(vpos.y)); vec4 texcolor = Texel(tex, texture_coords); return texcolor * color; } #endif ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [Shader](shader "Shader") * [love.graphics.setShader](love.graphics.setshader "love.graphics.setShader") * [Shader Variables](shader_variables "Shader Variables")
programming_docs
love Shader:getWarnings Shader:getWarnings ================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [PixelEffect:getWarnings](pixeleffect-getwarnings "PixelEffect:getWarnings"). Returns any warning and error messages from compiling the shader code. This can be used for debugging your shaders if there's anything the graphics hardware doesn't like. Function -------- ### Synopsis ``` warnings = Shader:getWarnings( ) ``` ### Arguments None. ### Returns `[string](string "string") warnings` Warning and error messages (if any). See Also -------- * [Shader](shader "Shader") love Rasterizer:getDescent Rasterizer:getDescent ===================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Gets descent height. Function -------- ### Synopsis ``` height = Rasterizer:getDescent() ``` ### Arguments None. ### Returns `[number](number "number") height` Descent height. See Also -------- * [Rasterizer](rasterizer "Rasterizer") love Text:getFont Text:getFont ============ **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets the [Font](font "Font") used with the [Text](text "Text") object. Function -------- ### Synopsis ``` font = Text:getFont( ) ``` ### Arguments None. ### Returns `[Font](font "Font") font` The font used with this Text object. See Also -------- * [Text](text "Text") * [Text:setFont](text-setfont "Text:setFont") love Thread Thread ====== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This type is not supported in earlier versions. A Thread is a chunk of code that can run in parallel with other threads. Data can be sent between different threads with [Channel](channel "Channel") objects. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.thread.newThread](love.thread.newthread "love.thread.newThread") | Creates a new Thread from a filename, string or [FileData](filedata "FileData") object containing Lua code. | 0.7.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | | [Thread:demand](thread-demand "Thread:demand") | Receive a message from a thread. Wait for the message to exist before returning. | 0.7.0 | 0.9.0 | | [Thread:get](thread-get "Thread:get") | Get a value. | 0.8.0 | 0.9.0 | | [Thread:getError](thread-geterror "Thread:getError") | Retrieves the error string from the thread. | 0.9.0 | | | [Thread:getKeys](thread-getkeys "Thread:getKeys") | Returns the names of all messages as a table. | 0.8.0 | 0.9.0 | | [Thread:getName](thread-getname "Thread:getName") | Get the name of a thread. | 0.7.0 | 0.9.0 | | [Thread:isRunning](thread-isrunning "Thread:isRunning") | Returns whether the thread is currently running. | 0.9.0 | | | [Thread:kill](thread-kill "Thread:kill") | Forcefully terminate the thread. | 0.7.0 | 0.8.0 | | [Thread:peek](thread-peek "Thread:peek") | Receive a message from a thread, but leave it in the message box. | 0.7.0 | 0.9.0 | | [Thread:receive](thread-receive "Thread:receive") | Receive a message from a thread. | 0.7.0 | 0.8.0 | | [Thread:send](thread-send "Thread:send") | Send a message. | 0.7.0 | 0.8.0 | | [Thread:set](thread-set "Thread:set") | Set a value. | 0.8.0 | 0.9.0 | | [Thread:start](thread-start "Thread:start") | Starts the thread. | 0.7.0 | | | [Thread:wait](thread-wait "Thread:wait") | Wait for a thread to finish. | 0.7.0 | | Supertypes ---------- * [Object](object "Object") Notes ----- **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This method for retrieving errors has been replaced by [Thread:getError](thread-geterror "Thread:getError") and [love.threaderror](love.threaderror "love.threaderror"). If a Lua error occurs in the thread, a message with the name "error" gets pushed to its message pool. Retrieve the message with Thread:get('error'). See Also -------- * [love.thread](love.thread "love.thread") love RevoluteJoint:enableLimits RevoluteJoint:enableLimits ========================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [RevoluteJoint:setLimitsEnabled](revolutejoint-setlimitsenabled "RevoluteJoint:setLimitsEnabled"). Enables or disables the joint limits. Function -------- ### Synopsis ``` RevoluteJoint:enableLimit( enable ) ``` ### Arguments `[boolean](boolean "boolean") enable` True to enable, false to disable. ### Returns Nothing. See Also -------- * [RevoluteJoint](revolutejoint "RevoluteJoint") * [RevoluteJoint:isLimitsEnabled](revolutejoint-islimitsenabled "RevoluteJoint:isLimitsEnabled") * [RevoluteJoint:setLimits](revolutejoint-setlimits "RevoluteJoint:setLimits") love love.keyboard.hasTextInput love.keyboard.hasTextInput ========================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets whether [text input](love.textinput "love.textinput") events are enabled. Function -------- ### Synopsis ``` enabled = love.keyboard.hasTextInput( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") enabled` Whether text input events are enabled. See Also -------- * [love.keyboard](love.keyboard "love.keyboard") * [love.keyboard.setTextInput](love.keyboard.settextinput "love.keyboard.setTextInput") * [love.textinput](love.textinput "love.textinput") love ChainShape:getPoints ChainShape:getPoints ==================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Returns all points of the shape. A bug in [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") causes memory corruption if this function gets called on a ChainShape with more than 8 points. Function -------- ### Synopsis ``` x1, y1, x2, y2, ... = ChainShape:getPoints( ) ``` ### Arguments None. ### Returns `[number](number "number") x1` The x-coordinate of the first point. `[number](number "number") y1` The y-coordinate of the first point. `[number](number "number") x2` The x-coordinate of the second point. `[number](number "number") y2` The y-coordinate of the second point. See Also -------- * [ChainShape](chainshape "ChainShape") love Source:setAirAbsorption Source:setAirAbsorption ======================= **Available since LÖVE [11.2](https://love2d.org/wiki/11.2 "11.2")** This function is not supported in earlier versions. Sets the amount of air absorption applied to the Source. By default the value is set to 0 which means that air absorption effects are disabled. A value of 1 will apply high frequency attenuation to the Source at a rate of 0.05 dB per meter. Air absorption can simulate sound transmission through foggy air, dry air, smoky atmosphere, etc. It can be used to simulate different atmospheric conditions within different locations in an area. Function -------- ### Synopsis ``` Source:setAirAbsorption( amount ) ``` ### Arguments `[number](number "number") amount` The amount of air absorption applied to the Source. Must be between 0 and 10. ### Returns Nothing. Notes ----- Audio air absorption functionality is not supported on iOS. See Also -------- * [Source](source "Source") * [Source:getAirAbsorption](source-getairabsorption "Source:getAirAbsorption") love enet.peer:connect id enet.peer:connect id ==================== Returns the field ENetPeer::connectID that is assigned for each connection. Function -------- ### Synopsis ``` peer:connect_id() ``` ### Arguments None. ### Returns `[number](number "number") id` Unique ID that was assigned to the connection. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.peer](enet.peer "enet.peer") love love.graphics love.graphics ============= The primary responsibility for the love.graphics module is the drawing of lines, shapes, text, [Images](image "Image") and other [Drawable](drawable "Drawable") objects onto the screen. Its secondary responsibilities include loading external files (including [Images](image "Image") and [Fonts](font "Font")) into memory, creating specialized objects (such as [ParticleSystems](particlesystem "ParticleSystem") or [Canvases](canvas "Canvas")) and managing screen geometry. LÖVE's coordinate system is rooted in the upper-left corner of the screen, which is at location (0, 0). The x axis is horizontal: larger values are further to the right. The y axis is vertical: larger values are further towards the bottom. It is worth noting that the location (0, 0) aligns with the upper-left corner of the pixel as well, meaning that for some functions you may encounter off-by-one problems in the render output when drawing 1 pixel wide lines. You can try aligning the coordinate system with the center of pixels rather than their upper-left corner. Do this by passing x+0.5 and y+0.5 or using love.graphics.translate(). In many cases, you draw images or shapes in terms of their upper-left corner (See the picture above). A note about angles in LÖVE: Angles are expressed in terms of [radians](https://en.wikipedia.org/wiki/Radian), with values in the range of 0 to 2Π (approximately 6.28); you may be more used to working in terms of degrees. Because of how the coordinate system is set up, with an origin in the upper left corner, angles in LÖVE may seem a bit backwards: 0 points right (along the X axis), ¼Π points diagonally down and to the right, ½Π points directly down (along the Y axis), with increasing values continuing **clockwise**. Many of the functions are used to manipulate the *graphics coordinate system*, which is essentially the way coordinates are mapped to the display. You can change the position, scale, and even change rotation in this way. Types ----- | | | | | | --- | --- | --- | --- | | [Canvas](canvas "Canvas") | Off-screen render target. | 0.8.0 | | | [Drawable](drawable "Drawable") | Superclass for all things that can be drawn on screen. | | | | [Font](font "Font") | Defines the shape of characters than can be drawn onto the screen. | | | | [Framebuffer](framebuffer "Framebuffer") | Off-screen render target. | 0.7.0 | 0.8.0 | | [Image](image "Image") | Drawable image type. | | | | [Mesh](mesh "Mesh") | A 2D polygon mesh used for drawing arbitrary textured shapes. | 0.9.0 | | | [ParticleSystem](particlesystem "ParticleSystem") | Used to create cool effects, like fire. | | | | [PixelEffect](pixeleffect "PixelEffect") | Pixel shader effect. | 0.8.0 | 0.9.0 | | [Quad](quad "Quad") | A quadrilateral with texture coordinate information. | | | | [Shader](shader "Shader") | Shader effect. | 0.9.0 | | | [SpriteBatch](spritebatch "SpriteBatch") | Store image positions in a buffer, and draw it in one call. | | | | [Text](text "Text") | Drawable text. | 0.10.0 | | | [Texture](texture "Texture") | Superclass for drawable objects which represent a texture. | 0.9.1 | | | [Video](video "Video") | A drawable video. | 0.10.0 | | Functions --------- ### Drawing | | | | | | --- | --- | --- | --- | | [love.graphics.arc](love.graphics.arc "love.graphics.arc") | Draws an arc. | 0.8.0 | | | [love.graphics.circle](love.graphics.circle "love.graphics.circle") | Draws a circle. | | | | [love.graphics.clear](love.graphics.clear "love.graphics.clear") | Clears the screen or active [Canvas](canvas "Canvas") to the specified color. | | | | [love.graphics.discard](love.graphics.discard "love.graphics.discard") | Discards the contents of the screen or active [Canvas](canvas "Canvas"). | 0.10.0 | | | [love.graphics.draw](love.graphics.draw "love.graphics.draw") | Draws objects on screen. | | | | [love.graphics.drawInstanced](love.graphics.drawinstanced "love.graphics.drawInstanced") | Draws many instances of a [Mesh](mesh "Mesh") with a single draw call, using hardware geometry instancing. | 11.0 | | | [love.graphics.drawLayer](love.graphics.drawlayer "love.graphics.drawLayer") | Draws a layer of an [Array Texture](love.graphics.newarrayimage "love.graphics.newArrayImage"). | 11.0 | | | [love.graphics.drawq](love.graphics.drawq "love.graphics.drawq") | Draw a Quad with the specified Image on screen. | | 0.9.0 | | [love.graphics.ellipse](love.graphics.ellipse "love.graphics.ellipse") | Draws an ellipse. | 0.10.0 | | | [love.graphics.flushBatch](love.graphics.flushbatch "love.graphics.flushBatch") | Immediately renders any pending automatically batched draws. | 11.0 | | | [love.graphics.line](love.graphics.line "love.graphics.line") | Draws lines between points. | | | | [love.graphics.point](love.graphics.point "love.graphics.point") | Draws a point. | | 0.10.0 | | [love.graphics.points](love.graphics.points "love.graphics.points") | Draws one or more points. | 0.10.0 | | | [love.graphics.polygon](love.graphics.polygon "love.graphics.polygon") | Draw a polygon. | 0.4.0 | | | [love.graphics.present](love.graphics.present "love.graphics.present") | Displays the results of drawing operations on the screen. | | | | [love.graphics.print](love.graphics.print "love.graphics.print") | Draws text on screen. If no Font is set, one will be created and set (once) if needed. | | | | [love.graphics.printf](love.graphics.printf "love.graphics.printf") | Draws formatted text, with word wrap and alignment. | | | | [love.graphics.quad](love.graphics.quad "love.graphics.quad") | Draws a quadrilateral shape. | | 0.9.0 | | [love.graphics.rectangle](love.graphics.rectangle "love.graphics.rectangle") | Draws a rectangle. | 0.3.2 | | | [love.graphics.stencil](love.graphics.stencil "love.graphics.stencil") | Draws geometry as a stencil. | 0.10.0 | | | [love.graphics.triangle](love.graphics.triangle "love.graphics.triangle") | Draws a triangle. | | 0.9.0 | ### Object Creation | | | | | | --- | --- | --- | --- | | [love.graphics.captureScreenshot](love.graphics.capturescreenshot "love.graphics.captureScreenshot") | Creates a screenshot once the current frame is done. | 11.0 | | | [love.graphics.newArrayImage](love.graphics.newarrayimage "love.graphics.newArrayImage") | Creates a new [array](texturetype "TextureType") [Image](image "Image"). | 11.0 | | | [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") | Creates a new [Canvas](canvas "Canvas"). | 0.8.0 | | | [love.graphics.newCubeImage](love.graphics.newcubeimage "love.graphics.newCubeImage") | Creates a new [cubemap](texturetype "TextureType") [Image](image "Image"). | 11.0 | | | [love.graphics.newFont](love.graphics.newfont "love.graphics.newFont") | Creates a new [Font](font "Font") from a TrueType Font or BMFont file. | | | | [love.graphics.newFramebuffer](love.graphics.newframebuffer "love.graphics.newFramebuffer") | Creates a new [Framebuffer](framebuffer "Framebuffer"). | 0.7.0 | 0.8.0 | | [love.graphics.newImage](love.graphics.newimage "love.graphics.newImage") | Creates a new [Image](image "Image"). | | | | [love.graphics.newImageFont](love.graphics.newimagefont "love.graphics.newImageFont") | Creates a new [Font](font "Font") by loading a specifically formatted image. | 0.2.0 | | | [love.graphics.newMesh](love.graphics.newmesh "love.graphics.newMesh") | Creates a new [Mesh](mesh "Mesh"). | 0.9.0 | | | [love.graphics.newParticleSystem](love.graphics.newparticlesystem "love.graphics.newParticleSystem") | Creates a new [ParticleSystem](particlesystem "ParticleSystem"). | | | | [love.graphics.newPixelEffect](love.graphics.newpixeleffect "love.graphics.newPixelEffect") | Creates a new [PixelEffect](pixeleffect "PixelEffect"). | 0.8.0 | 0.9.0 | | [love.graphics.newQuad](love.graphics.newquad "love.graphics.newQuad") | Creates a new [Quad](quad "Quad"). | | | | [love.graphics.newScreenshot](love.graphics.newscreenshot "love.graphics.newScreenshot") | Creates a screenshot and returns the [ImageData](imagedata "ImageData"). | | 11.0 | | [love.graphics.newShader](love.graphics.newshader "love.graphics.newShader") | Creates a new [Shader](shader "Shader"). | 0.9.0 | | | [love.graphics.newSpriteBatch](love.graphics.newspritebatch "love.graphics.newSpriteBatch") | Creates a new [SpriteBatch](spritebatch "SpriteBatch"). | | | | [love.graphics.newStencil](love.graphics.newstencil "love.graphics.newStencil") | Creates a new stencil. | 0.8.0 | 0.9.0 | | [love.graphics.newText](love.graphics.newtext "love.graphics.newText") | Creates a new drawable [Text](text "Text") object. | 0.10.0 | | | [love.graphics.newVideo](love.graphics.newvideo "love.graphics.newVideo") | Creates a new [Video](video "Video"). | 0.10.0 | | | [love.graphics.newVolumeImage](love.graphics.newvolumeimage "love.graphics.newVolumeImage") | Creates a new [volume](texturetype "TextureType") [Image](image "Image"). | 11.0 | | | [love.graphics.setNewFont](love.graphics.setnewfont "love.graphics.setNewFont") | Creates and sets a new [Font](font "Font"). | 0.8.0 | | | [love.graphics.validateShader](love.graphics.validateshader "love.graphics.validateShader") | Validates shader code. | 11.0 | | ### Graphics State | | | | | | --- | --- | --- | --- | | [love.graphics.getBackgroundColor](love.graphics.getbackgroundcolor "love.graphics.getBackgroundColor") | Gets the current background color. | | | | [love.graphics.getBlendMode](love.graphics.getblendmode "love.graphics.getBlendMode") | Gets the blending mode. | 0.2.0 | | | [love.graphics.getCanvas](love.graphics.getcanvas "love.graphics.getCanvas") | Returns the current target Canvas. | 0.8.0 | | | [love.graphics.getColor](love.graphics.getcolor "love.graphics.getColor") | Gets the current color. | | | | [love.graphics.getColorMask](love.graphics.getcolormask "love.graphics.getColorMask") | Gets the active color components used when drawing. | 0.9.0 | | | [love.graphics.getColorMode](love.graphics.getcolormode "love.graphics.getColorMode") | Gets the color mode (which controls how images are affected by the current color). | 0.2.0 | 0.9.0 | | [love.graphics.getDefaultFilter](love.graphics.getdefaultfilter "love.graphics.getDefaultFilter") | Returns the default scaling filters used with [Images](image "Image"), [Canvases](canvas "Canvas"), and [Fonts](font "Font"). | 0.9.0 | | | [love.graphics.getDefaultImageFilter](love.graphics.getdefaultimagefilter "love.graphics.getDefaultImageFilter") | Returns the default scaling filters. | 0.8.0 | 0.9.0 | | [love.graphics.getDepthMode](love.graphics.getdepthmode "love.graphics.getDepthMode") | Gets the current depth test mode and whether writing to the depth buffer is enabled. | 11.0 | | | [love.graphics.getFont](love.graphics.getfont "love.graphics.getFont") | Gets the current Font object. | 0.9.0 | | | [love.graphics.getFrontFaceWinding](love.graphics.getfrontfacewinding "love.graphics.getFrontFaceWinding") | Gets whether triangles with clockwise- or counterclockwise-ordered vertices are considered front-facing. | 11.0 | | | [love.graphics.getLineJoin](love.graphics.getlinejoin "love.graphics.getLineJoin") | Gets the line join style. | | | | [love.graphics.getLineStipple](love.graphics.getlinestipple "love.graphics.getLineStipple") | Gets the current line stipple. | | 0.8.0 | | [love.graphics.getLineStyle](love.graphics.getlinestyle "love.graphics.getLineStyle") | Gets the line style. | 0.3.2 | | | [love.graphics.getLineWidth](love.graphics.getlinewidth "love.graphics.getLineWidth") | Gets the current line width. | 0.3.2 | | | [love.graphics.getMeshCullMode](love.graphics.getmeshcullmode "love.graphics.getMeshCullMode") | Gets whether [back-facing](love.graphics.setfrontfacewinding "love.graphics.setFrontFaceWinding") triangles in a [Mesh](mesh "Mesh") are culled. | 11.0 | | | [love.graphics.getPixelEffect](love.graphics.getpixeleffect "love.graphics.getPixelEffect") | Returns the current PixelEffect. | 0.8.0 | 0.9.0 | | [love.graphics.getPointSize](love.graphics.getpointsize "love.graphics.getPointSize") | Gets the [point](love.graphics.point "love.graphics.point") size. | | | | [love.graphics.getPointStyle](love.graphics.getpointstyle "love.graphics.getPointStyle") | Gets the current point style. | | 0.10.0 | | [love.graphics.getScissor](love.graphics.getscissor "love.graphics.getScissor") | Gets the current scissor box. | 0.4.0 | | | [love.graphics.getShader](love.graphics.getshader "love.graphics.getShader") | Gets the current [Shader](shader "Shader"). | 0.9.0 | | | [love.graphics.getStackDepth](love.graphics.getstackdepth "love.graphics.getStackDepth") | Gets the current depth of the transform / state stack (the number of [pushes](love.graphics.push "love.graphics.push") without corresponding [pops](love.graphics.pop "love.graphics.pop")). | 11.0 | | | [love.graphics.getStencilTest](love.graphics.getstenciltest "love.graphics.getStencilTest") | Gets the current stencil test configuration. | 0.10.0 | | | [love.graphics.intersectScissor](love.graphics.intersectscissor "love.graphics.intersectScissor") | Sets the [scissor](love.graphics.setscissor "love.graphics.setScissor") to the rectangle created by the intersection of the specified rectangle with the existing scissor. | 0.10.0 | | | [love.graphics.isActive](love.graphics.isactive "love.graphics.isActive") | Gets whether the graphics module is able to be used. | 0.10.0 | | | [love.graphics.isGammaCorrect](love.graphics.isgammacorrect "love.graphics.isGammaCorrect") | Gets whether gamma-correct rendering is enabled. | 0.10.0 | | | [love.graphics.isSupported](love.graphics.issupported "love.graphics.isSupported") | Checks for the support of graphics related functions. | 0.8.0 | 0.10.0 | | [love.graphics.isWireframe](love.graphics.iswireframe "love.graphics.isWireframe") | Gets whether wireframe mode is used when drawing. | 0.9.1 | | | [love.graphics.reset](love.graphics.reset "love.graphics.reset") | Resets the current graphics settings. | | | | [love.graphics.setBackgroundColor](love.graphics.setbackgroundcolor "love.graphics.setBackgroundColor") | Sets the background color. | | | | [love.graphics.setBlendMode](love.graphics.setblendmode "love.graphics.setBlendMode") | Sets the blending mode. | 0.2.0 | | | [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas") | Captures drawing operations to a [Canvas](canvas "Canvas") | 0.8.0 | | | [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor") | Sets the color used for drawing. | | | | [love.graphics.setColorMask](love.graphics.setcolormask "love.graphics.setColorMask") | Sets the color mask. Enables or disables specific color components when rendering. | 0.9.0 | | | [love.graphics.setColorMode](love.graphics.setcolormode "love.graphics.setColorMode") | Sets the color mode (which controls how images are affected by the current color). | 0.2.0 | 0.9.0 | | [love.graphics.setDefaultFilter](love.graphics.setdefaultfilter "love.graphics.setDefaultFilter") | Sets the default scaling filters used with [Images](image "Image"), [Canvases](canvas "Canvas"), and [Fonts](font "Font"). | 0.9.0 | | | [love.graphics.setDefaultImageFilter](love.graphics.setdefaultimagefilter "love.graphics.setDefaultImageFilter") | Sets the default scaling filters. | 0.8.0 | 0.9.0 | | [love.graphics.setDepthMode](love.graphics.setdepthmode "love.graphics.setDepthMode") | Configures depth testing and writing to the depth buffer. | 11.0 | | | [love.graphics.setFont](love.graphics.setfont "love.graphics.setFont") | Set an already-loaded Font as the current font. | | | | [love.graphics.setFrontFaceWinding](love.graphics.setfrontfacewinding "love.graphics.setFrontFaceWinding") | Sets whether triangles with clockwise- or counterclockwise-ordered vertices are considered front-facing. | 11.0 | | | [love.graphics.setInvertedStencil](love.graphics.setinvertedstencil "love.graphics.setInvertedStencil") | Defines an inverted stencil. | 0.8.0 | 0.10.0 | | [love.graphics.setLine](love.graphics.setline "love.graphics.setLine") | Sets the line width and style. | | 0.9.0 | | [love.graphics.setLineJoin](love.graphics.setlinejoin "love.graphics.setLineJoin") | Sets the line join style. | | | | [love.graphics.setLineStipple](love.graphics.setlinestipple "love.graphics.setLineStipple") | Sets the line stipple pattern. | | 0.8.0 | | [love.graphics.setLineStyle](love.graphics.setlinestyle "love.graphics.setLineStyle") | Sets the line style. | 0.3.2 | | | [love.graphics.setLineWidth](love.graphics.setlinewidth "love.graphics.setLineWidth") | Sets the line width. | 0.3.2 | | | [love.graphics.setMeshCullMode](love.graphics.setmeshcullmode "love.graphics.setMeshCullMode") | Sets whether [back-facing](love.graphics.setfrontfacewinding "love.graphics.setFrontFaceWinding") triangles in a [Mesh](mesh "Mesh") are culled. | 11.0 | | | [love.graphics.setPixelEffect](love.graphics.setpixeleffect "love.graphics.setPixelEffect") | Routes drawing operations through a pixel shader. | 0.8.0 | 0.9.0 | | [love.graphics.setPoint](love.graphics.setpoint "love.graphics.setPoint") | Sets the point size and style. | | 0.9.0 | | [love.graphics.setPointSize](love.graphics.setpointsize "love.graphics.setPointSize") | Sets the [point](love.graphics.points "love.graphics.points") size. | | | | [love.graphics.setPointStyle](love.graphics.setpointstyle "love.graphics.setPointStyle") | Sets the [point](love.graphics.point "love.graphics.point") style. | | 0.10.0 | | [love.graphics.setRenderTarget](love.graphics.setrendertarget "love.graphics.setRenderTarget") | Captures drawing operations to a Framebuffer | 0.7.0 | 0.8.0 | | [love.graphics.setScissor](love.graphics.setscissor "love.graphics.setScissor") | Sets or disables scissor. | 0.4.0 | | | [love.graphics.setShader](love.graphics.setshader "love.graphics.setShader") | Routes drawing operations through a shader. | 0.9.0 | | | [love.graphics.setStencil](love.graphics.setstencil "love.graphics.setStencil") | Defines or releases a stencil. | 0.8.0 | 0.10.0 | | [love.graphics.setStencilTest](love.graphics.setstenciltest "love.graphics.setStencilTest") | Configures or disables stencil testing. | 0.10.0 | | | [love.graphics.setWireframe](love.graphics.setwireframe "love.graphics.setWireframe") | Sets whether wireframe lines will be used when drawing. | 0.9.1 | | ### Coordinate System | | | | | | --- | --- | --- | --- | | [love.graphics.applyTransform](love.graphics.applytransform "love.graphics.applyTransform") | Applies the given [Transform](transform "Transform") object to the current coordinate transformation. | 11.0 | | | [love.graphics.inverseTransformPoint](love.graphics.inversetransformpoint "love.graphics.inverseTransformPoint") | Converts the given 2D position from screen-space into global coordinates. | 11.0 | | | [love.graphics.origin](love.graphics.origin "love.graphics.origin") | Resets the current coordinate transformation. | 0.9.0 | | | [love.graphics.pop](love.graphics.pop "love.graphics.pop") | Pops the current coordinate transformation from the transformation stack. | | | | [love.graphics.push](love.graphics.push "love.graphics.push") | Copies and pushes the current coordinate transformation to the transformation stack. | | | | [love.graphics.replaceTransform](love.graphics.replacetransform "love.graphics.replaceTransform") | Replaces the current coordinate transformation with the given [Transform](transform "Transform") object. | 11.0 | | | [love.graphics.rotate](love.graphics.rotate "love.graphics.rotate") | Rotates the coordinate system in two dimensions. | | | | [love.graphics.scale](love.graphics.scale "love.graphics.scale") | Scales the coordinate system in two dimensions. | | | | [love.graphics.shear](love.graphics.shear "love.graphics.shear") | Shears the coordinate system. | 0.8.0 | | | [love.graphics.transformPoint](love.graphics.transformpoint "love.graphics.transformPoint") | Converts the given 2D position from global coordinates into screen-space. | 11.0 | | | [love.graphics.translate](love.graphics.translate "love.graphics.translate") | Translates the coordinate system in two dimensions. | | | ### Window | | | | | | --- | --- | --- | --- | | [love.graphics.checkMode](love.graphics.checkmode "love.graphics.checkMode") | Checks if a display mode is supported. | | 0.9.0 | | [love.graphics.getCaption](love.graphics.getcaption "love.graphics.getCaption") | Gets the window caption. | | 0.9.0 | | [love.graphics.getDPIScale](love.graphics.getdpiscale "love.graphics.getDPIScale") | Gets the DPI scale factor of the window. | 11.0 | | | [love.graphics.getDimensions](love.graphics.getdimensions "love.graphics.getDimensions") | Gets the width and height of the window. | 0.9.0 | | | [love.graphics.getHeight](love.graphics.getheight "love.graphics.getHeight") | Gets the height in pixels of the window. | 0.2.1 | | | [love.graphics.getMode](love.graphics.getmode "love.graphics.getMode") | Returns the current display mode. | 0.8.0 | 0.9.0 | | [love.graphics.getModes](love.graphics.getmodes "love.graphics.getModes") | Gets a list of supported fullscreen modes. | | 0.9.0 | | [love.graphics.getPixelDimensions](love.graphics.getpixeldimensions "love.graphics.getPixelDimensions") | Gets the width and height in pixels of the window. | 11.0 | | | [love.graphics.getPixelHeight](love.graphics.getpixelheight "love.graphics.getPixelHeight") | Gets the height in pixels of the window. | 11.0 | | | [love.graphics.getPixelWidth](love.graphics.getpixelwidth "love.graphics.getPixelWidth") | Gets the width in pixels of the window. | 11.0 | | | [love.graphics.getWidth](love.graphics.getwidth "love.graphics.getWidth") | Gets the width in pixels of the window. | 0.2.1 | | | [love.graphics.hasFocus](love.graphics.hasfocus "love.graphics.hasFocus") | Checks if the game window has keyboard focus. | 0.8.0 | 0.9.0 | | [love.graphics.isCreated](love.graphics.iscreated "love.graphics.isCreated") | Checks if the window has been created. | | 0.9.0 | | [love.graphics.setCaption](love.graphics.setcaption "love.graphics.setCaption") | Sets the window caption. | | 0.9.0 | | [love.graphics.setIcon](love.graphics.seticon "love.graphics.setIcon") | Set window icon. | 0.7.0 | 0.9.0 | | [love.graphics.setMode](love.graphics.setmode "love.graphics.setMode") | Changes the display mode. | | 0.9.0 | | [love.graphics.toggleFullscreen](love.graphics.togglefullscreen "love.graphics.toggleFullscreen") | Toggles fullscreen. | | 0.9.0 | ### System Information | | | | | | --- | --- | --- | --- | | [love.graphics.getCanvasFormats](love.graphics.getcanvasformats "love.graphics.getCanvasFormats") | Gets the available [Canvas formats](canvasformat "CanvasFormat"), and whether each is supported. | 0.9.2 | | | [love.graphics.getCompressedImageFormats](love.graphics.getcompressedimageformats "love.graphics.getCompressedImageFormats") | Gets the available [compressed image formats](compressedformat "CompressedFormat"), and whether each is supported. | 0.9.2 | 11.0 | | [love.graphics.getImageFormats](love.graphics.getimageformats "love.graphics.getImageFormats") | Gets the [pixel formats](pixelformat "PixelFormat") usable for [Images](image "Image"), and whether each is supported. | 11.0 | | | [love.graphics.getMaxImageSize](love.graphics.getmaximagesize "love.graphics.getMaxImageSize") | Gets the max supported width or height of Images and Canvases. | 0.9.0 | 0.10.0 | | [love.graphics.getMaxPointSize](love.graphics.getmaxpointsize "love.graphics.getMaxPointSize") | Gets the max supported [point](love.graphics.point "love.graphics.point") size. | | 0.10.0 | | [love.graphics.getRendererInfo](love.graphics.getrendererinfo "love.graphics.getRendererInfo") | Gets information about the system's video card and drivers. | 0.9.0 | | | [love.graphics.getStats](love.graphics.getstats "love.graphics.getStats") | Gets performance-related rendering statistics. | 0.9.2 | | | [love.graphics.getSupported](love.graphics.getsupported "love.graphics.getSupported") | Gets the optional graphics features and whether they're supported. | 0.10.0 | | | [love.graphics.getSystemLimit](love.graphics.getsystemlimit "love.graphics.getSystemLimit") | Gets the system-dependent maximum value for a love.graphics feature. | 0.9.1 | 0.10.0 | | [love.graphics.getSystemLimits](love.graphics.getsystemlimits "love.graphics.getSystemLimits") | Gets the system-dependent maximum values for love.graphics features. | 0.10.0 | | | [love.graphics.getTextureTypes](love.graphics.gettexturetypes "love.graphics.getTextureTypes") | Gets the available [texture types](texturetype "TextureType"), and whether each is supported. | 11.0 | | Enums ----- | | | | | | --- | --- | --- | --- | | [AlignMode](alignmode "AlignMode") | Text alignment. | | | | [ArcType](arctype "ArcType") | Different types of [arcs](love.graphics.arc "love.graphics.arc") that can be drawn. | 0.10.1 | | | [BlendAlphaMode](blendalphamode "BlendAlphaMode") | Different ways alpha affects color blending. | 0.10.0 | | | [BlendMode](blendmode "BlendMode") | Different ways to do color blending. | 0.2.0 | | | [CanvasFormat](canvasformat "CanvasFormat") | Canvas texture formats. | 0.9.0 | | | [ColorMode](colormode "ColorMode") | Controls how drawn images are affected by current color. | 0.2.0 | 0.9.0 | | [CompareMode](comparemode "CompareMode") | Different types of [stencil test](love.graphics.setstenciltest "love.graphics.setStencilTest") and [depth test](love.graphics.setdepthmode "love.graphics.setDepthMode") comparisons. | 0.10.0 | | | [CullMode](cullmode "CullMode") | How [Mesh](mesh "Mesh") geometry is culled when rendering. | 11.0 | | | [DrawMode](drawmode "DrawMode") | Controls whether shapes are drawn as an outline, or filled. | | | | [FilterMode](filtermode "FilterMode") | How the image is filtered when scaling. | | | | [GraphicsFeature](graphicsfeature "GraphicsFeature") | Graphics features that can be checked for with [love.graphics.getSupported](love.graphics.getsupported "love.graphics.getSupported"). | 0.8.0 | | | [GraphicsLimit](graphicslimit "GraphicsLimit") | Types of system-dependent graphics limits. | 0.9.1 | | | [IndexDataType](indexdatatype "IndexDataType") | Vertex map datatype. | 11.0 | | | [LineJoin](linejoin "LineJoin") | Line join style. | | | | [LineStyle](linestyle "LineStyle") | The styles in which lines are drawn. | | | | [MeshDrawMode](meshdrawmode "MeshDrawMode") | How a Mesh's vertices are used when drawing. | 0.9.0 | | | [MipmapMode](mipmapmode "MipmapMode") | Controls whether a [Canvas](canvas "Canvas") has mipmaps, and its behaviour when it does. | 11.0 | | | [PixelFormat](pixelformat "PixelFormat") | Pixel formats for [Textures](texture "Texture"), [ImageData](imagedata "ImageData"), and [CompressedImageData](compressedimagedata "CompressedImageData"). | 11.0 | | | [PointStyle](pointstyle "PointStyle") | How points should be drawn. | | 0.10.0 | | [SpriteBatchUsage](spritebatchusage "SpriteBatchUsage") | Usage hints for [SpriteBatches](spritebatch "SpriteBatch") and [Meshes](mesh "Mesh"). | 0.8.0 | | | [StackType](stacktype "StackType") | Graphics state stack types used with [love.graphics.push](love.graphics.push "love.graphics.push"). | 0.9.2 | | | [StencilAction](stencilaction "StencilAction") | How a [stencil function](love.graphics.stencil "love.graphics.stencil") modifies the stencil values of pixels it touches. | 0.10.0 | | | [TextureFormat](textureformat "TextureFormat") | Controls the canvas texture format. | 0.9.0 | 0.10.0 | | [TextureType](texturetype "TextureType") | Types of textures (2D, cubemap, etc.) | 11.0 | | | [VertexAttributeStep](vertexattributestep "VertexAttributeStep") | The frequency at which a vertex shader fetches the vertex attribute's data from the Mesh when it's drawn. | 11.0 | | | [VertexWinding](vertexwinding "VertexWinding") | Vertex winding. | 11.0 | | | [WrapMode](wrapmode "WrapMode") | How the image wraps inside a large Quad. | | | See Also -------- * [love](love "love")
programming_docs
love Video:setFilter Video:setFilter =============== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Sets the scaling filters used when drawing the Video. Function -------- ### Synopsis ``` Video:setFilter( min, mag, anisotropy ) ``` ### Arguments `[FilterMode](filtermode "FilterMode") min` The filter mode used when scaling the Video down. `[FilterMode](filtermode "FilterMode") mag` The filter mode used when scaling the Video up. `[number](number "number") anisotropy (1)` Maximum amount of anisotropic filtering used. ### Returns Nothing. See Also -------- * [Video](video "Video") * [Video:getFilter](video-getfilter "Video:getFilter") * [FilterMode](filtermode "FilterMode") love EdgeShape:getPreviousVertex EdgeShape:getPreviousVertex =========================== **Available since LÖVE [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2")** This function is not supported in earlier versions. Gets the vertex that establishes a connection to the previous shape. Setting next and previous EdgeShape vertices can help prevent unwanted collisions when a flat shape slides along the edge and moves over to the new shape. Function -------- ### Synopsis ``` x, y = EdgeShape:getPreviousVertex( ) ``` ### Arguments None. ### Returns `[number](number "number") x (nil)` The x-component of the vertex, or nil if [EdgeShape:setPreviousVertex](edgeshape-setpreviousvertex "EdgeShape:setPreviousVertex") hasn't been called. `[number](number "number") y (nil)` The y-component of the vertex, or nil if [EdgeShape:setPreviousVertex](edgeshape-setpreviousvertex "EdgeShape:setPreviousVertex") hasn't been called. See Also -------- * [EdgeShape](edgeshape "EdgeShape") * [EdgeShape:setPreviousVertex](edgeshape-setpreviousvertex "EdgeShape:setPreviousVertex") * [EdgeShape:getNextVertex](edgeshape-getnextvertex "EdgeShape:getNextVertex") love love.filesystem.getSaveDirectory love.filesystem.getSaveDirectory ================================ **Available since LÖVE [0.5.0](https://love2d.org/wiki/0.5.0 "0.5.0")** This function is not supported in earlier versions. Gets the full path to the designated save directory. This can be useful if you want to use the standard io library (or something else) to read or write in the save directory. Function -------- ### Synopsis ``` dir = love.filesystem.getSaveDirectory( ) ``` ### Arguments None. ### Returns `[string](string "string") dir` The absolute path to the save directory. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") love RopeJoint RopeJoint ========= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This type is not supported in earlier versions. The RopeJoint enforces a maximum distance between two points on two bodies. It has no other effect. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.physics.newRopeJoint](love.physics.newropejoint "love.physics.newRopeJoint") | Creates a joint between two bodies that enforces a max distance between them. | 0.8.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Joint:destroy](joint-destroy "Joint:destroy") | Explicitly destroys the Joint. | | | | [Joint:getAnchors](joint-getanchors "Joint:getAnchors") | Get the anchor points of the joint. | | | | [Joint:getBodies](joint-getbodies "Joint:getBodies") | Gets the [bodies](body "Body") that the Joint is attached to. | 0.9.2 | | | [Joint:getCollideConnected](joint-getcollideconnected "Joint:getCollideConnected") | Gets whether the connected Bodies collide. | | | | [Joint:getReactionForce](joint-getreactionforce "Joint:getReactionForce") | Returns the reaction force on the second body. | | | | [Joint:getReactionTorque](joint-getreactiontorque "Joint:getReactionTorque") | Returns the reaction torque on the second body. | | | | [Joint:getType](joint-gettype "Joint:getType") | Gets a string representing the type. | | | | [Joint:getUserData](joint-getuserdata "Joint:getUserData") | Returns the Lua value associated with this Joint. | 0.9.2 | | | [Joint:isDestroyed](joint-isdestroyed "Joint:isDestroyed") | Gets whether the Joint is destroyed. | 0.9.2 | | | [Joint:setCollideConnected](joint-setcollideconnected "Joint:setCollideConnected") | Sets whether the connected Bodies should collide with each other. | | 0.8.0 | | [Joint:setUserData](joint-setuserdata "Joint:setUserData") | Associates a Lua value with the Joint. | 0.9.2 | | | [RopeJoint:getMaxLength](ropejoint-getmaxlength "RopeJoint:getMaxLength") | Gets the maximum length of a RopeJoint. | 0.8.0 | | | [RopeJoint:setMaxLength](ropejoint-setmaxlength "RopeJoint:setMaxLength") | Sets the maximum length of a RopeJoint. | 11.0 | | Supertypes ---------- * [Joint](joint "Joint") * [Object](object "Object") See Also -------- * [love.physics](love.physics "love.physics") love GlyphData:getGlyphString GlyphData:getGlyphString ======================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Gets glyph string. Function -------- ### Synopsis ``` glyph = GlyphData:getGlyphString() ``` ### Arguments None. ### Returns `[string](string "string") glyph` Glyph string. See Also -------- * [GlyphData](glyphdata "GlyphData") love love.math.linearToGamma love.math.linearToGamma ======================= **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. Converts a color from linear-space (RGB) to gamma-space (sRGB). This is useful when storing linear RGB color values in an image, because the linear RGB color space has less precision than sRGB for dark colors, which can result in noticeable color banding when drawing. In general, colors chosen based on what they look like on-screen are already in gamma-space and should not be double-converted. Colors calculated using math are often in the linear RGB space. Read more about gamma-correct rendering [here](http://http.developer.nvidia.com/GPUGems3/gpugems3_ch24.html), [here](http://filmicgames.com/archives/299), and [here](http://renderwonk.com/blog/index.php/archive/adventures-with-gamma-correct-rendering/). In versions prior to [11.0](https://love2d.org/wiki/11.0 "11.0"), color component values were within the range of 0 to 255 instead of 0 to 1. Gamma-correct rendering is an advanced topic and it's easy to get color-spaces mixed up. If you're not sure whether you need this, you might want to avoid it. Function -------- ### Synopsis ``` cr, cg, cb = love.math.linearToGamma( lr, lg, lb ) ``` ### Arguments `[number](number "number") lr` The red channel of the linear RGB color to convert. `[number](number "number") lg` The green channel of the linear RGB color to convert. `[number](number "number") lb` The blue channel of the linear RGB color to convert. ### Returns `[number](number "number") cr` The red channel of the converted color in gamma sRGB space. `[number](number "number") cg` The green channel of the converted color in gamma sRGB space. `[number](number "number") cb` The blue channel of the converted color in gamma sRGB space. ### Notes An alpha value can be passed into the function as a fourth argument, but it will be returned unchanged because alpha is always linear. Function -------- ### Synopsis ``` cr, cg, cb = love.math.linearToGamma( color ) ``` ### Arguments `[table](table "table") color` An array with the red, green, and blue channels of the linear RGB color to convert. ### Returns `[number](number "number") cr` The red channel of the converted color in gamma sRGB space. `[number](number "number") cg` The green channel of the converted color in gamma sRGB space. `[number](number "number") cb` The blue channel of the converted color in gamma sRGB space. Function -------- ### Synopsis ``` c = love.math.linearToGamma( lc ) ``` ### Arguments `[number](number "number") lc` The value of a color channel in linear RGB space to convert. ### Returns `[number](number "number") c` The value of the color channel in gamma sRGB space. Examples -------- ### Pre-multiply an image's alpha with its RGB values in linear RGB space ``` local function PremultiplyLinearPixel(x, y, r, g, b, a) r = r * a g = g * a b = b * a return r, g, b, a end   local function PremultiplyGammaPixel(x, y, r, g, b, a) r, g, b = love.math.gammaToLinear(r, g, b) r = r * a g = g * a b = b * a r, g, b = love.math.linearToGamma(r, g, b) return r, g, b, a end   -- Loads an image and pre-multiplies its RGB values with its alpha, for use with the ('alpha', 'premultiplied') blend mode. -- The multiplication correctly accounts for the color-space of the image. function NewPremultipliedImage(filepath, flags) local imagedata = love.image.newImageData(filepath)   local mapfunction = (flags and flags.linear) and PremultiplyLinearPixel or PremultiplyGammaPixel imagedata:mapPixel(mapfunction)   return love.graphics.newImage(imagedata, flags) end   image = NewPremultipliedImage("pig.png") ``` See Also -------- * [love.math](love.math "love.math") * [love.math.gammaToLinear](love.math.gammatolinear "love.math.gammaToLinear") love love.math.colorToBytes love.math.colorToBytes ====================== **Available since LÖVE [11.3](https://love2d.org/wiki/11.3 "11.3")** This function is not supported in earlier versions. Converts a color from 0..1 to 0..255 range. Function -------- ### Synopsis ``` rb, gb, bb, ab = love.math.colorToBytes( r, g, b, a ) ``` ### Arguments `[number](number "number") r` Red color component. `[number](number "number") g` Green color component. `[number](number "number") b` Blue color component. `[number](number "number") a (nil)` Alpha color component. ### Returns `[number](number "number") rb` Red color component in 0..255 range. `[number](number "number") gb` Green color component in 0..255 range. `[number](number "number") bb` Blue color component in 0..255 range. `[number](number "number") ab (nil)` Alpha color component in 0..255 range or nil if alpha is not specified. Notes ----- Here's implementation for [11.2](https://love2d.org/wiki/11.2 "11.2") and earlier. ``` function love.math.colorToBytes(r, g, b, a) if type(r) == "table" then r, g, b, a = r[1], r[2], r[3], r[4] end r = floor(clamp01(r) * 255 + 0.5) g = floor(clamp01(g) * 255 + 0.5) b = floor(clamp01(b) * 255 + 0.5) a = a ~= nil and floor(clamp01(a) * 255 + 0.5) or nil return r, g, b, a end ``` Where `clamp01` is defined as follows ``` local function clamp01(x) return math.min(math.max(x, 0), 1) end ``` See Also -------- * [love.math](love.math "love.math") * [love.math.colorFromBytes](love.math.colorfrombytes "love.math.colorFromBytes") love Channel:supply Channel:supply ============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Send a message to the thread Channel and wait for a thread to accept it. See [Variant](variant "Variant") for the list of supported types. Function -------- ### Synopsis ``` success = Channel:supply( value ) ``` ### Arguments `[Variant](variant "Variant") value` The contents of the message. ### Returns `[boolean](boolean "boolean") success` Available since 11.0 Whether the message was successfully supplied (always `true`). Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` success = Channel:supply( value, timeout ) ``` ### Arguments `[Variant](variant "Variant") value` The contents of the message. `[number](number "number") timeout` The maximum amount of time to wait. ### Returns `[boolean](boolean "boolean") success` Whether the message was successfully supplied before the timeout expired. See Also -------- * [Channel](channel "Channel") * [Channel:demand](channel-demand "Channel:demand") * [Channel:push](channel-push "Channel:push") love love.audio.newSource love.audio.newSource ==================== Creates a new [Source](source "Source") from a filepath, [File](file "File"), [Decoder](decoder "Decoder") or [SoundData](sounddata "SoundData"). Sources created from SoundData are always static. This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` source = love.audio.newSource( filename, type ) ``` ### Arguments `[string](string "string") filename` The filepath to the audio file. `[SourceType](sourcetype "SourceType") type` Streaming or static source. ### Returns `[Source](source "Source") source` A new Source that can play the specified audio. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` source = love.audio.newSource( file, type ) ``` ### Arguments `[File](file "File") file` A File pointing to an audio file. `[SourceType](sourcetype "SourceType") type` Streaming or static source. ### Returns `[Source](source "Source") source` A new Source that can play the specified audio. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` source = love.audio.newSource( decoder, type ) ``` ### Arguments `[Decoder](decoder "Decoder") decoder` The Decoder to create a Source from. `[SourceType](sourcetype "SourceType") type` Streaming or static source. ### Returns `[Source](source "Source") source` A new Source that can play the specified audio. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` source = love.audio.newSource( data, type ) ``` ### Arguments `[FileData](filedata "FileData") data` The FileData to create a Source from. `[SourceType](sourcetype "SourceType") type` Streaming or static source. ### Returns `[Source](source "Source") source` A new Source that can play the specified audio. Function -------- ### Synopsis ``` source = love.audio.newSource( data ) ``` ### Arguments `[SoundData](sounddata "SoundData") data` The SoundData to create a Source from. ### Returns `[Source](source "Source") source` A new Source that can play the specified audio. The [SourceType](sourcetype "SourceType") of the returned audio is "static". Function -------- **Removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in that and later versions. ### Synopsis ``` source = love.audio.newSource( filename, type ) ``` ### Arguments `[string](string "string") filename` The filepath to the audio file. `[SourceType](sourcetype "SourceType") type ("stream")` Streaming or static source. ### Returns `[Source](source "Source") source` A new Source that can play the specified audio. Function -------- **Removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in that and later versions. ### Synopsis ``` source = love.audio.newSource( file, type ) ``` ### Arguments `[File](file "File") file` A File pointing to an audio file. `[SourceType](sourcetype "SourceType") type ("stream")` Streaming or static source. ### Returns `[Source](source "Source") source` A new Source that can play the specified audio. Function -------- **Removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in that and later versions. ### Synopsis ``` source = love.audio.newSource( decoder, type ) ``` ### Arguments `[Decoder](decoder "Decoder") decoder` The Decoder to create a Source from. `[SourceType](sourcetype "SourceType") type ("stream")` Streaming or static source. ### Returns `[Source](source "Source") source` A new Source that can play the specified audio. Function -------- **Removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in that and later versions. ### Synopsis ``` source = love.audio.newSource( data, type ) ``` ### Arguments `[FileData](filedata "FileData") data` The FileData to create a Source from. `[SourceType](sourcetype "SourceType") type ("stream")` Streaming or static source. ### Returns `[Source](source "Source") source` A new Source that can play the specified audio. Notes ----- From [11.0](https://love2d.org/wiki/11.0 "11.0") onwards, if **queue** is specified as [SourceType](sourcetype "SourceType") for this specific constructor, it won't error, and getType will return **stream**; this is a bug. One should use [love.audio.newQueueableSource](love.audio.newqueueablesource "love.audio.newQueueableSource") for that specific source type instead. Examples -------- ### Load background music and play it ``` bgm = love.audio.newSource("bgm.ogg", "stream") love.audio.play(bgm) ``` ### Load a sound effect and play it ``` sfx = love.audio.newSource("sfx.wav", "static") love.audio.play(sfx) ``` ### Load SoundData and create a Source ``` data = love.sound.newSoundData("sfx.wav") sfx = love.audio.newSource(data) ``` ### Load Decoder and create a Source ``` decoder = love.sound.newDecoder("bgm.ogg") bgm = love.audio.newSource(decoder, "stream") ``` See Also -------- * [love.audio](love.audio "love.audio") * [Source](source "Source") love Joint:getReactionTorque Joint:getReactionTorque ======================= Returns the reaction torque on the second body. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in earlier versions. ### Synopsis ``` torque = Joint:getReactionTorque( invdt ) ``` ### Arguments `[number](number "number") invdt` How long the force applies. Usually the inverse time step or 1/dt. ### Returns `[number](number "number") torque` The reaction torque on the second body. Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. ### Synopsis ``` torque = Joint:getReactionTorque( ) ``` ### Arguments None. ### Returns `[number](number "number") torque` The reaction torque on the second body. See Also -------- * [Joint](joint "Joint") love Joint:getUserData Joint:getUserData ================= **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This method is not supported in earlier versions. Returns the Lua value associated with this Joint. Use this function in one thread and one thread only. Using it in more threads will make Lua cry and most likely crash. Function -------- ### Synopsis ``` value = Joint:getUserData( ) ``` ### Arguments None. ### Returns `[any](https://love2d.org/w/index.php?title=any&action=edit&redlink=1 "any (page does not exist)") value` The Lua value associated with the Joint. See Also -------- * [Joint](joint "Joint") * [Joint:setUserData](joint-setuserdata "Joint:setUserData") love love.load love.load ========= This function is called exactly once at the beginning of the game. Function -------- ### Synopsis ``` love.load( arg, unfilteredArg ) ``` ### Arguments `[table](table "table") arg` Command-line arguments given to the game. `[table](table "table") unfilteredArg` Available since 11.0 Unfiltered command-line arguments given to the executable (see <#Notes>). ### Returns Nothing. Notes ----- In LÖVE 11.0, the passed arguments excludes the game name and the fused command-line flag (if exist) when runs from non-fused LÖVE executable. Previous version pass the argument as-is without any filtering. Examples -------- Establish some variables/resources on the game load, so that they can be used repeatedly in other functions (such as [love.draw](love.draw "love.draw")). ``` function love.load() hamster = love.graphics.newImage("hamster.png") x = 50 y = 50 end   function love.draw() love.graphics.draw(hamster, x, y) end ``` See Also -------- * [love](love "love")
programming_docs
love World:translateOrigin World:translateOrigin ===================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Translates the World's origin. Useful in large worlds where floating point precision issues become noticeable at far distances from the origin. Function -------- ### Synopsis ``` World:translateOrigin( x, y ) ``` ### Arguments `[number](number "number") x` The x component of the new origin with respect to the old origin. `[number](number "number") y` The y component of the new origin with respect to the old origin. ### Returns Nothing. See Also -------- * [World](world "World") love Body:getWorldPoints Body:getWorldPoints =================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Transforms multiple points from local coordinates to world coordinates. Function -------- ### Synopsis ``` x1, y1, x2, y2, ... = Body:getWorldPoints( x1, y1, x2, y2, ... ) ``` ### Arguments `[number](number "number") x1` The x position of the first point. `[number](number "number") y1` The y position of the first point. `[number](number "number") x2` The x position of the second point. `[number](number "number") y2` The y position of the second point. ### Returns `[number](number "number") x1` The transformed x position of the first point. `[number](number "number") y1` The transformed y position of the first point. `[number](number "number") x2` The transformed x position of the second point. `[number](number "number") y2` The transformed y position of the second point. See Also -------- * [Body](body "Body") love love.graphics.getPixelHeight love.graphics.getPixelHeight ============================ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets the height in pixels of the window. The graphics coordinate system and [love.graphics.getHeight](love.graphics.getheight "love.graphics.getHeight") use units scaled by the screen's [DPI scale factor](love.graphics.getdpiscale "love.graphics.getDPIScale"), 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](shader "Shader"), for example). Function -------- ### Synopsis ``` pixelheight = love.graphics.getPixelHeight( ) ``` ### Arguments None. ### Returns `[number](number "number") pixelheight` The height of the window in pixels. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.getPixelWidth](love.graphics.getpixelwidth "love.graphics.getPixelWidth") * [love.graphics.getPixelDimensions](love.graphics.getpixeldimensions "love.graphics.getPixelDimensions") love ParticleSystem:setSize ParticleSystem:setSize ====================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been replaced with [ParticleSystem:setSizes](particlesystem-setsizes "ParticleSystem:setSizes"). Sets the size of the particle (1.0 being normal size). The particles will grow/shrink from the starting size to the ending size. The variation affects starting size only. Function -------- ### Synopsis ``` ParticleSystem:setSize( min, max, variation ) ``` ### Arguments `[number](number "number") min` The minimum size (1.0 being normal size). `[number](number "number") max (min)` The maximum size (1.0 being normal size). `[number](number "number") variation (1)` The degree of variation (0 meaning no variation and 1 meaning full variation between start and end). ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love love.graphics.present love.graphics.present ===================== Displays the results of drawing operations on the screen. This function is used when writing your own [love.run](love.run "love.run") function. It presents all the results of your drawing operations on the screen. See the example in [love.run](love.run "love.run") for a typical use of this function. Function -------- ### Synopsis ``` love.graphics.present( ) ``` ### Arguments None. ### Returns Nothing. Notes ----- * If [love.window.setMode](love.window.setmode "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. See Also -------- * [love.graphics.clear](love.graphics.clear "love.graphics.clear") * [love.graphics](love.graphics "love.graphics") love love.joystick.getJoystickCount love.joystick.getJoystickCount ============================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [love.joystick.getNumJoysticks](love.joystick.getnumjoysticks "love.joystick.getNumJoysticks"). Gets the number of connected joysticks. Function -------- ### Synopsis ``` joystickcount = love.joystick.getJoystickCount( ) ``` ### Arguments None. ### Returns `[number](number "number") joystickcount` The number of connected joysticks. See Also -------- * [love.joystick](love.joystick "love.joystick") * [love.joystick.getJoysticks](love.joystick.getjoysticks "love.joystick.getJoysticks") love SpriteBatch:add SpriteBatch:add =============== Adds a sprite to the batch. Sprites are drawn in the order they are added. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in earlier versions. ### Synopsis ``` id = SpriteBatch:add( x, y, r, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[number](number "number") x` The position to draw the object (x-axis). `[number](number "number") y` The position to draw the object (y-axis). `[number](number "number") r (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Shear factor (x-axis). `[number](number "number") ky (0)` Shear factor (y-axis). ### Returns `[number](number "number") id` An identifier for the added sprite. Function -------- **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant has replaced [SpriteBatch:addq](spritebatch-addq "SpriteBatch:addq"). Adds a [Quad](quad "Quad") to the batch. ### Synopsis ``` id = SpriteBatch:add( quad, x, y, r, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[Quad](quad "Quad") quad` The Quad to add. `[number](number "number") x` The position to draw the object (x-axis). `[number](number "number") y` The position to draw the object (y-axis). `[number](number "number") r (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Shear factor (x-axis). `[number](number "number") ky (0)` Shear factor (y-axis). ### Returns `[number](number "number") id` An identifier for the added sprite. Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. ### Synopsis ``` SpriteBatch:add( x, y, r, sx, sy, ox, oy ) ``` ### Arguments `[number](number "number") x` The position to draw the object (x-axis). `[number](number "number") y` The position to draw the object (y-axis). `[number](number "number") r (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). ### Returns Nothing. Notes ----- The returned `id`s range from 1 to the set [buffer size](spritebatch-setbuffersize "SpriteBatch:setBufferSize"). If the buffer size is exceeded the returned `id` will default to 0 and the sprite won't be drawn. See Also -------- * [SpriteBatch](spritebatch "SpriteBatch") * [SpriteBatch:set](spritebatch-set "SpriteBatch:set") love love.run love.run ======== The main function, containing the main loop. A sensible default is used when left out. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` mainLoop = love.run ( ) ``` ### Arguments None. ### Returns `[function](function "function") mainLoop` Function which handles one frame, including events and rendering, when called. Function -------- **Removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in that and later versions. ### Synopsis ``` love.run( ) ``` ### Arguments None. ### Returns Nothing. Examples -------- ### The default function for [11.0](https://love2d.org/wiki/11.0 "11.0"), used if you don't supply your own. ``` function love.run() if love.load then love.load(love.arg.parseGameArguments(arg), arg) end   -- We don't want the first frame's dt to include time taken by love.load. if love.timer then love.timer.step() end   local dt = 0   -- Main loop time. return function() -- Process events. if love.event then love.event.pump() for name, a,b,c,d,e,f in love.event.poll() do if name == "quit" then if not love.quit or not love.quit() then return a or 0 end end love.handlers[name](a,b,c,d,e,f) end end   -- Update dt, as we'll be passing it to update if love.timer then dt = love.timer.step() end   -- Call update and draw if love.update then love.update(dt) end -- will pass 0 if love.timer is disabled   if love.graphics and love.graphics.isActive() then love.graphics.origin() love.graphics.clear(love.graphics.getBackgroundColor())   if love.draw then love.draw() end   love.graphics.present() end   if love.timer then love.timer.sleep(0.001) end end end ``` ### The default function for [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0"), [0.10.1](https://love2d.org/wiki/0.10.1 "0.10.1"), and [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2"), used if you don't supply your own. ``` function love.run()   if love.math then love.math.setRandomSeed(os.time()) end   if love.load then love.load(arg) end   -- We don't want the first frame's dt to include time taken by love.load. if love.timer then love.timer.step() end   local dt = 0   -- Main loop time. while true do -- Process events. if love.event then love.event.pump() for name, a,b,c,d,e,f in love.event.poll() do if name == "quit" then if not love.quit or not love.quit() then return a end end love.handlers[name](a,b,c,d,e,f) end end   -- Update dt, as we'll be passing it to update if love.timer then love.timer.step() dt = love.timer.getDelta() end   -- Call update and draw if love.update then love.update(dt) end -- will pass 0 if love.timer is disabled   if love.graphics and love.graphics.isActive() then love.graphics.clear(love.graphics.getBackgroundColor()) love.graphics.origin() if love.draw then love.draw() end love.graphics.present() end   if love.timer then love.timer.sleep(0.001) end end   end ``` ### The default function for [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0"), [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1"), and [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2"), used if you don't supply your own. ``` function love.run()   if love.math then love.math.setRandomSeed(os.time()) for i=1,3 do love.math.random() end end   if love.event then love.event.pump() end   if love.load then love.load(arg) end   -- We don't want the first frame's dt to include time taken by love.load. if love.timer then love.timer.step() end   local dt = 0   -- Main loop time. while true do -- Process events. if love.event then love.event.pump() for e,a,b,c,d in love.event.poll() do if e == "quit" then if not love.quit or not love.quit() then if love.audio then love.audio.stop() end return end end love.handlers[e](a,b,c,d) end end   -- Update dt, as we'll be passing it to update if love.timer then love.timer.step() dt = love.timer.getDelta() end   -- Call update and draw if love.update then love.update(dt) end -- will pass 0 if love.timer is disabled   if love.window and love.graphics and love.window.isCreated() then love.graphics.clear() love.graphics.origin() if love.draw then love.draw() end love.graphics.present() end   if love.timer then love.timer.sleep(0.001) end end   end ``` ### The default function for [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0"), used if you don't supply your own. ``` function love.run()   math.randomseed(os.time()) math.random() math.random()   if love.load then love.load(arg) end   local dt = 0   -- Main loop time. while true do -- Process events. if love.event then love.event.pump() for e,a,b,c,d in love.event.poll() do if e == "quit" then if not love.quit or not love.quit() then if love.audio then love.audio.stop() end return end end love.handlers[e](a,b,c,d) end end   -- Update dt, as we'll be passing it to update if love.timer then love.timer.step() dt = love.timer.getDelta() end   -- Call update and draw if love.update then love.update(dt) end -- will pass 0 if love.timer is disabled if love.graphics then love.graphics.clear() if love.draw then love.draw() end end   if love.timer then love.timer.sleep(0.001) end if love.graphics then love.graphics.present() end end   end ``` ### The default function for [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0"), [0.7.1](https://love2d.org/wiki/0.7.1 "0.7.1") and [0.7.2](https://love2d.org/wiki/0.7.2 "0.7.2"), used if you don't supply your own. ``` function love.run()   if love.load then love.load(arg) end   local dt = 0   -- Main loop time. while true do if love.timer then love.timer.step() dt = love.timer.getDelta() end if love.update then love.update(dt) end -- will pass 0 if love.timer is disabled if love.graphics then love.graphics.clear() if love.draw then love.draw() end end   -- Process events. if love.event then for e,a,b,c in love.event.poll() do if e == "q" then if not love.quit or not love.quit() then if love.audio then love.audio.stop() end return end end love.handlers[e](a,b,c) end end   if love.timer then love.timer.sleep(1) end if love.graphics then love.graphics.present() end end   end ``` Notes ----- ### Why is there a delay? ``` if love.timer then love.timer.sleep(0.001) end ``` It does a few useful things: * Limits FPS to 1000 if vsync isn't enabled. * Massively reduces CPU usage in many situations (especially with vsync disabled.) * Gives control back to the OS for a bit. For more information see <https://love2d.org/forums/viewtopic.php?f=4&t=76998>. See Also -------- * [love](love "love") love ParticleSystem:start ParticleSystem:start ==================== Starts the particle emitter. Function -------- ### Synopsis ``` ParticleSystem:start( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love enet.host:compress with range coder enet.host:compress with range coder =================================== Toggles an adaptive order-2 [PPM](https://en.wikipedia.org/wiki/Prediction_by_partial_matching) [range coder](https://en.wikipedia.org/wiki/Range_encoding) for the transmitted data of all peers. Function -------- ### Synopsis ``` host:compress_with_range_coder() ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") state` True if the compression algorithm is active, false if not. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.host](enet.host "enet.host") love love.window.getDisplayCount love.window.getDisplayCount =========================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the number of connected monitors. Function -------- ### Synopsis ``` count = love.window.getDisplayCount( ) ``` ### Arguments None. ### Returns `[number](number "number") count` The number of currently connected displays. See Also -------- * [love.window](love.window "love.window") * [love.window.setMode](love.window.setmode "love.window.setMode") * [love.window.getMode](love.window.getmode "love.window.getMode") * [love.window.getFullscreenModes](love.window.getfullscreenmodes "love.window.getFullscreenModes") * [love.window.getDesktopDimensions](love.window.getdesktopdimensions "love.window.getDesktopDimensions") love Body:isDynamic Body:isDynamic ============== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been replaced by [Body:getType](body-gettype "Body:getType"). Get the dynamic status of the body. A static body has no mass and a constant position. It will not react to collisions. Often used for walls. A dynamic body has mass and can move. It will react to collisions when the world is updated. Function -------- ### Synopsis ``` status = Body:isDynamic( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") status` The dynamic status of the body. See Also -------- * [Body](body "Body") love love.graphics.arc love.graphics.arc ================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Draws a filled or unfilled arc at position `(x, y)`. The arc is drawn from `angle1` to `angle2` in [radians](https://en.wikipedia.org/wiki/Radian). The `segments` parameter determines how many segments are used to draw the arc. The more segments, the smoother the edge. Function -------- Draws an arc using the "pie" [ArcType](arctype "ArcType"). ### Synopsis ``` love.graphics.arc( drawmode, x, y, radius, angle1, angle2, segments ) ``` ### Arguments `[DrawMode](drawmode "DrawMode") drawmode` How to draw the arc. `[number](number "number") x` The position of the center along x-axis. `[number](number "number") y` The position of the center along y-axis. `[number](number "number") radius` Radius of the arc. `[number](number "number") angle1` The angle at which the arc begins. `[number](number "number") angle2` The angle at which the arc terminates. `[number](number "number") segments (10)` The number of segments used for drawing the arc. ### Returns Nothing. Function -------- **Available since LÖVE [0.10.1](https://love2d.org/wiki/0.10.1 "0.10.1")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.arc( drawmode, arctype, x, y, radius, angle1, angle2, segments ) ``` ### Arguments `[DrawMode](drawmode "DrawMode") drawmode` How to draw the arc. `[ArcType](arctype "ArcType") arctype` The type of arc to draw. `[number](number "number") x` The position of the center along x-axis. `[number](number "number") y` The position of the center along y-axis. `[number](number "number") radius` Radius of the arc. `[number](number "number") angle1` The angle at which the arc begins. `[number](number "number") angle2` The angle at which the arc terminates. `[number](number "number") segments (10)` The number of segments used for drawing the arc. ### Returns Nothing. Examples -------- ### Drawing half a circle ``` function love.draw( ) love.graphics.arc( "fill", 400, 300, 100, 0, math.pi ) end ``` ### Drawing Pacman ``` pacwidth = math.pi / 6 -- size of his mouth function love.draw( ) love.graphics.setColor( 1, 1, 0 ) -- pacman needs to be yellow love.graphics.arc( "fill", 400, 300, 100, pacwidth, (math.pi * 2) - pacwidth ) end ``` Notes ----- The arc is drawn counter clockwise if the starting angle is numerically bigger than the final angle. The arc is drawn clockwise if the final angle is numerically bigger than the starting angle. See Also -------- * [love.graphics](love.graphics "love.graphics")
programming_docs
love love.math.newRandomGenerator love.math.newRandomGenerator ============================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Creates a new [RandomGenerator](randomgenerator "RandomGenerator") object which is completely independent of other RandomGenerator objects and random functions. Function -------- ### Synopsis ``` rng = love.math.newRandomGenerator( ) ``` ### Arguments None ### Returns `[RandomGenerator](randomgenerator "RandomGenerator") rng` The new Random Number Generator object. ### Notes The default seed used in version 11.x is the following low/high pair: 0xCBBF7A44, 0x0139408D. Function -------- ### Synopsis ``` rng = love.math.newRandomGenerator( seed ) ``` ### Arguments `[number](number "number") seed` The initial seed number to use for this object. ### Returns `[RandomGenerator](randomgenerator "RandomGenerator") rng` The new Random Number Generator object. ### Notes See [RandomGenerator:setSeed](randomgenerator-setseed "RandomGenerator:setSeed"). Function -------- ### Synopsis ``` rng = love.math.newRandomGenerator( low, high ) ``` ### Arguments `[number](number "number") low` The lower 32 bits of the seed number to use for this object. `[number](number "number") high` The higher 32 bits of the seed number to use for this object. ### Returns `[RandomGenerator](randomgenerator "RandomGenerator") rng` The new Random Number Generator object. ### Notes See [RandomGenerator:setSeed](randomgenerator-setseed "RandomGenerator:setSeed"). Examples -------- Creates a new RandomGenerator object, then generates a number between 1 and 100 inclusive. ``` function love.load() rng = love.math.newRandomGenerator() randomNumber = rng:random(1,100) end ``` See Also -------- * [love.math](love.math "love.math") * [RandomGenerator](randomgenerator "RandomGenerator") love Body:isSleepingAllowed Body:isSleepingAllowed ====================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the sleeping behaviour of the body. Function -------- ### Synopsis ``` allowed = Body:isSleepingAllowed( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") allowed` True if the body is allowed to sleep or false if not. See Also -------- * [Body](body "Body") * [Body:setSleepingAllowed](body-setsleepingallowed "Body:setSleepingAllowed") love SourceType SourceType ========== Types of audio sources. A good rule of thumb is to use `stream` for music files and `static` for all short sound effects. Basically, you want to avoid loading large files into memory at once. Constants --------- static The whole audio is decoded. stream The audio is decoded in chunks when needed. queue Available since 11.0 The audio must be [manually queued](source-queue "Source:queue") by the user. See Also -------- * [love.audio](love.audio "love.audio") * [Source](source "Source") love Rasterizer:getAdvance Rasterizer:getAdvance ===================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Gets font advance. Function -------- ### Synopsis ``` advance = Rasterizer:getAdvance() ``` ### Arguments None. ### Returns `[number](number "number") advance` Font advance. See Also -------- * [Rasterizer](rasterizer "Rasterizer") love Source:setVolume Source:setVolume ================ Sets the current volume of the Source. Function -------- ### Synopsis ``` Source:setVolume( volume ) ``` ### Arguments `[number](number "number") volume` The volume for a Source, where 1.0 is normal volume. Volume cannot be raised above 1.0. ### Returns Nothing. Examples -------- Make a sound quieter or completely silent. ``` function love.load() sound = love.audio.newSource("sound.wav")   -- Note that this code, as-is, will set the volume to 1.0, as per the last line, and that's how sound:play() will play it back. sound:setVolume(0.5) -- 50% volume sound:setVolume(0) -- No sound sound:setVolume(1) -- Reset to maximum volume. end ``` Set different volumes depending on the sound type. ``` function love.load() effect = love.audio.newSource("soundeffect.wav") music = love.audio.newSource("music.mp3")   masterVolume = 0.5 -- Maximum volume for all sounds effectVolume = 0.75 musicVolume = 1   effect:setVolume(masterVolume * effectVolume) music:setVolume(masterVolume * musicVolume) end ``` See Also -------- * [Source](source "Source") love ImageData:encode ImageData:encode ================ Encodes the ImageData to a file format and optionally writes it to the [save directory](love.filesystem "love.filesystem"). Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. ### Synopsis ``` filedata = ImageData:encode( format, filename ) ``` ### Arguments `[ImageEncodeFormat](imageencodeformat "ImageEncodeFormat") format` The format to encode the image as. `[string](string "string") filename (nil)` The filename to write the file to. If nil, no file will be written but the FileData will still be returned. ### Returns `[FileData](filedata "FileData") filedata` The encoded image as a new FileData object. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier or later versions. ### Synopsis ``` ImageData:encode( outFile ) ``` ### Arguments `[string](string "string") outFile` Name of a file to write encoded data to. The format will be automatically deduced from the file extension. ### Returns Nothing. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier or later versions. ### Synopsis ``` ImageData:encode( outFile, format ) ``` ### Arguments `[string](string "string") outFile` Name of a file to write encoded data to. `[ImageEncodeFormat](imageencodeformat "ImageEncodeFormat") format` The format to encode the image in. ### Returns Nothing. Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. ### Synopsis ``` data = ImageData:encode( format ) ``` ### Arguments `[ImageEncodeFormat](imageencodeformat "ImageEncodeFormat") format` The format to encode the image in. ### Returns `[Data](data "Data") data` The encoded image data. See Also -------- * [ImageData](imagedata "ImageData") User Notes ---------- * If you want the file to have an extension when saved add it in the file name. Example : ``` image:encode("png","aPngImage.png") ``` love Video:getStream Video:getStream =============== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets the [VideoStream](videostream "VideoStream") object used for decoding and controlling the video. Function -------- ### Synopsis ``` stream = Video:getStream( ) ``` ### Arguments None. ### Returns `[VideoStream](videostream "VideoStream") stream` The VideoStream used for decoding and controlling the video. See Also -------- * [Video](video "Video") * [VideoStream](videostream "VideoStream") love Shape:getMask Shape:getMask ============= **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** Use [Fixture:getMask](fixture-getmask "Fixture:getMask") instead. Gets which categories this shape should **NOT** collide with. The number of masked categories is the number of return values. Function -------- ### Synopsis ``` ... = Shape:getMask( ) ``` ### Arguments None. ### Returns `[number](number "number") ...` Numbers from 1-16 Examples -------- ### With how many categories does this shape collide? ``` print('shape collides with', select('#', shape:getMask()), 'categories') ``` See Also -------- * [Shape](shape "Shape") * [Shape:setMask](shape-setmask "Shape:setMask") love (File):isEOF (File):isEOF ============ **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** It has been renamed from [File:eof]((file)-eof "(File):eof"). Gets whether end-of-file has been reached. Function -------- ### Synopsis ``` eof = File:isEOF( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") eof` Whether EOF has been reached. See Also -------- * [File](file "File") love Contact:setFriction Contact:setFriction =================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Sets the contact friction. Function -------- ### Synopsis ``` Contact:setFriction( friction ) ``` ### Arguments `[number](number "number") friction` The contact friction. ### Returns Nothing. See Also -------- * [Contact](contact "Contact") love love.filesystem.newFileData love.filesystem.newFileData =========================== Creates a new [FileData](filedata "FileData") object from a file on disk, or from a string in memory. Function -------- Creates a new FileData object from a string in memory. ### Synopsis ``` data = love.filesystem.newFileData( contents, name ) ``` ### Arguments `[string](string "string") contents` The contents of the file in memory represented as a string. `[string](string "string") name` The name of the file. The extension may be parsed and used by LÖVE when passing the FileData object into [love.audio.newSource](love.audio.newsource "love.audio.newSource"). ### Returns `[FileData](filedata "FileData") data` The new FileData. Function -------- **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in earlier versions. Creates a new [FileData](filedata "FileData") from a file on the storage device. ### Synopsis ``` data, err = love.filesystem.newFileData( filepath ) ``` ### Arguments `[string](string "string") filepath` Path to the file. ### Returns `[FileData](filedata "FileData") data` The new FileData, or [nil](nil "nil") if an error occurred. `[string](string "string") err` The error string, if an error occurred. Function -------- **Removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** The variant which decodes base64 data has been replaced by [love.data.decode](love.data.decode "love.data.decode"). ### Synopsis ``` data = love.filesystem.newFileData( contents, name, decoder ) ``` ### Arguments `[string](string "string") contents` The contents of the file. `[string](string "string") name` The name of the file. `[FileDecoder](filedecoder "FileDecoder") decoder` The method to use when decoding the contents. ### Returns `[FileData](filedata "FileData") data` Your new FileData. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [FileData](filedata "FileData") love love.filesystem.write love.filesystem.write ===================== Write data to a file in the save directory. If the file existed already, it will be completely replaced by the new contents. Function -------- ### Synopsis ``` success, message = love.filesystem.write( name, data, size ) ``` ### Arguments `[string](string "string") name` The name (and path) of the file. `[string](string "string") data` The string data to write to the file. `[number](number "number") size (all)` How many bytes to write. ### Returns `[boolean](boolean "boolean") success` If the operation was successful. `[string](string "string") message` Error message if operation was unsuccessful. Function -------- ### Synopsis ``` success, message = love.filesystem.write( name, data, size ) ``` ### Arguments `[string](string "string") name` The name (and path) of the file. `[Data](data "Data") data` The Data object to write to the file. `[number](number "number") size (all)` How many bytes to write. ### Returns `[boolean](boolean "boolean") success` If the operation was successful. `[string](string "string") message` Error message if operation was unsuccessful. Notes ----- If you are getting the error message "Could not set write directory", try setting the save directory. This is done either with [love.filesystem.setIdentity](love.filesystem.setidentity "love.filesystem.setIdentity") or by setting the identity field in [love.conf](love.conf "love.conf"). **Writing to multiple lines**: In Windows, some text editors (e.g. Notepad) only treat CRLF ("\r\n") as a new line. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [love.filesystem.append](love.filesystem.append "love.filesystem.append") love Thread:peek Thread:peek =========== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been moved to the [Channel](channel "Channel") api. Retrieves the value of a message, but leaves it in the thread's message box. The name of the message can be any string. The value of the message can be a boolean, string, number or a LÖVE userdata. It returns nil, if there's no message with the given name. Function -------- ### Synopsis ``` value = Thread:peek( name ) ``` ### Arguments `[string](string "string") name` The name of the message. ### Returns `[boolean, number, string or LÖVE userdata](https://love2d.org/w/index.php?title=boolean,_number,_string_or_L%C3%96VE_userdata&action=edit&redlink=1 "boolean, number, string or LÖVE userdata (page does not exist)") value` The contents of the message. See Also -------- * [Thread](thread "Thread") love Source:isStopped Source:isStopped ================ **Removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** It has been replaced by [Source:isPlaying](source-isplaying "Source:isPlaying"). Returns whether the Source is stopped. Function -------- ### Synopsis ``` stopped = Source:isStopped( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") stopped` True if the Source is stopped, false otherwise. See Also -------- * [Source](source "Source") love love.graphics.draw love.graphics.draw ================== Draws a [Drawable](drawable "Drawable") object (an [Image](image "Image"), [Canvas](canvas "Canvas"), [SpriteBatch](spritebatch "SpriteBatch"), [ParticleSystem](particlesystem "ParticleSystem"), [Mesh](mesh "Mesh"), [Text](text "Text") object, or [Video](video "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](image "Image") and [Canvas](canvas "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. Function -------- ### Synopsis ``` love.graphics.draw( drawable, x, y, r, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[Drawable](drawable "Drawable") drawable` A drawable object. `[number](number "number") x (0)` The position to draw the object (x-axis). `[number](number "number") y (0)` The position to draw the object (y-axis). `[number](number "number") r (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Available since 0.8.0 Shearing factor (x-axis). `[number](number "number") ky (0)` Available since 0.8.0 Shearing factor (y-axis). ### Returns Nothing. Function -------- **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has replaced [love.graphics.drawq](love.graphics.drawq "love.graphics.drawq"). ### Synopsis ``` love.graphics.draw( texture, quad, x, y, r, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[Texture](texture "Texture") texture` A [Texture](texture "Texture") ([Image](image "Image") or [Canvas](canvas "Canvas")) to texture the [Quad](quad "Quad") with. `[Quad](quad "Quad") quad` The Quad to draw on screen. `[number](number "number") x` The position to draw the object (x-axis). `[number](number "number") y` The position to draw the object (y-axis). `[number](number "number") r (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Shearing factor (x-axis). `[number](number "number") ky (0)` Shearing factor (y-axis). ### Returns Nothing. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.draw( drawable, transform ) ``` ### Arguments `[Drawable](drawable "Drawable") drawable` A drawable object. `[Transform](transform "Transform") transform` Transformation object. ### Returns Nothing. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` love.graphics.draw( texture, quad, transform ) ``` ### Arguments `[Texture](texture "Texture") texture` A [Texture](texture "Texture") ([Image](image "Image") or [Canvas](canvas "Canvas")) to texture the [Quad](quad "Quad") with. `[Quad](quad "Quad") quad` The Quad to draw on screen. `[Transform](transform "Transform") transform` Transformation object. ### Returns Nothing. Examples -------- ### Draw an image (the [Hamster Ball](https://love2d.org/wiki/File:Resource-HamsterBall.png "File:Resource-HamsterBall.png")) at 100 by 100 pixels ``` function love.load() hamster = love.graphics.newImage("hamster.png") end function love.draw() love.graphics.draw(hamster, 100, 100) end ``` ### Draw an image (the [Hamster Ball](https://love2d.org/wiki/File:Resource-HamsterBall.png "File:Resource-HamsterBall.png")) from the center at 100 by 100 pixels, rotated by 90 degrees ``` function love.load() hamster = love.graphics.newImage("hamster.png") width = hamster:getWidth() height = hamster:getHeight() end function love.draw() love.graphics.draw(hamster, 100, 100, math.rad(90), 1, 1, width / 2, height / 2) end ``` **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This functionality is not supported in earlier versions. ### Draw the top half of an image (the [Hamster Ball](https://love2d.org/wiki/File:Resource-HamsterBall.png "File:Resource-HamsterBall.png")) at 100 by 100 pixels. ``` function love.load() image = love.graphics.newImage("hamster.png") quad = love.graphics.newQuad(0, 0, 128, 64, image:getWidth(), image:getHeight()) end   function love.draw() love.graphics.draw(image, quad, 100, 100) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics")
programming_docs
love VideoStream:pause VideoStream:pause ================= **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Pauses video stream. Function -------- ### Synopsis ``` VideoStream:pause( ) ``` ### Arguments None. ### Returns None. See Also -------- * [VideoStream](videostream "VideoStream") * [VideoStream:play](videostream-play "VideoStream:play") * [VideoStream:isPlaying](videostream-isplaying "VideoStream:isPlaying") love ChainShape:getNextVertex ChainShape:getNextVertex ======================== **Available since LÖVE [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2")** This function is not supported in earlier versions. Gets the vertex that establishes a connection to the next shape. Setting next and previous ChainShape vertices can help prevent unwanted collisions when a flat shape slides along the edge and moves over to the new shape. Function -------- ### Synopsis ``` x, y = ChainShape:getNextVertex( ) ``` ### Arguments None. ### Returns `[number](number "number") x (nil)` The x-component of the vertex, or nil if [ChainShape:setNextVertex](chainshape-setnextvertex "ChainShape:setNextVertex") hasn't been called. `[number](number "number") y (nil)` The y-component of the vertex, or nil if [ChainShape:setNextVertex](chainshape-setnextvertex "ChainShape:setNextVertex") hasn't been called. See Also -------- * [ChainShape](chainshape "ChainShape") * [ChainShape:setNextVertex](chainshape-setnextvertex "ChainShape:setNextVertex") * [ChainShape:getPreviousVertex](chainshape-getpreviousvertex "ChainShape:getPreviousVertex") love SpriteBatch:addq SpriteBatch:addq ================ **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been merged into [SpriteBatch:add](spritebatch-add "SpriteBatch:add"). Adds a Quad to the batch. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in earlier versions. ### Synopsis ``` id = SpriteBatch:addq( quad, x, y, r, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[Quad](quad "Quad") quad` The Quad to add. `[number](number "number") x` The position to draw the object (x-axis). `[number](number "number") y` The position to draw the object (y-axis). `[number](number "number") r (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Shear factor (x-axis). `[number](number "number") ky (0)` Shear factor (y-axis). ### Returns `[number](number "number") id` An identifier for the added sprite. Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. ### Synopsis ``` SpriteBatch:addq( quad, x, y, r, sx, sy, ox, oy ) ``` ### Arguments `[Quad](quad "Quad") quad` The Quad to add. `[number](number "number") x` The position to draw the object (x-axis). `[number](number "number") y` The position to draw the object (y-axis). `[number](number "number") r (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). ### Returns Nothing. See Also -------- * [SpriteBatch](spritebatch "SpriteBatch") * [SpriteBatch:add](spritebatch-add "SpriteBatch:add") * [SpriteBatch:set](spritebatch-set "SpriteBatch:set") * [SpriteBatch:setq](spritebatch-setq "SpriteBatch:setq") love love.filesystem.exists love.filesystem.exists ====================== | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | This function is deprecated and is replaced by [love.filesystem.getInfo](love.filesystem.getinfo "love.filesystem.getInfo"). | Check whether a file or directory exists. Function -------- ### Synopsis ``` exists = love.filesystem.exists( filename ) ``` ### Arguments `[string](string "string") filename` The path to a potential file or directory. ### Returns `[boolean](boolean "boolean") exists` True if there is a file or directory with the specified name. False otherwise. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") love Body:getLinearVelocity Body:getLinearVelocity ====================== Gets the linear velocity of the Body from its center of mass. The linear velocity is the *rate of change of position over time*. If you need the *rate of change of angle over time*, use [Body:getAngularVelocity](body-getangularvelocity "Body:getAngularVelocity"). If you need to get the linear velocity of a point different from the center of mass: * [Body:getLinearVelocityFromLocalPoint](body-getlinearvelocityfromlocalpoint "Body:getLinearVelocityFromLocalPoint") allows you to specify the point in local coordinates. * [Body:getLinearVelocityFromWorldPoint](body-getlinearvelocityfromworldpoint "Body:getLinearVelocityFromWorldPoint") allows you to specify the point in world coordinates. See [page 136 of "Essential Mathematics for Games and Interactive Applications"](http://books.google.com/books?id=g0-G2Dbk5vEC&lpg=PA250&ots=H6T6pJsOqu&dq=%22Essential%20Mathematics%20for%20Games%20and%20Interactive%20Applications%20local%20space&pg=PA136#v=onepage&q&f=false) for definitions of local and world coordinates. Function -------- ### Synopsis ``` x, y = Body:getLinearVelocity( ) ``` ### Arguments None. ### Returns `[number](number "number") x` The x-component of the velocity vector `[number](number "number") y` The y-component of the velocity vector See Also -------- * [Body](body "Body") love Video:setSource Video:setSource =============== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Sets the audio [Source](source "Source") used for playing back the video's audio. The audio Source also controls playback speed and synchronization. Function -------- ### Synopsis ``` Video:setSource( source ) ``` ### Arguments `[Source](source "Source") source (nil)` The audio Source used for audio playback, or nil to disable audio synchronization. ### Returns Nothing. See Also -------- * [Video](video "Video") * [Video:getSource](video-getsource "Video:getSource") * [Source](source "Source") love Shape:setFriction Shape:setFriction ================= **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** Has been replaced by [Fixture:setFriction](fixture-setfriction "Fixture:setFriction"). Sets the friction of the shape. Friction determines how shapes react when they "slide" along other shapes. Low friction indicates a slippery surface, like ice, while high friction indicates a rough surface, like concrete. Range: 0.0 - 1.0. Function -------- ### Synopsis ``` Shape:setFriction( friction ) ``` ### Arguments `[number](number "number") friction` The friction of the shape. ### Returns Nothing. See Also -------- * [Shape](shape "Shape") love Channel:demand Channel:demand ============== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Retrieves the value of a Channel message and removes it from the message queue. It waits until a message is in the queue then returns the message value. Function -------- ### Synopsis ``` value = Channel:demand( ) ``` ### Arguments None. ### Returns `[Variant](variant "Variant") value` The contents of the message. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` value = Channel:demand( timeout ) ``` ### Arguments `[number](number "number") timeout` The maximum amount of time to wait. ### Returns `[Variant](variant "Variant") value` The contents of the message or nil if the timeout expired. See Also -------- * [Channel](channel "Channel") * [Channel:supply](channel-supply "Channel:supply") * [Channel:pop](channel-pop "Channel:pop") love enet.host:channel limit enet.host:channel limit ======================= Sets the maximum number of channels allowed. If it is 0 then the system maximum allowable value is used. Function -------- ### Synopsis ``` host:channel_limit(limit) ``` ### Arguments `[number](number "number") limit` The maximum number of channels allowed. ### Returns Nothing. See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.host](enet.host "enet.host") love PulleyJoint:setConstant PulleyJoint:setConstant ======================= Set the total length of the rope. Setting a new length for the rope updates the maximum length values of the joint. Function -------- ### Synopsis ``` PulleyJoint:setConstant( length ) ``` ### Arguments `[number](number "number") length` The new length of the rope in the joint. ### Returns Nothing. See Also -------- * [PulleyJoint](pulleyjoint "PulleyJoint") * [PulleyJoint:getMaxLengths](pulleyjoint-getmaxlengths "PulleyJoint:getMaxLengths") love love.graphics.setPixelEffect love.graphics.setPixelEffect ============================ **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [love.graphics.setShader](love.graphics.setshader "love.graphics.setShader"). Sets or resets a [PixelEffect](pixeleffect "PixelEffect") as the current pixel effect. All drawing operations until the next *love.graphics.setPixelEffect* will be drawn using the [PixelEffect](pixeleffect "PixelEffect") object specified. Function -------- ### Synopsis ``` love.graphics.setPixelEffect( pixeleffect ) ``` ### Arguments `[PixelEffect](pixeleffect "PixelEffect") pixeleffect` The new pixel effect. ### Returns Nothing. ### Notes Sets the current pixel shader to a specified [PixelEffect](pixeleffect "PixelEffect"). All drawing operations until the next *love.graphics.setPixelEffect* will be drawn using the [PixelEffect](pixeleffect "PixelEffect") object specified. Function -------- ### Synopsis ``` love.graphics.setPixelEffect( ) ``` ### Arguments None. ### Returns Nothing. ### Notes Disables pixel effects, allowing unfiltered drawing operations. Examples -------- ### Drawing a rectangle using a pixel effect ``` function love.load() effect = love.graphics.newPixelEffect [[ extern number time; vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) { return vec4((1.0+sin(time))/2.0, abs(cos(time)), abs(sin(time)), 1.0); } ]] end   function love.draw() -- boring white love.graphics.setPixelEffect() love.graphics.rectangle('fill', 10,10,790,285)   -- LOOK AT THE PRETTY COLORS! love.graphics.setPixelEffect(effect) love.graphics.rectangle('fill', 10,305,790,285) end   local t = 0 function love.update(dt) t = t + dt effect:send("time", t) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [PixelEffect](pixeleffect "PixelEffect") love JoystickInputType JoystickInputType ================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This enum is not supported in earlier versions. Types of Joystick inputs. Constants --------- axis Analog axis. button Button. hat 8-direction [hat](joystickhat "JoystickHat") value. See Also -------- * [Joystick](joystick "Joystick") * [love.joystick](love.joystick "love.joystick") * [love.joystick.setGamepadMapping](love.joystick.setgamepadmapping "love.joystick.setGamepadMapping") * [Joystick:getGamepadMapping](joystick-getgamepadmapping "Joystick:getGamepadMapping") love love.data.newByteData love.data.newByteData ===================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Creates a new Data object containing arbitrary bytes. [Data:getPointer](data-getpointer "Data:getPointer") along with LuaJIT's FFI can be used to manipulate the contents of the ByteData object after it has been created. This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- Creates a new ByteData by copying the contents of the specified string. ### Synopsis ``` bytedata = love.data.newByteData( datastring ) ``` ### Arguments `[string](string "string") datastring` The byte string to copy. ### Returns `[ByteData](bytedata "ByteData") bytedata` The new Data object. Function -------- Creates a new ByteData by copying from an existing Data object. ### Synopsis ``` bytedata = love.data.newByteData( data, offset, size ) ``` ### Arguments `[Data](data "Data") data` The existing Data object to copy. `[number](number "number") offset (0)` The offset of the subsection to copy, in bytes. `[number](number "number") size (data:getSize())` The size in bytes of the new Data object. ### Returns `[ByteData](bytedata "ByteData") bytedata` The new Data object. Function -------- Creates a new empty (zero-initialized) ByteData with the specific size. ### Synopsis ``` bytedata = love.data.newByteData( size ) ``` ### Arguments `[number](number "number") size` The size in bytes of the new Data object. ### Returns `[ByteData](bytedata "ByteData") bytedata` The new Data object. See Also -------- * [love.data](love.data "love.data") * [ByteData](bytedata "ByteData") love ParticleSystem:setLinearAcceleration ParticleSystem:setLinearAcceleration ==================================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has replaced [ParticleSystem:setGravity](particlesystem-setgravity "ParticleSystem:setGravity"). Sets the linear acceleration (acceleration along the x and y axes) for particles. Every particle created will accelerate along the x and y axes between xmin,ymin and xmax,ymax. Function -------- ### Synopsis ``` ParticleSystem:setLinearAcceleration( xmin, ymin, xmax, ymax ) ``` ### Arguments `[number](number "number") xmin` The minimum acceleration along the x axis. `[number](number "number") ymin` The minimum acceleration along the y axis. `[number](number "number") xmax (xmin)` The maximum acceleration along the x axis. `[number](number "number") ymax (ymin)` The maximum acceleration along the y axis. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love FrictionJoint:setMaxTorque FrictionJoint:setMaxTorque ========================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Sets the maximum friction torque in Newton-meters. Function -------- ### Synopsis ``` FrictionJoint:setMaxTorque( torque ) ``` ### Arguments `[number](number "number") torque` Maximum torque in Newton-meters. ### Returns Nothing. See Also -------- * [FrictionJoint](frictionjoint "FrictionJoint") * [FrictionJoint:getMaxTorque](frictionjoint-getmaxtorque "FrictionJoint:getMaxTorque") love love.video love.video ========== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This module is not supported in earlier versions. This module is responsible for decoding, controlling, and streaming video files. It can't draw the videos, see [love.graphics.newVideo](love.graphics.newvideo "love.graphics.newVideo") and [Video](video "Video") objects for that. Types ----- | | | | | | --- | --- | --- | --- | | [VideoStream](videostream "VideoStream") | An object which decodes, streams, and controls [Videos](video "Video"). | 0.10.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [love.video.newVideoStream](love.video.newvideostream "love.video.newVideoStream") | Creates a new [VideoStream](videostream "VideoStream"). | 0.10.0 | | See Also -------- * [love](love "love") * [love.graphics.newVideo](love.graphics.newvideo "love.graphics.newVideo") * [Video](video "Video") love Canvas Canvas ====== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been renamed from [Framebuffer](framebuffer "Framebuffer"). A Canvas is used for off-screen rendering. Think of it as an invisible screen that you can draw to, but that will not be visible until you draw it to the actual visible screen. It is also known as "render to texture". By drawing things that do not change position often (such as background items) to the Canvas, and then drawing the entire Canvas instead of each item, you can reduce the number of draw operations performed each frame. In versions prior to [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0"), not all graphics cards that LÖVE supported could use Canvases. [love.graphics.isSupported("canvas")](love.graphics.issupported "love.graphics.isSupported") could be used to check for support at runtime. When drawing content to a Canvas using regular alpha blending, the alpha values of the content get multiplied with its RGB values. Therefore the Canvas' pixel colors will have *premultiplied alpha* once it has been drawn to, so when drawing the Canvas to the screen or to another Canvas you must use premultiplied alpha blending – [love.graphics.setBlendMode](love.graphics.setblendmode "love.graphics.setBlendMode")("alpha", "premultiplied"). Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") | Creates a new **Canvas**. | 0.8.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Canvas:clear](canvas-clear "Canvas:clear") | Clears the contents of a Canvas to a specific color. | 0.8.0 | 0.10.0 | | [Canvas:generateMipmaps](canvas-generatemipmaps "Canvas:generateMipmaps") | Generates mipmaps for the Canvas, based on the contents of the highest-resolution mipmap level. | 11.0 | | | [Canvas:getFSAA](canvas-getfsaa "Canvas:getFSAA") | Gets the number of FSAA samples used when drawing to the Canvas. | 0.9.1 | 0.10.0 | | [Canvas:getFormat](canvas-getformat "Canvas:getFormat") | Gets the texture format of the Canvas. | 0.9.1 | 11.0 | | [Canvas:getImageData](canvas-getimagedata "Canvas:getImageData") | Generates [ImageData](imagedata "ImageData") from the contents of the Canvas. | 0.8.0 | 0.10.0 | | [Canvas:getMSAA](canvas-getmsaa "Canvas:getMSAA") | Gets the number of MSAA samples used when drawing to the Canvas. | 0.9.2 | | | [Canvas:getMipmapMode](canvas-getmipmapmode "Canvas:getMipmapMode") | Gets the [MipmapMode](mipmapmode "MipmapMode") this Canvas was created with. | 11.0 | | | [Canvas:getPixel](canvas-getpixel "Canvas:getPixel") | Gets the pixel at the specified position in a Canvas. | 0.9.0 | 0.10.0 | | [Canvas:newImageData](canvas-newimagedata "Canvas:newImageData") | Generates [ImageData](imagedata "ImageData") from the contents of the Canvas. | 0.10.0 | | | [Canvas:renderTo](canvas-renderto "Canvas:renderTo") | Render to a Canvas using a function. | 0.8.0 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | | [Texture:getDPIScale](texture-getdpiscale "Texture:getDPIScale") | Gets the DPI scale factor of the Texture. | 11.0 | | | [Texture:getDepth](texture-getdepth "Texture:getDepth") | Gets the depth of a [Volume Texture](texturetype "TextureType"). | 11.0 | | | [Texture:getDepthSampleMode](texture-getdepthsamplemode "Texture:getDepthSampleMode") | Gets the comparison mode used when sampling from a [depth texture](pixelformat "PixelFormat") in a shader. | 11.0 | | | [Texture:getDimensions](texture-getdimensions "Texture:getDimensions") | Gets the width and height of the Texture. | 0.9.0 | | | [Texture:getFilter](texture-getfilter "Texture:getFilter") | Gets the [filter mode](filtermode "FilterMode") of the Texture. | | | | [Texture:getFormat](texture-getformat "Texture:getFormat") | Gets the [pixel format](pixelformat "PixelFormat") of the Texture. | 11.0 | | | [Texture:getHeight](texture-getheight "Texture:getHeight") | Gets the height of the Texture. | | | | [Texture:getLayerCount](texture-getlayercount "Texture:getLayerCount") | Gets the number of layers / slices in an [Array Texture](texturetype "TextureType"). | 11.0 | | | [Texture:getMipmapCount](texture-getmipmapcount "Texture:getMipmapCount") | Gets the number of mipmaps contained in the Texture. | 11.0 | | | [Texture:getMipmapFilter](texture-getmipmapfilter "Texture:getMipmapFilter") | Gets the mipmap filter mode for a Texture. | 0.9.0 | | | [Texture:getPixelDimensions](texture-getpixeldimensions "Texture:getPixelDimensions") | Gets the width and height in pixels of the Texture. | 11.0 | | | [Texture:getPixelHeight](texture-getpixelheight "Texture:getPixelHeight") | Gets the height in pixels of the Texture. | 11.0 | | | [Texture:getPixelWidth](texture-getpixelwidth "Texture:getPixelWidth") | Gets the width in pixels of the Texture. | 11.0 | | | [Texture:getTextureType](texture-gettexturetype "Texture:getTextureType") | Gets the [type](texturetype "TextureType") of the Texture. | 11.0 | | | [Texture:getWidth](texture-getwidth "Texture:getWidth") | Gets the width of the Texture. | | | | [Texture:getWrap](texture-getwrap "Texture:getWrap") | Gets the wrapping properties of a Texture. | | | | [Texture:isReadable](texture-isreadable "Texture:isReadable") | Gets whether the Texture can be drawn sent to a Shader. | 11.0 | | | [Texture:setDepthSampleMode](texture-setdepthsamplemode "Texture:setDepthSampleMode") | Sets the comparison mode used when sampling from a [depth texture](pixelformat "PixelFormat") in a shader. | 11.0 | | | [Texture:setFilter](texture-setfilter "Texture:setFilter") | Sets the [filter mode](filtermode "FilterMode") of the Texture. | | | | [Texture:setMipmapFilter](texture-setmipmapfilter "Texture:setMipmapFilter") | Sets the mipmap filter mode for a Texture. | 0.9.0 | | | [Texture:setWrap](texture-setwrap "Texture:setWrap") | Sets the wrapping properties of a Texture. | | | Enums ----- | | | | | | --- | --- | --- | --- | | [MipmapMode](mipmapmode "MipmapMode") | Controls whether a **Canvas** has mipmaps, and its behaviour when it does. | 11.0 | | Supertypes ---------- * [Texture](texture "Texture") * [Drawable](drawable "Drawable") * [Object](object "Object") Examples -------- ### Drawing something to the Canvas and then draw the Canvas to the screen. ``` function love.load() canvas = love.graphics.newCanvas(800, 600)   -- Rectangle is drawn to the canvas with the regular alpha blend mode. love.graphics.setCanvas(canvas) love.graphics.clear() love.graphics.setBlendMode("alpha") love.graphics.setColor(1, 0, 0, 0.5) love.graphics.rectangle('fill', 0, 0, 100, 100) love.graphics.setCanvas() end   function love.draw() -- very important!: reset color before drawing to canvas to have colors properly displayed -- see discussion here: https://love2d.org/forums/viewtopic.php?f=4&p=211418#p211418 love.graphics.setColor(1, 1, 1, 1)   -- The rectangle from the Canvas was already alpha blended. -- Use the premultiplied alpha blend mode when drawing the Canvas itself to prevent improper blending. love.graphics.setBlendMode("alpha", "premultiplied") love.graphics.draw(canvas) -- Observe the difference if the Canvas is drawn with the regular alpha blend mode instead. love.graphics.setBlendMode("alpha") love.graphics.draw(canvas, 100, 0)   -- Rectangle is drawn directly to the screen with the regular alpha blend mode. love.graphics.setBlendMode("alpha") love.graphics.setColor(1, 0, 0, 0.5) love.graphics.rectangle('fill', 200, 0, 100, 100) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setCanvas](love.graphics.setcanvas "love.graphics.setCanvas") * [love.graphics.setBlendMode](love.graphics.setblendmode "love.graphics.setBlendMode") * [love.graphics.isSupported](love.graphics.issupported "love.graphics.isSupported")
programming_docs
love ChainShape:setNextVertex ChainShape:setNextVertex ======================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Sets a vertex that establishes a connection to the next shape. This can help prevent unwanted collisions when a flat shape slides along the edge and moves over to the new shape. Function -------- ### Synopsis ``` ChainShape:setNextVertex( x, y ) ``` ### Arguments `[number](number "number") x` The x-component of the vertex. `[number](number "number") y` The y-component of the vertex. ### Returns Nothing. See Also -------- * [ChainShape](chainshape "ChainShape") * [ChainShape:setPreviousVertex](chainshape-setpreviousvertex "ChainShape:setPreviousVertex") love Source:getAttenuationDistances Source:getAttenuationDistances ============================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [Source:getDistance](source-getdistance "Source:getDistance"). Gets the reference and maximum attenuation distances of the Source. The values, combined with the current [DistanceModel](distancemodel "DistanceModel"), affect how the Source's volume attenuates based on distance from the listener. Function -------- ### Synopsis ``` ref, max = Source:getAttenuationDistances( ) ``` ### Arguments None. ### Returns `[number](number "number") ref` The current reference attenuation distance. If the current [DistanceModel](distancemodel "DistanceModel") is clamped, this is the minimum distance before the Source is no longer attenuated. `[number](number "number") max` The current maximum attenuation distance. See Also -------- * [Source](source "Source") * [Source:setAttenuationDistances](source-setattenuationdistances "Source:setAttenuationDistances") * [love.audio.setDistanceModel](love.audio.setdistancemodel "love.audio.setDistanceModel") love love.system.setClipboardText love.system.setClipboardText ============================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Puts text in the clipboard. Function -------- ### Synopsis ``` love.system.setClipboardText( text ) ``` ### Arguments `[string](string "string") text` The new text to hold in the system's clipboard. ### Returns Nothing. Examples -------- Set up OS agnostic keybindings for a copy paste buffer. ``` local buffer   function love.draw()   love.graphics.print( "OS: "..love.system.getOS().."\n".. "Local buffer: "..tostring(buffer).."\n".. "System buffer: "..tostring(love.system.getClipboardText()))   end   function love.keypressed(key)   local osString = love.system.getOS()   local control   if osString == "OS X" then control = love.keyboard.isDown("lgui","rgui") elseif osString == "Windows" or osString == "Linux" then control = love.keyboard.isDown("lctrl","rctrl") end   if control then if key == "c" then if buffer then love.system.setClipboardText(buffer) end end if key == "v" then buffer = love.system.getClipboardText() end end   end ``` See Also -------- * [love.system](love.system "love.system") * [love.system.getClipboardText](love.system.getclipboardtext "love.system.getClipboardText") love love.physics.newRevoluteJoint love.physics.newRevoluteJoint ============================= Creates a pivot joint between two bodies. This joint connects two bodies to a point around which they can pivot. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in earlier versions. ### Synopsis ``` joint = love.physics.newRevoluteJoint( body1, body2, x, y, collideConnected ) ``` ### Arguments `[Body](body "Body") body1` The first body. `[Body](body "Body") body2` The second body. `[number](number "number") x` The x position of the connecting point. `[number](number "number") y` The y position of the connecting point. `[boolean](boolean "boolean") collideConnected (false)` Specifies whether the two bodies should collide with each other. ### Returns `[RevoluteJoint](revolutejoint "RevoluteJoint") joint` The new revolute joint. Function -------- **Available since LÖVE [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2")** This variant is not supported in earlier versions. ### Synopsis ``` joint = love.physics.newRevoluteJoint( body1, body2, x1, y1, x2, y2, collideConnected, referenceAngle ) ``` ### Arguments `[Body](body "Body") body1` The first body. `[Body](body "Body") body2` The second body. `[number](number "number") x1` The x position of the first connecting point. `[number](number "number") y1` The y position of the first connecting point. `[number](number "number") x2` The x position of the second connecting point. `[number](number "number") y2` The y position of the second connecting point. `[boolean](boolean "boolean") collideConnected (false)` Specifies whether the two bodies should collide with each other. `[number](number "number") referenceAngle (0)` The reference angle between body1 and body2, in radians. ### Returns `[RevoluteJoint](revolutejoint "RevoluteJoint") joint` The new revolute joint. Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. ### Synopsis ``` joint = love.physics.newRevoluteJoint( body1, body2, x, y ) ``` ### Arguments `[Body](body "Body") body1` The first body to connect with a Revolute Joint. `[Body](body "Body") body2` The second body to connect with a Revolute Joint. `[number](number "number") x` The x position of the connecting point. `[number](number "number") y` The y position of the connecting point. ### Returns `[RevoluteJoint](revolutejoint "RevoluteJoint") joint` The new revolute joint. See Also -------- * [love.physics](love.physics "love.physics") * [RevoluteJoint](revolutejoint "RevoluteJoint") * [Joint](joint "Joint") love love.window.getPixelScale love.window.getPixelScale ========================= **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. **Removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function has been renamed to [love.window.getDPIScale](love.window.getdpiscale "love.window.getDPIScale"). Gets the DPI scale factor associated with the window. 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](love.window.setmode "love.window.setMode") enabled, the window may take up the same physical size as an 800x600 window, but the area inside the window uses 1600x1200 pixels. `love.window.getPixelScale()` would return `2.0` in that case. The [love.window.fromPixels](love.window.frompixels "love.window.fromPixels") and [love.window.toPixels](love.window.topixels "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. Function -------- ### Synopsis ``` scale = love.window.getPixelScale( ) ``` ### Arguments None. ### Returns `[number](number "number") scale` The pixel scale factor associated with the window. Notes ----- The units of [love.graphics.getWidth](love.graphics.getwidth "love.graphics.getWidth"), [love.graphics.getHeight](love.graphics.getheight "love.graphics.getHeight"), [love.mouse.getPosition](love.mouse.getposition "love.mouse.getPosition"), mouse events, [love.touch.getPosition](love.touch.getposition "love.touch.getPosition"), and touch events are always in terms of pixels. See Also -------- * [love.window](love.window "love.window") * [love.window.toPixels](love.window.topixels "love.window.toPixels") * [love.window.fromPixels](love.window.frompixels "love.window.fromPixels") * [love.window.setMode](love.window.setmode "love.window.setMode") * [Config Files](love.conf "Config Files") love enet.peer:timeout enet.peer:timeout ================= Returns or sets the parameters when a timeout is detected. This is happens either after a fixed timeout or a variable timeout of time that takes the round trip time into account. The former is specified with the maximum parameter. Function -------- ### Synopsis ``` peer:timeout(limit, minimum, maximum) ``` ### Arguments `[number](number "number") limit` A factor that is multiplied with a value that based on the average [round trip time](enet.peer-round_trip_time "enet.peer:round trip time") to compute the timeout limit. `[number](number "number") minimum` Timeout value, in milliseconds, that a reliable packet has to be acknowledged if the variable timeout limit was exceeded before dropping the [peer](enet.peer "enet.peer"). `[number](number "number") maximum` Fixed timeout in milliseconds for which any packet has to be acknowledged before dropping the [peer](enet.peer "enet.peer"). ### Returns Nothing. ### Synopsis ``` peer:timeout() ``` ### Arguments None. ### Returns `[number](number "number") limit` A factor that is multiplied with a value that based on the average [round trip time](enet.peer-round_trip_time "enet.peer:round trip time") to compute the timeout limit. `[number](number "number") minimum` Timeout value, in milliseconds, that a reliable packet has to be acknowledged if the variable timeout limit was exceeded before dropping the [peer](enet.peer "enet.peer"). `[number](number "number") maximum` Fixed timeout in milliseconds for which any packet has to be acknowledged before dropping the [peer](enet.peer "enet.peer"). See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.peer](enet.peer "enet.peer") * [enet.peer:round\_trip\_time](enet.peer-round_trip_time "enet.peer:round trip time") love PrismaticJoint:enableLimit PrismaticJoint:enableLimit ========================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [PrismaticJoint:setLimitsEnabled](prismaticjoint-setlimitsenabled "PrismaticJoint:setLimitsEnabled"). Enables or disables the limits of the joint. Function -------- ### Synopsis ``` PrismaticJoint:enableLimit( enable ) ``` ### Arguments `[boolean](boolean "boolean") enable` True to enable, false to disable. ### Returns Nothing. See Also -------- * [PrismaticJoint](prismaticjoint "PrismaticJoint") love Fixture:destroy Fixture:destroy =============== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Destroys the fixture. Function -------- ### Synopsis ``` Fixture:destroy( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Fixture](fixture "Fixture") love TextureMode TextureMode =========== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This enum is not supported in earlier or later versions. [Image](image "Image") texture formats. As of LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2"), [Canvases](canvas "Canvas") use [CanvasFormats](canvasformat "CanvasFormat") rather than TextureFormats. Constants --------- normal The default texture format: 8 bits per channel (32 bpp) RGBA. Color channel values range from 0-255 (0-1 in shaders.) hdr Only usable in Canvases. The high dynamic range texture format: floating point 16 bits per channel (64 bpp) RGBA. Color channel values inside the Canvas range from -infinity to +infinity. srgb Available since 0.9.1 The same as `normal`, but the texture is *interpreted* as being in the sRGB color space. It will be decoded from sRGB to linear RGB when drawn or sampled from in a shader. For Canvases, this will also convert everything drawn *to* the Canvas from linear RGB to sRGB. Notes ----- The HDR format is most useful when combined with pixel shaders. Effects such as tonemapped HDR with bloom can be accomplished, or the canvas can be used to store arbitrary non-color data such as positions which are then interpreted and used in a shader, as long as you draw the right things to the canvas. The sRGB format should only be used when doing gamma-correct rendering, which is an advanced topic and it's easy to get color-spaces mixed up. If you're not sure whether you need this, you might want to avoid it. Read more about gamma-correct rendering [here](http://http.developer.nvidia.com/GPUGems3/gpugems3_ch24.html), [here](http://filmicgames.com/archives/299), and [here](http://renderwonk.com/blog/index.php/archive/adventures-with-gamma-correct-rendering/). Not all systems support the HDR and sRGB formats. Use [love.graphics.isSupported](love.graphics.issupported "love.graphics.isSupported") to check before creating the Canvas or Image. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.newImage](love.graphics.newimage "love.graphics.newImage") * [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") * [love.graphics.isSupported](love.graphics.issupported "love.graphics.isSupported") love love.filesystem.isDirectory love.filesystem.isDirectory =========================== | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | This function is deprecated and is replaced by [love.filesystem.getInfo](love.filesystem.getinfo "love.filesystem.getInfo"). | Check whether something is a directory. Function -------- ### Synopsis ``` isDir = love.filesystem.isDirectory( filename ) ``` ### Arguments `[string](string "string") filename` The path to a potential directory. ### Returns `[boolean](boolean "boolean") isDir` True if there is a directory with the specified name. False otherwise. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [love.filesystem.isFile](love.filesystem.isfile "love.filesystem.isFile") love FrictionJoint FrictionJoint ============= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This type is not supported in earlier versions. A FrictionJoint applies friction to a body. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.physics.newFrictionJoint](love.physics.newfrictionjoint "love.physics.newFrictionJoint") | A **FrictionJoint** applies friction to a body. | 0.8.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [FrictionJoint:getMaxForce](frictionjoint-getmaxforce "FrictionJoint:getMaxForce") | Gets the maximum friction force in Newtons. | 0.8.0 | | | [FrictionJoint:getMaxTorque](frictionjoint-getmaxtorque "FrictionJoint:getMaxTorque") | Gets the maximum friction torque in Newton-meters. | 0.8.0 | | | [FrictionJoint:setMaxForce](frictionjoint-setmaxforce "FrictionJoint:setMaxForce") | Sets the maximum friction force in Newtons. | 0.8.0 | | | [FrictionJoint:setMaxTorque](frictionjoint-setmaxtorque "FrictionJoint:setMaxTorque") | Sets the maximum friction torque in Newton-meters. | 0.8.0 | | | [Joint:destroy](joint-destroy "Joint:destroy") | Explicitly destroys the Joint. | | | | [Joint:getAnchors](joint-getanchors "Joint:getAnchors") | Get the anchor points of the joint. | | | | [Joint:getBodies](joint-getbodies "Joint:getBodies") | Gets the [bodies](body "Body") that the Joint is attached to. | 0.9.2 | | | [Joint:getCollideConnected](joint-getcollideconnected "Joint:getCollideConnected") | Gets whether the connected Bodies collide. | | | | [Joint:getReactionForce](joint-getreactionforce "Joint:getReactionForce") | Returns the reaction force on the second body. | | | | [Joint:getReactionTorque](joint-getreactiontorque "Joint:getReactionTorque") | Returns the reaction torque on the second body. | | | | [Joint:getType](joint-gettype "Joint:getType") | Gets a string representing the type. | | | | [Joint:getUserData](joint-getuserdata "Joint:getUserData") | Returns the Lua value associated with this Joint. | 0.9.2 | | | [Joint:isDestroyed](joint-isdestroyed "Joint:isDestroyed") | Gets whether the Joint is destroyed. | 0.9.2 | | | [Joint:setCollideConnected](joint-setcollideconnected "Joint:setCollideConnected") | Sets whether the connected Bodies should collide with each other. | | 0.8.0 | | [Joint:setUserData](joint-setuserdata "Joint:setUserData") | Associates a Lua value with the Joint. | 0.9.2 | | Supertypes ---------- * [Joint](joint "Joint") * [Object](object "Object") See Also -------- * [love.physics](love.physics "love.physics") love BlendMode Formulas BlendMode Formulas ================== Equations used when blending drawn content with the screen or active [Canvas](canvas "Canvas"). Color components are generally in the range of [0, 1] rather than [0, 255] for the purposes of these equations. Results are clamped to [0, 1] except when a [Canvas](canvas "Canvas") is active that has a floating-point / HDR [format](canvasformat "CanvasFormat"). Description: * **dst** - existing color in the screen. * **src** - the color of the drawn object (the color output by the pixel shader, or the global color multiplied by the texture's color – if any, if no shader is used.) * **res** - resulting color. Here are the [BlendMode](blendmode "BlendMode") formulas for all 0.10.x and later versions: alpha ----- ### "alphamultiply" [alpha mode](blendalphamode "BlendAlphaMode") ``` res.r = dst.r * (1 - src.a) + src.r * src.a res.g = dst.g * (1 - src.a) + src.g * src.a res.b = dst.b * (1 - src.a) + src.b * src.a res.a = dst.a * (1 - src.a) + src.a ``` ### "premultiplied" [alpha mode](blendalphamode "BlendAlphaMode") ``` res.r = dst.r * (1 - src.a) + src.r res.g = dst.g * (1 - src.a) + src.g res.b = dst.b * (1 - src.a) + src.b res.a = dst.a * (1 - src.a) + src.a ``` add --- ### "alphamultiply" [alpha mode](blendalphamode "BlendAlphaMode") ``` res.r = dst.r + (src.r * src.a) res.g = dst.g + (src.g * src.a) res.b = dst.b + (src.b * src.a) res.a = dst.a ``` ### "premultiplied" [alpha mode](blendalphamode "BlendAlphaMode") ``` res.r = dst.r + src.r res.g = dst.g + src.g res.b = dst.b + src.b res.a = dst.a ``` subtract -------- ### "alphamultiply" [alpha mode](blendalphamode "BlendAlphaMode") ``` res.r = dst.r - (src.r * src.a) res.g = dst.g - (src.g * src.a) res.b = dst.b - (src.b * src.a) res.a = dst.a ``` ### "premultiplied" [alpha mode](blendalphamode "BlendAlphaMode") ``` res.r = dst.r - src.r res.g = dst.g - src.g res.b = dst.b - src.b res.a = dst.a ``` replace ------- ### "alphamultiply" [alpha mode](blendalphamode "BlendAlphaMode") ``` res.r = src.r * src.a res.g = src.g * src.a res.b = src.b * src.a res.a = src.a ``` ### "premultiplied" [alpha mode](blendalphamode "BlendAlphaMode") ``` res.r = src.r res.g = src.g res.b = src.b res.a = src.a ``` multiply -------- ### "premultiplied" [alpha mode](blendalphamode "BlendAlphaMode") ``` res.r = src.r * dst.r res.g = src.g * dst.g res.b = src.b * dst.b res.a = src.a * dst.a ``` Note: In 0.10.x, *multiply* with *alphamultiply* uses the same equations as with *premultiplied*. In [11.0](https://love2d.org/wiki/11.0 "11.0") and later versions, this variation is not supported. lighten ------- ### "premultiplied" [alpha mode](blendalphamode "BlendAlphaMode") ``` res.r = max(src.r, dst.r) res.g = max(src.g, dst.g) res.b = max(src.b, dst.b) res.a = max(src.a, dst.a) ``` darken ------ ### "premultiplied" [alpha mode](blendalphamode "BlendAlphaMode") ``` res.r = min(src.r, dst.r) res.g = min(src.g, dst.g) res.b = min(src.b, dst.b) res.a = min(src.a, dst.a) ``` screen ------ Note: The math for this blend mode is not completely correct when using the "alphamultiply" alpha mode. Prefer the "premultiplied" variant (and be sure your content has its RGB multiplied by its alpha at some point before blending), when possible. ### "alphamultiply" [alpha mode](blendalphamode "BlendAlphaMode") ``` res.r = dst.r * (1 - src.r) + (src.r * src.a) res.g = dst.g * (1 - src.g) + (src.g * src.a) res.b = dst.b * (1 - src.b) + (src.b * src.a) res.a = dst.a * (1 - src.a) + src.a ``` ### "premultiplied" [alpha mode](blendalphamode "BlendAlphaMode") ``` res.r = dst.r * (1 - src.r) + src.r res.g = dst.g * (1 - src.g) + src.g res.b = dst.b * (1 - src.b) + src.b res.a = dst.a * (1 - src.a) + src.a ``` Older Versions -------------- ### alpha ([0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0"), [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1"), and [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")) ``` res.r = dst.r * (1 - src.a) + src.r * src.a res.g = dst.g * (1 - src.a) + src.g * src.a res.b = dst.b * (1 - src.a) + src.b * src.a res.a = dst.a * (1 - src.a) + src.a ``` ### alpha ([0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and older) ``` res.r = dst.r * (1 - src.a) + src.r * src.a res.g = dst.g * (1 - src.a) + src.g * src.a res.b = dst.b * (1 - src.a) + src.b * src.a res.a = dst.a * (1 - src.a) + src.a * src.a ``` ### premultiplied ([0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2") and older) ``` res.r = dst.r * (1 - src.a) + src.r res.g = dst.g * (1 - src.a) + src.g res.b = dst.b * (1 - src.a) + src.b res.a = dst.a * (1 - src.a) + src.a ``` ### screen ([0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2") and older) ``` res.r = dst.r * (1 - src.r) + src.r res.g = dst.g * (1 - src.g) + src.g res.b = dst.b * (1 - src.b) + src.b res.a = dst.a * (1 - src.a) + src.a ``` ### additive ([0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2") and older) ``` res.r = dst.r + (src.r * src.a) res.g = dst.g + (src.g * src.a) res.b = dst.b + (src.b * src.a) res.a = dst.a + (src.a * src.a) ``` ### subtractive ([0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2") and older) ``` res.r = dst.r - src.r * src.a res.g = dst.g - src.g * src.a res.b = dst.b - src.b * src.a res.a = dst.a - src.a * src.a ``` ### multiplicative ([0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0"), [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1"), and [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")) ``` res.r = src.r * dst.r res.g = src.g * dst.g res.b = src.b * dst.b res.a = src.a * dst.a ``` ### multiplicative ([0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and older) ``` res.r = dst.r * (1 - src.a) + src.r * dst.r res.g = dst.g * (1 - src.a) + src.g * dst.g res.b = dst.b * (1 - src.a) + src.b * dst.b res.a = dst.a * (1 - src.a) + src.a * dst.a ``` ### replace ([0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2") and older) ``` res.r = src.r res.g = src.g res.b = src.b res.a = src.a ``` See Also -------- * [BlendMode](blendmode "BlendMode")
programming_docs
love love.graphics.validateShader love.graphics.validateShader ============================ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Validates shader code. Check if specified shader code does not contain any errors. Function -------- ### Synopsis ``` status, message = love.graphics.validateShader( gles, code ) ``` ### Arguments `[boolean](boolean "boolean") gles` Validate code as GLSL ES shader. `[string](string "string") code` The pixel shader or vertex shader code, or a filename pointing to a file with the code. ### Returns `[boolean](boolean "boolean") status` `true` if specified shader code doesn't contain any errors. `false` otherwise. `[string](string "string") message` Reason why shader code validation failed (or `nil` if validation succeded). Function -------- ### Synopsis ``` status, message = love.graphics.validateShader( gles, pixelcode, vertexcode ) ``` ### Arguments `[boolean](boolean "boolean") gles` Validate code as GLSL ES shader. `[string](string "string") pixelcode` The pixel shader code, or a filename pointing to a file with the code. `[string](string "string") vertexcode` The vertex shader code, or a filename pointing to a file with the code. ### Returns `[boolean](boolean "boolean") status` `true` if specified shader code doesn't contain any errors. `false` otherwise. `[string](string "string") message` Reason why shader code validation failed (or `nil` if validation succeded). See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.newShader](love.graphics.newshader "love.graphics.newShader") love love.audio.setVolume love.audio.setVolume ==================== Sets the master volume. Function -------- ### Synopsis ``` love.audio.setVolume( volume ) ``` ### Arguments `[number](number "number") volume` 1.0 is max and 0.0 is off. ### Returns Nothing. See Also -------- * [love.audio](love.audio "love.audio") love enet.peer enet.peer ========= Description ----------- An ENet peer which data packets may be sent or received from. In most applications you'll manually keep track of connected peers. Functions --------- | Function | Description | | --- | --- | | [peer:disconnect](enet.peer-disconnect "enet.peer:disconnect") | Requests a disconnection from the peer. | | [peer:disconnect\_now](enet.peer-disconnect_now "enet.peer:disconnect now") | Force immediate disconnection from peer. | | [peer:disconnect\_later](enet.peer-disconnect_later "enet.peer:disconnect later") | Request a disconnection from peer, but only after all queued outgoing packets are sent. | | [peer:reset](enet.peer-reset "enet.peer:reset") | Forcefully disconnects peer. The peer is not notified of the disconnection. | | [peer:ping](enet.peer-ping "enet.peer:ping") | Send a ping request to peer, updates [round\_trip\_time](enet.peer-round_trip_time "enet.peer:round trip time"). This is called automatically at regular intervals. | | [peer:receive](enet.peer-receive "enet.peer:receive") | Attempts to dequeue an incoming packet for this peer. | | [peer:send](enet.peer-send "enet.peer:send") | Queues a packet to be sent to peer. | | [peer:throttle\_configure](enet.peer-throttle_configure "enet.peer:throttle configure") | Changes the probability at which unreliable packets should not be dropped. | | [peer:ping\_interval](enet.peer-ping_interval "enet.peer:ping interval") | Specifies the interval in milliseconds that pings are sent to the other end of the connection (defaults to 500). | | [peer:timeout](enet.peer-timeout "enet.peer:timeout") | Returns or sets the parameters when a timeout is detected. | | [peer:index](enet.peer-index "enet.peer:index") | Returns the index of the peer. | | [peer:state](enet.peer-state "enet.peer:state") | Returns the state of the peer. | | [peer:connect\_id](enet.peer-connect_id "enet.peer:connect id") | Returns the field ENetPeer::connectID that is assigned for each connection. | | [peer:round\_trip\_time](enet.peer-round_trip_time "enet.peer:round trip time") | Returns or sets the current round trip time (i.e. ping). | | [peer:last\_round\_trip\_time](enet.peer-last_round_trip_time "enet.peer:last round trip time") | Returns or sets the round trip time of the previous round trip time computation. | See Also -------- * [lua-enet](lua-enet "lua-enet") * [enet.event](enet.event "enet.event") * [enet.host](enet.host "enet.host") love love.graphics.newParticleSystem love.graphics.newParticleSystem =============================== Creates a new [ParticleSystem](particlesystem "ParticleSystem"). This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- ### Synopsis ``` system = love.graphics.newParticleSystem( image, buffer ) ``` ### Arguments `[Image](image "Image") image` The image to use. `[number](number "number") buffer (1000)` The max number of particles at the same time. ### Returns `[ParticleSystem](particlesystem "ParticleSystem") system` A new ParticleSystem. Function -------- **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This variant is not supported in earlier versions. ### Synopsis ``` system = love.graphics.newParticleSystem( texture, buffer ) ``` ### Arguments `[Texture](texture "Texture") texture` The texture ([Image](image "Image") or [Canvas](canvas "Canvas")) to use. `[number](number "number") buffer (1000)` The max number of particles at the same time. ### Returns `[ParticleSystem](particlesystem "ParticleSystem") system` A new ParticleSystem. Examples -------- ### Creation and usage of a particle system You can use the [LÖVE logo](https://love2d.org/wiki/File:Love-game-logo-256x256.png "File:Love-game-logo-256x256.png") as an example image. ``` function love.load() local img = love.graphics.newImage('logo.png')   psystem = love.graphics.newParticleSystem(img, 32) psystem:setParticleLifetime(2, 5) -- Particles live at least 2s and at most 5s. psystem:setEmissionRate(5) psystem:setSizeVariation(1) psystem:setLinearAcceleration(-20, -20, 20, 20) -- Random movement in all directions. psystem:setColors(1, 1, 1, 1, 1, 1, 1, 0) -- Fade to transparency. end   function love.draw() -- Draw the particle system at the center of the game window. love.graphics.draw(psystem, love.graphics.getWidth() * 0.5, love.graphics.getHeight() * 0.5) end   function love.update(dt) psystem:update(dt) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [ParticleSystem:clone](particlesystem-clone "ParticleSystem:clone") * [ParticleSystem](particlesystem "ParticleSystem") love PixelEffect:getWarnings PixelEffect:getWarnings ======================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [Shader:getWarnings](shader-getwarnings "Shader:getWarnings"). Returns any warning messages from compiling the pixel effect code. This can be used for debugging your pixel effects if there's anything the graphics hardware doesn't like. Function -------- ### Synopsis ``` warnings = PixelEffect:getWarnings( ) ``` ### Arguments None. ### Returns `[string](string "string") warnings` Warning messages (if any). See Also -------- * [PixelEffect](pixeleffect "PixelEffect") love DistanceJoint:getDampingRatio DistanceJoint:getDampingRatio ============================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been renamed from [DistanceJoint:getDamping](distancejoint-getdamping "DistanceJoint:getDamping"). Gets the damping ratio. Function -------- ### Synopsis ``` ratio = DistanceJoint:getDampingRatio( ) ``` ### Arguments None. ### Returns `[number](number "number") ratio` The damping ratio. See Also -------- * [DistanceJoint](distancejoint "DistanceJoint") love love.graphics.rectangle love.graphics.rectangle ======================= **Available since LÖVE [0.3.2](https://love2d.org/wiki/0.3.2 "0.3.2")** This function is not supported in earlier versions. Draws a rectangle. Function -------- ### Synopsis ``` love.graphics.rectangle( mode, x, y, width, height ) ``` ### Arguments `[DrawMode](drawmode "DrawMode") mode` How to draw the rectangle. `[number](number "number") x` The position of top-left corner along the x-axis. `[number](number "number") y` The position of top-left corner along the y-axis. `[number](number "number") width` Width of the rectangle. `[number](number "number") height` Height of the rectangle. ### Returns Nothing. Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. Draws a rectangle with rounded corners. ### Synopsis ``` love.graphics.rectangle( mode, x, y, width, height, rx, ry, segments ) ``` ### Arguments `[DrawMode](drawmode "DrawMode") mode` How to draw the rectangle. `[number](number "number") x` The position of top-left corner along the x-axis. `[number](number "number") y` The position of top-left corner along the y-axis. `[number](number "number") width` Width of the rectangle. `[number](number "number") height` Height of the rectangle. `[number](number "number") rx` The x-axis radius of each round corner. Cannot be greater than half the rectangle's width. `[number](number "number") ry (rx)` The y-axis radius of each round corner. Cannot be greater than half the rectangle's height. `[number](number "number") segments (nil)` The number of segments used for drawing the round corners. A default amount will be chosen if no number is given. ### Returns Nothing. Notes ----- Custom shaders may not work correctly since this function (and other functions that draw primitives) doesn't have UV coordinates associated in it. Examples -------- ### Draws a rectangle at 20,50 with a width of 60 and a height of 120 ``` function love.draw() love.graphics.rectangle("fill", 20, 50, 60, 120 ) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") love Quad:setViewport Quad:setViewport ================ Sets the texture coordinates according to a viewport. Function -------- ### Synopsis ``` Quad:setViewport( x, y, w, h, sw, sh ) ``` ### Arguments `[number](number "number") x` The top-left corner along the x-axis. `[number](number "number") y` The top-left corner along the y-axis. `[number](number "number") w` The width of the viewport. `[number](number "number") h` The height of the viewport. `[number](number "number") sw` Available since 0.9.0 The reference width, the width of the [Image](image "Image"). (Must be greater than 0.) `[number](number "number") sh` Available since 0.9.0 The reference height, the height of the [Image](image "Image"). (Must be greater than 0.) ### Returns Nothing. See Also -------- * [Quad](quad "Quad") * [Quad:getViewport](quad-getviewport "Quad:getViewport") love GlyphData:getGlyph GlyphData:getGlyph ================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Gets glyph number. Function -------- ### Synopsis ``` glyph = GlyphData:getGlyph() ``` ### Arguments None. ### Returns `[number](number "number") glyph` Glyph number. See Also -------- * [GlyphData](glyphdata "GlyphData") love Body:setGravityScale Body:setGravityScale ==================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Sets a new gravity scale factor for the body. Function -------- ### Synopsis ``` Body:setGravityScale( scale ) ``` ### Arguments `[number](number "number") scale` The new gravity scale factor. ### Returns Nothing. See Also -------- * [Body](body "Body") * [Body:getGravityScale](body-getgravityscale "Body:getGravityScale") love ParticleSystem:getBufferSize ParticleSystem:getBufferSize ============================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the maximum number of particles the ParticleSystem can have at once. Function -------- ### Synopsis ``` size = ParticleSystem:getBufferSize( ) ``` ### Arguments None. ### Returns `[number](number "number") size` The maximum number of particles. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setBufferSize](particlesystem-setbuffersize "ParticleSystem:setBufferSize") * [ParticleSystem:getCount](particlesystem-getcount "ParticleSystem:getCount") love love.physics.newPulleyJoint love.physics.newPulleyJoint =========================== Creates a [PulleyJoint](pulleyjoint "PulleyJoint") to join two bodies to each other and the ground. The pulley joint simulates a pulley with an optional block and tackle. If the ratio parameter has a value different from one, then the simulated rope extends faster on one side than the other. In a pulley joint the total length of the simulated rope is the constant length1 + ratio \* length2, which is set when the pulley joint is created. Pulley joints can behave unpredictably if one side is fully extended. It is recommended that the method [setMaxLengths](pulleyjoint-setmaxlengths "PulleyJoint:setMaxLengths") be used to constrain the maximum lengths each side can attain. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in earlier versions. ### Synopsis ``` joint = love.physics.newPulleyJoint( body1, body2, gx1, gy1, gx2, gy2, x1, y1, x2, y2, ratio, collideConnected ) ``` ### Arguments `[Body](body "Body") body1` The first body to connect with a pulley joint. `[Body](body "Body") body2` The second body to connect with a pulley joint. `[number](number "number") gx1` The x coordinate of the first body's ground anchor. `[number](number "number") gy1` The y coordinate of the first body's ground anchor. `[number](number "number") gx2` The x coordinate of the second body's ground anchor. `[number](number "number") gy2` The y coordinate of the second body's ground anchor. `[number](number "number") x1` The x coordinate of the pulley joint anchor in the first body. `[number](number "number") y1` The y coordinate of the pulley joint anchor in the first body. `[number](number "number") x2` The x coordinate of the pulley joint anchor in the second body. `[number](number "number") y2` The y coordinate of the pulley joint anchor in the second body. `[number](number "number") ratio (1)` The joint ratio. `[boolean](boolean "boolean") collideConnected (true)` Specifies whether the two bodies should collide with each other. ### Returns `[PulleyJoint](pulleyjoint "PulleyJoint") joint` The new pulley joint. Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. ### Synopsis ``` joint = love.physics.newPulleyJoint( body1, body2, gx1, gy1, gx2, gy2, x1, y1, x2, y2, ratio ) ``` ### Arguments `[Body](body "Body") body1` The first body to connect with a pulley joint. `[Body](body "Body") body2` The second body to connect with a pulley joint. `[number](number "number") gx1` The x coordinate of the first body's ground anchor. `[number](number "number") gy1` The y coordinate of the first body's ground anchor. `[number](number "number") gx2` The x coordinate of the second body's ground anchor. `[number](number "number") gy2` The y coordinate of the second body's ground anchor. `[number](number "number") x1` The x coordinate of the pulley joint anchor in the first body. `[number](number "number") y1` The y coordinate of the pulley joint anchor in the first body. `[number](number "number") x2` The x coordinate of the pulley joint anchor in the second body. `[number](number "number") y2` The y coordinate of the pulley joint anchor in the second body. `[number](number "number") ratio (1)` The joint ratio. ### Returns `[PulleyJoint](pulleyjoint "PulleyJoint") joint` The new pulley joint. See Also -------- * [love.physics](love.physics "love.physics") * [PulleyJoint](pulleyjoint "PulleyJoint") * [Joint](joint "Joint") love Mesh:setVertices Mesh:setVertices ================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Replaces a range of vertices in the Mesh with new ones. The total number of vertices in a Mesh cannot be changed after it has been created. This is often more efficient than calling [Mesh:setVertex](mesh-setvertex "Mesh:setVertex") in a loop. Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. ### Synopsis ``` Mesh:setVertices( vertices, startvertex, count ) ``` ### Arguments `[table](table "table") vertices` The table filled with vertex information tables for each vertex, in the form of `{vertex, ...}` where each vertex is a table in the form of `{attributecomponent, ...}`. `[number](number "number") attributecomponent` The first component of the first vertex attribute in the vertex. `[number](number "number") ...` Additional components of all vertex attributes in the vertex. `[number](number "number") startvertex (1)` The index of the first vertex to replace. `[number](number "number") count (all)` Available since 11.3 Amount of vertices to replace. ### Returns Nothing. ### Notes The values in each vertex table are in the same order as the vertex attributes in the Mesh's [vertex format](mesh-getvertexformat "Mesh:getVertexFormat"). A standard Mesh that wasn't [created](love.graphics.newmesh "love.graphics.newMesh") with a custom vertex format will use two position numbers, two texture coordinate numbers, and four color components per vertex: x, y, u, v, r, g, b, a. If no value is supplied for a specific vertex attribute component, it will be set to a default value of 0 if its [data type](attributedatatype "AttributeDataType") is "float", or 255 if its data type is "byte". Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. Sets the vertex components of the Mesh by copying directly from the memory of a [Data](data "Data") object. ### Synopsis ``` Mesh:setVertices( data, startvertex, count ) ``` ### Arguments `[Data](data "Data") data` A Data object to copy from. The contents of the Data must match the layout of this Mesh's [vertex format](mesh-getvertexformat "Mesh:getVertexFormat"). `[number](number "number") startvertex (1)` The index of the first vertex to replace. `[number](number "number") count (all)` Available since 11.3 Amount of vertices to replace. ### Returns Nothing. ### Notes If LuaJIT's [FFI](https://luajit.org/ext_ffi_api.html) is used to populate the Data object via [Data:getPointer](data-getpointer "Data:getPointer") and [ffi.cast](https://luajit.org/ext_ffi_api.html#ffi_cast), this variant can be drastically more efficient than other methods of setting Mesh vertex data. Function -------- Sets the vertex components of a Mesh that wasn't [created](love.graphics.newmesh "love.graphics.newMesh") with a custom vertex format. ### Synopsis ``` Mesh:setVertices( vertices ) ``` ### Arguments `[table](table "table") vertices` The table filled with vertex information tables for each vertex as follows: `[number](number "number") [1]` The position of the vertex on the x-axis. `[number](number "number") [2]` The position of the vertex on the y-axis. `[number](number "number") [3]` The horizontal component of the texture coordinate. Texture coordinates are normally in the range of [0, 1], but can be greater or less (see [WrapMode](wrapmode "WrapMode")). `[number](number "number") [4]` The vertical component of the texture coordinate. Texture coordinates are normally in the range of [0, 1], but can be greater or less (see [WrapMode](wrapmode "WrapMode")). `[number](number "number") [5] (1)` The red color component. `[number](number "number") [6] (1)` The green color component. `[number](number "number") [7] (1)` The blue color component. `[number](number "number") [8] (1)` The alpha color component. ### Returns Nothing. See Also -------- * [Mesh](mesh "Mesh") * [Mesh:getVertex](mesh-getvertex "Mesh:getVertex") * [Mesh:getVertexCount](mesh-getvertexcount "Mesh:getVertexCount") * [Mesh:getVertexFormat](mesh-getvertexformat "Mesh:getVertexFormat")
programming_docs
love love.joystick.getGamepadMappingString love.joystick.getGamepadMappingString ===================================== **Available since LÖVE [11.3](https://love2d.org/wiki/11.3 "11.3")** This function is not supported in earlier versions. Gets the full gamepad mapping string of the Joysticks which have the given GUID, or nil if the GUID isn't recognized as a [gamepad](joystick-isgamepad "Joystick:isGamepad"). The mapping string contains binding information used to map the Joystick's buttons an axes to the standard [gamepad layout](joystick-isgamepad "Joystick:isGamepad"), and can be used later with [love.joystick.loadGamepadMappings](love.joystick.loadgamepadmappings "love.joystick.loadGamepadMappings"). Function -------- ### Synopsis ``` mappingstring = love.joystick.getGamepadMappingString( guid ) ``` ### Arguments `[string](string "string") guid` The [GUID](joystick-getguid "Joystick:getGUID") value to get the mapping string for. ### Returns `[string](string "string") mappingstring (nil)` A string containing the Joystick's gamepad mappings, or nil if the GUID is not recognized as a gamepad. See Also -------- * [love.joystick](love.joystick "love.joystick") * [Joystick:getGamepadMappingString](joystick-getgamepadmappingstring "Joystick:getGamepadMappingString") * [Joystick:isGamepad](joystick-isgamepad "Joystick:isGamepad") * [love.joystick.loadGamepadMappings](love.joystick.loadgamepadmappings "love.joystick.loadGamepadMappings") * [love.joystick.saveGamepadMappings](love.joystick.savegamepadmappings "love.joystick.saveGamepadMappings") * [love.joystick.setGamepadMapping](love.joystick.setgamepadmapping "love.joystick.setGamepadMapping") * [Joystick:getGamepadMapping](joystick-getgamepadmapping "Joystick:getGamepadMapping") love Texture:isReadable Texture:isReadable ================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets whether the Texture can be drawn and sent to a Shader. [Canvases](canvas "Canvas") created with stencil and/or depth [PixelFormats](pixelformat "PixelFormat") are not readable by default, unless `readable=true` is specified in the settings table passed into [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas"). Non-readable Canvases can still be rendered to. Function -------- ### Synopsis ``` readable = Texture:isReadable( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") readable` Whether the Texture is readable. See Also -------- * [Texture](texture "Texture") * [love.graphics.newCanvas](love.graphics.newcanvas "love.graphics.newCanvas") love WrapMode WrapMode ======== How the image wraps inside a [Quad](quad "Quad") with a larger quad size than image size. This also affects how [Meshes](mesh "Mesh") with texture coordinates which are outside the range of [0, 1] are drawn, and the color returned by the `Texel` [Shader](shader "Shader") function when using it to sample from texture coordinates outside of the range of [0, 1]. Constants --------- clamp Clamp the texture. Appears only once. The area outside the texture's normal range is colored based on the edge pixels of the texture. repeat Repeat the texture. Fills the whole available extent. mirroredrepeat Available since 0.9.2 Repeat the texture, flipping it each time it repeats. May produce better visual results than the `repeat` mode when the texture doesn't seamlessly tile. clampzero Available since 0.10.0 Clamp the texture. Fills the area outside the texture's normal range with transparent black (or opaque black for textures with no alpha channel.) Notes ----- The `clampzero` mode is not available on most mobile devices, and will fall back to the `clamp` mode when it's unsupported. Check the `clampzero` [GraphicsFeature](graphicsfeature "GraphicsFeature") constant by calling [love.graphics.getSupported](love.graphics.getsupported "love.graphics.getSupported"). See Also -------- * [love.graphics](love.graphics "love.graphics") * [Texture:setWrap](texture-setwrap "Texture:setWrap") * [Texture:getWrap](texture-getwrap "Texture:getWrap") love PrismaticJoint:isLimitEnabled PrismaticJoint:isLimitEnabled ============================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [PrismaticJoint:hasLimitsEnabled](prismaticjoint-haslimitsenabled "PrismaticJoint:hasLimitsEnabled"). Checks whether the limits are enabled. Function -------- ### Synopsis ``` enabled = PrismaticJoint:isLimitEnabled( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") enabled` True if enabled, false otherwise. See Also -------- * [PrismaticJoint](prismaticjoint "PrismaticJoint") love (File):open (File):open =========== Open the file for write, read or append. Function -------- ### Synopsis ``` ok, err = File:open( mode ) ``` ### Arguments `[FileMode](filemode "FileMode") mode` The mode to open the file in. ### Returns `[boolean](boolean "boolean") ok` True on success, false otherwise. `[string](string "string") err` The error string if an error occurred. ### Notes If you are getting the error message "Could not set write directory", try setting the save directory. This is done either with [love.filesystem.setIdentity](love.filesystem.setidentity "love.filesystem.setIdentity") or by setting the identity field in [love.conf](love.conf "love.conf") (only available with love 0.7 or higher). See Also -------- * [File](file "File") * [FileMode](filemode "FileMode") love VideoStream:isPlaying VideoStream:isPlaying ===================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets whatever the video stream is playing. Function -------- ### Synopsis ``` playing = VideoStream:isPlaying( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") playing` Whatever video stream is playing. See Also -------- * [VideoStream](videostream "VideoStream") * [VideoStream:play](videostream-play "VideoStream:play") * [VideoStream:pause](videostream-pause "VideoStream:pause") love love.timer.getFPS love.timer.getFPS ================= Returns the current number of frames per second. Function -------- ### Synopsis ``` fps = love.timer.getFPS( ) ``` ### Arguments None. ### Returns `[number](number "number") fps` The current FPS. ### Notes The returned value is the number of frames rendered during the last second, rounded to the nearest integer value. It is one divided by what [love.timer.getAverageDelta](love.timer.getaveragedelta "love.timer.getAverageDelta") returns, otherwise known as the reciprocal, or multiplicative inverse of it. To get instantaneous frame rate values, use `1.0 / love.timer.getDelta()`, or `1.0 / dt` if in [love.update](love.update "love.update"), with `dt` given as the parameter. Examples -------- Display text at the top left of the screen showing the current FPS. ``` function love.draw() love.graphics.print("Current FPS: "..tostring(love.timer.getFPS( )), 10, 10) end ``` See Also -------- * [love.timer](love.timer "love.timer") love love.mouse.getSystemCursor love.mouse.getSystemCursor ========================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets a [Cursor](cursor "Cursor") object representing a system-native hardware cursor. Hardware cursors are framerate-independent and work the same way as normal operating system cursors. Unlike drawing an image at the mouse's current coordinates, hardware cursors never have visible lag between when the mouse is moved and when the cursor position updates, even at low framerates. Function -------- ### Synopsis ``` cursor = love.mouse.getSystemCursor( ctype ) ``` ### Arguments `[CursorType](cursortype "CursorType") ctype` The type of system cursor to get. ### Returns `[Cursor](cursor "Cursor") cursor` The Cursor object representing the system cursor type. ### Notes The "image" CursorType is not a valid argument. Use [love.mouse.newCursor](love.mouse.newcursor "love.mouse.newCursor") to create a hardware cursor using a custom image. Examples -------- ``` function love.load() i_beam_cursor = love.mouse.getSystemCursor("ibeam") love.mouse.setCursor(i_beam_cursor) end ``` See Also -------- * [love.mouse](love.mouse "love.mouse") * [love.mouse.setCursor](love.mouse.setcursor "love.mouse.setCursor") * [Cursor](cursor "Cursor") love World:getCallbacks World:getCallbacks ================== Returns functions for the callbacks during the world update. Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in earlier versions. ### Synopsis ``` beginContact, endContact, preSolve, postSolve = World:getCallbacks( ) ``` ### Arguments None. ### Returns `[function](function "function") beginContact` Gets called when two fixtures begin to overlap. `[function](function "function") endContact` Gets called when two fixtures cease to overlap. `[function](function "function") preSolve` Gets called before a collision gets resolved. `[function](function "function") postSolve` Gets called after the collision has been resolved. Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. ### Synopsis ``` add, persist, remove, result = World:getCallbacks( ) ``` ### Arguments None. ### Returns `[function](function "function") add` Called when two shapes first collide. `[function](function "function") persist` Called each frame, if collision lasts more than 1 frame. `[function](function "function") remove` Called when two shapes finish colliding. `[function](function "function") result` No idea. Never seems to be called... See Also -------- * [World](world "World") love love love ==== When beginning to write games using LÖVE, the most important parts of the API are the callbacks: [love.load](love.load "love.load") to do one-time setup of your game, [love.update](love.update "love.update") which is used to manage your game's state frame-to-frame, and [love.draw](love.draw "love.draw") which is used to render the game state onto the screen. More interactive games will override additional callbacks in order to handle input from the user, and other aspects of a full-featured game. LÖVE provides default placeholders for these callbacks, which you can override inside your own code by creating your own function with the same name as the callback: ``` -- Load some default values for our rectangle. function love.load() x, y, w, h = 20, 20, 60, 20 end   -- Increase the size of the rectangle every frame. function love.update(dt) w = w + 1 h = h + 1 end   -- Draw a coloured rectangle. function love.draw() -- In versions prior to 11.0, color component values are (0, 102, 102) love.graphics.setColor(0, 0.4, 0.4) love.graphics.rectangle("fill", x, y, w, h) end ``` Modules ------- | | | | | | --- | --- | --- | --- | | [love.audio](love.audio "love.audio") | Provides of audio interface for playback/recording sound. | | | | [love.data](love.data "love.data") | Provides functionality for creating and transforming data. | 11.0 | | | [love.event](love.event "love.event") | Manages events, like keypresses. | 0.6.0 | | | [love.filesystem](love.filesystem "love.filesystem") | Provides an interface to the user's filesystem. | | | | [love.font](love.font "love.font") | Allows you to work with fonts. | 0.7.0 | | | [love.graphics](love.graphics "love.graphics") | Drawing of shapes and images, management of screen geometry. | | | | [love.image](love.image "love.image") | Provides an interface to decode encoded image data. | | | | [love.joystick](love.joystick "love.joystick") | Provides an interface to connected joysticks. | 0.5.0 | | | [love.keyboard](love.keyboard "love.keyboard") | Provides an interface to the user's keyboard. | | | | [love.math](love.math "love.math") | Provides system-independent mathematical functions. | 0.9.0 | | | [love.mouse](love.mouse "love.mouse") | Provides an interface to the user's mouse. | | | | [love.physics](love.physics "love.physics") | Can simulate 2D rigid body physics in a realistic manner. | 0.4.0 | | | [love.sound](love.sound "love.sound") | This module is responsible for decoding sound files. | | | | [love.system](love.system "love.system") | Provides access to information about the user's system. | 0.9.0 | | | [love.thread](love.thread "love.thread") | Allows you to work with threads. | 0.7.0 | | | [love.timer](love.timer "love.timer") | Provides high-resolution timing functionality. | | | | [love.touch](love.touch "love.touch") | Provides an interface to touch-screen presses. | 0.10.0 | | | [love.video](love.video "love.video") | This module is responsible for decoding and streaming video files. | 0.10.0 | | | [love.window](love.window "love.window") | Provides an interface for the program's window. | 0.9.0 | | Third-party modules ------------------- | | | | | | --- | --- | --- | --- | | [lua-enet](lua-enet "lua-enet") | Multiplayer networking module for games. | 0.9.0 | | | [socket](socket "socket") | Module for HTTP, TCP, and UDP networking. | 0.5.0 | | | [utf8](utf8 "utf8") | Provides basic support for manipulating UTF-8 strings. | 0.9.2 | | Functions --------- | | | | | | --- | --- | --- | --- | | [love.getVersion](love.getversion "love.getVersion") | Gets the current running version of LÖVE. | 0.9.1 | | | [love.hasDeprecationOutput](love.hasdeprecationoutput "love.hasDeprecationOutput") | Gets whether LÖVE displays warnings when using deprecated functionality. | 11.0 | | | [love.isVersionCompatible](love.isversioncompatible "love.isVersionCompatible") | Gets whatever the version is compatible with current running version of LÖVE. | 0.10.0 | | | [love.setDeprecationOutput](love.setdeprecationoutput "love.setDeprecationOutput") | Sets whether LÖVE displays warnings when using deprecated functionality. | 11.0 | | Types ----- | | | | | | --- | --- | --- | --- | | [Data](data "Data") | The superclass of all data. | | | | [Object](object "Object") | The superclass of all LÖVE types. | | | | [Variant](variant "Variant") | The types supported by [love.thread](love.thread "love.thread") and [love.event](love.event "love.event"). | | | Callbacks --------- All callbacks are only called in main thread. ### General | | | | | | --- | --- | --- | --- | | [Config Files](love.conf "Config Files") | Game configuration settings. | | | | [love.displayrotated](love.displayrotated "love.displayrotated") | Called when the device display orientation changed. | 11.3 | | | [love.draw](love.draw "love.draw") | Callback function used to draw on the screen every frame. | | | | [love.errhand](love.errhand "love.errhand") | The error handler, used to display error messages. | | 11.0 | | [love.errorhandler](love.errorhandler "love.errorhandler") | The error handler, used to display error messages. | 11.0 | | | [love.load](love.load "love.load") | This function is called exactly once at the beginning of the game. | | | | [love.lowmemory](love.lowmemory "love.lowmemory") | Callback function triggered when the system is running out of memory on mobile devices. | 0.10.0 | | | [love.quit](love.quit "love.quit") | Callback function triggered when the game is closed. | 0.7.0 | | | [love.run](love.run "love.run") | The main function, containing the main loop. A sensible default is used when left out. | | | | [love.threaderror](love.threaderror "love.threaderror") | Callback function triggered when a [Thread](thread "Thread") encounters an error. | 0.9.0 | | | [love.update](love.update "love.update") | Callback function used to update the state of the game every frame. | | | ### Window | | | | | | --- | --- | --- | --- | | [love.directorydropped](love.directorydropped "love.directorydropped") | Callback function triggered when a directory is dragged and dropped onto the window. | 0.10.0 | | | [love.filedropped](love.filedropped "love.filedropped") | Callback function triggered when a file is dragged and dropped onto the window. | 0.10.0 | | | [love.focus](love.focus "love.focus") | Callback function triggered when window receives or loses focus. | 0.7.0 | | | [love.mousefocus](love.mousefocus "love.mousefocus") | Callback function triggered when window receives or loses mouse focus. | 0.9.0 | | | [love.resize](love.resize "love.resize") | Called when the window is resized. | 0.9.0 | | | [love.visible](love.visible "love.visible") | Callback function triggered when window is shown or hidden. | 0.9.0 | | ### Keyboard | | | | | | --- | --- | --- | --- | | [love.keypressed](love.keypressed "love.keypressed") | Callback function triggered when a key is pressed. | | | | [love.keyreleased](love.keyreleased "love.keyreleased") | Callback function triggered when a keyboard key is released. | | | | [love.textedited](love.textedited "love.textedited") | Called when the candidate text for an IME has changed. | 0.10.0 | | | [love.textinput](love.textinput "love.textinput") | Called when text has been entered by the user. | 0.9.0 | | ### Mouse | | | | | | --- | --- | --- | --- | | [love.mousemoved](love.mousemoved "love.mousemoved") | Callback function triggered when the mouse is moved. | 0.9.2 | | | [love.mousepressed](love.mousepressed "love.mousepressed") | Callback function triggered when a mouse button is pressed. | | | | [love.mousereleased](love.mousereleased "love.mousereleased") | Callback function triggered when a mouse button is released. | | | | [love.wheelmoved](love.wheelmoved "love.wheelmoved") | Callback function triggered when the mouse wheel is moved. | 0.10.0 | | ### Joystick | | | | | | --- | --- | --- | --- | | [love.gamepadaxis](love.gamepadaxis "love.gamepadaxis") | Called when a Joystick's virtual gamepad axis is moved. | 0.9.0 | | | [love.gamepadpressed](love.gamepadpressed "love.gamepadpressed") | Called when a Joystick's virtual gamepad button is pressed. | 0.9.0 | | | [love.gamepadreleased](love.gamepadreleased "love.gamepadreleased") | Called when a Joystick's virtual gamepad button is released. | 0.9.0 | | | [love.joystickadded](love.joystickadded "love.joystickadded") | Called when a [Joystick](joystick "Joystick") is connected. | 0.9.0 | | | [love.joystickaxis](love.joystickaxis "love.joystickaxis") | Called when a joystick axis moves. | 0.9.0 | | | [love.joystickhat](love.joystickhat "love.joystickhat") | Called when a joystick hat direction changes. | 0.9.0 | | | [love.joystickpressed](love.joystickpressed "love.joystickpressed") | Called when a joystick button is pressed. | | | | [love.joystickreleased](love.joystickreleased "love.joystickreleased") | Called when a joystick button is released. | | | | [love.joystickremoved](love.joystickremoved "love.joystickremoved") | Called when a [Joystick](joystick "Joystick") is disconnected. | 0.9.0 | | ### Touch | | | | | | --- | --- | --- | --- | | [love.touchmoved](love.touchmoved "love.touchmoved") | Callback function triggered when a touch press moves inside the touch screen. | 0.10.0 | | | [love.touchpressed](love.touchpressed "love.touchpressed") | Callback function triggered when the touch screen is touched. | 0.10.0 | | | [love.touchreleased](love.touchreleased "love.touchreleased") | Callback function triggered when the touch screen stops being touched. | 0.10.0 | |
programming_docs
love Canvas:setWrap Canvas:setWrap ============== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been renamed from [Framebuffer:setWrap](framebuffer-setwrap "Framebuffer:setWrap"). Sets the wrapping properties of a Canvas. This function sets the way the edges of a Canvas are treated if it is scaled or rotated. If the WrapMode is set to 'clamp', the edge will not be interpolated. If set to 'repeat', the edge will be interpolated with the pixels on the opposing side of the framebuffer. Function -------- ### Synopsis ``` Canvas:setWrap( horiz, vert ) ``` ### Arguments `[WrapMode](wrapmode "WrapMode") horiz` Horizontal wrapping mode of the Canvas. `[WrapMode](wrapmode "WrapMode") vert` Vertical wrapping mode of the Canvas. ### Returns Nothing. See Also -------- * [Canvas](canvas "Canvas") * [Canvas:getWrap](canvas-getwrap "Canvas:getWrap") * [WrapMode](wrapmode "WrapMode") love love.filesystem.unmount love.filesystem.unmount ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Unmounts a zip file or folder previously mounted for reading with [love.filesystem.mount](love.filesystem.mount "love.filesystem.mount"). Function -------- ### Synopsis ``` success = love.filesystem.unmount( archive ) ``` ### Arguments `[string](string "string") archive` The folder or zip file in the game's save directory which is currently mounted. ### Returns `[boolean](boolean "boolean") success` True if the archive was successfully unmounted, false otherwise. Examples -------- ### Mount a zip file and then unmount it. ``` -- Assuming content.zip exists in the game's save directory and contains a file called 'myimage.png'. love.filesystem.mount("content.zip", "content") assert(love.filesystem.getInfo("content/myimage.png"))   love.filesystem.unmount("content.zip") assert(not love.filesystem.getInfo("content/myimage.png")) ``` See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [love.filesystem.mount](love.filesystem.mount "love.filesystem.mount") love love.graphics.transformPoint love.graphics.transformPoint ============================ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. 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](transform-transformpoint "Transform:transformPoint") method exists for [Transform](transform "Transform") objects. Function -------- ### Synopsis ``` screenX, screenY = love.graphics.transformPoint( globalX, globalY ) ``` ### Arguments `[number](number "number") globalX` The x component of the position in global coordinates. `[number](number "number") globalY` The y component of the position in global coordinates. ### Returns `[number](number "number") screenX` The x component of the position with graphics transformations applied. `[number](number "number") screenY` The y component of the position with graphics transformations applied. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.inverseTransformPoint](love.graphics.inversetransformpoint "love.graphics.inverseTransformPoint") * [Transform](transform "Transform") love WeldJoint:getDampingRatio WeldJoint:getDampingRatio ========================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the damping ratio of the joint. Function -------- ### Synopsis ``` ratio = WeldJoint:getDampingRatio( ) ``` ### Arguments None. ### Returns `[number](number "number") ratio` The damping ratio. See Also -------- * [WeldJoint](weldjoint "WeldJoint") * [WeldJoint:setDampingRatio](weldjoint-setdampingratio "WeldJoint:setDampingRatio") love love.graphics.setWireframe love.graphics.setWireframe ========================== **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. Sets whether wireframe lines will be used when drawing. This function does nothing on mobile devices and other systems which use OpenGL ES 2. Wireframe mode should only be used for debugging. The lines drawn with it enabled do not behave like regular love.graphics lines: their widths don't scale with the coordinate transformations or with [love.graphics.setLineWidth](love.graphics.setlinewidth "love.graphics.setLineWidth"), and they don't use the smooth LineStyle. Function -------- ### Synopsis ``` love.graphics.setWireframe( enable ) ``` ### Arguments `[boolean](boolean "boolean") enable` True to enable wireframe mode when drawing, false to disable it. ### Returns Nothing. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.isWireframe](love.graphics.iswireframe "love.graphics.isWireframe") love Audio Formats Audio Formats ============= As of LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1"), the following audio formats are supported: * Waveform Audio File Format (.wav) * MPEG-1 or MPEG-2 Audio Layer III (.mp3) * Ogg Vorbis (.ogg, .oga, .ogv) * Tracker module formats (.699, .amf, .ams, .dbm, .dmf, .dsm, .far, .it, .j2b, .mdl, .med, .mod, .mt2, .mtm, .okt, .psm, .s3m, .stm, .ult, .umx, .xm) * Other formats supported by libmodplug, without instrument data (.abc, .mid, .pat) * Free Lossless Audio Codec (.flac) See Also -------- * [love.audio](love.audio "love.audio") * [love.sound](love.sound "love.sound") love Source:getVolumeLimits Source:getVolumeLimits ====================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Returns the volume limits of the source. Function -------- ### Synopsis ``` min, max = Source:getVolumeLimits( ) ``` ### Arguments None. ### Returns `[number](number "number") min` The minimum volume. `[number](number "number") max` The maximum volume. See Also -------- * [Source](source "Source") love function function ======== [Functions in lua](https://www.lua.org/manual/5.1/manual.html#2.5.8). ``` function foo() end ``` love ImageEncodeFormat ImageEncodeFormat ================= Image file formats supported by [ImageData:encode](imagedata-encode "ImageData:encode"). Constants --------- tga Targa image format. png Available since 0.8.0 PNG image format. jpg Available since 0.8.0 and removed in LÖVE 0.10.0 JPG image format. bmp Available since 0.8.0 and removed in LÖVE 0.10.0 BMP image format. See Also -------- * [love.image](love.image "love.image") * [ImageData](imagedata "ImageData") * [ImageData:encode](imagedata-encode "ImageData:encode") love ParticleSystem:setBufferSize ParticleSystem:setBufferSize ============================ Sets the size of the buffer (the max allowed amount of particles in the system). Function -------- ### Synopsis ``` ParticleSystem:setBufferSize( size ) ``` ### Arguments `[number](number "number") size` The buffer size. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love love.thread.getThread love.thread.getThread ===================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier or later versions. Look for a thread and get its object. Function -------- ### Synopsis ``` thread = love.thread.getThread( name ) ``` ### Arguments `[string](string "string") name` The name of the thread to return. ### Returns `[Thread](thread "Thread") thread` The thread with that name. Function -------- ### Synopsis ``` thread = love.thread.getThread( ) ``` ### Arguments None. ### Returns `[Thread](thread "Thread") thread` The current thread. See Also -------- * [love.thread](love.thread "love.thread") love ParticleInsertMode ParticleInsertMode ================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This enum is not supported in earlier versions. How newly created particles are added to the ParticleSystem. Constants --------- top Particles are inserted at the top of the ParticleSystem's list of particles. bottom Particles are inserted at the bottom of the ParticleSystem's list of particles. random Particles are inserted at random positions in the ParticleSystem's list of particles. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setInsertMode](particlesystem-setinsertmode "ParticleSystem:setInsertMode") * [ParticleSystem:getInsertMode](particlesystem-getinsertmode "ParticleSystem:getInsertMode") love CompressedImageData:getHeight CompressedImageData:getHeight ============================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the height of the CompressedImageData. Function -------- ### Synopsis ``` height = CompressedImageData:getHeight( ) ``` ### Arguments None. ### Returns `[number](number "number") height` The height of the CompressedImageData. Function -------- ### Synopsis ``` height = CompressedImageData:getHeight( level ) ``` ### Arguments `[number](number "number") level` A mipmap level. Must be in the range of [1, [CompressedImageData:getMipmapCount()](compressedimagedata-getmipmapcount "CompressedImageData:getMipmapCount")]. ### Returns `[number](number "number") height` The height of a specific mipmap level of the CompressedImageData. See Also -------- * [CompressedImageData](compressedimagedata "CompressedImageData") * [CompressedImageData:getWidth](compressedimagedata-getwidth "CompressedImageData:getWidth") * [CompressedImageData:getMipmapCount](compressedimagedata-getmipmapcount "CompressedImageData:getMipmapCount") love Body:isSleeping Body:isSleeping =============== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in that and later versions. Get the sleeping status of a body. A sleeping body is much more efficient to simulate than when awake. If sleeping is allowed, a body that has come to rest will sleep. Function -------- ### Synopsis ``` status = Body:isSleeping( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") status` The sleeping status of the body. See Also -------- * [Body](body "Body") love Source:getAirAbsorption Source:getAirAbsorption ======================= **Available since LÖVE [11.2](https://love2d.org/wiki/11.2 "11.2")** This function is not supported in earlier versions. Gets the amount of air absorption applied to the Source. By default the value is set to 0 which means that air absorption effects are disabled. A value of 1 will apply high frequency attenuation to the Source at a rate of 0.05 dB per meter. Function -------- ### Synopsis ``` amount = Source:getAirAbsorption( ) ``` ### Arguments None. ### Returns `[number](number "number") amount` The amount of air absorption applied to the Source. Notes ----- Audio air absorption functionality is not supported on iOS. See Also -------- * [Source](source "Source") * [Source:setAirAbsorption](source-setairabsorption "Source:setAirAbsorption") love ParticleSystem:setSpin ParticleSystem:setSpin ====================== Sets the spin of the sprite. Function -------- ### Synopsis ``` ParticleSystem:setSpin( min, max ) ``` ### Arguments `[number](number "number") min` The minimum spin (radians per second). `[number](number "number") max (min)` The maximum spin (radians per second). ### Returns Nothing. Function -------- **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** Use [ParticleSystem:setSpinVariation](particlesystem-setspinvariation "ParticleSystem:setSpinVariation") instead. ### Synopsis ``` ParticleSystem:setSpin( min, max, variation ) ``` ### Arguments `[number](number "number") min` The minimum spin (radians per second). `[number](number "number") max (min)` The maximum spin (radians per second). `[number](number "number") variation (0)` The degree of variation (0 meaning no variation and 1 meaning full variation between start and end). ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love Mesh:getDrawMode Mesh:getDrawMode ================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the mode used when drawing the Mesh. Function -------- ### Synopsis ``` mode = Mesh:getDrawMode( ) ``` ### Arguments None. ### Returns `[MeshDrawMode](meshdrawmode "MeshDrawMode") mode` The mode used when drawing the Mesh. See Also -------- * [Mesh](mesh "Mesh") * [love.graphics.newMesh](love.graphics.newmesh "love.graphics.newMesh") love Source:setFilter Source:setFilter ================ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Sets a low-pass, high-pass, or band-pass filter to apply when playing the Source. Function -------- ### Synopsis ``` success = Source:setFilter( settings ) ``` ### Arguments `[table](table "table") settings` The filter settings to use for this Source, with the following fields: `[FilterType](filtertype "FilterType") type` The type of filter to use. `[number](number "number") volume` The overall volume of the audio. Must be between 0 and 1. `[number](number "number") highgain` Volume of high-frequency audio. Only applies to low-pass and band-pass filters. Must be between 0 and 1. `[number](number "number") lowgain` Volume of low-frequency audio. Only applies to high-pass and band-pass filters. Must be between 0 and 1. ### Returns `[boolean](boolean "boolean") success` Whether the filter was successfully applied to the Source. Function -------- Disables filtering on this Source. ### Synopsis ``` Source:setFilter( ) ``` ### Arguments None. ### Returns Nothing. Examples -------- ### Playing music at half volume with a low pass filter applied ``` function love.load() local source = love.audio.newSource('music.ogg', 'stream') source:setFilter { type = 'lowpass', volume = .5, highgain = .4, } source:play() end ``` Notes ----- Audio filter functionality is not supported on iOS. While the cutoff frequency cannot be set directly, changing high/lowgain has the effect of altering the cutoff. See it explained in [this thread](https://github.com/kcat/openal-soft/issues/164). See Also -------- * [Source](source "Source") * [Source:getFilter](source-getfilter "Source:getFilter") * [Source:setEffect](source-seteffect "Source:setEffect") love (File):setBuffer (File):setBuffer ================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Sets the buffer mode for a file opened for writing or appending. Files with buffering enabled will not write data to the disk until the buffer size limit is reached, depending on the buffer mode. [File:flush]((file)-flush "(File):flush") will force any buffered data to be written to the disk. Function -------- ### Synopsis ``` success, errorstr = File:setBuffer( mode, size ) ``` ### Arguments `[BufferMode](buffermode "BufferMode") mode` The buffer mode to use. `[number](number "number") size (0)` The maximum size in bytes of the file's buffer. ### Returns `[boolean](boolean "boolean") success` Whether the buffer mode was successfully set. `[string](string "string") errorstr (nil)` The error string, if the buffer mode could not be set and an error occurred. See Also -------- * [File](file "File") * [File:getBuffer]((file)-getbuffer "(File):getBuffer") * [File:write]((file)-write "(File):write") * [File:flush]((file)-flush "(File):flush") love Body:putToSleep Body:putToSleep =============== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in that and later versions. Put the body to sleep. A sleeping body is much more efficient to simulate than when awake. The body will wake up if another body collides with it, if a joint or contact attached to it is destroyed, or if [Body:wakeUp](body-wakeup "Body:wakeUp") is called. Function -------- ### Synopsis ``` Body:putToSleep( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Body](body "Body") love Source:setVelocity Source:setVelocity ================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. Sets the velocity of the Source. This does **not** change the position of the Source, but lets the application know how it has to calculate the doppler effect. Function -------- ### Synopsis ``` Source:setVelocity( x, y, z ) ``` ### Arguments `[number](number "number") x` The X part of the velocity vector. `[number](number "number") y` The Y part of the velocity vector. `[number](number "number") z` The Z part of the velocity vector. ### Returns Nothing. See Also -------- * [Source](source "Source") love SpriteBatch:unbind SpriteBatch:unbind ================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been renamed from [SpriteBatch:unlock](spritebatch-unlock "SpriteBatch:unlock"). | | | --- | | ***Deprecated in LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")*** | | It happens automatically since this version. | **Removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in that and later versions. Unbinds the [SpriteBatch](spritebatch "SpriteBatch"). All [SpriteBatch:bind](spritebatch-bind "SpriteBatch:bind") calls should have a matching *SpriteBatch:unbind* after the batch has been updated. Function -------- ### Synopsis ``` SpriteBatch:unbind( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [SpriteBatch](spritebatch "SpriteBatch") * [SpriteBatch:bind](spritebatch-bind "SpriteBatch:bind") love ParticleSystem:getOffset ParticleSystem:getOffset ======================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been moved from [ParticleSystem:getOffsetX](particlesystem-getoffsetx "ParticleSystem:getOffsetX") and [ParticleSystem:getOffsetY](particlesystem-getoffsety "ParticleSystem:getOffsetY"). Gets the particle image's draw offset. Function -------- ### Synopsis ``` ox, oy = ParticleSystem:getOffset( ) ``` ### Arguments None. ### Returns `[number](number "number") ox` The x coordinate of the particle image's draw offset. `[number](number "number") oy` The y coordinate of the particle image's draw offset. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setOffset](particlesystem-setoffset "ParticleSystem:setOffset") love Cursor Cursor ====== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This type is not supported in earlier versions. Represents a hardware cursor. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.mouse.getSystemCursor](love.mouse.getsystemcursor "love.mouse.getSystemCursor") | Gets a **Cursor** object representing a system-native hardware cursor. | 0.9.0 | | | [love.mouse.newCursor](love.mouse.newcursor "love.mouse.newCursor") | Creates a new hardware **Cursor** object from an image. | 0.9.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Cursor:getType](cursor-gettype "Cursor:getType") | Gets the type of the Cursor. | 0.9.0 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Enums ----- | | | | | | --- | --- | --- | --- | | [CursorType](cursortype "CursorType") | Types of hardware cursors. | 0.9.0 | | Supertypes ---------- * [Object](object "Object") See Also -------- * [love.mouse](love.mouse "love.mouse") * [love.mouse.setCursor](love.mouse.setcursor "love.mouse.setCursor") * [love.mouse.getCursor](love.mouse.getcursor "love.mouse.getCursor")
programming_docs
love MotorJoint:setAngularOffset MotorJoint:setAngularOffset =========================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This method is not supported in earlier versions. Sets the target angluar offset between the two Bodies the Joint is attached to. Function -------- ### Synopsis ``` MotorJoint:setAngularOffset( angleoffset ) ``` ### Arguments `[number](number "number") angleoffset` The target angular offset in radians: the second body's angle minus the first body's angle. ### Returns Nothing. See Also -------- * [MotorJoint](motorjoint "MotorJoint") * [MotorJoint:getAngularOffset](motorjoint-getangularoffset "MotorJoint:getAngularOffset") love ParticleSystem:setParticleLifetime ParticleSystem:setParticleLifetime ================================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [ParticleSystem:setParticleLife](particlesystem-setparticlelife "ParticleSystem:setParticleLife"). Sets the lifetime of the particles. Function -------- ### Synopsis ``` ParticleSystem:setParticleLifetime( min, max ) ``` ### Arguments `[number](number "number") min` The minimum life of the particles (in seconds). `[number](number "number") max (min)` The maximum life of the particles (in seconds). ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love CircleShape:getRadius CircleShape:getRadius ===================== Gets the radius of the circle shape. Function -------- ### Synopsis ``` radius = CircleShape:getRadius( ) ``` ### Arguments None. ### Returns `[number](number "number") radius` The radius of the circle See Also -------- * [CircleShape](circleshape "CircleShape") love Shape:setDensity Shape:setDensity ================ **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in that and later versions. Sets the density of a Shape. Do this before calling [Body:setMassFromShapes](body-setmassfromshapes "Body:setMassFromShapes"). Function -------- ### Synopsis ``` Shape:setDensity( density ) ``` ### Arguments `[number](number "number") density` The new density of the Shape. ### Returns Nothing. See Also -------- * [Shape](shape "Shape") love love.filesystem.getRealDirectory love.filesystem.getRealDirectory ================================ **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Gets the platform-specific absolute path of the directory containing a filepath. This can be used to determine whether a file is inside the save directory or the game's source .love. Function -------- ### Synopsis ``` realdir = love.filesystem.getRealDirectory( filepath ) ``` ### Arguments `[string](string "string") filepath` The filepath to get the directory of. ### Returns `[string](string "string") realdir` The platform-specific full path of the directory containing the filepath. Notes ----- This function returns the directory containing the given *file path*, rather than file. For example, if the file `screenshot1.png` exists in a directory called `screenshots` in the game's save directory, `love.filesystem.getRealDirectory("screenshots/screenshot1.png")` will return the same value as [love.filesystem.getSaveDirectory](love.filesystem.getsavedirectory "love.filesystem.getSaveDirectory"). Examples -------- ``` -- Get all files in the "levels" folder. -- There might be a "levels" folder in both the save directory and the game's source, -- in which case this will get all files in both. local filepaths = love.filesystem.getDirectoryItems("levels")   for i, filename in ipairs(filepaths) do -- For each filename, check whether it's in the save directory or not. local path = "levels/"..filename if love.filesystem.getRealDirectory(path) == love.filesystem.getSaveDirectory() then -- This file is in the save directory. end end ``` See Also -------- * [love.filesystem](love.filesystem "love.filesystem") love love.graphics.newMesh love.graphics.newMesh ===================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Creates a new [Mesh](mesh "Mesh"). Use [Mesh:setTexture](mesh-settexture "Mesh:setTexture") if the Mesh should be textured with an [Image](image "Image") or [Canvas](canvas "Canvas") when it's drawn. In versions prior to [11.0](https://love2d.org/wiki/11.0 "11.0"), color and byte component values were within the range of 0 to 255 instead of 0 to 1. This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. Creates a standard Mesh with the specified vertices. ### Synopsis ``` mesh = love.graphics.newMesh( vertices, mode, usage ) ``` ### Arguments `[table](table "table") vertices` The table filled with vertex information tables for each vertex as follows: `[number](number "number") [1]` The position of the vertex on the x-axis. `[number](number "number") [2]` The position of the vertex on the y-axis. `[number](number "number") [3] (0)` The u texture coordinate of the vertex. Texture coordinates are normally in the range of [0, 1], but can be greater or less (see [WrapMode](wrapmode "WrapMode").) `[number](number "number") [4] (0)` The v texture coordinate of the vertex. Texture coordinates are normally in the range of [0, 1], but can be greater or less (see [WrapMode](wrapmode "WrapMode").) `[number](number "number") [5] (1)` The red component of the vertex color. `[number](number "number") [6] (1)` The green component of the vertex color. `[number](number "number") [7] (1)` The blue component of the vertex color. `[number](number "number") [8] (1)` The alpha component of the vertex color. `[MeshDrawMode](meshdrawmode "MeshDrawMode") mode ("fan")` How the vertices are used when drawing. The default mode "fan" is sufficient for simple convex polygons. `[SpriteBatchUsage](spritebatchusage "SpriteBatchUsage") usage ("dynamic")` The expected usage of the Mesh. The specified usage mode affects the Mesh's memory usage and performance. ### Returns `[Mesh](mesh "Mesh") mesh` The new mesh. Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. Creates a standard Mesh with the specified number of vertices. ### Synopsis ``` mesh = love.graphics.newMesh( vertexcount, mode, usage ) ``` ### Arguments `[number](number "number") vertexcount` The total number of vertices the Mesh will use. Each vertex is initialized to `{0,0, 0,0, 1,1,1,1}`. `[MeshDrawMode](meshdrawmode "MeshDrawMode") mode ("fan")` How the vertices are used when drawing. The default mode "fan" is sufficient for simple convex polygons. `[SpriteBatchUsage](spritebatchusage "SpriteBatchUsage") usage ("dynamic")` The expected usage of the Mesh. The specified usage mode affects the Mesh's memory usage and performance. ### Returns `[Mesh](mesh "Mesh") mesh` The new mesh. ### Notes [Mesh:setVertices](mesh-setvertices "Mesh:setVertices") or [Mesh:setVertex](mesh-setvertex "Mesh:setVertex") and [Mesh:setDrawRange](mesh-setdrawrange "Mesh:setDrawRange") can be used to specify vertex information once the Mesh is created. Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. Creates a Mesh with custom vertex attributes and the specified vertex data. ### Synopsis ``` mesh = love.graphics.newMesh( vertexformat, vertices, mode, usage ) ``` ### Arguments `[table](table "table") vertexformat` A table in the form of `{attribute, ...}`. Each attribute is a table which specifies a custom vertex attribute used for each vertex. `[table](table "table") attribute` A table containing the attribute's name, it's [data type](attributedatatype "AttributeDataType"), and the number of components in the attribute, in the form of `{name, datatype, components}`. `[table](table "table") ...` Additional vertex attribute format tables. `[table](table "table") vertices` The table filled with vertex information tables for each vertex, in the form of `{vertex, ...}` where each vertex is a table in the form of `{attributecomponent, ...}`. `[number](number "number") attributecomponent` The first component of the first vertex attribute in the vertex. `[number](number "number") ...` Additional components of all vertex attributes in the vertex. `[MeshDrawMode](meshdrawmode "MeshDrawMode") mode ("fan")` How the vertices are used when drawing. The default mode "fan" is sufficient for simple convex polygons. `[SpriteBatchUsage](spritebatchusage "SpriteBatchUsage") usage ("dynamic")` The expected usage of the Mesh. The specified usage mode affects the Mesh's memory usage and performance. ### Returns `[Mesh](mesh "Mesh") mesh` The new mesh. ### Notes The values in each vertex table are in the same order as the vertex attributes in the specified vertex format. If no value is supplied for a specific vertex attribute component, it will be set to a default value of 0 if its [data type](attributedatatype "AttributeDataType") is "float", or 1 if its data type is "byte". If the data type of an attribute is "float", components can be in the range 1 to 4, if the data type is "byte" it must be 4. If a custom vertex attribute uses the name "VertexPosition", "VertexTexCoord", or "VertexColor", then the vertex data for that vertex attribute will be used for the standard vertex positions, texture coordinates, or vertex colors respectively, when drawing the Mesh. Otherwise a [Vertex Shader](shader "Shader") is required in order to make use of the vertex attribute when the Mesh is drawn. A Mesh **must** have a "VertexPosition" attribute in order to be drawn, but it can be attached from a different Mesh via [Mesh:attachAttribute](mesh-attachattribute "Mesh:attachAttribute"). To use a custom named vertex attribute in a Vertex Shader, it must be declared as an `attribute` variable of the same name. Variables can be sent from Vertex Shader code to Pixel Shader code by making a `varying` variable. For example: *Vertex Shader code* ``` attribute vec2 CoolVertexAttribute;   varying vec2 CoolVariable;   vec4 position(mat4 transform_projection, vec4 vertex_position) { CoolVariable = CoolVertexAttribute; return transform_projection * vertex_position; } ``` *Pixel Shader code* ``` varying vec2 CoolVariable;   vec4 effect(vec4 color, Image tex, vec2 texcoord, vec2 pixcoord) { vec4 texcolor = Texel(tex, texcoord + CoolVariable); return texcolor * color; } ``` Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier versions. Creates a Mesh with custom vertex attributes and the specified number of vertices. ### Synopsis ``` mesh = love.graphics.newMesh( vertexformat, vertexcount, mode, usage ) ``` ### Arguments `[table](table "table") vertexformat` A table in the form of `{attribute, ...}`. Each attribute is a table which specifies a custom vertex attribute used for each vertex. `[table](table "table") attribute` A table containing the attribute's name, it's [data type](attributedatatype "AttributeDataType"), and the number of components in the attribute, in the form of `{name, datatype, components}`. `[table](table "table") ...` Additional vertex attribute format tables. `[number](number "number") vertexcount` The total number of vertices the Mesh will use. `[MeshDrawMode](meshdrawmode "MeshDrawMode") mode ("fan")` How the vertices are used when drawing. The default mode "fan" is sufficient for simple convex polygons. `[SpriteBatchUsage](spritebatchusage "SpriteBatchUsage") usage ("dynamic")` The expected usage of the Mesh. The specified usage mode affects the Mesh's memory usage and performance. ### Returns `[Mesh](mesh "Mesh") mesh` The new mesh. ### Notes Each vertex attribute component is initialized to 0 if its data type is "float", or 1 if its data type is "byte". [Mesh:setVertices](mesh-setvertices "Mesh:setVertices") or [Mesh:setVertex](mesh-setvertex "Mesh:setVertex") and [Mesh:setDrawRange](mesh-setdrawrange "Mesh:setDrawRange") can be used to specify vertex information once the Mesh is created. If the data type of an attribute is "float", components can be in the range 1 to 4, if the data type is "byte" it must be 4. If a custom vertex attribute uses the name "VertexPosition", "VertexTexCoord", or "VertexColor", then the vertex data for that vertex attribute will be used for the standard vertex positions, texture coordinates, or vertex colors respectively, when drawing the Mesh. Otherwise a [Vertex Shader](shader "Shader") is required in order to make use of the vertex attribute when the Mesh is drawn. A Mesh **must** have a "VertexPosition" attribute in order to be drawn, but it can be attached from a different Mesh via [Mesh:attachAttribute](mesh-attachattribute "Mesh:attachAttribute"). Function -------- **Removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in that and later versions. ### Synopsis ``` mesh = love.graphics.newMesh( vertices, texture, mode ) ``` ### Arguments `[table](table "table") vertices` The table filled with vertex information tables for each vertex as follows: `[number](number "number") [1]` The position of the vertex on the x-axis. `[number](number "number") [2]` The position of the vertex on the y-axis. `[number](number "number") [3]` The u texture coordinate. Texture coordinates are normally in the range of [0, 1], but can be greater or less (see [WrapMode](wrapmode "WrapMode").) `[number](number "number") [4]` The v texture coordinate. Texture coordinates are normally in the range of [0, 1], but can be greater or less (see [WrapMode](wrapmode "WrapMode").) `[number](number "number") [5] (255)` The red color component. `[number](number "number") [6] (255)` The green color component. `[number](number "number") [7] (255)` The blue color component. `[number](number "number") [8] (255)` The alpha color component. `[Texture](texture "Texture") texture (nil)` The [Image](image "Image") or [Canvas](canvas "Canvas") to use when drawing the Mesh. May be nil to use no texture. `[MeshDrawMode](meshdrawmode "MeshDrawMode") mode ("fan")` How the vertices are used when drawing. The default mode "fan" is sufficient for simple convex polygons. ### Returns `[Mesh](mesh "Mesh") mesh` The new mesh. Function -------- **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1") and removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This variant is not supported in earlier or later versions. ### Synopsis ``` mesh = love.graphics.newMesh( vertexcount, texture, mode ) ``` ### Arguments `[number](number "number") vertexcount` The total number of vertices the Mesh will use. Each vertex is initialized to `{0,0, 0,0, 255,255,255,255}`. `[Texture](texture "Texture") texture (nil)` The [Image](image "Image") or [Canvas](canvas "Canvas") to use when drawing the Mesh. May be nil to use no texture. `[MeshDrawMode](meshdrawmode "MeshDrawMode") mode ("fan")` How the vertices are used when drawing. The default mode "fan" is sufficient for simple convex polygons. ### Returns `[Mesh](mesh "Mesh") mesh` The new mesh. ### Notes [Mesh:setVertices](mesh-setvertices "Mesh:setVertices") or [Mesh:setVertex](mesh-setvertex "Mesh:setVertex") and [Mesh:setDrawRange](mesh-setdrawrange "Mesh:setDrawRange") can be used to specify vertex information once the Mesh is created. Examples -------- ### Creates and draws a Mesh identical to a normal drawn image but with different colors at each corner ``` function love.load() image = love.graphics.newImage("pig.png")   local vertices = { { -- top-left corner (red-tinted) 0, 0, -- position of the vertex 0, 0, -- texture coordinate at the vertex position 1, 0, 0, -- color of the vertex }, { -- top-right corner (green-tinted) image:getWidth(), 0, 1, 0, -- texture coordinates are in the range of [0, 1] 0, 1, 0 }, { -- bottom-right corner (blue-tinted) image:getWidth(), image:getHeight(), 1, 1, 0, 0, 1 }, { -- bottom-left corner (yellow-tinted) 0, image:getHeight(), 0, 1, 1, 1, 0 }, }   -- the Mesh DrawMode "fan" works well for 4-vertex Meshes. mesh = love.graphics.newMesh(vertices, "fan") mesh:setTexture(image) end   function love.draw() love.graphics.draw(mesh, 0, 0) end ``` ### Creates and draws a textured circle with a red tint at the center. ``` function CreateTexturedCircle(image, segments) segments = segments or 40 local vertices = {}   -- The first vertex is at the center, and has a red tint. We're centering the circle around the origin (0, 0). table.insert(vertices, {0, 0, 0.5, 0.5, 255, 0, 0})   -- Create the vertices at the edge of the circle. for i=0, segments do local angle = (i / segments) * math.pi * 2   -- Unit-circle. local x = math.cos(angle) local y = math.sin(angle)   -- Our position is in the range of [-1, 1] but we want the texture coordinate to be in the range of [0, 1]. local u = (x + 1) * 0.5 local v = (y + 1) * 0.5   -- The per-vertex color defaults to white. table.insert(vertices, {x, y, u, v}) end   -- The "fan" draw mode is perfect for our circle. local mesh = love.graphics.newMesh(vertices, "fan") mesh:setTexture(image)   return mesh end   function love.load() image = love.graphics.newImage("pig.png") mesh = CreateTexturedCircle(image) end   function love.draw() local radius = 100 local mx, my = love.mouse.getPosition()   -- We created a unit-circle, so we can use the scale parameter for the radius directly. love.graphics.draw(mesh, mx, my, 0, radius, radius) end ``` ### Creates a circle and draws it more efficiently than love.graphics.circle. ``` function CreateCircle(segments) segments = segments or 40 local vertices = {}   -- The first vertex is at the origin (0, 0) and will be the center of the circle. table.insert(vertices, {0, 0})   -- Create the vertices at the edge of the circle. for i=0, segments do local angle = (i / segments) * math.pi * 2   -- Unit-circle. local x = math.cos(angle) local y = math.sin(angle)   table.insert(vertices, {x, y}) end   -- The "fan" draw mode is perfect for our circle. return love.graphics.newMesh(vertices, "fan") end   function love.load() mesh = CreateCircle() end   function love.draw() local radius = 100 local mx, my = love.mouse.getPosition()   -- We created a unit-circle, so we can use the scale parameter for the radius directly. love.graphics.draw(mesh, mx, my, 0, radius, radius) end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [Mesh](mesh "Mesh") love love.math.randomNormal love.math.randomNormal ====================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Get a normally distributed pseudo random number. Function -------- ### Synopsis ``` number = love.math.randomNormal( stddev, mean ) ``` ### Arguments `[number](number "number") stddev (1)` Standard deviation of the distribution. `[number](number "number") mean (0)` The mean of the distribution. ### Returns `[number](number "number") number` Normally distributed random number with variance (stddev)² and the specified mean. See Also -------- * [love.math](love.math "love.math")
programming_docs
love SpriteBatch:setImage SpriteBatch:setImage ==================== **Available since LÖVE [0.7.2](https://love2d.org/wiki/0.7.2 "0.7.2")** This method is not supported in earlier versions. **Removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** Use [SpriteBatch:setTexture](spritebatch-settexture "SpriteBatch:setTexture") instead. Replaces the image used for the sprites. Function -------- ### Synopsis ``` SpriteBatch:setImage( image ) ``` ### Arguments `[Image](image "Image") image` The new Image to use for the sprites. ### Returns Nothing. See Also -------- * [SpriteBatch](spritebatch "SpriteBatch") * [SpriteBatch:getImage](spritebatch-getimage "SpriteBatch:getImage") love ParticleSystem:setSpeed ParticleSystem:setSpeed ======================= Sets the speed of the particles. Function -------- ### Synopsis ``` ParticleSystem:setSpeed( min, max ) ``` ### Arguments `[number](number "number") min` The minimum linear speed of the particles. `[number](number "number") max (min)` The maximum linear speed of the particles. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love Joint:destroy Joint:destroy ============= Explicitly destroys the Joint. An error will occur if you attempt to use the object after calling this function. In 0.7.2, when you don't have time to wait for garbage collection, this function may be used to free the object immediately. Function -------- ### Synopsis ``` Joint:destroy( ) ``` ### Arguments None. ### Returns Nothing. See Also -------- * [Joint](joint "Joint") love Texture:getHeight Texture:getHeight ================= Gets the height of the Texture. Function -------- ### Synopsis ``` height = Texture:getHeight( ) ``` ### Arguments None. ### Returns `[number](number "number") height` The height of the Texture, in pixels. See Also -------- * [Texture](texture "Texture") * [Texture:getWidth](texture-getwidth "Texture:getWidth") * [Texture:getDimensions](texture-getdimensions "Texture:getDimensions") love love.window.setVSync love.window.setVSync ==================== **Available since LÖVE [11.3](https://love2d.org/wiki/11.3 "11.3")** This function is not supported in earlier versions. Sets vertical synchronization mode. Function -------- ### Synopsis ``` love.window.setVSync( vsync ) ``` ### Arguments `[number](number "number") vsync` VSync number: 1 to enable, 0 to disable, and -1 for adaptive vsync. ### Returns Nothing. Notes ----- * Not all graphics drivers support adaptive vsync (-1 value) and values more than 1 (vsync at other intervals). In that case, it will be automatically set to 1. * It is recommended to keep vsync activated if you don't know about the possible implications of turning it off. * This function doesn't recreate the window, unlike [love.window.setMode](love.window.setmode "love.window.setMode") and [love.window.updateMode](love.window.updatemode "love.window.updateMode"). See Also -------- * [love.window](love.window "love.window") * [love.window.getVSync](love.window.getvsync "love.window.getVSync") love KeyConstant KeyConstant =========== All the keys you can press. Note that some keys may not be available on your keyboard or system. Constants --------- | Key string | Description | Note(s) | | --- | --- | --- | | Character keys | | a | The A key | | | b | The B key | | | c | The C key | | | d | The D key | | | e | The E key | | | f | The F key | | | g | The G key | | | h | The H key | | | i | The I key | | | j | The J key | | | k | The K key | | | l | The L key | | | m | The M key | | | n | The N key | | | o | The O key | | | p | The P key | | | q | The Q key | | | r | The R key | | | s | The S key | | | t | The T key | | | u | The U key | | | v | The V key | | | w | The W key | | | x | The X key | | | y | The Y key | | | z | The Z key | | | 0 | The zero key | | | 1 | The one key | | | 2 | The two key | | | 3 | The three key | | | 4 | The four key | | | 5 | The five key | | | 6 | The six key | | | 7 | The seven key | | | 8 | The eight key | | | 9 | The nine key | | | space | Space key | In version [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2") and earlier this is represented by the actual space character ' '. | | ! | Exclamation mark key | | | " | Double quote key | | | # | Hash key | | | $ | Dollar key | | | & | Ampersand key | | | ' | Single quote key | | | ( | Left parenthesis key | | | ) | Right parenthesis key | | | \* | Asterisk key | | | + | Plus key | | | , | Comma key | | | - | Hyphen-minus key | | | . | Full stop key | | | / | Slash key | | | : | Colon key | | | ; | Semicolon key | | | < | Less-than key | | | = | Equal key | | | > | Greater-than key | | | ? | Question mark key | | | @ | At sign key | | | [ | Left square bracket key | | | \ | Backslash key | | | ] | Right square bracket key | | | ^ | Caret key | | | \_ | Underscore key | | | ` | Grave accent key | Also known as the "Back tick" key | | Numpad keys | | kp0 | The numpad zero key | | | kp1 | The numpad one key | | | kp2 | The numpad two key | | | kp3 | The numpad three key | | | kp4 | The numpad four key | | | kp5 | The numpad five key | | | kp6 | The numpad six key | | | kp7 | The numpad seven key | | | kp8 | The numpad eight key | | | kp9 | The numpad nine key | | | kp. | The numpad decimal point key | | | kp, | The numpad comma key | | | kp/ | The numpad division key | | | kp\* | The numpad multiplication key | | | kp- | The numpad substraction key | | | kp+ | The numpad addition key | | | kpenter | The numpad enter key | | | kp= | The numpad equals key | | | Navigation keys | | up | Up arrow key | | | down | Down arrow key | | | right | Right arrow key | | | left | Left arrow key | | | home | Home key | | | end | End key | | | pageup | Page up key | | | pagedown | Page down key | | | Editing keys | | insert | Insert key | | | backspace | Backspace key | | | tab | Tab key | | | clear | Clear key | | | return | Return key | Also known as the Enter key | | delete | Delete key | | | Function keys | | f1 | The 1st function key | | | f2 | The 2nd function key | | | f3 | The 3rd function key | | | f4 | The 4th function key | | | f5 | The 5th function key | | | f6 | The 6th function key | | | f7 | The 7th function key | | | f8 | The 8th function key | | | f9 | The 9th function key | | | f10 | The 10th function key | | | f11 | The 11th function key | | | f12 | The 12th function key | | | f13 | The 13th function key | | | f14 | The 14th function key | | | f15 | The 15th function key | | | f16 | The 16th function key | | | f17 | The 17th function key | | | f18 | The 18th function key | | | Modifier keys | | numlock | Num-lock key | Clear on Mac keyboards. | | capslock | Caps-lock key | Caps-on is a key press. Caps-off is a key release. | | scrolllock | Scroll-lock key | | | rshift | Right shift key | | | lshift | Left shift key | | | rctrl | Right control key | | | lctrl | Left control key | | | ralt | Right alt key | | | lalt | Left alt key | | | rgui | Right gui key | Command key in OS X, Windows key in Windows. | | lgui | Left gui key | Command key in OS X, Windows key in Windows. | | mode | Mode key | | | Application keys | | www | WWW key | | | mail | Mail key | | | calculator | Calculator key | | | computer | Computer key | | | appsearch | Application search key | | | apphome | Application home key | | | appback | Application back key | | | appforward | Application forward key | | | apprefresh | Application refresh key | | | appbookmarks | Application bookmarks key | | | Miscellaneous keys | | pause | Pause key | Sends a key release immediately on some platforms, even if held down. | | escape | Escape key | | | help | Help key | | | printscreen | Printscreen key | Sends a key release immediately on Windows, even if held down. | | sysreq | System request key | | | menu | Menu key | | | application | Application key | Windows contextual menu, compose key. | | power | Power key | | | currencyunit | Currency unit key | e.g. the Euro (€) key. | | undo | Undo key | | Examples -------- Note how [love.keypressed](love.keypressed "love.keypressed") gives direct key presses, whereas [love.textinput](love.textinput "love.textinput") gives the text that key combinations produce. Let's take the "#" symbol as an example (assuming a U.S. keyboard): ``` function love.keypressed(key) print(key) end --> shift --> 3   function love.textinput(text) print(text) end --> # ``` See Also -------- * [love.keyboard](love.keyboard "love.keyboard") * [love.keypressed](love.keypressed "love.keypressed") * [love.keyreleased](love.keyreleased "love.keyreleased") * [love.keyboard.isDown](love.keyboard.isdown "love.keyboard.isDown") * [love.keyboard.getScancodeFromKey](love.keyboard.getscancodefromkey "love.keyboard.getScancodeFromKey") * [love.keyboard.getKeyFromScancode](love.keyboard.getkeyfromscancode "love.keyboard.getKeyFromScancode") love GearJoint:setRatio GearJoint:setRatio ================== Set the ratio of a [gear joint.](gearjoint "GearJoint") Function -------- ### Synopsis ``` GearJoint:setRatio( ratio ) ``` ### Arguments `[number](number "number") ratio` The new ratio of the joint. ### Returns Nothing. See Also -------- * [GearJoint](gearjoint "GearJoint") love ParticleSystem:setColors ParticleSystem:setColors ======================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has replaced [ParticleSystem:setColor](particlesystem-setcolor "ParticleSystem:setColor"). Sets a series of colors to apply to the particle sprite. The particle system will interpolate between each color evenly over the particle's lifetime. Arguments can be passed in groups of four, representing the components of the desired RGBA value, or as tables of RGBA component values, with a default alpha value of 1 if only three values are given. At least one color must be specified. A maximum of eight may be used. In versions prior to [11.0](https://love2d.org/wiki/11.0 "11.0"), color component values were within the range of 0 to 255 instead of 0 to 1. Function -------- ### Synopsis ``` ParticleSystem:setColors( r1, g1, b1, a1, r2, g2, b2, a2, ..., r8, g8, b8, a8 ) ``` ### Arguments `[number](number "number") r1` First color, red component (0-1). `[number](number "number") g1` First color, green component (0-1). `[number](number "number") b1` First color, blue component (0-1). `[number](number "number") a1` First color, alpha component (0-1). `[number](number "number") r2` Second color, red component (0-1). `[number](number "number") g2` Second color, green component (0-1). `[number](number "number") b2` Second color, blue component (0-1). `[number](number "number") a2` Second color, alpha component (0-1). `[number](number "number") r8` Eighth color, red component (0-1). `[number](number "number") g8` Eighth color, green component (0-1). `[number](number "number") b8` Eighth color, blue component (0-1). `[number](number "number") a8` Eighth color, alpha component (0-1). ### Returns Nothing. Function -------- **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in earlier versions. ### Synopsis ``` ParticleSystem:setColors( rgba1, rgba2, ..., rgba8 ) ``` ### Arguments `[table](table "table") rgba1` First color, a numerical indexed table with the red, green, blue and alpha values as numbers (0-1). The alpha is optional and defaults to 1 if it is left out. `[table](table "table") rgba2` Second color, a numerical indexed table with the red, green, blue and alpha values as numbers (0-1). The alpha is optional and defaults to 1 if it is left out. `[table](table "table") rgba8` Eighth color, a numerical indexed table with the red, green, blue and alpha values as numbers (0-1). The alpha is optional and defaults to 1 if it is left out. ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love EdgeShape:setPreviousVertex EdgeShape:setPreviousVertex =========================== **Available since LÖVE [0.10.2](https://love2d.org/wiki/0.10.2 "0.10.2")** This function is not supported in earlier versions. Sets a vertex that establishes a connection to the previous shape. This can help prevent unwanted collisions when a flat shape slides along the edge and moves over to the new shape. Function -------- ### Synopsis ``` EdgeShape:setPreviousVertex( x, y ) ``` ### Arguments `[number](number "number") x` The x-component of the vertex. `[number](number "number") y` The y-component of the vertex. ### Returns Nothing. See Also -------- * [EdgeShape](edgeshape "EdgeShape") * [EdgeShape:getPreviousVertex](edgeshape-getpreviousvertex "EdgeShape:getPreviousVertex") * [EdgeShape:setNextVertex](edgeshape-setnextvertex "EdgeShape:setNextVertex") love ParticleSystem:setLifetime ParticleSystem:setLifetime ========================== **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [ParticleSystem:setEmitterLifetime](particlesystem-setemitterlifetime "ParticleSystem:setEmitterLifetime"). Sets how long the particle system should emit particles (if -1 then it emits particles forever). Function -------- ### Synopsis ``` ParticleSystem:setLifetime( life ) ``` ### Arguments `[number](number "number") life` The lifetime of the emitter (in seconds). ### Returns Nothing. See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") love love.window.getTitle love.window.getTitle ==================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the window title. Function -------- ### Synopsis ``` title = love.window.getTitle( ) ``` ### Arguments None. ### Returns `[string](string "string") title` The current window title. See Also -------- * [love.window](love.window "love.window") * [love.window.setTitle](love.window.settitle "love.window.setTitle") love love.window.hasFocus love.window.hasFocus ==================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Checks if the game window has keyboard focus. Function -------- ### Synopsis ``` focus = love.window.hasFocus( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") focus` True if the window has the focus or false if not. See Also -------- * [love.window](love.window "love.window") love love.image.newEncodedImageData love.image.newEncodedImageData ============================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been replaced by [ImageData:encode](imagedata-encode "ImageData:encode"). Encodes ImageData. Function -------- ### Synopsis ``` data = love.image.newEncodedImageData( imageData, format ) ``` ### Arguments `[ImageData](imagedata "ImageData") imageData` The raw ImageData to encode. `[ImageFormat](imageencodeformat "ImageFormat") format` The format to encode the image in. ### Returns `[Data](data "Data") data` The encoded image data. See Also -------- * [love.image](love.image "love.image") love ParticleSystem:getEmitterLifetime ParticleSystem:getEmitterLifetime ================================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets how long the particle system will emit particles (if -1 then it emits particles forever). Function -------- ### Synopsis ``` life = ParticleSystem:getEmitterLifetime( ) ``` ### Arguments Nothing. ### Returns `[number](number "number") life` The lifetime of the emitter (in seconds). See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setEmitterLifetime](particlesystem-setemitterlifetime "ParticleSystem:setEmitterLifetime") love PulleyJoint:getLength1 PulleyJoint:getLength1 ====================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in that and later versions. ".0" can not be assigned to a declared number type with value 0.8. Get the current length of the rope segment attached to the first body. Function -------- ### Synopsis ``` length = PulleyJoint:getLength1( ) ``` ### Arguments None. ### Returns `[number](number "number") length` The length of the rope segment. See Also -------- * [PulleyJoint](pulleyjoint "PulleyJoint") love Body:getFixtureList Body:getFixtureList =================== | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | It has been renamed to [Body:getFixtures](body-getfixtures "Body:getFixtures"). | **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns a table with all fixtures. Function -------- ### Synopsis ``` fixtures = Body:getFixtureList( ) ``` ### Arguments None. ### Returns `[table](table "table") fixtures` A [sequence](sequence "sequence") with all fixtures. See Also -------- * [Body](body "Body") love RecordingDevice:isRecording RecordingDevice:isRecording =========================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Gets whether the device is currently recording. Function -------- ### Synopsis ``` recording = RecordingDevice:isRecording( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") recording` True if the [RecordingDevice](recordingdevice "RecordingDevice") is [recording](recordingdevice-start "RecordingDevice:start"), false otherwise. See Also -------- * [RecordingDevice](recordingdevice "RecordingDevice") * [RecordingDevice:start](recordingdevice-start "RecordingDevice:start") * [RecordingDevice:stop](recordingdevice-stop "RecordingDevice:stop") love Channel:peek Channel:peek ============ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Retrieves the value of a Channel message, but leaves it in the queue. It returns nil if there's no message in the queue. Function -------- ### Synopsis ``` value = Channel:peek( ) ``` ### Arguments None. ### Returns `[Variant](variant "Variant") value` The contents of the message. See Also -------- * [Channel](channel "Channel") * [Channel:pop](channel-pop "Channel:pop") love World:isSleepingAllowed World:isSleepingAllowed ======================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [World:getAllowSleeping](world-getallowsleeping "World:getAllowSleeping"). Gets the sleep behaviour of the world. Function -------- ### Synopsis ``` allow = World:isSleepingAllowed( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") allow` True if bodies in the world are allowed to sleep, or false if not. See Also -------- * [World](world "World") * [World:setSleepingAllowed](world-setsleepingallowed "World:setSleepingAllowed")
programming_docs
love love.filesystem.setCRequirePath love.filesystem.setCRequirePath =============================== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Sets the filesystem paths that will be searched for c libraries when [require](https://www.lua.org/manual/5.1/manual.html#pdf-require) is called. The paths string returned by this function is a sequence of path templates separated by semicolons. The argument passed to *require* will be inserted in place of any question mark ("?") character in each template (after the dot characters in the argument passed to *require* are replaced by directory separators.) Additionally, any occurrence of a double question mark ("??") will be replaced by the name passed to require and the default library extension for the platform. The paths are relative to the game's source and save directories, as well as any paths mounted with [love.filesystem.mount](love.filesystem.mount "love.filesystem.mount"). Function -------- ### Synopsis ``` love.filesystem.setCRequirePath( paths ) ``` ### Arguments `[string](string "string") paths` The paths that the *require* function will check in love's filesystem. ### Returns Nothing. Notes ----- The default paths string is `"??"`, which makes `require("cool")` try to load `cool.dll`, or `cool.so` depending on the platform. See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [love.filesystem.getCRequirePath](love.filesystem.getcrequirepath "love.filesystem.getCRequirePath") love World:isDestroyed World:isDestroyed ================= **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Gets whether the World is destroyed. Destroyed worlds cannot be used. Function -------- ### Synopsis ``` destroyed = World:isDestroyed( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") destroyed` Whether the World is destroyed. See Also -------- * [World](world "World") * [World:destroy](world-destroy "World:destroy") love Shape:getBody Shape:getBody ============= **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0")** This function is not supported in earlier versions. **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in that and later versions. Get the [Body](body "Body") the shape is attached to. Function -------- ### Synopsis ``` body = Shape:getBody( ) ``` ### Arguments None. ### Returns `[Body](body "Body") body` The body the shape is attached to. See Also -------- * [Shape](shape "Shape") love Body:setMassData Body:setMassData ================ **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Overrides the calculated mass data. Function -------- ### Synopsis ``` Body:setMassData( x, y, mass, inertia ) ``` ### Arguments `[number](number "number") x` The x position of the center of mass. `[number](number "number") y` The y position of the center of mass. `[number](number "number") mass` The mass of the body. `[number](number "number") inertia` The rotational inertia. ### Returns Nothing. See Also -------- * [Body](body "Body") * [Body:getMassData](body-getmassdata "Body:getMassData") love Source:setRolloff Source:setRolloff ================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Sets the rolloff factor which affects the strength of the used [distance attenuation](distancemodel "DistanceModel"). Extended information and detailed formulas can be found in the chapter "3.4. Attenuation By Distance" of [OpenAL 1.1 specification](https://www.openal.org/documentation/openal-1.1-specification.pdf). Function -------- ### Synopsis ``` Source:setRolloff( rolloff ) ``` ### Arguments `[number](number "number") rolloff` The new rolloff factor. ### Returns Nothing. See Also -------- * [Source](source "Source") love RevoluteJoint:getJointAngle RevoluteJoint:getJointAngle =========================== Get the current joint angle. Function -------- ### Synopsis ``` angle = RevoluteJoint:getJointAngle( ) ``` ### Arguments None. ### Returns `[number](number "number") angle` The joint angle in radians. See Also -------- * [RevoluteJoint](revolutejoint "RevoluteJoint") love light userdata light userdata ============== From the Lua Reference Manual: (Full) userdata represent C values in Lua. A light userdata represents a pointer. It is a value (like a number): you do not create it, it has no individual metatable, and it is not garbage collected (as it was never created). A light userdata is equal to "any" light userdata with the same C address. love WheelJoint:getJointTranslation WheelJoint:getJointTranslation ============================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the current joint translation. Function -------- ### Synopsis ``` position = WheelJoint:getJointTranslation( ) ``` ### Arguments None. ### Returns `[number](number "number") position` The translation of the joint in meters. See Also -------- * [WheelJoint](wheeljoint "WheelJoint") love Shape Shape ===== **Shapes** are solid 2d geometrical objects which handle the mass and collision of a [Body](body "Body") in [love.physics](love.physics "love.physics"). **Shapes** are attached to a [Body](body "Body") via a [Fixture](fixture "Fixture"). The **Shape** object is copied when this happens. The **Shape**'s position is relative to the position of the [Body](body "Body") it has been attached to. Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.physics.newChainShape](love.physics.newchainshape "love.physics.newChainShape") | Creates a new [ChainShape](chainshape "ChainShape"). | 0.8.0 | | | [love.physics.newCircleShape](love.physics.newcircleshape "love.physics.newCircleShape") | Creates a new [CircleShape](circleshape "CircleShape"). | | | | [love.physics.newEdgeShape](love.physics.newedgeshape "love.physics.newEdgeShape") | Creates a new [EdgeShape](edgeshape "EdgeShape"). | 0.8.0 | | | [love.physics.newPolygonShape](love.physics.newpolygonshape "love.physics.newPolygonShape") | Creates a new [PolygonShape](polygonshape "PolygonShape"). | | | | [love.physics.newRectangleShape](love.physics.newrectangleshape "love.physics.newRectangleShape") | Shorthand for creating rectangular [PolygonShapes](polygonshape "PolygonShape"). | | | Functions --------- | | | | | | --- | --- | --- | --- | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | | [Shape:computeAABB](shape-computeaabb "Shape:computeAABB") | Returns the points of the bounding box for the transformed shape. | 0.8.0 | | | [Shape:computeMass](shape-computemass "Shape:computeMass") | Computes the mass properties for the shape. | 0.8.0 | | | [Shape:destroy](shape-destroy "Shape:destroy") | Explicitly destroys the Shape. | | 0.8.0 | | [Shape:getBody](shape-getbody "Shape:getBody") | Get the body the shape is attached to. | 0.7.0 | 0.8.0 | | [Shape:getBoundingBox](shape-getboundingbox "Shape:getBoundingBox") | Gets the bounding box of the shape. | | 0.8.0 | | [Shape:getCategory](shape-getcategory "Shape:getCategory") | Gets the categories this shape is a member of. | | 0.8.0 | | [Shape:getCategoryBits](shape-getcategorybits "Shape:getCategoryBits") | Gets the categories as a 16-bit integer. | | 0.8.0 | | [Shape:getChildCount](shape-getchildcount "Shape:getChildCount") | Returns the number of children the shape has. | 0.8.0 | | | [Shape:getData](shape-getdata "Shape:getData") | Get the data set with setData. | | 0.8.0 | | [Shape:getDensity](shape-getdensity "Shape:getDensity") | Gets the density of the Shape. | | 0.8.0 | | [Shape:getFilterData](shape-getfilterdata "Shape:getFilterData") | Gets the filter data of the Shape. | | 0.8.0 | | [Shape:getFriction](shape-getfriction "Shape:getFriction") | Gets the friction of this shape. | | 0.8.0 | | [Shape:getMask](shape-getmask "Shape:getMask") | Gets which categories this shape should **NOT** collide with. | | 0.8.0 | | [Shape:getRadius](shape-getradius "Shape:getRadius") | Gets the radius of the shape. | | | | [Shape:getRestitution](shape-getrestitution "Shape:getRestitution") | Gets the restitution of this shape. | | 0.8.0 | | [Shape:getType](shape-gettype "Shape:getType") | Gets a string representing the Shape. | | | | [Shape:isSensor](shape-issensor "Shape:isSensor") | Checks whether a Shape is a sensor or not. | | 0.8.0 | | [Shape:rayCast](shape-raycast "Shape:rayCast") | Casts a ray against the shape. | 0.8.0 | | | [Shape:setCategory](shape-setcategory "Shape:setCategory") | Sets the categories this shape is a member of. | | 0.8.0 | | [Shape:setData](shape-setdata "Shape:setData") | Set data to be passed to the collision callback. | | 0.8.0 | | [Shape:setDensity](shape-setdensity "Shape:setDensity") | Sets the density of a Shape. | | 0.8.0 | | [Shape:setFilterData](shape-setfilterdata "Shape:setFilterData") | Sets the filter data for a Shape. | | 0.8.0 | | [Shape:setFriction](shape-setfriction "Shape:setFriction") | Sets the friction of the shape. | | 0.8.0 | | [Shape:setMask](shape-setmask "Shape:setMask") | Sets which categories this shape should **NOT** collide with. | | 0.8.0 | | [Shape:setRestitution](shape-setrestitution "Shape:setRestitution") | Sets the restitution of the shape. | | 0.8.0 | | [Shape:setSensor](shape-setsensor "Shape:setSensor") | Sets whether this shape should act as a sensor. | | 0.8.0 | | [Shape:testPoint](shape-testpoint "Shape:testPoint") | Checks whether a point lies inside the shape. | | | | [Shape:testSegment](shape-testsegment "Shape:testSegment") | Checks whether a line segment intersects a shape. | | 0.8.0 | Enums ----- | | | | | | --- | --- | --- | --- | | [ShapeType](shapetype "ShapeType") | The different types of **Shapes**, as returned by [Shape:getType](shape-gettype "Shape:getType"). | | | Supertypes ---------- * [Object](object "Object") Subtypes -------- | | | | | | --- | --- | --- | --- | | [ChainShape](chainshape "ChainShape") | A ChainShape consists of multiple line segments. | | | | [CircleShape](circleshape "CircleShape") | Circle extends Shape and adds a radius and a local position. | | | | [EdgeShape](edgeshape "EdgeShape") | EdgeShape is a line segment. | | | | [PolygonShape](polygonshape "PolygonShape") | Polygon is a convex polygon with up to 8 sides. | | | See Also -------- * [love.physics](love.physics "love.physics") love World:setContactFilter World:setContactFilter ====================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Sets a function for collision filtering. If the group and category filtering doesn't generate a collision decision, this function gets called with the two fixtures as arguments. The function should return a boolean value where true means the fixtures will collide and false means they will pass through each other. Function -------- ### Synopsis ``` World:setContactFilter( filter ) ``` ### Arguments `[function](function "function") filter` The function handling the contact filtering. ### Returns Nothing. See Also -------- * [World](world "World") love ParticleSystem:getSizeVariation ParticleSystem:getSizeVariation =============================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the amount of size variation (0 meaning no variation and 1 meaning full variation between start and end). Function -------- ### Synopsis ``` variation = ParticleSystem:getSizeVariation( ) ``` ### Arguments Nothing. ### Returns `[number](number "number") variation` The amount of variation (0 meaning no variation and 1 meaning full variation between start and end). See Also -------- * [ParticleSystem](particlesystem "ParticleSystem") * [ParticleSystem:setSizeVariation](particlesystem-setsizevariation "ParticleSystem:setSizeVariation") love Source:setLooping Source:setLooping ================= Sets whether the Source should loop. Function -------- ### Synopsis ``` Source:setLooping( loop ) ``` ### Arguments `[boolean](boolean "boolean") loop` True if the source should loop, false otherwise. ### Returns Nothing. Examples -------- ``` function love.load() music = love.audio.newSource("music_loop.wav")   music:setLooping(true) music:play() -- Music will now play forever, until stopped or paused. end ``` See Also -------- * [Source](source "Source") love love.graphics.getDefaultFilter love.graphics.getDefaultFilter ============================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed from [love.graphics.getDefaultImageFilter](love.graphics.getdefaultimagefilter "love.graphics.getDefaultImageFilter"). Returns the default scaling filters used with [Images](image "Image"), [Canvases](canvas "Canvas"), and [Fonts](font "Font"). Function -------- ### Synopsis ``` min, mag, anisotropy = love.graphics.getDefaultFilter( ) ``` ### Arguments None. ### Returns `[FilterMode](filtermode "FilterMode") min` Filter mode used when scaling the image down. `[FilterMode](filtermode "FilterMode") mag` Filter mode used when scaling the image up. `[number](number "number") anisotropy` Maximum amount of Anisotropic Filtering used. See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setDefaultFilter](love.graphics.setdefaultfilter "love.graphics.setDefaultFilter") * [FilterMode](filtermode "FilterMode") love PrismaticJoint:setLimitsEnabled PrismaticJoint:setLimitsEnabled =============================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in that version. **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed again. Enables/disables the joint limit. Function -------- ### Synopsis ``` enable = PrismaticJoint:setLimitsEnabled( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") enable` True if enabled, false if disabled. See Also -------- * [PrismaticJoint](prismaticjoint "PrismaticJoint") love Joint:getReactionForce Joint:getReactionForce ====================== Returns the reaction force in newtons on the second body Function -------- **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in earlier versions. ### Synopsis ``` x, y = Joint:getReactionForce( invdt ) ``` ### Arguments `[number](number "number") x` How long the force applies. Usually the inverse time step or 1/dt. ### Returns `[number](number "number") x` The x-component of the force. `[number](number "number") y` The y-component of the force. Function -------- **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This variant is not supported in that and later versions. ### Synopsis ``` x, y = Joint:getReactionForce( ) ``` ### Arguments None. ### Returns `[number](number "number") x` The x-component of the force. `[number](number "number") y` The y-component of the force. See Also -------- * [Joint](joint "Joint") love Contact:getPositions Contact:getPositions ==================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Returns the contact points of the two colliding fixtures. There can be one or two points. Function -------- ### Synopsis ``` x1, y1, x2, y2 = Contact:getPositions( ) ``` ### Arguments None. ### Returns `[number](number "number") x1` The x coordinate of the first contact point. `[number](number "number") y1` The y coordinate of the first contact point. `[number](number "number") x2` The x coordinate of the second contact point. `[number](number "number") y2` The y coordinate of the second contact point. See Also -------- * [Contact](contact "Contact") love BezierCurve:insertControlPoint BezierCurve:insertControlPoint ============================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Insert control point as the new i-th control point. Existing control points from i onwards are pushed back by 1. Indices start with 1. Negative indices wrap around: -1 is the last control point, -2 the one before the last, etc. Function -------- ### Synopsis ``` BezierCurve:insertControlPoint( x, y, i ) ``` ### Arguments `[number](number "number") x` Position of the control point along the x axis. `[number](number "number") y` Position of the control point along the y axis. `[number](number "number") i (-1)` Index of the control point. ### Returns Nothing. See Also -------- * [BezierCurve](beziercurve "BezierCurve") * [BezierCurve:getDegree](beziercurve-getdegree "BezierCurve:getDegree") * [BezierCurve:getControlPoint](beziercurve-getcontrolpoint "BezierCurve:getControlPoint") * [BezierCurve:setControlPoint](beziercurve-setcontrolpoint "BezierCurve:setControlPoint") * [love.math](love.math "love.math") love ImageData:paste ImageData:paste =============== Paste into ImageData from another source ImageData. Function -------- ### Synopsis ``` ImageData:paste( source, dx, dy, sx, sy, sw, sh ) ``` ### Arguments `[ImageData](imagedata "ImageData") source` Source ImageData from which to copy. `[number](number "number") dx` Destination top-left position on x-axis. `[number](number "number") dy` Destination top-left position on y-axis. `[number](number "number") sx` Source top-left position on x-axis. `[number](number "number") sy` Source top-left position on y-axis. `[number](number "number") sw` Source width. `[number](number "number") sh` Source height. ### Returns Nothing. Notes ----- Note that this function just replaces the contents in the destination rectangle; it does not do any alpha blending. See Also -------- * [ImageData](imagedata "ImageData") love WheelJoint:setMotorSpeed WheelJoint:setMotorSpeed ======================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Sets a new speed for the motor. Function -------- ### Synopsis ``` WheelJoint:setMotorSpeed( speed ) ``` ### Arguments `[number](number "number") speed` The new speed for the joint motor in radians per second. ### Returns Nothing. See Also -------- * [WheelJoint](wheeljoint "WheelJoint") * [WheelJoint:getMotorSpeed](wheeljoint-getmotorspeed "WheelJoint:getMotorSpeed") love DistanceJoint:setDamping DistanceJoint:setDamping ======================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been replaced with [DistanceJoint:setDampingRatio](distancejoint-setdampingratio "DistanceJoint:setDampingRatio"). Sets the damping ratio. Function -------- ### Synopsis ``` DistanceJoint:setDamping( ratio ) ``` ### Arguments `[number](number "number") ratio` The damping ratio. ### Returns Nothing. See Also -------- * [DistanceJoint](distancejoint "DistanceJoint")
programming_docs
love Fixture Fixture ======= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This type is not supported in earlier versions. Fixtures attach [shapes](shape "Shape") to [bodies](body "Body"). Constructors ------------ | | | | | | --- | --- | --- | --- | | [love.physics.newFixture](love.physics.newfixture "love.physics.newFixture") | Creates and attaches a fixture. | 0.8.0 | | Functions --------- | | | | | | --- | --- | --- | --- | | [Fixture:destroy](fixture-destroy "Fixture:destroy") | Destroys the fixture. | 0.8.0 | | | [Fixture:getBody](fixture-getbody "Fixture:getBody") | Returns the body the fixture is attached to. | 0.8.0 | | | [Fixture:getBoundingBox](fixture-getboundingbox "Fixture:getBoundingBox") | Returns the points of the fixture bounding box. | 0.8.0 | | | [Fixture:getCategory](fixture-getcategory "Fixture:getCategory") | Returns the categories the fixture belongs to. | 0.8.0 | | | [Fixture:getDensity](fixture-getdensity "Fixture:getDensity") | Returns the density of the fixture. | 0.8.0 | | | [Fixture:getFilterData](fixture-getfilterdata "Fixture:getFilterData") | Returns the filter data of the fixture. | 0.8.0 | | | [Fixture:getFriction](fixture-getfriction "Fixture:getFriction") | Returns the friction of the fixture. | 0.8.0 | | | [Fixture:getGroupIndex](fixture-getgroupindex "Fixture:getGroupIndex") | Returns the group the fixture belongs to. | 0.8.0 | | | [Fixture:getMask](fixture-getmask "Fixture:getMask") | Returns which categories this fixture should **NOT** collide with. | 0.8.0 | | | [Fixture:getMassData](fixture-getmassdata "Fixture:getMassData") | Returns the mass, its center and the rotational inertia. | 0.8.0 | | | [Fixture:getRestitution](fixture-getrestitution "Fixture:getRestitution") | Returns the restitution of the fixture. | 0.8.0 | | | [Fixture:getShape](fixture-getshape "Fixture:getShape") | Returns the shape of the fixture. | 0.8.0 | | | [Fixture:getUserData](fixture-getuserdata "Fixture:getUserData") | Returns the Lua value associated with this fixture. | 0.8.0 | | | [Fixture:isDestroyed](fixture-isdestroyed "Fixture:isDestroyed") | Gets whether the Fixture is destroyed. | 0.9.2 | | | [Fixture:isSensor](fixture-issensor "Fixture:isSensor") | Returns whether the fixture is a sensor. | 0.8.0 | | | [Fixture:rayCast](fixture-raycast "Fixture:rayCast") | Casts a ray against the shape of the fixture. | 0.8.0 | | | [Fixture:setCategory](fixture-setcategory "Fixture:setCategory") | Sets the categories the fixture belongs to. | 0.8.0 | | | [Fixture:setDensity](fixture-setdensity "Fixture:setDensity") | Sets the density of the fixture. | 0.8.0 | | | [Fixture:setFilterData](fixture-setfilterdata "Fixture:setFilterData") | Sets the filter data of the fixture. | 0.8.0 | | | [Fixture:setFriction](fixture-setfriction "Fixture:setFriction") | Sets the friction of the fixture. | 0.8.0 | | | [Fixture:setGroupIndex](fixture-setgroupindex "Fixture:setGroupIndex") | Sets the group the fixture belongs to. | 0.8.0 | | | [Fixture:setMask](fixture-setmask "Fixture:setMask") | Sets which categories this fixture should **NOT** collide with. | 0.8.0 | | | [Fixture:setRestitution](fixture-setrestitution "Fixture:setRestitution") | Sets the restitution of the fixture. | 0.8.0 | | | [Fixture:setSensor](fixture-setsensor "Fixture:setSensor") | Sets whether the fixture should act as a sensor. | 0.8.0 | | | [Fixture:setUserData](fixture-setuserdata "Fixture:setUserData") | Associates a Lua value with the fixture. | 0.8.0 | | | [Fixture:testPoint](fixture-testpoint "Fixture:testPoint") | Checks if a point is inside the shape of the fixture. | 0.8.0 | | | [Object:release](object-release "Object:release") | Immediately destroys the object's Lua reference. | 11.0 | | | [Object:type](object-type "Object:type") | Gets the type of the object as a string. | | | | [Object:typeOf](object-typeof "Object:typeOf") | Checks whether an object is of a certain type. | | | Supertypes ---------- * [Object](object "Object") See Also -------- * [love.physics](love.physics "love.physics") love Body:isActive Body:isActive ============= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns whether the body is actively used in the simulation. Function -------- ### Synopsis ``` status = Body:isActive( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") status` True if the body is active or false if not. See Also -------- * [Body](body "Body") love Contact:getVelocity Contact:getVelocity =================== **Removed in LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in that and later versions. Get the linear impact velocity of a contact. Function -------- ### Synopsis ``` vx, vy = Contact:getVelocity( ) ``` ### Arguments None. ### Returns `[number](number "number") vx` The x component of the velocity vector. `[number](number "number") vy` The y component of the velocity vector. See Also -------- * [Contact](contact "Contact") love WheelJoint:enableMotor WheelJoint:enableMotor ====================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. **Removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [WheelJoint:setMotorEnabled](wheeljoint-setmotorenabled "WheelJoint:setMotorEnabled"). Starts and stops the joint motor. Function -------- ### Synopsis ``` WheelJoint:enableMotor( on ) ``` ### Arguments `[boolean](boolean "boolean") on` True turns the motor on and false turns it off. ### Returns Nothing. See Also -------- * [WheelJoint](wheeljoint "WheelJoint") love PixelEffect:send PixelEffect:send ================ **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** It has been renamed to [Shader:send](shader-send "Shader:send"). Sends one or more values to a special (*extern*) variable inside the pixel effect. Extern variables have to be marked using the *extern* keyword, e.g. ``` extern number time; extern vec2 light_pos; extern vec4 colors[4]; ``` The corresponding send calls would be ``` effect:send("time", t) effect:send("light_pos", {light_x, light_y}) effect:send("colors", {r1, g1, b1, a1}, {r2, g2, b2, a2}, {r3, g3, b3, a3}, {r4, g4, b4, a4}) ``` Function -------- ### Synopsis ``` PixelEffect:send( name, number, ... ) ``` ### Arguments `[string](string "string") name` Name of the number to send to the pixel effect. `[number](number "number") number` Number to send to store in the extern. `[number](number "number") ...` Additional numbers to send in case the extern is an array. ### Returns Nothing. Function -------- ### Synopsis ``` PixelEffect:send( name, vector, ... ) ``` ### Arguments `[string](string "string") name` Name of the vector to send to the pixel effect. `[table](table "table") vector` Numbers to send to the extern as a vector. The number of elements in the table determines the type of the vector (e.g. two numbers -> vec2). At least two and at most four numbers can be used. `[table](table "table") ...` Additional vectors to send in case the extern is an array. All vectors need to be of the same size (e.g. only vec3's) ### Returns Nothing. Function -------- ### Synopsis ``` PixelEffect:send( name, matrix, ... ) ``` ### Arguments `[string](string "string") name` Name of the matrix to send to the pixel effect. `[table](table "table") matrix` 2x2, 3x3, or 4x4 matrix to send to the extern. Using table form: `{{a,b,c,d}, {e,f,g,h}, ... }` `[table](table "table") ...` Additional matrices of the same type as *matrix* to store in the extern array. ### Returns Nothing. Function -------- ### Synopsis ``` PixelEffect:send( name, image, ... ) ``` ### Arguments `[string](string "string") name` Name of the Image to send to the pixel effect. `[Image](image "Image") image` Image to send to the extern. `[Image](image "Image") ...` Additional images in case the extern is an array. ### Returns Nothing. Function -------- ### Synopsis ``` PixelEffect:send( name, canvas, ... ) ``` ### Arguments `[string](string "string") name` Name of the Canvas to send to the pixel effect. `[Canvas](canvas "Canvas") canvas` Canvas to send to the extern. The pixel effect type is *Image*. `[Image](image "Image") ...` Additional canvases to send to the extern array. ### Returns Nothing. See Also -------- * [PixelEffect](pixeleffect "PixelEffect") love love.thread.getChannel love.thread.getChannel ====================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Creates or retrieves a named thread channel. Function -------- ### Synopsis ``` channel = love.thread.getChannel( name ) ``` ### Arguments `[string](string "string") name` The name of the channel you want to create or retrieve. ### Returns `[Channel](channel "Channel") channel` The Channel object associated with the name. Examples -------- ### Communication between main/thread ``` -- main thread = love.thread.newThread ( "thread.lua" ); thread:start (); channel = {}; channel.a = love.thread.getChannel ( "a" ); channel.b = love.thread.getChannel ( "b" ); channel.b:push ( "foo" );   function love.update ( dt ) local v = channel.a:pop (); if v then print ( tostring ( v ) ); channel.b:push ( "foo" ); end end   -- thread channel = {}; channel.a = love.thread.getChannel ( "a" ); channel.b = love.thread.getChannel ( "b" );   while true do local v = channel.b:pop (); if v then print ( tostring ( v ) ); channel.a:push ( "bar" ); end end ``` See Also -------- * [love.thread](love.thread "love.thread") * [Channel](channel "Channel") love Contact:getChildren Contact:getChildren =================== **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Gets the child indices of the shapes of the two colliding fixtures. For [ChainShapes](chainshape "ChainShape"), an index of 1 is the first edge in the chain. Used together with [Fixture:rayCast](fixture-raycast "Fixture:rayCast") or [ChainShape:getChildEdge](chainshape-getchildedge "ChainShape:getChildEdge"). Function -------- ### Synopsis ``` indexA, indexB = Contact:getChildren( ) ``` ### Arguments None. ### Returns `[number](number "number") indexA` The child index of the first fixture's shape. `[number](number "number") indexB` The child index of the second fixture's shape. See Also -------- * [Contact](contact "Contact") * [Fixture:rayCast](fixture-raycast "Fixture:rayCast") * [ChainShape:getChildEdge](chainshape-getchildedge "ChainShape:getChildEdge") love love.getVersion love.getVersion =============== **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. Gets the current running version of LÖVE. Function -------- ### Synopsis ``` major, minor, revision, codename = love.getVersion( ) ``` ### Arguments None. ### Returns `[number](number "number") major` The major version of LÖVE, i.e. 0 for version 0.9.1. `[number](number "number") minor` The minor version of LÖVE, i.e. 9 for version 0.9.1. `[number](number "number") revision` The revision version of LÖVE, i.e. 1 for version 0.9.1. `[string](string "string") codename` The codename of the current version, i.e. "Baby Inspector" for version 0.9.1. Notes ----- For LÖVE versions below 0.9.1, the following variables can be used instead (and still work in 0.9.2 and newer): ``` love._version_major love._version_minor love._version_revision ``` Examples -------- ### display the current version ``` function love.draw() local major, minor, revision, codename = love.getVersion() local str = string.format("Version %d.%d.%d - %s", major, minor, revision, codename) love.graphics.print(str, 20, 20) end ``` See Also -------- * [love](love "love") * [love.isVersionCompatible](love.isversioncompatible "love.isVersionCompatible") love love.filesystem.newFile love.filesystem.newFile ======================= Creates a new [File](file "File") object. It needs to be opened before it can be accessed. Function -------- ### Synopsis ``` file = love.filesystem.newFile( filename ) ``` ### Arguments `[string](string "string") filename` The filename of the file. ### Returns `[File](file "File") file` The new File object. ### Notes Please note that this function will not return any error message (e.g. if you use an invalid filename) because it just creates the File Object. You can still check if the file is valid by using [File:open]((file)-open "(File):open") which returns a boolean and an error message if something goes wrong while opening the file. Function -------- **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This variant is not supported in earlier versions. Creates a [File](file "File") object and opens it for reading, writing, or appending. ### Synopsis ``` file, errorstr = love.filesystem.newFile( filename, mode ) ``` ### Arguments `[string](string "string") filename` The filename of the file. `[FileMode](filemode "FileMode") mode` The mode to open the file in. ### Returns `[File](file "File") file` The new File object, or nil if an error occurred. `[string](string "string") errorstr` The error string if an error occurred. Examples -------- ### Open a file and read everything ``` file = love.filesystem.newFile("data.txt") file:open("r") data = file:read() file:close() -- use the data ... ``` See Also -------- * [love.filesystem](love.filesystem "love.filesystem") * [File](file "File") love love.window.getDisplayOrientation love.window.getDisplayOrientation ================================= **Available since LÖVE [11.3](https://love2d.org/wiki/11.3 "11.3")** This function is not supported in earlier versions. Gets current device display orientation. Function -------- ### Synopsis ``` orientation = love.window.getDisplayOrientation( index ) ``` ### Arguments `[number](number "number") index (nil)` Display index to get its display orientation, or nil for default display index. ### Returns `[DisplayOrientation](displayorientation "DisplayOrientation") orientation` Current device display orientation. See Also -------- * [love.window](love.window "love.window") * [DisplayOrientation](displayorientation "DisplayOrientation") * [love.displayrotated](love.displayrotated "love.displayrotated") love love.thread.getThreads love.thread.getThreads ====================== **Available since LÖVE [0.7.0](https://love2d.org/wiki/0.7.0 "0.7.0") and removed in LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier or later versions. Get all threads. Function -------- ### Synopsis ``` threads = love.thread.getThreads( ) ``` ### Arguments None. ### Returns `[table](table "table") threads` A table containing all threads indexed by their names. See Also -------- * [love.thread](love.thread "love.thread") love love.data.unpack love.data.unpack ================ **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This function is not supported in earlier versions. Unpacks (deserializes) a byte-string or Data into simple Lua values. This function behaves the same as Lua 5.3's [string.unpack](https://www.lua.org/manual/5.3/manual.html#pdf-string.unpack). Function -------- ### Synopsis ``` v1, ..., index = love.data.unpack( format, datastring, pos ) ``` ### Arguments `[string](string "string") format` A string determining how the values were packed. Follows the rules of [Lua 5.3's string.pack format strings](https://www.lua.org/manual/5.3/manual.html#6.4.2). `[string](string "string") datastring` A string containing the packed (serialized) data. `[number](number "number") pos (1)` Where to start reading in the string. Negative values can be used to read relative from the end of the string. ### Returns `[value](value "value") v1` The first value (number, boolean, or string) that was unpacked. `[value](value "value") ...` Additional unpacked values. `[number](number "number") index` The index of the first unread byte in the data string. Function -------- ### Synopsis ``` v1, ..., index = love.data.unpack( format, data, pos ) ``` ### Arguments `[string](string "string") format` A string determining how the values were packed. Follows the rules of [Lua 5.3's string.pack format strings](https://www.lua.org/manual/5.3/manual.html#6.4.2). `[Data](data "Data") data` A Data object containing the packed (serialized) data. `[number](number "number") pos (1)` 1-based index indicating where to start reading in the Data. Negative values can be used to read relative from the end of the Data object. ### Returns `[value](value "value") v1` The first value (number, boolean, or string) that was unpacked. `[value](value "value") ...` Additional unpacked values. `[number](number "number") index` The 1-based index of the first unread byte in the Data. Notes ----- Unpacking integers with values greater than 2^52 is not supported, as Lua 5.1 cannot represent those values in its number type. See Also -------- * [love.data](love.data "love.data") * [love.data.pack](love.data.pack "love.data.pack") * [love.data.getPackedSize](love.data.getpackedsize "love.data.getPackedSize") love Mesh:setVertexMap Mesh:setVertexMap ================= **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Sets the vertex map for the Mesh. The vertex map describes the order in which the vertices are used when the Mesh is drawn. The vertices, vertex map, and mesh draw mode work together to determine what exactly is displayed on the screen. The vertex map allows you to re-order or reuse vertices when drawing without changing the actual vertex parameters or duplicating vertices. It is especially useful when combined with different [Mesh Draw Modes](meshdrawmode "MeshDrawMode"). Function -------- ### Synopsis ``` Mesh:setVertexMap( map ) ``` ### Arguments `[table](table "table") map` A table containing a list of vertex indices to use when drawing. Values must be in the range of [1, [Mesh:getVertexCount()](mesh-getvertexcount "Mesh:getVertexCount")]. ### Returns Nothing. Function -------- ### Synopsis ``` Mesh:setVertexMap( vi1, vi2, vi3, ... ) ``` ### Arguments `[number](number "number") vi1` The index of the first vertex to use when drawing. Must be in the range of [1, [Mesh:getVertexCount()](mesh-getvertexcount "Mesh:getVertexCount")]. `[number](number "number") vi2` The index of the second vertex to use when drawing. `[number](number "number") vi3` The index of the third vertex to use when drawing. ### Returns Nothing. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` Mesh:setVertexMap( data, datatype ) ``` ### Arguments `[Data](data "Data") data` Array of vertex indices to use when drawing. Values must be in the range of [0, [Mesh:getVertexCount()](mesh-getvertexcount "Mesh:getVertexCount")-1] `[IndexDataType](indexdatatype "IndexDataType") datatype` Datatype of the vertex indices array above. ### Returns Nothing. Examples -------- Use a vertex map to fix a visual glitch without copy/pasting vertices. ``` function love.load() image = love.graphics.newImage("pig.png") local w,h = image:getDimensions()   -- We want to make a Mesh with 1 vertex in the middle of the image, and 4 at the corners. local vertices = { {w/2, h/2, 0.5, 0.5, 1, 0, 0}, -- Center vertex, with a red tint. {0, 0, 0, 0, 1, 1, 1}, -- Top left. {w, 0, 1, 0, 1, 1, 1}, -- Top right. {w, h, 1, 1, 1, 1, 1}, -- Bottom right. {0, h, 0, 1, 1, 1, 1}, -- Bottom left. }   -- But there's a problem! The drawn mesh will have a big triangle missing on its left side. -- This is because, in the default mesh draw mode ("fan"), the vertices don't "loop": the top left vertex (#2) is unconnected to the bottom left one (#5). mesh = love.graphics.newMesh(vertices) mesh:setTexture(image)   -- We could copy/paste the second vertex onto the end of the table of vertices. -- But instead we can just change the vertex map! mesh:setVertexMap(1, 2, 3, 4, 5, 2) end   function love.draw() love.graphics.draw(mesh, 0, 0) end ``` See Also -------- * [Mesh](mesh "Mesh") * [Mesh:getVertexMap](mesh-getvertexmap "Mesh:getVertexMap") * [MeshDrawMode](meshdrawmode "MeshDrawMode")
programming_docs
love Video:getHeight Video:getHeight =============== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Gets the height of the Video in pixels. Function -------- ### Synopsis ``` height = Video:getHeight( ) ``` ### Arguments None. ### Returns `[number](number "number") height` The height of the Video. See Also -------- * [Video](video "Video") * [Video:getWidth](video-getwidth "Video:getWidth") * [Video:getDimensions](video-getdimensions "Video:getDimensions") love RandomGenerator:getState RandomGenerator:getState ======================== **Available since LÖVE [0.9.1](https://love2d.org/wiki/0.9.1 "0.9.1")** This function is not supported in earlier versions. Gets the current state of the random number generator. This returns an opaque string which is only useful for later use with [RandomGenerator:setState](randomgenerator-setstate "RandomGenerator:setState") in the same major version of LÖVE. This is different from [RandomGenerator:getSeed](randomgenerator-getseed "RandomGenerator:getSeed") in that getState gets the RandomGenerator's current state, whereas getSeed gets the previously set seed number. Function -------- ### Synopsis ``` state = RandomGenerator:getState( ) ``` ### Arguments None. ### Returns `[string](string "string") state` The current state of the RandomGenerator object, represented as a string. Notes ----- The value of the state string does not depend on the current operating system. Examples -------- ``` rng = love.math.newRandomGenerator(os.time())   for i=1, 100 do -- Use some random numbers. rng:random() end   -- Make a new RandomGenerator and set its state to the current state of the first one. rng2 = love.math.newRandomGenerator() rng2:setState(rng:getState())   -- Both 'rng' and 'rng2' will now give the same results. assert(rng:random() == rng2:random()) ``` See Also -------- * [RandomGenerator](randomgenerator "RandomGenerator") * [RandomGenerator:setState](randomgenerator-setstate "RandomGenerator:setState") love love.audio.setDopplerScale love.audio.setDopplerScale ========================== **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Sets a global scale factor for velocity-based doppler effects. The default scale value is 1. Function -------- ### Synopsis ``` love.audio.setDopplerScale( scale ) ``` ### Arguments `[number](number "number") scale` The new doppler scale factor. The scale must be greater than 0. ### Returns Nothing. See Also -------- * [love.audio](love.audio "love.audio") * [love.audio.getDopplerScale](love.audio.getdopplerscale "love.audio.getDopplerScale") love Body:isDestroyed Body:isDestroyed ================ **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This function is not supported in earlier versions. Gets whether the Body is destroyed. Destroyed bodies cannot be used. Function -------- ### Synopsis ``` destroyed = Body:isDestroyed( ) ``` ### Arguments None. ### Returns `[boolean](boolean "boolean") destroyed` Whether the Body is destroyed. See Also -------- * [Body](body "Body") * [Body:destroy](body-destroy "Body:destroy") love love.image.newImageData love.image.newImageData ======================= Creates a new [ImageData](imagedata "ImageData") object. This function can be slow if it is called repeatedly, such as from [love.update](love.update "love.update") or [love.draw](love.draw "love.draw"). If you need to use a specific resource often, create it once and store it somewhere it can be reused! Function -------- ### Synopsis ``` imageData = love.image.newImageData( width, height ) ``` ### Arguments `[number](number "number") width` The width of the ImageData. `[number](number "number") height` The height of the ImageData. ### Returns `[ImageData](imagedata "ImageData") imageData` The new blank ImageData object. Each pixel's color values, (including the alpha values!) will be set to zero. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` imageData = love.image.newImageData( width, height, format, rawdata ) ``` ### Arguments `[number](number "number") width` The width of the ImageData. `[number](number "number") height` The height of the ImageData. `[PixelFormat](pixelformat "PixelFormat") format ("rgba8")` The pixel format of the ImageData. `[string or Data](https://love2d.org/w/index.php?title=string_or_Data&action=edit&redlink=1 "string or Data (page does not exist)") rawdata (nil)` Optional raw byte data to load into the ImageData, in the format specified by *format*. ### Returns `[ImageData](imagedata "ImageData") imageData` The new ImageData object. Function -------- **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0") and removed in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier or later versions. ### Synopsis ``` imageData = love.image.newImageData( width, height, rawdata ) ``` ### Arguments `[number](number "number") width` The width of the ImageData. `[number](number "number") height` The height of the ImageData. `[string](string "string") rawdata` The data to load into the ImageData (RGBA bytes, left to right and top to bottom). ### Returns `[ImageData](imagedata "ImageData") imageData` The new ImageData object. Function -------- ### Synopsis ``` imageData = love.image.newImageData( filename ) ``` ### Arguments `[string](string "string") filename` The filename of the image file. ### Returns `[ImageData](imagedata "ImageData") imageData` The new ImageData object. Function -------- ### Synopsis ``` imageData = love.image.newImageData( filedata ) ``` ### Arguments `[FileData](filedata "FileData") filedata` The encoded file data to decode into image data. ### Returns `[ImageData](imagedata "ImageData") imageData` The new ImageData object. Function -------- **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This variant is not supported in earlier versions. ### Synopsis ``` imageData = love.image.newImageData( encodeddata ) ``` ### Arguments `[Data](data "Data") encodeddata` The encoded data to load into the ImageData. ### Returns `[ImageData](imagedata "ImageData") imageData` The new ImageData object. See Also -------- * [love.image](love.image "love.image") * [ImageData](imagedata "ImageData") love Text:addf Text:addf ========= **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** This function is not supported in earlier versions. Adds additional formatted / colored text to the Text object at the specified position. 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. Text may appear blurry if it's rendered at non-integer pixel locations. Function -------- ### Synopsis ``` index = Text:addf( textstring, wraplimit, alignmode, x, y, angle, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[string](string "string") textstring` The text to add to the object. `[number](number "number") wraplimit` The maximum width in pixels of the text before it gets automatically wrapped to a new line. `[AlignMode](alignmode "AlignMode") align` The alignment of the text. `[number](number "number") x` The position of the new text (x-axis). `[number](number "number") y` The position of the new text (y-axis). `[number](number "number") angle (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Shearing / skew factor (x-axis). `[number](number "number") ky (0)` Shearing / skew factor (y-axis). ### Returns `[number](number "number") index` An index number that can be used with [Text:getWidth](text-getwidth "Text:getWidth") or [Text:getHeight](text-getheight "Text:getHeight"). Function -------- ### Synopsis ``` index = Text:addf( coloredtext, wraplimit, alignmode, x, y, angle, sx, sy, ox, oy, kx, ky ) ``` ### Arguments `[table](table "table") coloredtext` A table containing colors and strings to add to the object, in the form of `{color1, string1, color2, string2, ...}`. `[table](table "table") 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}`. `[string](string "string") string1` A string of text which has a color specified by the previous color. `[table](table "table") 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}`. `[string](string "string") string2` A string of text which has a color specified by the previous color. `[tables and strings](https://love2d.org/w/index.php?title=tables_and_strings&action=edit&redlink=1 "tables and strings (page does not exist)") ...` Additional colors and strings. `[number](number "number") wraplimit` The maximum width in pixels of the text before it gets automatically wrapped to a new line. `[AlignMode](alignmode "AlignMode") align` The alignment of the text. `[number](number "number") x` The position of the new text (x-axis). `[number](number "number") y` The position of the new text (y-axis). `[number](number "number") angle (0)` Orientation (radians). `[number](number "number") sx (1)` Scale factor (x-axis). `[number](number "number") sy (sx)` Scale factor (y-axis). `[number](number "number") ox (0)` Origin offset (x-axis). `[number](number "number") oy (0)` Origin offset (y-axis). `[number](number "number") kx (0)` Shearing / skew factor (x-axis). `[number](number "number") ky (0)` Shearing / skew factor (y-axis). ### Returns `[number](number "number") index` An index number that can be used with [Text:getWidth](text-getwidth "Text:getWidth") or [Text:getHeight](text-getheight "Text:getHeight"). ### Notes The color set by [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor") will be combined (multiplied) with the colors of the text, when drawing the Text object. See Also -------- * [Text](text "Text") * [Text:add](text-add "Text:add") * [Text:set](text-set "Text:set") * [Text:setf](text-setf "Text:setf") * [Text:clear](text-clear "Text:clear") love Body:getJointList Body:getJointList ================= | | | --- | | ***Deprecated in LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")*** | | It has been renamed to [Body:getJoints](body-getjoints "Body:getJoints"). | **Available since LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")** This method is not supported in earlier versions. Returns a table containing the Joints attached to this Body. Function -------- ### Synopsis ``` joints = Body:getJointList( ) ``` ### Arguments None. ### Returns `[table](table "table") joints` A [sequence](sequence "sequence") with the [Joints](joint "Joint") attached to the Body. See Also -------- * [Body](body "Body") love love.graphics.points love.graphics.points ==================== **Available since LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** It has replaced [love.graphics.point](love.graphics.point "love.graphics.point"). Draws one or more points. Function -------- ### Synopsis ``` love.graphics.points( x, y, ... ) ``` ### Arguments `[number](number "number") x` The position of the first point on the x-axis. `[number](number "number") y` The position of the first point on the y-axis. `[number](number "number") ...` The x and y coordinates of additional points. ### Returns Nothing. Function -------- ### Synopsis ``` love.graphics.points( points ) ``` ### Arguments `[table](table "table") points` A table containing multiple point positions, in the form of `{x, y, ...}`. `[number](number "number") x` The position of the first point on the x-axis. `[number](number "number") y` The position of the first point on the y-axis. `[number](number "number") ...` The x and y coordinates of additional points. ### Returns Nothing. Function -------- Draws one or more individually colored points. In versions prior to [11.0](https://love2d.org/wiki/11.0 "11.0"), color component values were within the range of 0 to 255 instead of 0 to 1. ### Synopsis ``` love.graphics.points( points ) ``` ### Arguments `[table](table "table") points` A table containing multiple individually colored points, in the form of `{point, ...}`. `[table](table "table") point` A table containing the position and color of the first point, in the form of `{x, y, r, g, b, a}`. The color components are optional. `[table](table "table") ...` Additional tables containing the position and color of more points, in the form of `{x, y, r, g, b, a}`. The color components are optional. ### Returns Nothing. ### Notes The global color set by [love.graphics.setColor](love.graphics.setcolor "love.graphics.setColor") is modulated (multiplied) with the per-point colors. Notes ----- 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 [love.graphics.scale](love.graphics.scale "love.graphics.scale") - their [size](love.graphics.setpointsize "love.graphics.setPointSize") is always in pixels. Examples -------- Render a starfield ``` function love.load() local screen_width, screen_height = love.graphics.getDimensions() local max_stars = 100 -- how many stars we want   stars = {} -- table which will hold our stars   for i=1, max_stars do -- generate the coords of our stars local x = love.math.random(5, screen_width-5) -- generate a "random" number for the x coord of this star local y = love.math.random(5, screen_height-5) -- both coords are limited to the screen size, minus 5 pixels of padding stars[i] = {x, y} -- stick the values into the table end end   function love.draw() love.graphics.points(stars) -- draw all stars as points end ``` See Also -------- * [love.graphics](love.graphics "love.graphics") * [love.graphics.setPointSize](love.graphics.setpointsize "love.graphics.setPointSize") love FrictionJoint:getMaxForce FrictionJoint:getMaxForce ========================= **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This function is not supported in earlier versions. Gets the maximum friction force in Newtons. Function -------- ### Synopsis ``` force = FrictionJoint:getMaxForce( ) ``` ### Arguments None. ### Returns `[number](number "number") force` Maximum force in Newtons. See Also -------- * [FrictionJoint](frictionjoint "FrictionJoint") * [FrictionJoint:setMaxForce](frictionjoint-setmaxforce "FrictionJoint:setMaxForce") love RevoluteJoint:getMotorTorque RevoluteJoint:getMotorTorque ============================ Get the current motor force. Function -------- ### Synopsis ``` f = RevoluteJoint:getMotorTorque( ) ``` ### Arguments None. ### Returns `[number](number "number") f` The current motor force, in Nm. See Also -------- * [RevoluteJoint](revolutejoint "RevoluteJoint") love FilterType FilterType ========== **Available since LÖVE [11.0](https://love2d.org/wiki/11.0 "11.0")** This enum is not supported in earlier versions. Types of filters for Sources. Constants --------- lowpass Low-pass filter. High frequency sounds are attenuated. highpass High-pass filter. Low frequency sounds are attenuated. bandpass Band-pass filter. Both high and low frequency sounds are attenuated based on the given parameters. See Also -------- * [Source](source "Source") * [Source:setFilter](source-setfilter "Source:setFilter") * [Source:getFilter](source-getfilter "Source:getFilter") love SpriteBatch:bind SpriteBatch:bind ================ **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** It has been renamed from [SpriteBatch:lock](spritebatch-lock "SpriteBatch:lock"). | | | --- | | ***Deprecated in LÖVE [0.9.2](https://love2d.org/wiki/0.9.2 "0.9.2")*** | | It happends automatically since this version. | **Removed in LÖVE [0.10.0](https://love2d.org/wiki/0.10.0 "0.10.0")** Use [SpriteBatch:flush](spritebatch-flush "SpriteBatch:flush") if absolutely necessary. Binds the [SpriteBatch](spritebatch "SpriteBatch") to memory for more efficient updating. Binding a SpriteBatch before updating its content can improve the performance as it doesn't push each update to the graphics card separately. Don't forget to [unbind](spritebatch-unbind "SpriteBatch:unbind") the SpriteBatch or the updates won't show up. Function -------- ### Synopsis ``` SpriteBatch:bind( ) ``` ### Arguments None. ### Returns Nothing. Examples -------- ### Updating a SpriteBatch with binding ``` function update_spritebatch(spritebatch) spritebatch:bind()   for i = 1, 100 do add_tile(spritebatch) end   spritebatch:unbind() end ``` See Also -------- * [SpriteBatch](spritebatch "SpriteBatch") * [SpriteBatch:unbind](spritebatch-unbind "SpriteBatch:unbind") love love.gamepadaxis love.gamepadaxis ================ **Available since LÖVE [0.9.0](https://love2d.org/wiki/0.9.0 "0.9.0")** This function is not supported in earlier versions. Called when a Joystick's virtual gamepad axis is moved. Function -------- ### Synopsis ``` love.gamepadaxis( joystick, axis, value ) ``` ### Arguments `[Joystick](joystick "Joystick") joystick` The joystick object. `[GamepadAxis](gamepadaxis "GamepadAxis") axis` The virtual gamepad axis. `[number](number "number") value` The new axis value. ### Returns Nothing. See Also -------- * [love](love "love") * [Joystick:isGamepad](joystick-isgamepad "Joystick:isGamepad") * [Joystick:getGamepadAxis](joystick-getgamepadaxis "Joystick:getGamepadAxis") love WheelJoint:getMotorSpeed WheelJoint:getMotorSpeed ======================== **Available since LÖVE [0.8.0](https://love2d.org/wiki/0.8.0 "0.8.0")** This method is not supported in earlier versions. Returns the speed of the motor. Function -------- ### Synopsis ``` speed = WheelJoint:getMotorSpeed( ) ``` ### Arguments None. ### Returns `[number](number "number") speed` The speed of the joint motor in radians per second. See Also -------- * [WheelJoint](wheeljoint "WheelJoint") * [WheelJoint:setMotorSpeed](wheeljoint-setmotorspeed "WheelJoint:setMotorSpeed") elisp None #### Wrong Time The most common problem in writing macros is doing some of the real work prematurely—while expanding the macro, rather than in the expansion itself. For instance, one real package had this macro definition: ``` (defmacro my-set-buffer-multibyte (arg) (if (fboundp 'set-buffer-multibyte) (set-buffer-multibyte arg))) ``` With this erroneous macro definition, the program worked fine when interpreted but failed when compiled. This macro definition called `set-buffer-multibyte` during compilation, which was wrong, and then did nothing when the compiled package was run. The definition that the programmer really wanted was this: ``` (defmacro my-set-buffer-multibyte (arg) (if (fboundp 'set-buffer-multibyte) `(set-buffer-multibyte ,arg))) ``` This macro expands, if appropriate, into a call to `set-buffer-multibyte` that will be executed when the compiled program is actually run.
programming_docs
elisp None ### Frame Geometry The geometry of a frame depends on the toolkit that was used to build this instance of Emacs and the terminal that displays the frame. This chapter describes these dependencies and some of the functions to deal with them. Note that the frame argument of all of these functions has to specify a live frame (see [Deleting Frames](deleting-frames)). If omitted or `nil`, it specifies the selected frame (see [Input Focus](input-focus)). | | | | | --- | --- | --- | | • [Frame Layout](frame-layout) | | Basic layout of frames. | | • [Frame Font](frame-font) | | The default font of a frame and how to set it. | | • [Frame Position](frame-position) | | The position of a frame on its display. | | • [Frame Size](frame-size) | | Specifying and retrieving a frame’s size. | | • [Implied Frame Resizing](implied-frame-resizing) | | Implied resizing of frames and how to prevent it. | elisp None ### Window History Each window remembers in a list the buffers it has previously displayed, and the order in which these buffers were removed from it. This history is used, for example, by `replace-buffer-in-windows` (see [Buffers and Windows](buffers-and-windows)), and when quitting windows (see [Quitting Windows](quitting-windows)). The list is automatically maintained by Emacs, but you can use the following functions to explicitly inspect or alter it: Function: **window-prev-buffers** *&optional window* This function returns a list specifying the previous contents of window. The optional argument window should be a live window and defaults to the selected one. Each list element has the form `(buffer window-start window-pos)`, where buffer is a buffer previously shown in the window, window-start is the window start position (see [Window Start and End](window-start-and-end)) when that buffer was last shown, and window-pos is the point position (see [Window Point](window-point)) when that buffer was last shown in window. The list is ordered so that earlier elements correspond to more recently-shown buffers, and the first element usually corresponds to the buffer most recently removed from the window. Function: **set-window-prev-buffers** *window prev-buffers* This function sets window’s previous buffers to the value of prev-buffers. The argument window must be a live window and defaults to the selected one. The argument prev-buffers should be a list of the same form as that returned by `window-prev-buffers`. In addition, each window maintains a list of *next buffers*, which is a list of buffers re-shown by `switch-to-prev-buffer` (see below). This list is mainly used by `switch-to-prev-buffer` and `switch-to-next-buffer` for choosing buffers to switch to. Function: **window-next-buffers** *&optional window* This function returns the list of buffers recently re-shown in window via `switch-to-prev-buffer`. The window argument must denote a live window or `nil` (meaning the selected window). Function: **set-window-next-buffers** *window next-buffers* This function sets the next buffer list of window to next-buffers. The window argument should be a live window or `nil` (meaning the selected window). The argument next-buffers should be a list of buffers. The following commands can be used to cycle through the global buffer list, much like `bury-buffer` and `unbury-buffer`. However, they cycle according to the specified window’s history list, rather than the global buffer list. In addition, they restore window-specific window start and point positions, and may show a buffer even if it is already shown in another window. The `switch-to-prev-buffer` command, in particular, is used by `replace-buffer-in-windows`, `bury-buffer` and `quit-window` to find a replacement buffer for a window. Command: **switch-to-prev-buffer** *&optional window bury-or-kill* This command displays the previous buffer in window. The argument window should be a live window or `nil` (meaning the selected window). If the optional argument bury-or-kill is non-`nil`, this means that the buffer currently shown in window is about to be buried or killed and consequently should not be switched to in future invocations of this command. The previous buffer is usually the buffer shown before the buffer currently shown in window. However, a buffer that has been buried or killed, or has been already shown by a recent invocation of `switch-to-prev-buffer`, does not qualify as previous buffer. If repeated invocations of this command have already shown all buffers previously shown in window, further invocations will show buffers from the buffer list of the frame window appears on (see [Buffer List](buffer-list)). The option `switch-to-prev-buffer-skip` described below can be used to inhibit switching to certain buffers, for example, to those already shown in another window. Also, if window’s frame has a `buffer-predicate` parameter (see [Buffer Parameters](buffer-parameters)), that predicate may inhibit switching to certain buffers. Command: **switch-to-next-buffer** *&optional window* This command switches to the next buffer in window, thus undoing the effect of the last `switch-to-prev-buffer` command in window. The argument window must be a live window and defaults to the selected one. If there is no recent invocation of `switch-to-prev-buffer` that can be undone, this function tries to show a buffer from the buffer list of the frame window appears on (see [Buffer List](buffer-list)). The option `switch-to-prev-buffer-skip` and the `buffer-predicate` (see [Buffer Parameters](buffer-parameters)) of window’s frame affect this command as they do for `switch-to-prev-buffer`. By default `switch-to-prev-buffer` and `switch-to-next-buffer` can switch to a buffer that is already shown in another window. The following option can be used to override this behavior. User Option: **switch-to-prev-buffer-skip** If this variable is `nil`, `switch-to-prev-buffer` may switch to any buffer, including those already shown in other windows. If this variable is non-`nil`, `switch-to-prev-buffer` will refrain from switching to certain buffers. The following values can be used: * `this` means do not switch to a buffer shown on the frame that hosts the window `switch-to-prev-buffer` is acting upon. * `visible` means do not switch to a buffer shown on any visible frame. * 0 (the number zero) means do not switch to a buffer shown on any visible or iconified frame. * `t` means do not switch to a buffer shown on any live frame. * A function that takes three arguments—the window argument of `switch-to-prev-buffer`, a buffer `switch-to-prev-buffer` intends to switch to and the bury-or-kill argument of `switch-to-prev-buffer`. If that function returns non-`nil`, `switch-to-prev-buffer` will refrain from switching to the buffer specified by the second argument. The command `switch-to-next-buffer` obeys this option in a similar way. If this option specifies a function, `switch-to-next-buffer` will call that function with the third argument always `nil`. Note that since `switch-to-prev-buffer` is called by `bury-buffer`, `replace-buffer-in-windows` and `quit-restore-window` as well, customizing this option may also affect the behavior of Emacs when a window is quit or a buffer gets buried or killed. Note also that under certain circumstances `switch-to-prev-buffer` and `switch-to-next-buffer` may ignore this option, for example, when there is only one buffer left these functions can switch to. elisp None #### Functions and macros using rx regexps Macro: **rx** *rx-form…* Translate the rx-forms to a string regexp, as if they were the body of a `(seq …)` form. The `rx` macro expands to a string constant, or, if `literal` or `regexp` forms are used, a Lisp expression that evaluates to a string. Example: ``` (rx (+ alpha) "=" (+ digit)) ⇒ "[[:alpha:]]+=[[:digit:]]+" ``` Function: **rx-to-string** *rx-expr &optional no-group* Translate rx-expr to a string regexp which is returned. If no-group is absent or nil, bracket the result in a non-capturing group, ‘`\(?:…\)`’, if necessary to ensure that a postfix operator appended to it will apply to the whole expression. Example: ``` (rx-to-string '(seq (+ alpha) "=" (+ digit)) t) ⇒ "[[:alpha:]]+=[[:digit:]]+" ``` Arguments to `literal` and `regexp` forms in rx-expr must be string literals. The `pcase` macro can use `rx` expressions as patterns directly; see [rx in pcase](pcase-macro#rx-in-pcase). For mechanisms to add user-defined extensions to the `rx` notation, see [Extending Rx](extending-rx). elisp None #### Module Initialization Code Begin your module by including the header file `emacs-module.h` and defining the GPL compatibility symbol: ``` #include <emacs-module.h> int plugin_is_GPL_compatible; ``` The `emacs-module.h` file is installed into your system’s include tree as part of the Emacs installation. Alternatively, you can find it in the Emacs source tree. Next, write an initialization function for the module. Function: *int* **emacs\_module\_init** *(struct emacs\_runtime \*runtime)* Emacs calls this function when it loads a module. If a module does not export a function named `emacs_module_init`, trying to load the module will signal an error. The initialization function should return zero if the initialization succeeds, non-zero otherwise. In the latter case, Emacs will signal an error, and the loading of the module will fail. If the user presses `C-g` during the initialization, Emacs ignores the return value of the initialization function and quits (see [Quitting](quitting)). (If needed, you can catch user quitting inside the initialization function, see [should\_quit](module-misc#should_005fquit).) The argument runtime is a pointer to a C `struct` that includes 2 public fields: `size`, which provides the size of the structure in bytes; and `get_environment`, which provides a pointer to a function that allows the module initialization function access to the Emacs environment object and its interfaces. The initialization function should perform whatever initialization is required for the module. In addition, it can perform the following tasks: Compatibility verification A module can verify that the Emacs executable which loads the module is compatible with the module, by comparing the `size` member of the runtime structure with the value compiled into the module: ``` int emacs_module_init (struct emacs_runtime *runtime) { if (runtime->size < sizeof (*runtime)) return 1; } ``` If the size of the runtime object passed to the module is smaller than what it expects, it means the module was compiled for an Emacs version newer (later) than the one which attempts to load it, i.e. the module might be incompatible with the Emacs binary. In addition, a module can verify the compatibility of the module API with what the module expects. The following sample code assumes it is part of the `emacs_module_init` function shown above: ``` emacs_env *env = runtime->get_environment (runtime); if (env->size < sizeof (*env)) return 2; ``` This calls the `get_environment` function using the pointer provided in the `runtime` structure to retrieve a pointer to the API’s *environment*, a C `struct` which also has a `size` field holding the size of the structure in bytes. Finally, you can write a module that will work with older versions of Emacs, by comparing the size of the environment passed by Emacs with known sizes, like this: ``` emacs_env *env = runtime->get_environment (runtime); if (env->size >= sizeof (struct emacs_env_26)) emacs_version = 26; /* Emacs 26 or later. */ else if (env->size >= sizeof (struct emacs_env_25)) emacs_version = 25; else return 2; /* Unknown or unsupported version. */ ``` This works because later Emacs versions always *add* members to the environment, never *remove* any members, so the size can only grow with new Emacs releases. Given the version of Emacs, the module can use only the parts of the module API that existed in that version, since those parts are identical in later versions. `emacs-module.h` defines a preprocessor macro `EMACS_MAJOR_VERSION`. It expands to an integer literal which is the latest major version of Emacs supported by the header. See [Version Info](version-info). Note that the value of `EMACS_MAJOR_VERSION` is a compile-time constant and does not represent the version of Emacs that is currently running and has loaded your module. If you want your module to be compatible with various versions of `emacs-module.h` as well as various versions of Emacs, you can use conditional compilation based on `EMACS_MAJOR_VERSION`. We recommend that modules always perform the compatibility verification, unless they do their job entirely in the initialization function, and don’t access any Lisp objects or use any Emacs functions accessible through the environment structure. Binding module functions to Lisp symbols This gives the module functions names so that Lisp code could call it by that name. We describe how to do this in [Module Functions](module-functions) below. elisp None #### Defining Images The functions `create-image`, `defimage` and `find-image` provide convenient ways to create image descriptors. Function: **create-image** *file-or-data &optional type data-p &rest props* This function creates and returns an image descriptor which uses the data in file-or-data. file-or-data can be a file name or a string containing the image data; data-p should be `nil` for the former case, non-`nil` for the latter case. The optional argument type is a symbol specifying the image type. If type is omitted or `nil`, `create-image` tries to determine the image type from the file’s first few bytes, or else from the file’s name. The remaining arguments, props, specify additional image properties—for example, ``` (create-image "foo.xpm" 'xpm nil :heuristic-mask t) ``` The function returns `nil` if images of this type are not supported. Otherwise it returns an image descriptor. Macro: **defimage** *symbol specs &optional doc* This macro defines symbol as an image name. The arguments specs is a list which specifies how to display the image. The third argument, doc, is an optional documentation string. Each argument in specs has the form of a property list, and each one should specify at least the `:type` property and either the `:file` or the `:data` property. The value of `:type` should be a symbol specifying the image type, the value of `:file` is the file to load the image from, and the value of `:data` is a string containing the actual image data. Here is an example: ``` (defimage test-image ((:type xpm :file "~/test1.xpm") (:type xbm :file "~/test1.xbm"))) ``` `defimage` tests each argument, one by one, to see if it is usable—that is, if the type is supported and the file exists. The first usable argument is used to make an image descriptor which is stored in symbol. If none of the alternatives will work, then symbol is defined as `nil`. Function: **image-property** *image property* Return the value of property in image. Properties can be set by using `setf`. Setting a property to `nil` will remove the property from the image. Function: **find-image** *specs* This function provides a convenient way to find an image satisfying one of a list of image specifications specs. Each specification in specs is a property list with contents depending on image type. All specifications must at least contain the properties `:type type` and either `:file file` or `:data data`, where type is a symbol specifying the image type, e.g., `xbm`, file is the file to load the image from, and data is a string containing the actual image data. The first specification in the list whose type is supported, and file exists, is used to construct the image specification to be returned. If no specification is satisfied, `nil` is returned. The image is looked for in `image-load-path`. User Option: **image-load-path** This variable’s value is a list of locations in which to search for image files. If an element is a string or a variable symbol whose value is a string, the string is taken to be the name of a directory to search. If an element is a variable symbol whose value is a list, that is taken to be a list of directories to search. The default is to search in the `images` subdirectory of the directory specified by `data-directory`, then the directory specified by `data-directory`, and finally in the directories in `load-path`. Subdirectories are not automatically included in the search, so if you put an image file in a subdirectory, you have to supply the subdirectory explicitly. For example, to find the image `images/foo/bar.xpm` within `data-directory`, you should specify the image as follows: ``` (defimage foo-image '((:type xpm :file "foo/bar.xpm"))) ``` Function: **image-load-path-for-library** *library image &optional path no-error* This function returns a suitable search path for images used by the Lisp package library. The function searches for image first using `image-load-path`, excluding ``data-directory`/images`, and then in `load-path`, followed by a path suitable for library, which includes `../../etc/images` and `../etc/images` relative to the library file itself, and finally in ``data-directory`/images`. Then this function returns a list of directories which contains first the directory in which image was found, followed by the value of `load-path`. If path is given, it is used instead of `load-path`. If no-error is non-`nil` and a suitable path can’t be found, don’t signal an error. Instead, return a list of directories as before, except that `nil` appears in place of the image directory. Here is an example of using `image-load-path-for-library`: ``` (defvar image-load-path) ; shush compiler (let* ((load-path (image-load-path-for-library "mh-e" "mh-logo.xpm")) (image-load-path (cons (car load-path) image-load-path))) (mh-tool-bar-folder-buttons-init)) ``` Images are automatically scaled when created based on the `image-scaling-factor` variable. The value is either a floating point number (where numbers higher than 1 means to increase the size and lower means to shrink the size), or the symbol `auto`, which will compute a scaling factor based on the font pixel size. elisp None ### Input Focus At any time, one frame in Emacs is the *selected frame*. The selected window (see [Selecting Windows](selecting-windows)) always resides on the selected frame. When Emacs displays its frames on several terminals (see [Multiple Terminals](multiple-terminals)), each terminal has its own selected frame. But only one of these is *the* selected frame: it’s the frame that belongs to the terminal from which the most recent input came. That is, when Emacs runs a command that came from a certain terminal, the selected frame is the one of that terminal. Since Emacs runs only a single command at any given time, it needs to consider only one selected frame at a time; this frame is what we call *the selected frame* in this manual. The display on which the selected frame is shown is the *selected frame’s display*. Function: **selected-frame** This function returns the selected frame. Some window systems and window managers direct keyboard input to the window object that the mouse is in; others require explicit clicks or commands to *shift the focus* to various window objects. Either way, Emacs automatically keeps track of which frames have focus. To explicitly switch to a different frame from a Lisp function, call `select-frame-set-input-focus`. The plural “frames” in the previous paragraph is deliberate: while Emacs itself has only one selected frame, Emacs can have frames on many different terminals (recall that a connection to a window system counts as a terminal), and each terminal has its own idea of which frame has input focus. When you set the input focus to a frame, you set the focus for that frame’s terminal, but frames on other terminals may still remain focused. Lisp programs can switch frames temporarily by calling the function `select-frame`. This does not alter the window system’s concept of focus; rather, it escapes from the window manager’s control until that control is somehow reasserted. When using a text terminal, only one frame can be displayed at a time on the terminal, so after a call to `select-frame`, the next redisplay actually displays the newly selected frame. This frame remains selected until a subsequent call to `select-frame`. Each frame on a text terminal has a number which appears in the mode line before the buffer name (see [Mode Line Variables](mode-line-variables)). Function: **select-frame-set-input-focus** *frame &optional norecord* This function selects frame, raises it (should it happen to be obscured by other frames) and tries to give it the window system’s focus. On a text terminal, the next redisplay displays the new frame on the entire terminal screen. The optional argument norecord has the same meaning as for `select-frame` (see below). The return value of this function is not significant. Ideally, the function described next should focus a frame without also raising it above other frames. Unfortunately, many window-systems or window managers may refuse to comply. Function: **x-focus-frame** *frame &optional noactivate* This function gives frame the focus of the X server without necessarily raising it. frame `nil` means use the selected frame. Under X, the optional argument noactivate, if non-`nil`, means to avoid making frame’s window-system window the “active” window which should insist a bit more on avoiding to raise frame above other frames. On MS-Windows the noactivate argument has no effect. However, if frame is a child frame (see [Child Frames](child-frames)), this function usually focuses frame without raising it above other child frames. If there is no window system support, this function does nothing. Command: **select-frame** *frame &optional norecord* This function selects frame frame, temporarily disregarding the focus of the X server if any. The selection of frame lasts until the next time the user does something to select a different frame, or until the next time this function is called. (If you are using a window system, the previously selected frame may be restored as the selected frame after return to the command loop, because it still may have the window system’s input focus.) The specified frame becomes the selected frame, and its terminal becomes the selected terminal. This function then calls `select-window` as a subroutine, passing the window selected within frame as its first argument and norecord as its second argument (hence, if norecord is non-`nil`, this avoids changing the order of recently selected windows and the buffer list). See [Selecting Windows](selecting-windows). This function returns frame, or `nil` if frame has been deleted. In general, you should never use `select-frame` in a way that could switch to a different terminal without switching back when you’re done. Emacs cooperates with the window system by arranging to select frames as the server and window manager request. When a window system informs Emacs that one of its frames has been selected, Emacs internally generates a *focus-in* event. When an Emacs frame is displayed on a text-terminal emulator, such as `xterm`, which supports reporting of focus-change notification, the focus-in and focus-out events are available even for text-mode frames. Focus events are normally handled by `handle-focus-in`. Command: **handle-focus-in** *event* This function handles focus-in events from window systems and terminals that support explicit focus notifications. It updates the per-frame focus flags that `frame-focus-state` queries and calls `after-focus-change-function`. In addition, it generates a `switch-frame` event in order to switch the Emacs notion of the selected frame to the frame most recently focused in some terminal. It’s important to note that this switching of the Emacs selected frame to the most recently focused frame does not mean that other frames do not continue to have the focus in their respective terminals. Do not invoke this function yourself: instead, attach logic to `after-focus-change-function`. Command: **handle-switch-frame** *frame* This function handles a switch-frame event, which Emacs generates for itself upon focus notification or under various other circumstances involving an input event arriving at a different frame from the last event. Do not invoke this function yourself. Function: **redirect-frame-focus** *frame &optional focus-frame* This function redirects focus from frame to focus-frame. This means that focus-frame will receive subsequent keystrokes and events intended for frame. After such an event, the value of `last-event-frame` will be focus-frame. Also, switch-frame events specifying frame will instead select focus-frame. If focus-frame is omitted or `nil`, that cancels any existing redirection for frame, which therefore once again receives its own events. One use of focus redirection is for frames that don’t have minibuffers. These frames use minibuffers on other frames. Activating a minibuffer on another frame redirects focus to that frame. This puts the focus on the minibuffer’s frame, where it belongs, even though the mouse remains in the frame that activated the minibuffer. Selecting a frame can also change focus redirections. Selecting frame `bar`, when `foo` had been selected, changes any redirections pointing to `foo` so that they point to `bar` instead. This allows focus redirection to work properly when the user switches from one frame to another using `select-window`. This means that a frame whose focus is redirected to itself is treated differently from a frame whose focus is not redirected. `select-frame` affects the former but not the latter. The redirection lasts until `redirect-frame-focus` is called to change it. Function: **frame-focus-state** *frame* This function retrieves the last known focus state of frame. It returns `nil` if the frame is known not to be focused, `t` if the frame is known to be focused, or `unknown` if Emacs does not know the focus state of the frame. (You may see this last state in TTY frames running on terminals that do not support explicit focus notifications.) Variable: **after-focus-change-function** This function is an extension point that code can use to receive a notification that focus has changed. This function is called with no arguments when Emacs notices that the set of focused frames may have changed. Code wanting to do something when frame focus changes should use `add-function` to add a function to this one, and in this added function, re-scan the set of focused frames, calling `frame-focus-state` to retrieve the last known focus state of each frame. Focus events are delivered asynchronously, and frame input focus according to an external system may not correspond to the notion of the Emacs selected frame. Multiple frames may appear to have input focus simultaneously due to focus event delivery differences, the presence of multiple Emacs terminals, and other factors, and code should be robust in the face of this situation. Depending on window system, focus events may also be delivered repeatedly and with different focus states before settling to the expected values. Code relying on focus notifications should “debounce” any user-visible updates arising from focus changes, perhaps by deferring work until redisplay. This function may be called in arbitrary contexts, including from inside `read-event`, so take the same care as you might when writing a process filter. User Option: **focus-follows-mouse** This option informs Emacs whether and how the window manager transfers focus when you move the mouse pointer into a frame. It can have three meaningful values: `nil` The default value `nil` should be used when your window manager follows a “click-to-focus” policy where you have to click the mouse inside of a frame in order for that frame to gain focus. `t` The value `t` should be used when your window manager has the focus automatically follow the position of the mouse pointer but a frame that gains focus is not raised automatically and may even remain occluded by other window-system windows. `auto-raise` The value `auto-raise` should be used when your window manager has the focus automatically follow the position of the mouse pointer and a frame that gains focus is raised automatically. If this option is non-`nil`, Emacs moves the mouse pointer to the frame selected by `select-frame-set-input-focus`. That function is used by a number of commands like, for example, `other-frame` and `pop-to-buffer`. The distinction between the values `t` and `auto-raise` is not needed for “normal” frames because the window manager usually takes care of raising them. It is useful to automatically raise child frames via `mouse-autoselect-window` (see [Mouse Window Auto-selection](mouse-window-auto_002dselection)). Note that this option does not distinguish “sloppy” focus (where the frame that previously had focus retains focus as long as the mouse pointer does not move into another window-system window) from “strict” focus (where a frame immediately loses focus when it’s left by the mouse pointer). Neither does it recognize whether your window manager supports delayed focusing or auto-raising where you can explicitly specify the time until a new frame gets focus or is auto-raised. You can supply a “focus follows mouse” policy for individual Emacs windows by customizing the variable `mouse-autoselect-window` (see [Mouse Window Auto-selection](mouse-window-auto_002dselection)).
programming_docs
elisp None Symbols ------- A *symbol* is an object with a unique name. This chapter describes symbols, their components, their property lists, and how they are created and interned. Separate chapters describe the use of symbols as variables and as function names; see [Variables](variables), and [Functions](functions). For the precise read syntax for symbols, see [Symbol Type](symbol-type). You can test whether an arbitrary Lisp object is a symbol with `symbolp`: Function: **symbolp** *object* This function returns `t` if object is a symbol, `nil` otherwise. | | | | | --- | --- | --- | | • [Symbol Components](symbol-components) | | Symbols have names, values, function definitions and property lists. | | • [Definitions](definitions) | | A definition says how a symbol will be used. | | • [Creating Symbols](creating-symbols) | | How symbols are kept unique. | | • [Symbol Properties](symbol-properties) | | Each symbol has a property list for recording miscellaneous information. | | • [Shorthands](shorthands) | | Properly organize your symbol names but type less of them. | | | elisp None #### GnuTLS Cryptographic Functions Function: **gnutls-digests** This function returns the alist of the GnuTLS digest algorithms. Each entry has a key which represents the algorithm, followed by a plist with internal details about the algorithm. The plist will have `:type gnutls-digest-algorithm` and also will have the key `:digest-algorithm-length 64` to indicate the size, in bytes, of the resulting digest. There is a name parallel between GnuTLS MAC and digest algorithms but they are separate things internally and should not be mixed. Function: **gnutls-hash-digest** *digest-method input* The digest-method can be the whole plist from `gnutls-digests`, or just the symbol key, or a string with the name of that symbol. The input can be specified as a buffer or string or in other ways (see [Format of GnuTLS Cryptography Inputs](format-of-gnutls-cryptography-inputs)). This function returns `nil` on error, and signals a Lisp error if the digest-method or input are invalid. On success, it returns a list of a binary string (the output) and the IV used. Function: **gnutls-macs** This function returns the alist of the GnuTLS MAC algorithms. Each entry has a key which represents the algorithm, followed by a plist with internal details about the algorithm. The plist will have `:type gnutls-mac-algorithm` and also will have the keys `:mac-algorithm-length` `:mac-algorithm-keysize` `:mac-algorithm-noncesize` to indicate the size, in bytes, of the resulting hash, the key, and the nonce respectively. The nonce is currently unused and only some MACs support it. There is a name parallel between GnuTLS MAC and digest algorithms but they are separate things internally and should not be mixed. Function: **gnutls-hash-mac** *hash-method key input* The hash-method can be the whole plist from `gnutls-macs`, or just the symbol key, or a string with the name of that symbol. The key can be specified as a buffer or string or in other ways (see [Format of GnuTLS Cryptography Inputs](format-of-gnutls-cryptography-inputs)). The key will be wiped after use if it’s a string. The input can be specified as a buffer or string or in other ways (see [Format of GnuTLS Cryptography Inputs](format-of-gnutls-cryptography-inputs)). This function returns `nil` on error, and signals a Lisp error if the hash-method or key or input are invalid. On success, it returns a list of a binary string (the output) and the IV used. Function: **gnutls-ciphers** This function returns the alist of the GnuTLS ciphers. Each entry has a key which represents the cipher, followed by a plist with internal details about the algorithm. The plist will have `:type gnutls-symmetric-cipher` and also will have the keys `:cipher-aead-capable` set to `nil` or `t` to indicate AEAD capability; and `:cipher-tagsize` `:cipher-blocksize` `:cipher-keysize` `:cipher-ivsize` to indicate the size, in bytes, of the tag, block size of the resulting data, the key, and the IV respectively. Function: **gnutls-symmetric-encrypt** *cipher key iv input &optional aead\_auth* The cipher can be the whole plist from `gnutls-ciphers`, or just the symbol key, or a string with the name of that symbol. The key can be specified as a buffer or string or in other ways (see [Format of GnuTLS Cryptography Inputs](format-of-gnutls-cryptography-inputs)). The key will be wiped after use if it’s a string. The iv and input and the optional aead\_auth can be specified as a buffer or string or in other ways (see [Format of GnuTLS Cryptography Inputs](format-of-gnutls-cryptography-inputs)). aead\_auth is only checked with AEAD ciphers, that is, ciphers whose plist has `:cipher-aead-capable t`. Otherwise it’s ignored. This function returns `nil` on error, and signals a Lisp error if the cipher or key, iv, or input are invalid, or if aead\_auth was specified with an AEAD cipher and was invalid. On success, it returns a list of a binary string (the output) and the IV used. Function: **gnutls-symmetric-decrypt** *cipher key iv input &optional aead\_auth* The cipher can be the whole plist from `gnutls-ciphers`, or just the symbol key, or a string with the name of that symbol. The key can be specified as a buffer or string or in other ways (see [Format of GnuTLS Cryptography Inputs](format-of-gnutls-cryptography-inputs)). The key will be wiped after use if it’s a string. The iv and input and the optional aead\_auth can be specified as a buffer or string or in other ways (see [Format of GnuTLS Cryptography Inputs](format-of-gnutls-cryptography-inputs)). aead\_auth is only checked with AEAD ciphers, that is, ciphers whose plist has `:cipher-aead-capable t`. Otherwise it’s ignored. This function returns `nil` on decryption error, and signals a Lisp error if the cipher or key, iv, or input are invalid, or if aead\_auth was specified with an AEAD cipher and was invalid. On success, it returns a list of a binary string (the output) and the IV used. elisp None ### Display Feature Testing The functions in this section describe the basic capabilities of a particular display. Lisp programs can use them to adapt their behavior to what the display can do. For example, a program that ordinarily uses a popup menu could use the minibuffer if popup menus are not supported. The optional argument display in these functions specifies which display to ask the question about. It can be a display name, a frame (which designates the display that frame is on), or `nil` (which refers to the selected frame’s display, see [Input Focus](input-focus)). See [Color Names](color-names), [Text Terminal Colors](text-terminal-colors), for other functions to obtain information about displays. Function: **display-popup-menus-p** *&optional display* This function returns `t` if popup menus are supported on display, `nil` if not. Support for popup menus requires that the mouse be available, since the menu is popped up by clicking the mouse on some portion of the Emacs display. Function: **display-graphic-p** *&optional display* This function returns `t` if display is a graphic display capable of displaying several frames and several different fonts at once. This is true for displays that use a window system such as X, and false for text terminals. Function: **display-mouse-p** *&optional display* This function returns `t` if display has a mouse available, `nil` if not. Function: **display-color-p** *&optional display* This function returns `t` if the screen is a color screen. It used to be called `x-display-color-p`, and that name is still supported as an alias. Function: **display-grayscale-p** *&optional display* This function returns `t` if the screen can display shades of gray. (All color displays can do this.) Function: **display-supports-face-attributes-p** *attributes &optional display* This function returns non-`nil` if all the face attributes in attributes are supported (see [Face Attributes](face-attributes)). The definition of “supported” is somewhat heuristic, but basically means that a face containing all the attributes in attributes, when merged with the default face for display, can be represented in a way that’s 1. different in appearance than the default face, and 2. close in spirit to what the attributes specify, if not exact. Point (2) implies that a `:weight black` attribute will be satisfied by any display that can display bold, as will `:foreground "yellow"` as long as some yellowish color can be displayed, but `:slant italic` will *not* be satisfied by the tty display code’s automatic substitution of a dim face for italic. Function: **display-selections-p** *&optional display* This function returns `t` if display supports selections. Windowed displays normally support selections, but they may also be supported in some other cases. Function: **display-images-p** *&optional display* This function returns `t` if display can display images. Windowed displays ought in principle to handle images, but some systems lack the support for that. On a display that does not support images, Emacs cannot display a tool bar. Function: **display-screens** *&optional display* This function returns the number of screens associated with the display. Function: **display-pixel-height** *&optional display* This function returns the height of the screen in pixels. On a character terminal, it gives the height in characters. For graphical terminals, note that on multi-monitor setups this refers to the pixel height for all physical monitors associated with display. See [Multiple Terminals](multiple-terminals). Function: **display-pixel-width** *&optional display* This function returns the width of the screen in pixels. On a character terminal, it gives the width in characters. For graphical terminals, note that on multi-monitor setups this refers to the pixel width for all physical monitors associated with display. See [Multiple Terminals](multiple-terminals). Function: **display-mm-height** *&optional display* This function returns the height of the screen in millimeters, or `nil` if Emacs cannot get that information. For graphical terminals, note that on multi-monitor setups this refers to the height for all physical monitors associated with display. See [Multiple Terminals](multiple-terminals). Function: **display-mm-width** *&optional display* This function returns the width of the screen in millimeters, or `nil` if Emacs cannot get that information. For graphical terminals, note that on multi-monitor setups this refers to the width for all physical monitors associated with display. See [Multiple Terminals](multiple-terminals). User Option: **display-mm-dimensions-alist** This variable allows the user to specify the dimensions of graphical displays returned by `display-mm-height` and `display-mm-width` in case the system provides incorrect values. Function: **display-backing-store** *&optional display* This function returns the backing store capability of the display. Backing store means recording the pixels of windows (and parts of windows) that are not exposed, so that when exposed they can be displayed very quickly. Values can be the symbols `always`, `when-mapped`, or `not-useful`. The function can also return `nil` when the question is inapplicable to a certain kind of display. Function: **display-save-under** *&optional display* This function returns non-`nil` if the display supports the SaveUnder feature. That feature is used by pop-up windows to save the pixels they obscure, so that they can pop down quickly. Function: **display-planes** *&optional display* This function returns the number of planes the display supports. This is typically the number of bits per pixel. For a tty display, it is log to base two of the number of colors supported. Function: **display-visual-class** *&optional display* This function returns the visual class for the screen. The value is one of the symbols `static-gray` (a limited, unchangeable number of grays), `gray-scale` (a full range of grays), `static-color` (a limited, unchangeable number of colors), `pseudo-color` (a limited number of colors), `true-color` (a full range of colors), and `direct-color` (a full range of colors). Function: **display-color-cells** *&optional display* This function returns the number of color cells the screen supports. These functions obtain additional information about the window system in use where Emacs shows the specified display. (Their names begin with `x-` for historical reasons.) Function: **x-server-version** *&optional display* This function returns the list of version numbers of the GUI window system running on display, such as the X server on GNU and Unix systems. The value is a list of three integers: the major and minor version numbers of the protocol, and the distributor-specific release number of the window system software itself. On GNU and Unix systems, these are normally the version of the X protocol and the distributor-specific release number of the X server software. On MS-Windows, this is the version of the Windows OS. Function: **x-server-vendor** *&optional display* This function returns the vendor that provided the window system software (as a string). On GNU and Unix systems this really means whoever distributes the X server. On MS-Windows this is the vendor ID string of the Windows OS (Microsoft). When the developers of X labeled software distributors as “vendors”, they showed their false assumption that no system could ever be developed and distributed noncommercially. elisp None #### make-network-process The basic function for creating network connections and network servers is `make-network-process`. It can do either of those jobs, depending on the arguments you give it. Function: **make-network-process** *&rest args* This function creates a network connection or server and returns the process object that represents it. The arguments args are a list of keyword/argument pairs. Omitting a keyword is always equivalent to specifying it with value `nil`, except for `:coding`, `:filter-multibyte`, and `:reuseaddr`. Here are the meaningful keywords (those corresponding to network options are listed in the following section): :name name Use the string name as the process name. It is modified if necessary to make it unique. :type type Specify the communication type. A value of `nil` specifies a stream connection (the default); `datagram` specifies a datagram connection; `seqpacket` specifies a sequenced packet stream connection. Both connections and servers can be of these types. :server server-flag If server-flag is non-`nil`, create a server. Otherwise, create a connection. For a stream type server, server-flag may be an integer, which then specifies the length of the queue of pending connections to the server. The default queue length is 5. :host host Specify the host to connect to. host should be a host name or Internet address, as a string, or the symbol `local` to specify the local host. If you specify host for a server, it must specify a valid address for the local host, and only clients connecting to that address will be accepted. When using `local`, by default IPv4 will be used, specify a family of `ipv6` to override this. To listen on all interfaces, specify an address of ‘`"0.0.0.0"`’ for IPv4 or ‘`"::"`’ for IPv6. Note that on some operating systems, listening on ‘`"::"`’ will also listen on IPv4, so attempting to then listen separately on IPv4 will result in `EADDRINUSE` errors (‘`"Address already in use"`’). :service service service specifies a port number to connect to; or, for a server, the port number to listen on. It should be a service name like ‘`"https"`’ that translates to a port number, or an integer like ‘`443`’ or an integer string like ‘`"443"`’ that specifies the port number directly. For a server, it can also be `t`, which means to let the system select an unused port number. :family family family specifies the address (and protocol) family for communication. `nil` means determine the proper address family automatically for the given host and service. `local` specifies a Unix socket, in which case host is ignored. `ipv4` and `ipv6` specify to use IPv4 and IPv6, respectively. :use-external-socket use-external-socket If use-external-socket is non-`nil` use any sockets passed to Emacs on invocation instead of allocating one. This is used by the Emacs server code to allow on-demand socket activation. If Emacs wasn’t passed a socket, this option is silently ignored. :local local-address For a server process, local-address is the address to listen on. It overrides family, host and service, so you might as well not specify them. :remote remote-address For a connection, remote-address is the address to connect to. It overrides family, host and service, so you might as well not specify them. For a datagram server, remote-address specifies the initial setting of the remote datagram address. The format of local-address or remote-address depends on the address family: * - An IPv4 address is represented as a five-element vector of four 8-bit integers and one 16-bit integer `[a b c d p]` corresponding to numeric IPv4 address a.b.c.d and port number p. * - An IPv6 address is represented as a nine-element vector of 16-bit integers `[a b c d e f g h p]` corresponding to numeric IPv6 address a:b:c:d:e:f:g:h and port number p. * - A local address is represented as a string, which specifies the address in the local address space. * - An unsupported-family address is represented by a cons `(f . av)`, where f is the family number and av is a vector specifying the socket address using one element per address data byte. Do not rely on this format in portable code, as it may depend on implementation defined constants, data sizes, and data structure alignment. :nowait bool If bool is non-`nil` for a stream connection, return without waiting for the connection to complete. When the connection succeeds or fails, Emacs will call the sentinel function, with a second argument matching `"open"` (if successful) or `"failed"`. The default is to block, so that `make-network-process` does not return until the connection has succeeded or failed. If you’re setting up an asynchronous TLS connection, you have to also provide the `:tls-parameters` parameter (see below). Depending on the capabilities of Emacs, how asynchronous `:nowait` is may vary. The three elements that may (or may not) be done asynchronously are domain name resolution, socket setup, and (for TLS connections) TLS negotiation. Many functions that interact with process objects, (for instance, `process-datagram-address`) rely on them at least having a socket before they can return a useful value. These functions will block until the socket has achieved the desired status. The recommended way of interacting with asynchronous sockets is to place a sentinel on the process, and not try to interact with it before it has changed status to ‘`"run"`’. That way, none of these functions will block. :tls-parameters When opening a TLS connection, this should be where the first element is the TLS type (which should either be `gnutls-x509pki` or `gnutls-anon`, and the remaining elements should form a keyword list acceptable for `gnutls-boot`. (This keyword list can be obtained from the `gnutls-boot-parameters` function.) The TLS connection will then be negotiated after completing the connection to the host. :stop stopped If stopped is non-`nil`, start the network connection or server in the stopped state. :buffer buffer Use buffer as the process buffer. :coding coding Use coding as the coding system for this process. To specify different coding systems for decoding data from the connection and for encoding data sent to it, specify `(decoding . encoding)` for coding. If you don’t specify this keyword at all, the default is to determine the coding systems from the data. :noquery query-flag Initialize the process query flag to query-flag. See [Query Before Exit](query-before-exit). :filter filter Initialize the process filter to filter. :filter-multibyte multibyte If multibyte is non-`nil`, strings given to the process filter are multibyte, otherwise they are unibyte. The default is `t`. :sentinel sentinel Initialize the process sentinel to sentinel. :log log Initialize the log function of a server process to log. The log function is called each time the server accepts a network connection from a client. The arguments passed to the log function are server, connection, and message; where server is the server process, connection is the new process for the connection, and message is a string describing what has happened. :plist plist Initialize the process plist to plist. The original argument list, modified with the actual connection information, is available via the `process-contact` function.
programming_docs
elisp None #### High-Level Completion Functions This section describes the higher-level convenience functions for reading certain sorts of names with completion. In most cases, you should not call these functions in the middle of a Lisp function. When possible, do all minibuffer input as part of reading the arguments for a command, in the `interactive` specification. See [Defining Commands](defining-commands). Function: **read-buffer** *prompt &optional default require-match predicate* This function reads the name of a buffer and returns it as a string. It prompts with prompt. The argument default is the default name to use, the value to return if the user exits with an empty minibuffer. If non-`nil`, it should be a string, a list of strings, or a buffer. If it is a list, the default value is the first element of this list. It is mentioned in the prompt, but is not inserted in the minibuffer as initial input. The argument prompt should be a string ending with a colon and a space. If default is non-`nil`, the function inserts it in prompt before the colon to follow the convention for reading from the minibuffer with a default value (see [Programming Tips](https://www.gnu.org/software/emacs/manual/html_node/elisp/Programming-Tips.html)). The optional argument require-match has the same meaning as in `completing-read`. See [Minibuffer Completion](minibuffer-completion). The optional argument predicate, if non-`nil`, specifies a function to filter the buffers that should be considered: the function will be called with every potential candidate as its argument, and should return `nil` to reject the candidate, non-`nil` to accept it. In the following example, the user enters ‘`minibuffer.t`’, and then types RET. The argument require-match is `t`, and the only buffer name starting with the given input is ‘`minibuffer.texi`’, so that name is the value. ``` (read-buffer "Buffer name: " "foo" t) ``` ``` ;; After evaluation of the preceding expression, ;; the following prompt appears, ;; with an empty minibuffer: ``` ``` ---------- Buffer: Minibuffer ---------- Buffer name (default foo): ∗ ---------- Buffer: Minibuffer ---------- ``` ``` ;; The user types `minibuffer.t RET`. ⇒ "minibuffer.texi" ``` User Option: **read-buffer-function** This variable, if non-`nil`, specifies a function for reading buffer names. `read-buffer` calls this function instead of doing its usual work, with the same arguments passed to `read-buffer`. User Option: **read-buffer-completion-ignore-case** If this variable is non-`nil`, `read-buffer` ignores case when performing completion while reading the buffer name. Function: **read-command** *prompt &optional default* This function reads the name of a command and returns it as a Lisp symbol. The argument prompt is used as in `read-from-minibuffer`. Recall that a command is anything for which `commandp` returns `t`, and a command name is a symbol for which `commandp` returns `t`. See [Interactive Call](interactive-call). The argument default specifies what to return if the user enters null input. It can be a symbol, a string or a list of strings. If it is a string, `read-command` interns it before returning it. If it is a list, `read-command` interns the first element of this list. If default is `nil`, that means no default has been specified; then if the user enters null input, the return value is `(intern "")`, that is, a symbol whose name is an empty string, and whose printed representation is `##` (see [Symbol Type](symbol-type)). ``` (read-command "Command name? ") ``` ``` ;; After evaluation of the preceding expression, ;; the following prompt appears with an empty minibuffer: ``` ``` ---------- Buffer: Minibuffer ---------- Command name? ---------- Buffer: Minibuffer ---------- ``` If the user types `forward-c RET`, then this function returns `forward-char`. The `read-command` function is a simplified interface to `completing-read`. It uses the variable `obarray` so as to complete in the set of extant Lisp symbols, and it uses the `commandp` predicate so as to accept only command names: ``` (read-command prompt) ≡ (intern (completing-read prompt obarray 'commandp t nil)) ``` Function: **read-variable** *prompt &optional default* This function reads the name of a customizable variable and returns it as a symbol. Its arguments have the same form as those of `read-command`. It behaves just like `read-command`, except that it uses the predicate `custom-variable-p` instead of `commandp`. Command: **read-color** *&optional prompt convert allow-empty display* This function reads a string that is a color specification, either the color’s name or an RGB hex value such as `#RRRGGGBBB`. It prompts with prompt (default: `"Color (name or #RGB triplet):"`) and provides completion for color names, but not for hex RGB values. In addition to names of standard colors, completion candidates include the foreground and background colors at point. Valid RGB values are described in [Color Names](color-names). The function’s return value is the string typed by the user in the minibuffer. However, when called interactively or if the optional argument convert is non-`nil`, it converts any input color name into the corresponding RGB value string and instead returns that. This function requires a valid color specification to be input. Empty color names are allowed when allow-empty is non-`nil` and the user enters null input. Interactively, or when display is non-`nil`, the return value is also displayed in the echo area. See also the functions `read-coding-system` and `read-non-nil-coding-system`, in [User-Chosen Coding Systems](user_002dchosen-coding-systems), and `read-input-method-name`, in [Input Methods](input-methods). elisp None ### Syntax Table Internals Syntax tables are implemented as char-tables (see [Char-Tables](char_002dtables)), but most Lisp programs don’t work directly with their elements. Syntax tables do not store syntax data as syntax descriptors (see [Syntax Descriptors](syntax-descriptors)); they use an internal format, which is documented in this section. This internal format can also be assigned as syntax properties (see [Syntax Properties](syntax-properties)). Each entry in a syntax table is a *raw syntax descriptor*: a cons cell of the form `(syntax-code . matching-char)`. syntax-code is an integer which encodes the syntax class and syntax flags, according to the table below. matching-char, if non-`nil`, specifies a matching character (similar to the second character in a syntax descriptor). Use `aref` (see [Array Functions](array-functions)) to get the raw syntax descriptor of a character, e.g. `(aref (syntax-table) ch)`. Here are the syntax codes corresponding to the various syntax classes: | | | | | | --- | --- | --- | --- | | *Code* | *Class* | *Code* | *Class* | | 0 | whitespace | 8 | paired delimiter | | 1 | punctuation | 9 | escape | | 2 | word | 10 | character quote | | 3 | symbol | 11 | comment-start | | 4 | open parenthesis | 12 | comment-end | | 5 | close parenthesis | 13 | inherit | | 6 | expression prefix | 14 | generic comment | | 7 | string quote | 15 | generic string | For example, in the standard syntax table, the entry for ‘`(`’ is `(4 . 41)`. 41 is the character code for ‘`)`’. Syntax flags are encoded in higher order bits, starting 16 bits from the least significant bit. This table gives the power of two which corresponds to each syntax flag. | | | | | | --- | --- | --- | --- | | *Prefix* | *Flag* | *Prefix* | *Flag* | | ‘`1`’ | `(ash 1 16)` | ‘`p`’ | `(ash 1 20)` | | ‘`2`’ | `(ash 1 17)` | ‘`b`’ | `(ash 1 21)` | | ‘`3`’ | `(ash 1 18)` | ‘`n`’ | `(ash 1 22)` | | ‘`4`’ | `(ash 1 19)` | ‘`c`’ | `(ash 1 23)` | Function: **string-to-syntax** *desc* Given a syntax descriptor desc (a string), this function returns the corresponding raw syntax descriptor. Function: **syntax-class-to-char** *syntax* Given a raw syntax descriptor syntax (an integer), this function returns the corresponding syntax descriptor (a character). Function: **syntax-after** *pos* This function returns the raw syntax descriptor for the character in the buffer after position pos, taking account of syntax properties as well as the syntax table. If pos is outside the buffer’s accessible portion (see [accessible portion](narrowing)), the return value is `nil`. Function: **syntax-class** *syntax* This function returns the syntax code for the raw syntax descriptor syntax. More precisely, it takes the raw syntax descriptor’s syntax-code component, masks off the high 16 bits which record the syntax flags, and returns the resulting integer. If syntax is `nil`, the return value is `nil`. This is so that the expression ``` (syntax-class (syntax-after pos)) ``` evaluates to `nil` if `pos` is outside the buffer’s accessible portion, without throwing errors or returning an incorrect code. elisp None #### Autoloading The *autoload* feature allows you to call a function or macro whose function definition has not yet been loaded into Emacs. It specifies which file contains the definition. When an autoload object appears as a symbol’s function definition, calling that symbol as a function automatically loads the specified file; then it calls the real definition loaded from that file. The way to arrange for an autoload object to appear as a symbol’s function definition is described in [Autoload](autoload). elisp None ### Selecting Windows In each frame, at any time, exactly one Emacs window is designated as *selected within the frame*. For the selected frame, that window is called the *selected window*—the one in which most editing takes place, and in which the cursor for selected windows appears (see [Cursor Parameters](cursor-parameters)). Keyboard input that inserts or deletes text is also normally directed to this window. The selected window’s buffer is usually also the current buffer, except when `set-buffer` has been used (see [Current Buffer](current-buffer)). As for non-selected frames, the window selected within the frame becomes the selected window if the frame is ever selected. Function: **selected-window** This function returns the selected window (which is always a live window). The following function explicitly selects a window and its frame. Function: **select-window** *window &optional norecord* This function makes window the selected window and the window selected within its frame, and selects that frame. It also makes window’s buffer (see [Buffers and Windows](buffers-and-windows)) current and sets that buffer’s value of `point` to the value of `window-point` (see [Window Point](window-point)) in window. window must be a live window. The return value is window. By default, this function also moves window’s buffer to the front of the buffer list (see [Buffer List](buffer-list)) and makes window the most recently selected window. If the optional argument norecord is non-`nil`, these additional actions are omitted. In addition, this function by default also tells the display engine to update the display of window when its frame gets redisplayed the next time. If norecord is non-`nil`, such updates are usually not performed. If, however, norecord equals the special symbol `mark-for-redisplay`, the additional actions mentioned above are omitted but window’s display will be nevertheless updated. Note that sometimes selecting a window is not enough to show it, or make its frame the top-most frame on display: you may also need to raise the frame or make sure input focus is directed to that frame. See [Input Focus](input-focus). For historical reasons, Emacs does not run a separate hook whenever a window gets selected. Applications and internal routines often temporarily select a window to perform a few actions on it. They do that either to simplify coding—because many functions by default operate on the selected window when no window argument is specified—or because some functions did not (and still do not) take a window as argument and always operate(d) on the selected window instead. Running a hook every time a window gets selected for a short time and once more when the previously selected window gets restored is not useful. However, when its norecord argument is `nil`, `select-window` updates the buffer list and thus indirectly runs the normal hook `buffer-list-update-hook` (see [Buffer List](buffer-list)). Consequently, that hook provides one way to run a function whenever a window gets selected more “permanently”. Since `buffer-list-update-hook` is also run by functions that are not related to window management, it will usually make sense to save the value of the selected window somewhere and compare it with the value of `selected-window` while running that hook. Also, to avoid false positives when using `buffer-list-update-hook`, it is good practice that every `select-window` call supposed to select a window only temporarily passes a non-`nil` norecord argument. If possible, the macro `with-selected-window` (see below) should be used in such cases. Emacs also runs the hook `window-selection-change-functions` whenever the redisplay routine detects that another window has been selected since last redisplay. See [Window Hooks](window-hooks), for a detailed explanation. `window-state-change-functions` (described in the same section) is another abnormal hook run after a different window has been selected but is triggered by other window changes as well. The sequence of calls to `select-window` with a non-`nil` norecord argument determines an ordering of windows by their selection or use time, see below. The function `get-lru-window`, for example, can then be used to retrieve the least recently selected window (see [Cyclic Window Ordering](cyclic-window-ordering)). Function: **frame-selected-window** *&optional frame* This function returns the window on frame that is selected within that frame. frame should be a live frame; if omitted or `nil`, it defaults to the selected frame. Function: **set-frame-selected-window** *frame window &optional norecord* This function makes window the window selected within the frame frame. frame should be a live frame; if `nil`, it defaults to the selected frame. window should be a live window; if `nil`, it defaults to the selected window. If frame is the selected frame, this makes window the selected window. If the optional argument norecord is non-`nil`, this function does not alter the ordering of the most recently selected windows, nor the buffer list. The following macros are useful to temporarily select a window without affecting the ordering of recently selected windows or the buffer list. Macro: **save-selected-window** *forms…* This macro records the selected frame, as well as the selected window of each frame, executes forms in sequence, then restores the earlier selected frame and windows. It also saves and restores the current buffer. It returns the value of the last form in forms. This macro does not save or restore anything about the sizes, arrangement or contents of windows; therefore, if forms change them, the change persists. If the previously selected window of some frame is no longer live at the time of exit from forms, that frame’s selected window is left alone. If the previously selected window is no longer live, then whatever window is selected at the end of forms remains selected. The current buffer is restored if and only if it is still live when exiting forms. This macro changes neither the ordering of recently selected windows nor the buffer list. Macro: **with-selected-window** *window forms…* This macro selects window, executes forms in sequence, then restores the previously selected window and current buffer. The ordering of recently selected windows and the buffer list remain unchanged unless you deliberately change them within forms; for example, by calling `select-window` with argument norecord `nil`. Hence, this macro is the preferred way to temporarily work with window as the selected window without needlessly running `buffer-list-update-hook`. Macro: **with-selected-frame** *frame forms…* This macro executes forms with frame as the selected frame. The value returned is the value of the last form in forms. This macro saves and restores the selected frame, and changes the order of neither the recently selected windows nor the buffers in the buffer list. Function: **window-use-time** *&optional window* This function returns the use time of window window. window must be a live window and defaults to the selected one. The *use time* of a window is not really a time value, but an integer that does increase monotonically with each call of `select-window` with a `nil` norecord argument. The window with the lowest use time is usually called the least recently used window while the window with the highest use time is called the most recently used one (see [Cyclic Window Ordering](cyclic-window-ordering)). Function: **window-bump-use-time** *&optional window* This function marks window as being the most recently used one. This can be useful when writing certain `pop-to-buffer` scenarios (see [Switching Buffers](switching-buffers)). window must be a live window and defaults to the selected one. Sometimes several windows collectively and cooperatively display a buffer, for example, under the management of Follow Mode (see [(emacs)Follow Mode](https://www.gnu.org/software/emacs/manual/html_node/emacs/Follow-Mode.html#Follow-Mode)), where the windows together display a bigger portion of the buffer than one window could alone. It is often useful to consider such a *window group* as a single entity. Several functions such as `window-group-start` (see [Window Start and End](window-start-and-end)) allow you to do this by supplying, as an argument, one of the windows as a stand-in for the whole group. Function: **selected-window-group** When the selected window is a member of a group of windows, this function returns a list of the windows in the group, ordered such that the first window in the list is displaying the earliest part of the buffer, and so on. Otherwise the function returns a list containing just the selected window. The selected window is considered part of a group when the buffer local variable `selected-window-group-function` is set to a function. In this case, `selected-window-group` calls it with no arguments and returns its result (which should be the list of windows in the group). elisp None ### Selecting a Representation Sometimes it is useful to examine an existing buffer or string as multibyte when it was unibyte, or vice versa. Function: **set-buffer-multibyte** *multibyte* Set the representation type of the current buffer. If multibyte is non-`nil`, the buffer becomes multibyte. If multibyte is `nil`, the buffer becomes unibyte. This function leaves the buffer contents unchanged when viewed as a sequence of bytes. As a consequence, it can change the contents viewed as characters; for instance, a sequence of three bytes which is treated as one character in multibyte representation will count as three characters in unibyte representation. Eight-bit characters representing raw bytes are an exception. They are represented by one byte in a unibyte buffer, but when the buffer is set to multibyte, they are converted to two-byte sequences, and vice versa. This function sets `enable-multibyte-characters` to record which representation is in use. It also adjusts various data in the buffer (including overlays, text properties and markers) so that they cover the same text as they did before. This function signals an error if the buffer is narrowed, since the narrowing might have occurred in the middle of multibyte character sequences. This function also signals an error if the buffer is an indirect buffer. An indirect buffer always inherits the representation of its base buffer. Function: **string-as-unibyte** *string* If string is already a unibyte string, this function returns string itself. Otherwise, it returns a new string with the same bytes as string, but treating each byte as a separate character (so that the value may have more characters than string); as an exception, each eight-bit character representing a raw byte is converted into a single byte. The newly-created string contains no text properties. Function: **string-as-multibyte** *string* If string is a multibyte string, this function returns string itself. Otherwise, it returns a new string with the same bytes as string, but treating each multibyte sequence as one character. This means that the value may have fewer characters than string has. If a byte sequence in string is invalid as a multibyte representation of a single character, each byte in the sequence is treated as a raw 8-bit byte. The newly-created string contains no text properties.
programming_docs
elisp None ### Type Predicates for Numbers The functions in this section test for numbers, or for a specific type of number. The functions `integerp` and `floatp` can take any type of Lisp object as argument (they would not be of much use otherwise), but the `zerop` predicate requires a number as its argument. See also `integer-or-marker-p` and `number-or-marker-p`, in [Predicates on Markers](predicates-on-markers). Function: **bignump** *object* This predicate tests whether its argument is a large integer, and returns `t` if so, `nil` otherwise. Unlike small integers, large integers can be `=` or `eql` even if they are not `eq`. Function: **fixnump** *object* This predicate tests whether its argument is a small integer, and returns `t` if so, `nil` otherwise. Small integers can be compared with `eq`. Function: **floatp** *object* This predicate tests whether its argument is floating point and returns `t` if so, `nil` otherwise. Function: **integerp** *object* This predicate tests whether its argument is an integer, and returns `t` if so, `nil` otherwise. Function: **numberp** *object* This predicate tests whether its argument is a number (either integer or floating point), and returns `t` if so, `nil` otherwise. Function: **natnump** *object* This predicate (whose name comes from the phrase “natural number”) tests to see whether its argument is a nonnegative integer, and returns `t` if so, `nil` otherwise. 0 is considered non-negative. `wholenump` is a synonym for `natnump`. Function: **zerop** *number* This predicate tests whether its argument is zero, and returns `t` if so, `nil` otherwise. The argument must be a number. `(zerop x)` is equivalent to `(= x 0)`. elisp None ### Abbrev Tables This section describes how to create and manipulate abbrev tables. Function: **make-abbrev-table** *&optional props* This function creates and returns a new, empty abbrev table—an obarray containing no symbols. It is a vector filled with zeros. props is a property list that is applied to the new table (see [Abbrev Table Properties](abbrev-table-properties)). Function: **abbrev-table-p** *object* This function returns a non-`nil` value if object is an abbrev table. Function: **clear-abbrev-table** *abbrev-table* This function undefines all the abbrevs in abbrev-table, leaving it empty. Function: **copy-abbrev-table** *abbrev-table* This function returns a copy of abbrev-table—a new abbrev table containing the same abbrev definitions. It does *not* copy any property lists; only the names, values, and functions. Function: **define-abbrev-table** *tabname definitions &optional docstring &rest props* This function defines tabname (a symbol) as an abbrev table name, i.e., as a variable whose value is an abbrev table. It defines abbrevs in the table according to definitions, a list of elements of the form `(abbrevname expansion [hook] [props...])`. These elements are passed as arguments to `define-abbrev`. The optional string docstring is the documentation string of the variable tabname. The property list props is applied to the abbrev table (see [Abbrev Table Properties](abbrev-table-properties)). If this function is called more than once for the same tabname, subsequent calls add the definitions in definitions to tabname, rather than overwriting the entire original contents. (A subsequent call only overrides abbrevs explicitly redefined or undefined in definitions.) Variable: **abbrev-table-name-list** This is a list of symbols whose values are abbrev tables. `define-abbrev-table` adds the new abbrev table name to this list. Function: **insert-abbrev-table-description** *name &optional human* This function inserts before point a description of the abbrev table named name. The argument name is a symbol whose value is an abbrev table. If human is non-`nil`, the description is human-oriented. System abbrevs are listed and identified as such. Otherwise the description is a Lisp expression—a call to `define-abbrev-table` that would define name as it is currently defined, but without the system abbrevs. (The mode or package using name is supposed to add these to name separately.) elisp None ### Files and Secondary Storage After Emacs changes a file, there are two reasons the changes might not survive later failures of power or media, both having to do with efficiency. First, the operating system might alias written data with data already stored elsewhere on secondary storage until one file or the other is later modified; this will lose both files if the only copy on secondary storage is lost due to media failure. Second, the operating system might not write data to secondary storage immediately, which will lose the data if power is lost. Although both sorts of failures can largely be avoided by a suitably configured file system, such systems are typically more expensive or less efficient. In more-typical systems, to survive media failure you can copy the file to a different device, and to survive a power failure you can use the `write-region` function with the `write-region-inhibit-fsync` variable set to `nil`. See [Writing to Files](writing-to-files). elisp None #### Motion Events Emacs sometimes generates *mouse motion* events to describe motion of the mouse without any button activity. Mouse motion events are represented by lists that look like this: ``` (mouse-movement POSITION) ``` position is a mouse position list (see [Click Events](click-events)), specifying the current position of the mouse cursor. As with the end-position of a drag event, this position list may represent a location outside the boundaries of the initially selected frame, in which case the list contains that frame in place of a window. The special form `track-mouse` enables generation of motion events within its body. Outside of `track-mouse` forms, Emacs does not generate events for mere motion of the mouse, and these events do not appear. See [Mouse Tracking](mouse-tracking). Variable: **mouse-fine-grained-tracking** When non-`nil`, mouse motion events are generated even for very small movements. Otherwise, motion events are not generated as long as the mouse cursor remains pointing to the same glyph in the text. elisp None #### Major Mode Examples Text mode is perhaps the simplest mode besides Fundamental mode. Here are excerpts from `text-mode.el` that illustrate many of the conventions listed above: ``` ;; Create the syntax table for this mode. (defvar text-mode-syntax-table (let ((st (make-syntax-table))) (modify-syntax-entry ?\" ". " st) (modify-syntax-entry ?\\ ". " st) ;; Add 'p' so M-c on 'hello' leads to 'Hello', not 'hello'. (modify-syntax-entry ?' "w p" st) … st) "Syntax table used while in `text-mode'.") ``` ``` ;; Create the keymap for this mode. ``` ``` (defvar text-mode-map (let ((map (make-sparse-keymap))) (define-key map "\e\t" 'ispell-complete-word) … map) "Keymap for `text-mode'. Many other modes, such as `mail-mode', `outline-mode' and `indented-text-mode', inherit all the commands defined in this map.") ``` Here is how the actual mode command is defined now: ``` (define-derived-mode text-mode nil "Text" "Major mode for editing text written for humans to read. In this mode, paragraphs are delimited only by blank or white lines. You can thus get the full benefit of adaptive filling (see the variable `adaptive-fill-mode'). \\{text-mode-map} Turning on Text mode runs the normal hook `text-mode-hook'." ``` ``` (setq-local text-mode-variant t) (setq-local require-final-newline mode-require-final-newline)) ``` The three Lisp modes (Lisp mode, Emacs Lisp mode, and Lisp Interaction mode) have more features than Text mode and the code is correspondingly more complicated. Here are excerpts from `lisp-mode.el` that illustrate how these modes are written. Here is how the Lisp mode syntax and abbrev tables are defined: ``` ;; Create mode-specific table variables. (define-abbrev-table 'lisp-mode-abbrev-table () "Abbrev table for Lisp mode.") (defvar lisp-mode-syntax-table (let ((table (make-syntax-table lisp--mode-syntax-table))) (modify-syntax-entry ?\[ "_ " table) (modify-syntax-entry ?\] "_ " table) (modify-syntax-entry ?# "' 14" table) (modify-syntax-entry ?| "\" 23bn" table) table) "Syntax table used in `lisp-mode'.") ``` The three modes for Lisp share much of their code. For instance, Lisp mode and Emacs Lisp mode inherit from Lisp Data mode and Lisp Interaction Mode inherits from Emacs Lisp mode. Amongst other things, Lisp Data mode sets up the `comment-start` variable to handle Lisp comments: ``` (setq-local comment-start ";") … ``` Each of the different Lisp modes has a slightly different keymap. For example, Lisp mode binds `C-c C-z` to `run-lisp`, but the other Lisp modes do not. However, all Lisp modes have some commands in common. The following code sets up the common commands: ``` (defvar lisp-mode-shared-map (let ((map (make-sparse-keymap))) (set-keymap-parent map prog-mode-map) (define-key map "\e\C-q" 'indent-sexp) (define-key map "\177" 'backward-delete-char-untabify) map) "Keymap for commands shared by all sorts of Lisp modes.") ``` And here is the code to set up the keymap for Lisp mode: ``` (defvar lisp-mode-map (let ((map (make-sparse-keymap)) (menu-map (make-sparse-keymap "Lisp"))) (set-keymap-parent map lisp-mode-shared-map) (define-key map "\e\C-x" 'lisp-eval-defun) (define-key map "\C-c\C-z" 'run-lisp) … map) "Keymap for ordinary Lisp mode. All commands in `lisp-mode-shared-map' are inherited by this map.") ``` Finally, here is the major mode command for Lisp mode: ``` (define-derived-mode lisp-mode lisp-data-mode "Lisp" "Major mode for editing Lisp code for Lisps other than GNU Emacs Lisp. Commands: Delete converts tabs to spaces as it moves back. Blank lines separate paragraphs. Semicolons start comments. \\{lisp-mode-map} Note that `run-lisp' may be used either to start an inferior Lisp job or to switch back to an existing one." ``` ``` (setq-local find-tag-default-function 'lisp-find-tag-default) (setq-local comment-start-skip "\\(\\(^\\|[^\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *") (setq imenu-case-fold-search t)) ``` elisp None #### Displaying in the Margins A buffer can have blank areas called *display margins* on the left and on the right. Ordinary text never appears in these areas, but you can put things into the display margins using the `display` property. There is currently no way to make text or images in the margin mouse-sensitive. The way to display something in the margins is to specify it in a margin display specification in the `display` property of some text. This is a replacing display specification, meaning that the text you put it on does not get displayed; the margin display appears, but that text does not. A margin display specification looks like `((margin right-margin) spec)` or `((margin left-margin) spec)`. Here, spec is another display specification that says what to display in the margin. Typically it is a string of text to display, or an image descriptor. To display something in the margin *in association with* certain buffer text, without altering or preventing the display of that text, put a `before-string` property on the text and put the margin display specification on the contents of the before-string. Note that if the string to be displayed in the margin doesn’t specify a face, its face is determined using the same rules and priorities as it is for strings displayed in the text area (see [Displaying Faces](displaying-faces)). If this results in undesirable “leaking” of faces into the margin, make sure the string has an explicit face specified for it. Before the display margins can display anything, you must give them a nonzero width. The usual way to do that is to set these variables: Variable: **left-margin-width** This variable specifies the width of the left margin, in character cell (a.k.a. “column”) units. It is buffer-local in all buffers. A value of `nil` means no left marginal area. Variable: **right-margin-width** This variable specifies the width of the right margin, in character cell units. It is buffer-local in all buffers. A value of `nil` means no right marginal area. Setting these variables does not immediately affect the window. These variables are checked when a new buffer is displayed in the window. Thus, you can make changes take effect by calling `set-window-buffer`. Do not use these variables to try to determine the current width of the left or right margin. Instead, use the function `window-margins`. You can also set the margin widths immediately. Function: **set-window-margins** *window left &optional right* This function specifies the margin widths for window window, in character cell units. The argument left controls the left margin, and right controls the right margin (default `0`). If window is not large enough to accommodate margins of the desired width, this leaves the margins of window unchanged. The values specified here may be later overridden by invoking `set-window-buffer` (see [Buffers and Windows](buffers-and-windows)) on window with its keep-margins argument `nil` or omitted. Function: **window-margins** *&optional window* This function returns the width of the left and right margins of window as a cons cell of the form `(left . right)`. If one of the two marginal areas does not exist, its width is returned as `nil`; if neither of the two margins exist, the function returns `(nil)`. If window is `nil`, the selected window is used. elisp None #### Motion by Words The functions for parsing words described below use the syntax table and `char-script-table` to decide whether a given character is part of a word. See [Syntax Tables](syntax-tables), and see [Character Properties](character-properties). Command: **forward-word** *&optional count* This function moves point forward count words (or backward if count is negative). If count is omitted or `nil`, it defaults to 1. In an interactive call, count is specified by the numeric prefix argument. “Moving one word” means moving until point crosses a word-constituent character, which indicates the beginning of a word, and then continue moving until the word ends. By default, characters that begin and end words, known as *word boundaries*, are defined by the current buffer’s syntax table (see [Syntax Class Table](syntax-class-table)), but modes can override that by setting up a suitable `find-word-boundary-function-table`, described below. Characters that belong to different scripts (as defined by `char-script-table`), also define a word boundary (see [Character Properties](character-properties)). In any case, this function cannot move point past the boundary of the accessible portion of the buffer, or across a field boundary (see [Fields](fields)). The most common case of a field boundary is the end of the prompt in the minibuffer. If it is possible to move count words, without being stopped prematurely by the buffer boundary or a field boundary, the value is `t`. Otherwise, the return value is `nil` and point stops at the buffer boundary or field boundary. If `inhibit-field-text-motion` is non-`nil`, this function ignores field boundaries. Command: **backward-word** *&optional count* This function is just like `forward-word`, except that it moves backward until encountering the front of a word, rather than forward. User Option: **words-include-escapes** This variable affects the behavior of `forward-word` and `backward-word`, and everything that uses them. If it is non-`nil`, then characters in the escape and character-quote syntax classes count as part of words. Otherwise, they do not. Variable: **inhibit-field-text-motion** If this variable is non-`nil`, certain motion functions including `forward-word`, `forward-sentence`, and `forward-paragraph` ignore field boundaries. Variable: **find-word-boundary-function-table** This variable affects the behavior of `forward-word` and `backward-word`, and everything that uses them. Its value is a char-table (see [Char-Tables](char_002dtables)) of functions to search for word boundaries. If a character has a non-`nil` entry in this table, then when a word starts or ends with that character, the corresponding function will be called with 2 arguments: pos and limit. The function should return the position of the other word boundary. Specifically, if pos is smaller than limit, then pos is at the beginning of a word, and the function should return the position after the last character of the word; otherwise, pos is at the last character of a word, and the function should return the position of that word’s first character. Function: **forward-word-strictly** *&optional count* This function is like `forward-word`, but it is not affected by `find-word-boundary-function-table`. Lisp programs that should not change behavior when word movement is modified by modes which set that table, such as `subword-mode`, should use this function instead of `forward-word`. Function: **backward-word-strictly** *&optional count* This function is like `backward-word`, but it is not affected by `find-word-boundary-function-table`. Like with `forward-word-strictly`, use this function instead of `backward-word` when movement by words should only consider syntax tables. elisp None ### Connection Local Variables Connection-local variables provide a general mechanism for different variable settings in buffers with a remote connection. They are bound and set depending on the remote connection a buffer is dedicated to. Function: **connection-local-set-profile-variables** *profile variables* This function defines a set of variable settings for the connection profile, which is a symbol. You can later assign the connection profile to one or more remote connections, and Emacs will apply those variable settings to all process buffers for those connections. The list in variables is an alist of the form `(name . value)`. Example: ``` (connection-local-set-profile-variables 'remote-bash '((shell-file-name . "/bin/bash") (shell-command-switch . "-c") (shell-interactive-switch . "-i") (shell-login-switch . "-l"))) ``` ``` (connection-local-set-profile-variables 'remote-ksh '((shell-file-name . "/bin/ksh") (shell-command-switch . "-c") (shell-interactive-switch . "-i") (shell-login-switch . "-l"))) ``` ``` (connection-local-set-profile-variables 'remote-null-device '((null-device . "/dev/null"))) ``` Variable: **connection-local-profile-alist** This alist holds the connection profile symbols and the associated variable settings. It is updated by `connection-local-set-profile-variables`. Function: **connection-local-set-profiles** *criteria &rest profiles* This function assigns profiles, which are symbols, to all remote connections identified by criteria. criteria is a plist identifying a connection and the application using this connection. Property names might be `:application`, `:protocol`, `:user` and `:machine`. The property value of `:application` is a symbol, all other property values are strings. All properties are optional; if criteria is `nil`, it always applies. Example: ``` (connection-local-set-profiles '(:application 'tramp :protocol "ssh" :machine "localhost") 'remote-bash 'remote-null-device) ``` ``` (connection-local-set-profiles '(:application 'tramp :protocol "sudo" :user "root" :machine "localhost") 'remote-ksh 'remote-null-device) ``` If criteria is `nil`, it applies for all remote connections. Therefore, the example above would be equivalent to ``` (connection-local-set-profiles '(:application 'tramp :protocol "ssh" :machine "localhost") 'remote-bash) ``` ``` (connection-local-set-profiles '(:application 'tramp :protocol "sudo" :user "root" :machine "localhost") 'remote-ksh) ``` ``` (connection-local-set-profiles nil 'remote-null-device) ``` Any connection profile of profiles must have been already defined by `connection-local-set-profile-variables`. Variable: **connection-local-criteria-alist** This alist contains connection criteria and their assigned profile names. The function `connection-local-set-profiles` updates this list. Function: **hack-connection-local-variables** *criteria* This function collects applicable connection-local variables associated with criteria in `connection-local-variables-alist`, without applying them. Example: ``` (hack-connection-local-variables '(:application 'tramp :protocol "ssh" :machine "localhost")) ``` ``` connection-local-variables-alist ⇒ ((null-device . "/dev/null") (shell-login-switch . "-l") (shell-interactive-switch . "-i") (shell-command-switch . "-c") (shell-file-name . "/bin/bash")) ``` Function: **hack-connection-local-variables-apply** *criteria* This function looks for connection-local variables according to criteria, and immediately applies them in the current buffer. Macro: **with-connection-local-variables** *&rest body* All connection-local variables, which are specified by `default-directory`, are applied. After that, body is executed, and the connection-local variables are unwound. Example: ``` (connection-local-set-profile-variables 'remote-perl '((perl-command-name . "/usr/local/bin/perl") (perl-command-switch . "-e %s"))) ``` ``` (connection-local-set-profiles '(:application 'tramp :protocol "ssh" :machine "remotehost") 'remote-perl) ``` ``` (let ((default-directory "/ssh:remotehost:/working/dir/")) (with-connection-local-variables do something useful)) ``` Variable: **enable-connection-local-variables** If `nil`, connection-local variables are ignored. This variable shall be changed temporarily only in special modes.
programming_docs
elisp None #### Basic Completion Functions The following completion functions have nothing in themselves to do with minibuffers. We describe them here to keep them near the higher-level completion features that do use the minibuffer. Function: **try-completion** *string collection &optional predicate* This function returns the longest common substring of all possible completions of string in collection. collection is called the *completion table*. Its value must be a list of strings or cons cells, an obarray, a hash table, or a completion function. `try-completion` compares string against each of the permissible completions specified by the completion table. If no permissible completions match, it returns `nil`. If there is just one matching completion, and the match is exact, it returns `t`. Otherwise, it returns the longest initial sequence common to all possible matching completions. If collection is a list, the permissible completions are specified by the elements of the list, each of which should be either a string, or a cons cell whose CAR is either a string or a symbol (a symbol is converted to a string using `symbol-name`). If the list contains elements of any other type, those are ignored. If collection is an obarray (see [Creating Symbols](creating-symbols)), the names of all symbols in the obarray form the set of permissible completions. If collection is a hash table, then the keys that are strings or symbols are the possible completions. Other keys are ignored. You can also use a function as collection. Then the function is solely responsible for performing completion; `try-completion` returns whatever this function returns. The function is called with three arguments: string, predicate and `nil` (the third argument is so that the same function can be used in `all-completions` and do the appropriate thing in either case). See [Programmed Completion](programmed-completion). If the argument predicate is non-`nil`, then it must be a function of one argument, unless collection is a hash table, in which case it should be a function of two arguments. It is used to test each possible match, and the match is accepted only if predicate returns non-`nil`. The argument given to predicate is either a string or a cons cell (the CAR of which is a string) from the alist, or a symbol (*not* a symbol name) from the obarray. If collection is a hash table, predicate is called with two arguments, the string key and the associated value. In addition, to be acceptable, a completion must also match all the regular expressions in `completion-regexp-list`. (Unless collection is a function, in which case that function has to handle `completion-regexp-list` itself.) In the first of the following examples, the string ‘`foo`’ is matched by three of the alist CARs. All of the matches begin with the characters ‘`fooba`’, so that is the result. In the second example, there is only one possible match, and it is exact, so the return value is `t`. ``` (try-completion "foo" '(("foobar1" 1) ("barfoo" 2) ("foobaz" 3) ("foobar2" 4))) ⇒ "fooba" ``` ``` (try-completion "foo" '(("barfoo" 2) ("foo" 3))) ⇒ t ``` In the following example, numerous symbols begin with the characters ‘`forw`’, and all of them begin with the word ‘`forward`’. In most of the symbols, this is followed with a ‘`-`’, but not in all, so no more than ‘`forward`’ can be completed. ``` (try-completion "forw" obarray) ⇒ "forward" ``` Finally, in the following example, only two of the three possible matches pass the predicate `test` (the string ‘`foobaz`’ is too short). Both of those begin with the string ‘`foobar`’. ``` (defun test (s) (> (length (car s)) 6)) ⇒ test ``` ``` (try-completion "foo" '(("foobar1" 1) ("barfoo" 2) ("foobaz" 3) ("foobar2" 4)) 'test) ⇒ "foobar" ``` Function: **all-completions** *string collection &optional predicate* This function returns a list of all possible completions of string. The arguments to this function are the same as those of `try-completion`, and it uses `completion-regexp-list` in the same way that `try-completion` does. If collection is a function, it is called with three arguments: string, predicate and `t`; then `all-completions` returns whatever the function returns. See [Programmed Completion](programmed-completion). Here is an example, using the function `test` shown in the example for `try-completion`: ``` (defun test (s) (> (length (car s)) 6)) ⇒ test ``` ``` (all-completions "foo" '(("foobar1" 1) ("barfoo" 2) ("foobaz" 3) ("foobar2" 4)) 'test) ⇒ ("foobar1" "foobar2") ``` Function: **test-completion** *string collection &optional predicate* This function returns non-`nil` if string is a valid completion alternative specified by collection and predicate. The arguments are the same as in `try-completion`. For instance, if collection is a list of strings, this is true if string appears in the list and predicate is satisfied. This function uses `completion-regexp-list` in the same way that `try-completion` does. If predicate is non-`nil` and if collection contains several strings that are equal to each other, as determined by `compare-strings` according to `completion-ignore-case`, then predicate should accept either all or none of them. Otherwise, the return value of `test-completion` is essentially unpredictable. If collection is a function, it is called with three arguments, the values string, predicate and `lambda`; whatever it returns, `test-completion` returns in turn. Function: **completion-boundaries** *string collection predicate suffix* This function returns the boundaries of the field on which collection will operate, assuming that string holds the text before point and suffix holds the text after point. Normally completion operates on the whole string, so for all normal collections, this will always return `(0 . (length suffix))`. But more complex completion, such as completion on files, is done one field at a time. For example, completion of `"/usr/sh"` will include `"/usr/share/"` but not `"/usr/share/doc"` even if `"/usr/share/doc"` exists. Also `all-completions` on `"/usr/sh"` will not include `"/usr/share/"` but only `"share/"`. So if string is `"/usr/sh"` and suffix is `"e/doc"`, `completion-boundaries` will return `(5 . 1)` which tells us that the collection will only return completion information that pertains to the area after `"/usr/"` and before `"/doc"`. `try-completion` is not affected by nontrivial boundaries; e.g., `try-completion` on `"/usr/sh"` might still return `"/usr/share/"`, not `"share/"`. If you store a completion alist in a variable, you should mark the variable as risky by giving it a non-`nil` `risky-local-variable` property. See [File Local Variables](file-local-variables). Variable: **completion-ignore-case** If the value of this variable is non-`nil`, case is not considered significant in completion. Within `read-file-name`, this variable is overridden by `read-file-name-completion-ignore-case` (see [Reading File Names](reading-file-names)); within `read-buffer`, it is overridden by `read-buffer-completion-ignore-case` (see [High-Level Completion](high_002dlevel-completion)). Variable: **completion-regexp-list** This is a list of regular expressions. The completion functions only consider a completion acceptable if it matches all regular expressions in this list, with `case-fold-search` (see [Searching and Case](searching-and-case)) bound to the value of `completion-ignore-case`. Macro: **lazy-completion-table** *var fun* This macro provides a way to initialize the variable var as a collection for completion in a lazy way, not computing its actual contents until they are first needed. You use this macro to produce a value that you store in var. The actual computation of the proper value is done the first time you do completion using var. It is done by calling fun with no arguments. The value fun returns becomes the permanent value of var. Here is an example: ``` (defvar foo (lazy-completion-table foo make-my-alist)) ``` There are several functions that take an existing completion table and return a modified version. `completion-table-case-fold` returns a case-insensitive table. `completion-table-in-turn` and `completion-table-merge` combine multiple input tables in different ways. `completion-table-subvert` alters a table to use a different initial prefix. `completion-table-with-quoting` returns a table suitable for operating on quoted text. `completion-table-with-predicate` filters a table with a predicate function. `completion-table-with-terminator` adds a terminating string. elisp None ### Indentation The indentation functions are used to examine, move to, and change whitespace that is at the beginning of a line. Some of the functions can also change whitespace elsewhere on a line. Columns and indentation count from zero at the left margin. | | | | | --- | --- | --- | | • [Primitive Indent](primitive-indent) | | Functions used to count and insert indentation. | | • [Mode-Specific Indent](mode_002dspecific-indent) | | Customize indentation for different modes. | | • [Region Indent](region-indent) | | Indent all the lines in a region. | | • [Relative Indent](relative-indent) | | Indent the current line based on previous lines. | | • [Indent Tabs](indent-tabs) | | Adjustable, typewriter-like tab stops. | | • [Motion by Indent](motion-by-indent) | | Move to first non-blank character. | elisp None #### Functions that Rearrange Lists Here are some functions that rearrange lists destructively by modifying the CDRs of their component cons cells. These functions are destructive because they chew up the original lists passed to them as arguments, relinking their cons cells to form a new list that is the returned value. See `delq`, in [Sets And Lists](sets-and-lists), for another function that modifies cons cells. Function: **nconc** *&rest lists* This function returns a list containing all the elements of lists. Unlike `append` (see [Building Lists](building-lists)), the lists are *not* copied. Instead, the last CDR of each of the lists is changed to refer to the following list. The last of the lists is not altered. For example: ``` (setq x (list 1 2 3)) ⇒ (1 2 3) ``` ``` (nconc x '(4 5)) ⇒ (1 2 3 4 5) ``` ``` x ⇒ (1 2 3 4 5) ``` Since the last argument of `nconc` is not itself modified, it is reasonable to use a constant list, such as `'(4 5)`, as in the above example. For the same reason, the last argument need not be a list: ``` (setq x (list 1 2 3)) ⇒ (1 2 3) ``` ``` (nconc x 'z) ⇒ (1 2 3 . z) ``` ``` x ⇒ (1 2 3 . z) ``` However, the other arguments (all but the last) should be mutable lists. A common pitfall is to use a constant list as a non-last argument to `nconc`. If you do this, the resulting behavior is undefined (see [Self-Evaluating Forms](self_002devaluating-forms)). It is possible that your program will change each time you run it! Here is what might happen (though this is not guaranteed to happen): ``` (defun add-foo (x) ; We want this function to add (nconc '(foo) x)) ; `foo` to the front of its arg. ``` ``` (symbol-function 'add-foo) ⇒ (lambda (x) (nconc '(foo) x)) ``` ``` (setq xx (add-foo '(1 2))) ; It seems to work. ⇒ (foo 1 2) ``` ``` (setq xy (add-foo '(3 4))) ; What happened? ⇒ (foo 1 2 3 4) ``` ``` (eq xx xy) ⇒ t ``` ``` (symbol-function 'add-foo) ⇒ (lambda (x) (nconc '(foo 1 2 3 4) x)) ``` elisp None #### Symbol Function Indirection If the first element of the list is a symbol then evaluation examines the symbol’s function cell, and uses its contents instead of the original symbol. If the contents are another symbol, this process, called *symbol function indirection*, is repeated until it obtains a non-symbol. See [Function Names](function-names), for more information about symbol function indirection. One possible consequence of this process is an infinite loop, in the event that a symbol’s function cell refers to the same symbol. Otherwise, we eventually obtain a non-symbol, which ought to be a function or other suitable object. More precisely, we should now have a Lisp function (a lambda expression), a byte-code function, a primitive function, a Lisp macro, a special form, or an autoload object. Each of these types is a case described in one of the following sections. If the object is not one of these types, Emacs signals an `invalid-function` error. The following example illustrates the symbol indirection process. We use `fset` to set the function cell of a symbol and `symbol-function` to get the function cell contents (see [Function Cells](function-cells)). Specifically, we store the symbol `car` into the function cell of `first`, and the symbol `first` into the function cell of `erste`. ``` ;; Build this function cell linkage: ;; ------------- ----- ------- ------- ;; | #<subr car> | <-- | car | <-- | first | <-- | erste | ;; ------------- ----- ------- ------- ``` ``` (symbol-function 'car) ⇒ #<subr car> ``` ``` (fset 'first 'car) ⇒ car ``` ``` (fset 'erste 'first) ⇒ first ``` ``` (erste '(1 2 3)) ; Call the function referenced by `erste`. ⇒ 1 ``` By contrast, the following example calls a function without any symbol function indirection, because the first element is an anonymous Lisp function, not a symbol. ``` ((lambda (arg) (erste arg)) '(1 2 3)) ⇒ 1 ``` Executing the function itself evaluates its body; this does involve symbol function indirection when calling `erste`. This form is rarely used and is now deprecated. Instead, you should write it as: ``` (funcall (lambda (arg) (erste arg)) '(1 2 3)) ``` or just ``` (let ((arg '(1 2 3))) (erste arg)) ``` The built-in function `indirect-function` provides an easy way to perform symbol function indirection explicitly. Function: **indirect-function** *function &optional noerror* This function returns the meaning of function as a function. If function is a symbol, then it finds function’s function definition and starts over with that value. If function is not a symbol, then it returns function itself. This function returns `nil` if the final symbol is unbound. It signals a `cyclic-function-indirection` error if there is a loop in the chain of symbols. The optional argument noerror is obsolete, kept for backward compatibility, and has no effect. Here is how you could define `indirect-function` in Lisp: ``` (defun indirect-function (function) (if (and function (symbolp function)) (indirect-function (symbol-function function)) function)) ``` elisp None ### Reporting Warnings *Warnings* are a facility for a program to inform the user of a possible problem, but continue running. | | | | | --- | --- | --- | | • [Warning Basics](warning-basics) | | Warnings concepts and functions to report them. | | • [Warning Variables](warning-variables) | | Variables programs bind to customize their warnings. | | • [Warning Options](warning-options) | | Variables users set to control display of warnings. | | • [Delayed Warnings](delayed-warnings) | | Deferring a warning until the end of a command. | elisp None ### The Region The text between point and the mark is known as *the region*. Various functions operate on text delimited by point and the mark, but only those functions specifically related to the region itself are described here. The next two functions signal an error if the mark does not point anywhere. If Transient Mark mode is enabled and `mark-even-if-inactive` is `nil`, they also signal an error if the mark is inactive. Function: **region-beginning** This function returns the position of the beginning of the region (as an integer). This is the position of either point or the mark, whichever is smaller. Function: **region-end** This function returns the position of the end of the region (as an integer). This is the position of either point or the mark, whichever is larger. Instead of using `region-beginning` and `region-end`, a command designed to operate on a region should normally use `interactive` with the ‘`r`’ specification to find the beginning and end of the region. This lets other Lisp programs specify the bounds explicitly as arguments. See [Interactive Codes](interactive-codes). Function: **use-region-p** This function returns `t` if Transient Mark mode is enabled, the mark is active, and there is a valid region in the buffer. This function is intended to be used by commands that operate on the region, instead of on text near point, when the mark is active. A region is valid if it has a non-zero size, or if the user option `use-empty-active-region` is non-`nil` (by default, it is `nil`). The function `region-active-p` is similar to `use-region-p`, but considers all regions as valid. In most cases, you should not use `region-active-p`, since if the region is empty it is often more appropriate to operate on point. elisp None #### Indentation Relative to Previous Lines This section describes two commands that indent the current line based on the contents of previous lines. Command: **indent-relative** *&optional first-only unindented-ok* This command inserts whitespace at point, extending to the same column as the next *indent point* of the previous nonblank line. An indent point is a non-whitespace character following whitespace. The next indent point is the first one at a column greater than the current column of point. For example, if point is underneath and to the left of the first non-blank character of a line of text, it moves to that column by inserting whitespace. If the previous nonblank line has no next indent point (i.e., none at a great enough column position), `indent-relative` either does nothing (if unindented-ok is non-`nil`) or calls `tab-to-tab-stop`. Thus, if point is underneath and to the right of the last column of a short line of text, this command ordinarily moves point to the next tab stop by inserting whitespace. If first-only is non-`nil`, only the first indent point is considered. The return value of `indent-relative` is unpredictable. In the following example, point is at the beginning of the second line: ``` This line is indented twelve spaces. ∗The quick brown fox jumped. ``` Evaluation of the expression `(indent-relative nil)` produces the following: ``` This line is indented twelve spaces. ∗The quick brown fox jumped. ``` In this next example, point is between the ‘`m`’ and ‘`p`’ of ‘`jumped`’: ``` This line is indented twelve spaces. The quick brown fox jum∗ped. ``` Evaluation of the expression `(indent-relative nil)` produces the following: ``` This line is indented twelve spaces. The quick brown fox jum ∗ped. ``` Command: **indent-relative-first-indent-point** This command indents the current line like the previous nonblank line, by calling `indent-relative` with `t` as the first-only argument. The return value is unpredictable. If the previous nonblank line has no indent points beyond the current column, this command does nothing. elisp None ### Minibuffer History A *minibuffer history list* records previous minibuffer inputs so the user can reuse them conveniently. It is a variable whose value is a list of strings (previous inputs), most recent first. There are many separate minibuffer history lists, used for different kinds of inputs. It’s the Lisp programmer’s job to specify the right history list for each use of the minibuffer. You specify a minibuffer history list with the optional history argument to `read-from-minibuffer` or `completing-read`. Here are the possible values for it: variable Use variable (a symbol) as the history list. (variable . startpos) Use variable (a symbol) as the history list, and assume that the initial history position is startpos (a nonnegative integer). Specifying 0 for startpos is equivalent to just specifying the symbol variable. `previous-history-element` will display the most recent element of the history list in the minibuffer. If you specify a positive startpos, the minibuffer history functions behave as if `(elt variable (1- startpos))` were the history element currently shown in the minibuffer. For consistency, you should also specify that element of the history as the initial minibuffer contents, using the initial argument to the minibuffer input function (see [Initial Input](initial-input)). If you don’t specify history, then the default history list `minibuffer-history` is used. For other standard history lists, see below. You can also create your own history list variable; just initialize it to `nil` before the first use. If the variable is buffer local, then each buffer will have its own input history list. Both `read-from-minibuffer` and `completing-read` add new elements to the history list automatically, and provide commands to allow the user to reuse items on the list. The only thing your program needs to do to use a history list is to initialize it and to pass its name to the input functions when you wish. But it is safe to modify the list by hand when the minibuffer input functions are not using it. Emacs functions that add a new element to a history list can also delete old elements if the list gets too long. The variable `history-length` specifies the maximum length for most history lists. To specify a different maximum length for a particular history list, put the length in the `history-length` property of the history list symbol. The variable `history-delete-duplicates` specifies whether to delete duplicates in history. Function: **add-to-history** *history-var newelt &optional maxelt keep-all* This function adds a new element newelt, if it isn’t the empty string, to the history list stored in the variable history-var, and returns the updated history list. It limits the list length to the value of maxelt (if non-`nil`) or `history-length` (described below). The possible values of maxelt have the same meaning as the values of `history-length`. history-var cannot refer to a lexical variable. Normally, `add-to-history` removes duplicate members from the history list if `history-delete-duplicates` is non-`nil`. However, if keep-all is non-`nil`, that says not to remove duplicates, and to add newelt to the list even if it is empty. Variable: **history-add-new-input** If the value of this variable is `nil`, standard functions that read from the minibuffer don’t add new elements to the history list. This lets Lisp programs explicitly manage input history by using `add-to-history`. The default value is `t`. User Option: **history-length** The value of this variable specifies the maximum length for all history lists that don’t specify their own maximum lengths. If the value is `t`, that means there is no maximum (don’t delete old elements). If a history list variable’s symbol has a non-`nil` `history-length` property, it overrides this variable for that particular history list. User Option: **history-delete-duplicates** If the value of this variable is `t`, that means when adding a new history element, all previous identical elements are deleted. Here are some of the standard minibuffer history list variables: Variable: **minibuffer-history** The default history list for minibuffer history input. Variable: **query-replace-history** A history list for arguments to `query-replace` (and similar arguments to other commands). Variable: **file-name-history** A history list for file-name arguments. Variable: **buffer-name-history** A history list for buffer-name arguments. Variable: **regexp-history** A history list for regular expression arguments. Variable: **extended-command-history** A history list for arguments that are names of extended commands. Variable: **shell-command-history** A history list for arguments that are shell commands. Variable: **read-expression-history** A history list for arguments that are Lisp expressions to evaluate. Variable: **face-name-history** A history list for arguments that are faces. Variable: **custom-variable-history** A history list for variable-name arguments read by `read-variable`. Variable: **read-number-history** A history list for numbers read by `read-number`. Variable: **goto-line-history** A history list for arguments to `goto-line`. This variable can be made local in every buffer by customizing the user option `goto-line-history-local`.
programming_docs
elisp None #### Non-ASCII Characters in Strings There are two text representations for non-ASCII characters in Emacs strings: multibyte and unibyte (see [Text Representations](text-representations)). Roughly speaking, unibyte strings store raw bytes, while multibyte strings store human-readable text. Each character in a unibyte string is a byte, i.e., its value is between 0 and 255. By contrast, each character in a multibyte string may have a value between 0 to 4194303 (see [Character Type](character-type)). In both cases, characters above 127 are non-ASCII. You can include a non-ASCII character in a string constant by writing it literally. If the string constant is read from a multibyte source, such as a multibyte buffer or string, or a file that would be visited as multibyte, then Emacs reads each non-ASCII character as a multibyte character and automatically makes the string a multibyte string. If the string constant is read from a unibyte source, then Emacs reads the non-ASCII character as unibyte, and makes the string unibyte. Instead of writing a character literally into a multibyte string, you can write it as its character code using an escape sequence. See [General Escape Syntax](general-escape-syntax), for details about escape sequences. If you use any Unicode-style escape sequence ‘`\uNNNN`’ or ‘`\U00NNNNNN`’ in a string constant (even for an ASCII character), Emacs automatically assumes that it is multibyte. You can also use hexadecimal escape sequences (‘`\xn`’) and octal escape sequences (‘`\n`’) in string constants. **But beware:** If a string constant contains hexadecimal or octal escape sequences, and these escape sequences all specify unibyte characters (i.e., less than 256), and there are no other literal non-ASCII characters or Unicode-style escape sequences in the string, then Emacs automatically assumes that it is a unibyte string. That is to say, it assumes that all non-ASCII characters occurring in the string are 8-bit raw bytes. In hexadecimal and octal escape sequences, the escaped character code may contain a variable number of digits, so the first subsequent character which is not a valid hexadecimal or octal digit terminates the escape sequence. If the next character in a string could be interpreted as a hexadecimal or octal digit, write ‘`\` ’ (backslash and space) to terminate the escape sequence. For example, ‘`\xe0\` ’ represents one character, ‘`a`’ with grave accent. ‘`\` ’ in a string constant is just like backslash-newline; it does not contribute any character to the string, but it does terminate any preceding hex escape. elisp None Markers ------- A *marker* is a Lisp object used to specify a position in a buffer relative to the surrounding text. A marker changes its offset from the beginning of the buffer automatically whenever text is inserted or deleted, so that it stays with the two characters on either side of it. | | | | | --- | --- | --- | | • [Overview of Markers](overview-of-markers) | | The components of a marker, and how it relocates. | | • [Predicates on Markers](predicates-on-markers) | | Testing whether an object is a marker. | | • [Creating Markers](creating-markers) | | Making empty markers or markers at certain places. | | • [Information from Markers](information-from-markers) | | Finding the marker’s buffer or character position. | | • [Marker Insertion Types](marker-insertion-types) | | Two ways a marker can relocate when you insert where it points. | | • [Moving Markers](moving-markers) | | Moving the marker to a new buffer or position. | | • [The Mark](the-mark) | | How the mark is implemented with a marker. | | • [The Region](the-region) | | How to access the region. | elisp None ### File Local Variables A file can specify local variable values; Emacs uses these to create buffer-local bindings for those variables in the buffer visiting that file. See [Local Variables in Files](https://www.gnu.org/software/emacs/manual/html_node/emacs/File-Variables.html#File-Variables) in The GNU Emacs Manual, for basic information about file-local variables. This section describes the functions and variables that affect how file-local variables are processed. If a file-local variable could specify an arbitrary function or Lisp expression that would be called later, visiting a file could take over your Emacs. Emacs protects against this by automatically setting only those file-local variables whose specified values are known to be safe. Other file-local variables are set only if the user agrees. For additional safety, `read-circle` is temporarily bound to `nil` when Emacs reads file-local variables (see [Input Functions](input-functions)). This prevents the Lisp reader from recognizing circular and shared Lisp structures (see [Circular Objects](circular-objects)). User Option: **enable-local-variables** This variable controls whether to process file-local variables. The possible values are: `t` (the default) Set the safe variables, and query (once) about any unsafe variables. `:safe` Set only the safe variables and do not query. `:all` Set all the variables and do not query. `nil` Don’t set any variables. anything else Query (once) about all the variables. Variable: **inhibit-local-variables-regexps** This is a list of regular expressions. If a file has a name matching an element of this list, then it is not scanned for any form of file-local variable. For examples of why you might want to use this, see [Auto Major Mode](auto-major-mode). Variable: **permanently-enabled-local-variables** Some local variable settings will, by default, be heeded even if `enable-local-variables` is `nil`. By default, this is only the case for the `lexical-binding` local variable setting, but this can be controlled by using this variable, which is a list of symbols. Function: **hack-local-variables** *&optional handle-mode* This function parses, and binds or evaluates as appropriate, any local variables specified by the contents of the current buffer. The variable `enable-local-variables` has its effect here. However, this function does not look for the ‘`mode:`’ local variable in the ‘`-\*-`’ line. `set-auto-mode` does that, also taking `enable-local-variables` into account (see [Auto Major Mode](auto-major-mode)). This function works by walking the alist stored in `file-local-variables-alist` and applying each local variable in turn. It calls `before-hack-local-variables-hook` and `hack-local-variables-hook` before and after applying the variables, respectively. It only calls the before-hook if the alist is non-`nil`; it always calls the other hook. This function ignores a ‘`mode`’ element if it specifies the same major mode as the buffer already has. If the optional argument handle-mode is `t`, then all this function does is return a symbol specifying the major mode, if the ‘`-\*-`’ line or the local variables list specifies one, and `nil` otherwise. It does not set the mode or any other file-local variable. If handle-mode has any value other than `nil` or `t`, any settings of ‘`mode`’ in the ‘`-\*-`’ line or the local variables list are ignored, and the other settings are applied. If handle-mode is `nil`, all the file local variables are set. Variable: **file-local-variables-alist** This buffer-local variable holds the alist of file-local variable settings. Each element of the alist is of the form `(var . value)`, where var is a symbol of the local variable and value is its value. When Emacs visits a file, it first collects all the file-local variables into this alist, and then the `hack-local-variables` function applies them one by one. Variable: **before-hack-local-variables-hook** Emacs calls this hook immediately before applying file-local variables stored in `file-local-variables-alist`. Variable: **hack-local-variables-hook** Emacs calls this hook immediately after it finishes applying file-local variables stored in `file-local-variables-alist`. You can specify safe values for a variable with a `safe-local-variable` property. The property has to be a function of one argument; any value is safe if the function returns non-`nil` given that value. Many commonly-encountered file variables have `safe-local-variable` properties; these include `fill-column`, `fill-prefix`, and `indent-tabs-mode`. For boolean-valued variables that are safe, use `booleanp` as the property value. If you want to define `safe-local-variable` properties for variables defined in C source code, add the names and the properties of those variables to the list in the “Safe local variables” section of `files.el`. When defining a user option using `defcustom`, you can set its `safe-local-variable` property by adding the arguments `:safe function` to `defcustom` (see [Variable Definitions](variable-definitions)). However, a safety predicate defined using `:safe` will only be known once the package that contains the `defcustom` is loaded, which is often too late. As an alternative, you can use the autoload cookie (see [Autoload](autoload)) to assign the option its safety predicate, like this: ``` ;;;###autoload (put 'var 'safe-local-variable 'pred) ``` The safe value definitions specified with `autoload` are copied into the package’s autoloads file (`loaddefs.el` for most packages bundled with Emacs), and are known to Emacs since the beginning of a session. User Option: **safe-local-variable-values** This variable provides another way to mark some variable values as safe. It is a list of cons cells `(var . val)`, where var is a variable name and val is a value which is safe for that variable. When Emacs asks the user whether or not to obey a set of file-local variable specifications, the user can choose to mark them as safe. Doing so adds those variable/value pairs to `safe-local-variable-values`, and saves it to the user’s custom file. User Option: **ignored-local-variable-values** If there are some values of particular local variables that you always want to ignore completely, you can use this variable. Its value has the same form as `safe-local-variable-values`; a file-local variable setting to the value that appears in the list will always be ignored when processing the local variables specified by the file. As with that variable, when Emacs queries the user about whether to obey file-local variables, the user can choose to ignore their particular values permanently, and that will alter this variable and save it to the user’s custom file. Variable-value pairs that appear in this variable take precedence over the same pairs in `safe-local-variable-values`. Function: **safe-local-variable-p** *sym val* This function returns non-`nil` if it is safe to give sym the value val, based on the above criteria. Some variables are considered *risky*. If a variable is risky, it is never entered automatically into `safe-local-variable-values`; Emacs always queries before setting a risky variable, unless the user explicitly allows a value by customizing `safe-local-variable-values` directly. Any variable whose name has a non-`nil` `risky-local-variable` property is considered risky. When you define a user option using `defcustom`, you can set its `risky-local-variable` property by adding the arguments `:risky value` to `defcustom` (see [Variable Definitions](variable-definitions)). In addition, any variable whose name ends in any of ‘`-command`’, ‘`-frame-alist`’, ‘`-function`’, ‘`-functions`’, ‘`-hook`’, ‘`-hooks`’, ‘`-form`’, ‘`-forms`’, ‘`-map`’, ‘`-map-alist`’, ‘`-mode-alist`’, ‘`-program`’, or ‘`-predicate`’ is automatically considered risky. The variables ‘`font-lock-keywords`’, ‘`font-lock-keywords`’ followed by a digit, and ‘`font-lock-syntactic-keywords`’ are also considered risky. Function: **risky-local-variable-p** *sym* This function returns non-`nil` if sym is a risky variable, based on the above criteria. Variable: **ignored-local-variables** This variable holds a list of variables that should not be given local values by files. Any value specified for one of these variables is completely ignored. The ‘`Eval:`’ “variable” is also a potential loophole, so Emacs normally asks for confirmation before handling it. User Option: **enable-local-eval** This variable controls processing of ‘`Eval:`’ in ‘`-\*-`’ lines or local variables lists in files being visited. A value of `t` means process them unconditionally; `nil` means ignore them; anything else means ask the user what to do for each file. The default value is `maybe`. User Option: **safe-local-eval-forms** This variable holds a list of expressions that are safe to evaluate when found in the ‘`Eval:`’ “variable” in a file local variables list. If the expression is a function call and the function has a `safe-local-eval-function` property, the property value determines whether the expression is safe to evaluate. The property value can be a predicate to call to test the expression, a list of such predicates (it’s safe if any predicate succeeds), or `t` (always safe provided the arguments are constant). Text properties are also potential loopholes, since their values could include functions to call. So Emacs discards all text properties from string values specified for file-local variables. elisp None #### Miscellaneous Edebug Commands Some miscellaneous Edebug commands are described here. `?` Display the help message for Edebug (`edebug-help`). `a` `C-]` Abort one level back to the previous command level (`abort-recursive-edit`). `q` Return to the top level editor command loop (`top-level`). This exits all recursive editing levels, including all levels of Edebug activity. However, instrumented code protected with `unwind-protect` or `condition-case` forms may resume debugging. `Q` Like `q`, but don’t stop even for protected code (`edebug-top-level-nonstop`). `r` Redisplay the most recently known expression result in the echo area (`edebug-previous-result`). `d` Display a backtrace, excluding Edebug’s own functions for clarity (`edebug-pop-to-backtrace`). See [Backtraces](backtraces), for a description of backtraces and the commands which work on them. If you would like to see Edebug’s functions in the backtrace, use `M-x edebug-backtrace-show-instrumentation`. To hide them again use `M-x edebug-backtrace-hide-instrumentation`. If a backtrace frame starts with ‘`>`’ that means that Edebug knows where the source code for the frame is located. Use `s` to jump to the source code for the current frame. The backtrace buffer is killed automatically when you continue execution. You can invoke commands from Edebug that activate Edebug again recursively. Whenever Edebug is active, you can quit to the top level with `q` or abort one recursive edit level with `C-]`. You can display a backtrace of all the pending evaluations with `d`. elisp None #### Special Forms A *special form* is a primitive function specially marked so that its arguments are not all evaluated. Most special forms define control structures or perform variable bindings—things which functions cannot do. Each special form has its own rules for which arguments are evaluated and which are used without evaluation. Whether a particular argument is evaluated may depend on the results of evaluating other arguments. If an expression’s first symbol is that of a special form, the expression should follow the rules of that special form; otherwise, Emacs’s behavior is not well-defined (though it will not crash). For example, `((lambda (x) x . 3) 4)` contains a subexpression that begins with `lambda` but is not a well-formed `lambda` expression, so Emacs may signal an error, or may return 3 or 4 or `nil`, or may behave in other ways. Function: **special-form-p** *object* This predicate tests whether its argument is a special form, and returns `t` if so, `nil` otherwise. Here is a list, in alphabetical order, of all of the special forms in Emacs Lisp with a reference to where each is described. `and` see [Combining Conditions](combining-conditions) `catch` see [Catch and Throw](catch-and-throw) `cond` see [Conditionals](conditionals) `condition-case` see [Handling Errors](handling-errors) `defconst` see [Defining Variables](defining-variables) `defvar` see [Defining Variables](defining-variables) `function` see [Anonymous Functions](anonymous-functions) `if` see [Conditionals](conditionals) `interactive` see [Interactive Call](interactive-call) `lambda` see [Lambda Expressions](lambda-expressions) `let` `let*` see [Local Variables](local-variables) `or` see [Combining Conditions](combining-conditions) `prog1` `prog2` `progn` see [Sequencing](sequencing) `quote` see [Quoting](quoting) `save-current-buffer` see [Current Buffer](current-buffer) `save-excursion` see [Excursions](excursions) `save-restriction` see [Narrowing](narrowing) `setq` see [Setting Variables](setting-variables) `setq-default` see [Creating Buffer-Local](creating-buffer_002dlocal) `unwind-protect` see [Nonlocal Exits](nonlocal-exits) `while` see [Iteration](iteration) > **Common Lisp note:** Here are some comparisons of special forms in GNU Emacs Lisp and Common Lisp. `setq`, `if`, and `catch` are special forms in both Emacs Lisp and Common Lisp. `save-excursion` is a special form in Emacs Lisp, but doesn’t exist in Common Lisp. `throw` is a special form in Common Lisp (because it must be able to throw multiple values), but it is a function in Emacs Lisp (which doesn’t have multiple values). > > > elisp None ### Help Functions Emacs provides a variety of built-in help functions, all accessible to the user as subcommands of the prefix `C-h`. For more information about them, see [Help](https://www.gnu.org/software/emacs/manual/html_node/emacs/Help.html#Help) in The GNU Emacs Manual. Here we describe some program-level interfaces to the same information. Command: **apropos** *pattern &optional do-all* This function finds all meaningful symbols whose names contain a match for the apropos pattern pattern. An apropos pattern is either a word to match, a space-separated list of words of which at least two must match, or a regular expression (if any special regular expression characters occur). A symbol is meaningful if it has a definition as a function, variable, or face, or has properties. The function returns a list of elements that look like this: ``` (symbol score function-doc variable-doc plist-doc widget-doc face-doc group-doc) ``` Here, score is an integer measure of how important the symbol seems to be as a match. Each of the remaining elements is a documentation string, or `nil`, for symbol as a function, variable, etc. It also displays the symbols in a buffer named `\*Apropos\*`, each with a one-line description taken from the beginning of its documentation string. If do-all is non-`nil`, or if the user option `apropos-do-all` is non-`nil`, then `apropos` also shows key bindings for the functions that are found; it also shows *all* interned symbols, not just meaningful ones (and it lists them in the return value as well). Variable: **help-map** The value of this variable is a local keymap for characters following the Help key, `C-h`. Prefix Command: **help-command** This symbol is not a function; its function definition cell holds the keymap known as `help-map`. It is defined in `help.el` as follows: ``` (define-key global-map (string help-char) 'help-command) (fset 'help-command help-map) ``` User Option: **help-char** The value of this variable is the help character—the character that Emacs recognizes as meaning Help. By default, its value is 8, which stands for `C-h`. When Emacs reads this character, if `help-form` is a non-`nil` Lisp expression, it evaluates that expression, and displays the result in a window if it is a string. Usually the value of `help-form` is `nil`. Then the help character has no special meaning at the level of command input, and it becomes part of a key sequence in the normal way. The standard key binding of `C-h` is a prefix key for several general-purpose help features. The help character is special after prefix keys, too. If it has no binding as a subcommand of the prefix key, it runs `describe-prefix-bindings`, which displays a list of all the subcommands of the prefix key. User Option: **help-event-list** The value of this variable is a list of event types that serve as alternative help characters. These events are handled just like the event specified by `help-char`. Variable: **help-form** If this variable is non-`nil`, its value is a form to evaluate whenever the character `help-char` is read. If evaluating the form produces a string, that string is displayed. A command that calls `read-event`, `read-char-choice`, `read-char`, `read-char-from-minibuffer`, or `y-or-n-p` probably should bind `help-form` to a non-`nil` expression while it does input. (The time when you should not do this is when `C-h` has some other meaning.) Evaluating this expression should result in a string that explains what the input is for and how to enter it properly. Entry to the minibuffer binds this variable to the value of `minibuffer-help-form` (see [Definition of minibuffer-help-form](minibuffer-misc#Definition-of-minibuffer_002dhelp_002dform)). Variable: **prefix-help-command** This variable holds a function to print help for a prefix key. The function is called when the user types a prefix key followed by the help character, and the help character has no binding after that prefix. The variable’s default value is `describe-prefix-bindings`. Command: **describe-prefix-bindings** This function calls `describe-bindings` to display a list of all the subcommands of the prefix key of the most recent key sequence. The prefix described consists of all but the last event of that key sequence. (The last event is, presumably, the help character.) The following two functions are meant for modes that want to provide help without relinquishing control, such as the electric modes. Their names begin with ‘`Helper`’ to distinguish them from the ordinary help functions. Command: **Helper-describe-bindings** This command pops up a window displaying a help buffer containing a listing of all of the key bindings from both the local and global keymaps. It works by calling `describe-bindings`. Command: **Helper-help** This command provides help for the current mode. It prompts the user in the minibuffer with the message ‘`Help (Type ? for further options)`’, and then provides assistance in finding out what the key bindings are, and what the mode is intended for. It returns `nil`. This can be customized by changing the map `Helper-help-map`. Variable: **data-directory** This variable holds the name of the directory in which Emacs finds certain documentation and text files that come with Emacs. Function: **help-buffer** This function returns the name of the help buffer, which is normally `\*Help\*`; if such a buffer does not exist, it is first created. Macro: **with-help-window** *buffer-or-name body…* This macro evaluates body like `with-output-to-temp-buffer` (see [Temporary Displays](temporary-displays)), inserting any output produced by its forms into a buffer specified by buffer-or-name, which can be a buffer or the name of a buffer. (Frequently, buffer-or-name is the value returned by the function `help-buffer`.) This macro puts the specified buffer into Help mode and displays a message telling the user how to quit and scroll the help window. It selects the help window if the current value of the user option `help-window-select` has been set accordingly. It returns the last value in body. Function: **help-setup-xref** *item interactive-p* This function updates the cross reference data in the `\*Help\*` buffer, which is used to regenerate the help information when the user clicks on the ‘`Back`’ or ‘`Forward`’ buttons. Most commands that use the `\*Help\*` buffer should invoke this function before clearing the buffer. The item argument should have the form `(function . args)`, where function is a function to call, with argument list args, to regenerate the help buffer. The interactive-p argument is non-`nil` if the calling command was invoked interactively; in that case, the stack of items for the `\*Help\*` buffer’s ‘`Back`’ buttons is cleared. See [describe-symbols example](accessing-documentation#describe_002dsymbols-example), for an example of using `help-buffer`, `with-help-window`, and `help-setup-xref`. Macro: **make-help-screen** *fname help-line help-text help-map* This macro defines a help command named fname that acts like a prefix key that shows a list of the subcommands it offers. When invoked, fname displays help-text in a window, then reads and executes a key sequence according to help-map. The string help-text should describe the bindings available in help-map. The command fname is defined to handle a few events itself, by scrolling the display of help-text. When fname reads one of those special events, it does the scrolling and then reads another event. When it reads an event that is not one of those few, and which has a binding in help-map, it executes that key’s binding and then returns. The argument help-line should be a single-line summary of the alternatives in help-map. In the current version of Emacs, this argument is used only if you set the option `three-step-help` to `t`. This macro is used in the command `help-for-help` which is the binding of `C-h C-h`. User Option: **three-step-help** If this variable is non-`nil`, commands defined with `make-help-screen` display their help-line strings in the echo area at first, and display the longer help-text strings only if the user types the help character again.
programming_docs
elisp None ### Maintaining Undo Lists This section describes how to enable and disable undo information for a given buffer. It also explains how the undo list is truncated automatically so it doesn’t get too big. Recording of undo information in a newly created buffer is normally enabled to start with; but if the buffer name starts with a space, the undo recording is initially disabled. You can explicitly enable or disable undo recording with the following two functions, or by setting `buffer-undo-list` yourself. Command: **buffer-enable-undo** *&optional buffer-or-name* This command enables recording undo information for buffer buffer-or-name, so that subsequent changes can be undone. If no argument is supplied, then the current buffer is used. This function does nothing if undo recording is already enabled in the buffer. It returns `nil`. In an interactive call, buffer-or-name is the current buffer. You cannot specify any other buffer. Command: **buffer-disable-undo** *&optional buffer-or-name* This function discards the undo list of buffer-or-name, and disables further recording of undo information. As a result, it is no longer possible to undo either previous changes or any subsequent changes. If the undo list of buffer-or-name is already disabled, this function has no effect. In an interactive call, BUFFER-OR-NAME is the current buffer. You cannot specify any other buffer. This function returns `nil`. As editing continues, undo lists get longer and longer. To prevent them from using up all available memory space, garbage collection trims them back to size limits you can set. (For this purpose, the size of an undo list measures the cons cells that make up the list, plus the strings of deleted text.) Three variables control the range of acceptable sizes: `undo-limit`, `undo-strong-limit` and `undo-outer-limit`. In these variables, size is counted as the number of bytes occupied, which includes both saved text and other data. User Option: **undo-limit** This is the soft limit for the acceptable size of an undo list. The change group at which this size is exceeded is the last one kept. User Option: **undo-strong-limit** This is the upper limit for the acceptable size of an undo list. The change group at which this size is exceeded is discarded itself (along with all older change groups). There is one exception: the very latest change group is only discarded if it exceeds `undo-outer-limit`. User Option: **undo-outer-limit** If at garbage collection time the undo info for the current command exceeds this limit, Emacs discards the info and displays a warning. This is a last ditch limit to prevent memory overflow. User Option: **undo-ask-before-discard** If this variable is non-`nil`, when the undo info exceeds `undo-outer-limit`, Emacs asks in the echo area whether to discard the info. The default value is `nil`, which means to discard it automatically. This option is mainly intended for debugging. Garbage collection is inhibited while the question is asked, which means that Emacs might leak memory if the user waits too long before answering the question. elisp None ### Documentation Strings and Compilation When Emacs loads functions and variables from a byte-compiled file, it normally does not load their documentation strings into memory. Each documentation string is dynamically loaded from the byte-compiled file only when needed. This saves memory, and speeds up loading by skipping the processing of the documentation strings. This feature has a drawback: if you delete, move, or alter the compiled file (such as by compiling a new version), Emacs may no longer be able to access the documentation string of previously-loaded functions or variables. Such a problem normally only occurs if you build Emacs yourself, and happen to edit and/or recompile the Lisp source files. To solve it, just reload each file after recompilation. Dynamic loading of documentation strings from byte-compiled files is determined, at compile time, for each byte-compiled file. It can be disabled via the option `byte-compile-dynamic-docstrings`. User Option: **byte-compile-dynamic-docstrings** If this is non-`nil`, the byte compiler generates compiled files that are set up for dynamic loading of documentation strings. To disable the dynamic loading feature for a specific file, set this option to `nil` in its header line (see [Local Variables in Files](https://www.gnu.org/software/emacs/manual/html_node/emacs/File-Variables.html#File-Variables) in The GNU Emacs Manual), like this: ``` -*-byte-compile-dynamic-docstrings: nil;-*- ``` This is useful mainly if you expect to change the file, and you want Emacs sessions that have already loaded it to keep working when the file changes. Internally, the dynamic loading of documentation strings is accomplished by writing compiled files with a special Lisp reader construct, ‘`#@count`’. This construct skips the next count characters. It also uses the ‘`#$`’ construct, which stands for the name of this file, as a string. Do not use these constructs in Lisp source files; they are not designed to be clear to humans reading the file. elisp None #### Font Selection Before Emacs can draw a character on a graphical display, it must select a *font* for that character[26](#FOOT26). See [Fonts](https://www.gnu.org/software/emacs/manual/html_node/emacs/Fonts.html#Fonts) in The GNU Emacs Manual. Normally, Emacs automatically chooses a font based on the faces assigned to that character—specifically, the face attributes `:family`, `:weight`, `:slant`, and `:width` (see [Face Attributes](face-attributes)). The choice of font also depends on the character to be displayed; some fonts can only display a limited set of characters. If no available font exactly fits the requirements, Emacs looks for the *closest matching font*. The variables in this section control how Emacs makes this selection. User Option: **face-font-family-alternatives** If a given family is specified but does not exist, this variable specifies alternative font families to try. Each element should have this form: ``` (family alternate-families…) ``` If family is specified but not available, Emacs will try the other families given in alternate-families, one by one, until it finds a family that does exist. User Option: **face-font-selection-order** If there is no font that exactly matches all desired face attributes (`:width`, `:height`, `:weight`, and `:slant`), this variable specifies the order in which these attributes should be considered when selecting the closest matching font. The value should be a list containing those four attribute symbols, in order of decreasing importance. The default is `(:width :height :weight :slant)`. Font selection first finds the best available matches for the first attribute in the list; then, among the fonts which are best in that way, it searches for the best matches in the second attribute, and so on. The attributes `:weight` and `:width` have symbolic values in a range centered around `normal`. Matches that are more extreme (farther from `normal`) are somewhat preferred to matches that are less extreme (closer to `normal`); this is designed to ensure that non-normal faces contrast with normal ones, whenever possible. One example of a case where this variable makes a difference is when the default font has no italic equivalent. With the default ordering, the `italic` face will use a non-italic font that is similar to the default one. But if you put `:slant` before `:height`, the `italic` face will use an italic font, even if its height is not quite right. User Option: **face-font-registry-alternatives** This variable lets you specify alternative font registries to try, if a given registry is specified and doesn’t exist. Each element should have this form: ``` (registry alternate-registries…) ``` If registry is specified but not available, Emacs will try the other registries given in alternate-registries, one by one, until it finds a registry that does exist. Emacs can make use of scalable fonts, but by default it does not use them. User Option: **scalable-fonts-allowed** This variable controls which scalable fonts to use. A value of `nil`, the default, means do not use scalable fonts. `t` means to use any scalable font that seems appropriate for the text. Otherwise, the value must be a list of regular expressions. Then a scalable font is enabled for use if its name matches any regular expression in the list. For example, ``` (setq scalable-fonts-allowed '("iso10646-1$")) ``` allows the use of scalable fonts with registry `iso10646-1`. Variable: **face-font-rescale-alist** This variable specifies scaling for certain faces. Its value should be a list of elements of the form ``` (fontname-regexp . scale-factor) ``` If fontname-regexp matches the font name that is about to be used, this says to choose a larger similar font according to the factor scale-factor. You would use this feature to normalize the font size if certain fonts are bigger or smaller than their nominal heights and widths would suggest. elisp None ### Active Keymaps Emacs contains many keymaps, but at any time only a few keymaps are *active*. When Emacs receives user input, it translates the input event (see [Translation Keymaps](translation-keymaps)), and looks for a key binding in the active keymaps. Usually, the active keymaps are: (i) the keymap specified by the `keymap` property, (ii) the keymaps of enabled minor modes, (iii) the current buffer’s local keymap, and (iv) the global keymap, in that order. Emacs searches for each input key sequence in all these keymaps. Of these usual keymaps, the highest-precedence one is specified by the `keymap` text or overlay property at point, if any. (For a mouse input event, Emacs uses the event position instead of point; see [Searching Keymaps](searching-keymaps).) Next in precedence are keymaps specified by enabled minor modes. These keymaps, if any, are specified by the variables `emulation-mode-map-alists`, `minor-mode-overriding-map-alist`, and `minor-mode-map-alist`. See [Controlling Active Maps](controlling-active-maps). Next in precedence is the buffer’s *local keymap*, containing key bindings specific to the buffer. The minibuffer also has a local keymap (see [Intro to Minibuffers](intro-to-minibuffers)). If there is a `local-map` text or overlay property at point, that specifies the local keymap to use, in place of the buffer’s default local keymap. The local keymap is normally set by the buffer’s major mode, and every buffer with the same major mode shares the same local keymap. Hence, if you call `local-set-key` (see [Key Binding Commands](key-binding-commands)) to change the local keymap in one buffer, that also affects the local keymaps in other buffers with the same major mode. Finally, the *global keymap* contains key bindings that are defined regardless of the current buffer, such as `C-f`. It is always active, and is bound to the variable `global-map`. Apart from the above usual keymaps, Emacs provides special ways for programs to make other keymaps active. Firstly, the variable `overriding-local-map` specifies a keymap that replaces the usual active keymaps, except for the global keymap. Secondly, the terminal-local variable `overriding-terminal-local-map` specifies a keymap that takes precedence over *all* other keymaps (including `overriding-local-map`); this is normally used for modal/transient keybindings (the function `set-transient-map` provides a convenient interface for this). See [Controlling Active Maps](controlling-active-maps), for details. Making keymaps active is not the only way to use them. Keymaps are also used in other ways, such as for translating events within `read-key-sequence`. See [Translation Keymaps](translation-keymaps). See [Standard Keymaps](standard-keymaps), for a list of some standard keymaps. Function: **current-active-maps** *&optional olp position* This returns the list of active keymaps that would be used by the command loop in the current circumstances to look up a key sequence. Normally it ignores `overriding-local-map` and `overriding-terminal-local-map`, but if olp is non-`nil` then it pays attention to them. position can optionally be either an event position as returned by `event-start` or a buffer position, and may change the keymaps as described for `key-binding`. Function: **key-binding** *key &optional accept-defaults no-remap position* This function returns the binding for key according to the current active keymaps. The result is `nil` if key is undefined in the keymaps. The argument accept-defaults controls checking for default bindings, as in `lookup-key` (see [Functions for Key Lookup](functions-for-key-lookup)). When commands are remapped (see [Remapping Commands](remapping-commands)), `key-binding` normally processes command remappings so as to return the remapped command that will actually be executed. However, if no-remap is non-`nil`, `key-binding` ignores remappings and returns the binding directly specified for key. If key starts with a mouse event (perhaps following a prefix event), the maps to be consulted are determined based on the event’s position. Otherwise, they are determined based on the value of point. However, you can override either of them by specifying position. If position is non-`nil`, it should be either a buffer position or an event position like the value of `event-start`. Then the maps consulted are determined based on position. Emacs signals an error if key is not a string or a vector. ``` (key-binding "\C-x\C-f") ⇒ find-file ``` elisp None #### Edebug Views These Edebug commands let you view aspects of the buffer and window status as they were before entry to Edebug. The outside window configuration is the collection of windows and contents that were in effect outside of Edebug. `P` `v` Switch to viewing the outside window configuration (`edebug-view-outside`). Type `C-x X w` to return to Edebug. `p` Temporarily display the outside current buffer with point at its outside position (`edebug-bounce-point`), pausing for one second before returning to Edebug. With a prefix argument n, pause for n seconds instead. `w` Move point back to the current stop point in the source code buffer (`edebug-where`). If you use this command in a different window displaying the same buffer, that window will be used instead to display the current definition in the future. `W` Toggle whether Edebug saves and restores the outside window configuration (`edebug-toggle-save-windows`). With a prefix argument, `W` only toggles saving and restoring of the selected window. To specify a window that is not displaying the source code buffer, you must use `C-x X W` from the global keymap. You can view the outside window configuration with `v` or just bounce to the point in the current buffer with `p`, even if it is not normally displayed. After moving point, you may wish to jump back to the stop point. You can do that with `w` from a source code buffer. You can jump back to the stop point in the source code buffer from any buffer using `C-x X w`. Each time you use `W` to turn saving *off*, Edebug forgets the saved outside window configuration—so that even if you turn saving back *on*, the current window configuration remains unchanged when you next exit Edebug (by continuing the program). However, the automatic redisplay of `\*edebug\*` and `\*edebug-trace\*` may conflict with the buffers you wish to see unless you have enough windows open. elisp None #### Fringe Indicators *Fringe indicators* are tiny icons displayed in the window fringe to indicate truncated or continued lines, buffer boundaries, etc. User Option: **indicate-empty-lines** When this is non-`nil`, Emacs displays a special glyph in the fringe of each empty line at the end of the buffer, on graphical displays. See [Fringes](fringes). This variable is automatically buffer-local in every buffer. User Option: **indicate-buffer-boundaries** This buffer-local variable controls how the buffer boundaries and window scrolling are indicated in the window fringes. Emacs can indicate the buffer boundaries—that is, the first and last line in the buffer—with angle icons when they appear on the screen. In addition, Emacs can display an up-arrow in the fringe to show that there is text above the screen, and a down-arrow to show there is text below the screen. There are three kinds of basic values: `nil` Don’t display any of these fringe icons. `left` Display the angle icons and arrows in the left fringe. `right` Display the angle icons and arrows in the right fringe. any non-alist Display the angle icons in the left fringe and don’t display the arrows. Otherwise the value should be an alist that specifies which fringe indicators to display and where. Each element of the alist should have the form `(indicator . position)`. Here, indicator is one of `top`, `bottom`, `up`, `down`, and `t` (which covers all the icons not yet specified), while position is one of `left`, `right` and `nil`. For example, `((top . left) (t . right))` places the top angle bitmap in left fringe, and the bottom angle bitmap as well as both arrow bitmaps in right fringe. To show the angle bitmaps in the left fringe, and no arrow bitmaps, use `((top . left) (bottom . left))`. Variable: **fringe-indicator-alist** This buffer-local variable specifies the mapping from logical fringe indicators to the actual bitmaps displayed in the window fringes. The value is an alist of elements `(indicator . bitmaps)`, where indicator specifies a logical indicator type and bitmaps specifies the fringe bitmaps to use for that indicator. Each indicator should be one of the following symbols: `truncation`, `continuation`. Used for truncation and continuation lines. `up`, `down`, `top`, `bottom`, `top-bottom` Used when `indicate-buffer-boundaries` is non-`nil`: `up` and `down` indicate a buffer boundary lying above or below the window edge; `top` and `bottom` indicate the topmost and bottommost buffer text line; and `top-bottom` indicates where there is just one line of text in the buffer. `empty-line` Used to indicate empty lines after the buffer end when `indicate-empty-lines` is non-`nil`. `overlay-arrow` Used for overlay arrows (see [Overlay Arrow](overlay-arrow)). Each bitmaps value may be a list of symbols `(left right [left1 right1])`. The left and right symbols specify the bitmaps shown in the left and/or right fringe, for the specific indicator. left1 and right1 are specific to the `bottom` and `top-bottom` indicators, and are used to indicate that the last text line has no final newline. Alternatively, bitmaps may be a single symbol which is used in both left and right fringes. See [Fringe Bitmaps](fringe-bitmaps), for a list of standard bitmap symbols and how to define your own. In addition, `nil` represents the empty bitmap (i.e., an indicator that is not shown). When `fringe-indicator-alist` has a buffer-local value, and there is no bitmap defined for a logical indicator, or the bitmap is `t`, the corresponding value from the default value of `fringe-indicator-alist` is used. elisp None Documentation ------------- GNU Emacs has convenient built-in help facilities, most of which derive their information from documentation strings associated with functions and variables. This chapter describes how to access documentation strings in Lisp programs. The contents of a documentation string should follow certain conventions. In particular, its first line should be a complete sentence (or two complete sentences) that briefly describes what the function or variable does. See [Documentation Tips](https://www.gnu.org/software/emacs/manual/html_node/elisp/Documentation-Tips.html), for how to write good documentation strings. Note that the documentation strings for Emacs are not the same thing as the Emacs manual. Manuals have their own source files, written in the Texinfo language; documentation strings are specified in the definitions of the functions and variables they apply to. A collection of documentation strings is not sufficient as a manual because a good manual is not organized in that fashion; it is organized in terms of topics of discussion. For commands to display documentation strings, see [Help](https://www.gnu.org/software/emacs/manual/html_node/emacs/Help.html#Help) in The GNU Emacs Manual. | | | | | --- | --- | --- | | • [Documentation Basics](documentation-basics) | | Where doc strings are defined and stored. | | • [Accessing Documentation](accessing-documentation) | | How Lisp programs can access doc strings. | | • [Keys in Documentation](keys-in-documentation) | | Substituting current key bindings. | | • [Text Quoting Style](text-quoting-style) | | Quotation marks in doc strings and messages. | | • [Describing Characters](describing-characters) | | Making printable descriptions of non-printing characters and key sequences. | | • [Help Functions](help-functions) | | Subroutines used by Emacs help facilities. | | • [Documentation Groups](documentation-groups) | | Listing functions by groups. |
programming_docs
elisp None #### Explicit Nonlocal Exits: catch and throw Most control constructs affect only the flow of control within the construct itself. The function `throw` is the exception to this rule of normal program execution: it performs a nonlocal exit on request. (There are other exceptions, but they are for error handling only.) `throw` is used inside a `catch`, and jumps back to that `catch`. For example: ``` (defun foo-outer () (catch 'foo (foo-inner))) (defun foo-inner () … (if x (throw 'foo t)) …) ``` The `throw` form, if executed, transfers control straight back to the corresponding `catch`, which returns immediately. The code following the `throw` is not executed. The second argument of `throw` is used as the return value of the `catch`. The function `throw` finds the matching `catch` based on the first argument: it searches for a `catch` whose first argument is `eq` to the one specified in the `throw`. If there is more than one applicable `catch`, the innermost one takes precedence. Thus, in the above example, the `throw` specifies `foo`, and the `catch` in `foo-outer` specifies the same symbol, so that `catch` is the applicable one (assuming there is no other matching `catch` in between). Executing `throw` exits all Lisp constructs up to the matching `catch`, including function calls. When binding constructs such as `let` or function calls are exited in this way, the bindings are unbound, just as they are when these constructs exit normally (see [Local Variables](local-variables)). Likewise, `throw` restores the buffer and position saved by `save-excursion` (see [Excursions](excursions)), and the narrowing status saved by `save-restriction`. It also runs any cleanups established with the `unwind-protect` special form when it exits that form (see [Cleanups](cleanups)). The `throw` need not appear lexically within the `catch` that it jumps to. It can equally well be called from another function called within the `catch`. As long as the `throw` takes place chronologically after entry to the `catch`, and chronologically before exit from it, it has access to that `catch`. This is why `throw` can be used in commands such as `exit-recursive-edit` that throw back to the editor command loop (see [Recursive Editing](recursive-editing)). > **Common Lisp note:** Most other versions of Lisp, including Common Lisp, have several ways of transferring control nonsequentially: `return`, `return-from`, and `go`, for example. Emacs Lisp has only `throw`. The `cl-lib` library provides versions of some of these. See [Blocks and Exits](https://www.gnu.org/software/emacs/manual/html_node/cl/Blocks-and-Exits.html#Blocks-and-Exits) in Common Lisp Extensions. > > > Special Form: **catch** *tag body…* `catch` establishes a return point for the `throw` function. The return point is distinguished from other such return points by tag, which may be any Lisp object except `nil`. The argument tag is evaluated normally before the return point is established. With the return point in effect, `catch` evaluates the forms of the body in textual order. If the forms execute normally (without error or nonlocal exit) the value of the last body form is returned from the `catch`. If a `throw` is executed during the execution of body, specifying the same value tag, the `catch` form exits immediately; the value it returns is whatever was specified as the second argument of `throw`. Function: **throw** *tag value* The purpose of `throw` is to return from a return point previously established with `catch`. The argument tag is used to choose among the various existing return points; it must be `eq` to the value specified in the `catch`. If multiple return points match tag, the innermost one is used. The argument value is used as the value to return from that `catch`. If no return point is in effect with tag tag, then a `no-catch` error is signaled with data `(tag value)`. elisp None #### Nonprinting Characters in Strings You can use the same backslash escape-sequences in a string constant as in character literals (but do not use the question mark that begins a character constant). For example, you can write a string containing the nonprinting characters tab and `C-a`, with commas and spaces between them, like this: `"\t, \C-a"`. See [Character Type](character-type), for a description of the read syntax for characters. However, not all of the characters you can write with backslash escape-sequences are valid in strings. The only control characters that a string can hold are the ASCII control characters. Strings do not distinguish case in ASCII control characters. Properly speaking, strings cannot hold meta characters; but when a string is to be used as a key sequence, there is a special convention that provides a way to represent meta versions of ASCII characters in a string. If you use the ‘`\M-`’ syntax to indicate a meta character in a string constant, this sets the 2\*\*7 bit of the character in the string. If the string is used in `define-key` or `lookup-key`, this numeric code is translated into the equivalent meta character. See [Character Type](character-type). Strings cannot hold characters that have the hyper, super, or alt modifiers. elisp None #### Backtraces Debugger mode is derived from Backtrace mode, which is also used to show backtraces by Edebug and ERT. (see [Edebug](edebug), and [the ERT manual](https://www.gnu.org/software/emacs/manual/html_node/ert/index.html#Top) in ERT: Emacs Lisp Regression Testing.) The backtrace buffer shows you the functions that are executing and their argument values. When a backtrace buffer is created, it shows each stack frame on one, possibly very long, line. (A stack frame is the place where the Lisp interpreter records information about a particular invocation of a function.) The most recently called function will be at the top. In a backtrace you can specify a stack frame by moving point to a line describing that frame. The frame whose line point is on is considered the *current frame*. If a function name is underlined, that means Emacs knows where its source code is located. You can click with the mouse on that name, or move to it and type RET, to visit the source code. You can also type RET while point is on any name of a function or variable which is not underlined, to see help information for that symbol in a help buffer, if any exists. The `xref-find-definitions` command, bound to `M-.`, can also be used on any identifier in a backtrace (see [Looking Up Identifiers](https://www.gnu.org/software/emacs/manual/html_node/emacs/Looking-Up-Identifiers.html#Looking-Up-Identifiers) in The GNU Emacs Manual). In backtraces, the tails of long lists and the ends of long strings, vectors or structures, as well as objects which are deeply nested, will be printed as underlined “...”. You can click with the mouse on a “...”, or type RET while point is on it, to show the part of the object that was hidden. To control how much abbreviation is done, customize `backtrace-line-length`. Here is a list of commands for navigating and viewing backtraces: `v` Toggle the display of local variables of the current stack frame. `p` Move to the beginning of the frame, or to the beginning of the previous frame. `n` Move to the beginning of the next frame. `+` Add line breaks and indentation to the top-level Lisp form at point to make it more readable. `-` Collapse the top-level Lisp form at point back to a single line. `#` Toggle `print-circle` for the frame at point. `:` Toggle `print-gensym` for the frame at point. `.` Expand all the forms abbreviated with “...” in the frame at point. elisp None #### Side Window Options and Functions The following options provide additional control over the placement of side windows. User Option: **window-sides-vertical** If non-`nil`, the side windows on the left and right of a frame occupy the frame’s full height. Otherwise, the side windows on the top and bottom of the frame occupy the frame’s full width. User Option: **window-sides-slots** This option specifies the maximum number of side windows on each side of a frame. The value is a list of four elements specifying the number of side window slots on (in this order) the left, top, right and bottom of each frame. If an element is a number, it means to display at most that many windows on the corresponding side. If an element is `nil`, it means there’s no bound on the number of slots on that side. If any of the specified values is zero, no window can be created on the corresponding side. `display-buffer-in-side-window` will not signal an error in that case, but will return `nil`. If a specified value just forbids the creation of an additional side window, the most suitable window on that side is reused and may have its `window-slot` parameter changed accordingly. User Option: **window-sides-reversed** This option specifies whether top/bottom side windows should appear in reverse order. When this is `nil`, side windows on the top and bottom of a frame are always drawn from left to right with increasing slot values. When this is `t`, the drawing order is reversed and side windows on the top and bottom of a frame are drawn from right to left with increasing slot values. When this is `bidi`, the drawing order is reversed if and only if the value of `bidi-paragraph-direction` (see [Bidirectional Display](bidirectional-display)) is `right-to-left` in the buffer displayed in the window most recently selected within the main window area of this frame. Sometimes that window may be hard to find, so heuristics are used to avoid that the drawing order changes inadvertently when another window gets selected. The layout of side windows on the left or right of a frame is not affected by the value of this variable. When a frame has side windows, the following function returns the main window of that frame. Function: **window-main-window** *&optional frame* This function returns the main window of the specified frame. The optional argument frame must be a live frame and defaults to the selected one. If frame has no side windows, it returns frame’s root window. Otherwise, it returns either an internal non-side window such that all other non-side windows on frame descend from it, or the single live non-side window of frame. Note that the main window of a frame cannot be deleted via `delete-window`. The following command is handy to toggle the appearance of all side windows on a specified frame. Command: **window-toggle-side-windows** *&optional frame* This command toggles side windows on the specified frame. The optional argument frame must be a live frame and defaults to the selected one. If frame has at least one side window, this command saves the state of frame’s root window in the frame’s `window-state` frame parameter and deletes all side windows on frame afterwards. If frame has no side windows, but does have a `window-state` parameter, this command uses that parameter’s value to restore the side windows on frame leaving frame’s main window alone. An error is signaled if frame has no side windows and no saved state is found for it. elisp None ### Switching to a Buffer in a Window This section describes high-level functions for switching to a specified buffer in some window. In general, “switching to a buffer” means to (1) show the buffer in some window, (2) make that window the selected window (and its frame the selected frame), and (3) make the buffer the current buffer. Do *not* use these functions to make a buffer temporarily current just so a Lisp program can access or modify it. They have side-effects, such as changing window histories (see [Window History](window-history)), which will surprise the user if used that way. If you want to make a buffer current to modify it in Lisp, use `with-current-buffer`, `save-current-buffer`, or `set-buffer`. See [Current Buffer](current-buffer). Command: **switch-to-buffer** *buffer-or-name &optional norecord force-same-window* This command attempts to display buffer-or-name in the selected window and make it the current buffer. It is often used interactively (as the binding of `C-x b`), as well as in Lisp programs. The return value is the buffer switched to. If buffer-or-name is `nil`, it defaults to the buffer returned by `other-buffer` (see [Buffer List](buffer-list)). If buffer-or-name is a string that is not the name of any existing buffer, this function creates a new buffer with that name; the new buffer’s major mode is determined by the variable `major-mode` (see [Major Modes](major-modes)). Normally, the specified buffer is put at the front of the buffer list—both the global buffer list and the selected frame’s buffer list (see [Buffer List](buffer-list)). However, this is not done if the optional argument norecord is non-`nil`. Sometimes, the selected window may not be suitable for displaying the buffer. This happens if the selected window is a minibuffer window, or if the selected window is strongly dedicated to its buffer (see [Dedicated Windows](dedicated-windows)). In such cases, the command normally tries to display the buffer in some other window, by invoking `pop-to-buffer` (see below). If the optional argument force-same-window is non-`nil` and the selected window is not suitable for displaying the buffer, this function always signals an error when called non-interactively. In interactive use, if the selected window is a minibuffer window, this function will try to use some other window instead. If the selected window is strongly dedicated to its buffer, the option `switch-to-buffer-in-dedicated-window` described next can be used to proceed. User Option: **switch-to-buffer-in-dedicated-window** This option, if non-`nil`, allows `switch-to-buffer` to proceed when called interactively and the selected window is strongly dedicated to its buffer. The following values are respected: `nil` Disallows switching and signals an error as in non-interactive use. `prompt` Prompts the user whether to allow switching. `pop` Invokes `pop-to-buffer` to proceed. `t` Marks the selected window as non-dedicated and proceeds. This option does not affect non-interactive calls of `switch-to-buffer`. By default, `switch-to-buffer` tries to preserve `window-point`. This behavior can be tuned using the following option. User Option: **switch-to-buffer-preserve-window-point** If this variable is `nil`, `switch-to-buffer` displays the buffer specified by buffer-or-name at the position of that buffer’s `point`. If this variable is `already-displayed`, it tries to display the buffer at its previous position in the selected window, provided the buffer is currently displayed in some other window on any visible or iconified frame. If this variable is `t`, `switch-to-buffer` unconditionally tries to display the buffer at its previous position in the selected window. This variable is ignored if the buffer is already displayed in the selected window or never appeared in it before, or if `switch-to-buffer` calls `pop-to-buffer` to display the buffer. User Option: **switch-to-buffer-obey-display-actions** If this variable is non-`nil`, `switch-to-buffer` respects display actions specified by `display-buffer-overriding-action`, `display-buffer-alist` and other display related variables. The next two commands are similar to `switch-to-buffer`, except for the described features. Command: **switch-to-buffer-other-window** *buffer-or-name &optional norecord* This function displays the buffer specified by buffer-or-name in some window other than the selected window. It uses the function `pop-to-buffer` internally (see below). If the selected window already displays the specified buffer, it continues to do so, but another window is nonetheless found to display it as well. The buffer-or-name and norecord arguments have the same meanings as in `switch-to-buffer`. Command: **switch-to-buffer-other-frame** *buffer-or-name &optional norecord* This function displays the buffer specified by buffer-or-name in a new frame. It uses the function `pop-to-buffer` internally (see below). If the specified buffer is already displayed in another window, in any frame on the current terminal, this switches to that window instead of creating a new frame. However, the selected window is never used for this. The buffer-or-name and norecord arguments have the same meanings as in `switch-to-buffer`. The above commands use the function `pop-to-buffer`, which flexibly displays a buffer in some window and selects that window for editing. In turn, `pop-to-buffer` uses `display-buffer` for displaying the buffer. Hence, all the variables affecting `display-buffer` will affect it as well. See [Choosing Window](choosing-window), for the documentation of `display-buffer`. Command: **pop-to-buffer** *buffer-or-name &optional action norecord* This function makes buffer-or-name the current buffer and displays it in some window, preferably not the window currently selected. It then selects the displaying window. If that window is on a different graphical frame, that frame is given input focus if possible (see [Input Focus](input-focus)). If buffer-or-name is `nil`, it defaults to the buffer returned by `other-buffer` (see [Buffer List](buffer-list)). If buffer-or-name is a string that is not the name of any existing buffer, this function creates a new buffer with that name; the new buffer’s major mode is determined by the variable `major-mode` (see [Major Modes](major-modes)). In any case, that buffer is made current and returned, even when no suitable window was found to display it. If action is non-`nil`, it should be a display action to pass to `display-buffer` (see [Choosing Window](choosing-window)). Alternatively, a non-`nil`, non-list value means to pop to a window other than the selected one—even if the buffer is already displayed in the selected window. Like `switch-to-buffer`, this function updates the buffer list unless norecord is non-`nil`. elisp None #### Motion by Screen Lines The line functions in the previous section count text lines, delimited only by newline characters. By contrast, these functions count screen lines, which are defined by the way the text appears on the screen. A text line is a single screen line if it is short enough to fit the width of the selected window, but otherwise it may occupy several screen lines. In some cases, text lines are truncated on the screen rather than continued onto additional screen lines. In these cases, `vertical-motion` moves point much like `forward-line`. See [Truncation](truncation). Because the width of a given string depends on the flags that control the appearance of certain characters, `vertical-motion` behaves differently, for a given piece of text, depending on the buffer it is in, and even on the selected window (because the width, the truncation flag, and display table may vary between windows). See [Usual Display](usual-display). These functions scan text to determine where screen lines break, and thus take time proportional to the distance scanned. Function: **vertical-motion** *count &optional window cur-col* This function moves point to the start of the screen line count screen lines down from the screen line containing point. If count is negative, it moves up instead. The count argument can be a cons cell, `(cols . lines)`, instead of an integer. Then the function moves by lines screen lines, and puts point cols columns from the visual start of that screen line. Note that cols are counted from the *visual* start of the line; if the window is scrolled horizontally (see [Horizontal Scrolling](horizontal-scrolling)), the column on which point will end is in addition to the number of columns by which the text is scrolled. The return value is the number of screen lines over which point was moved. The value may be less in absolute value than count if the beginning or end of the buffer was reached. The window window is used for obtaining parameters such as the width, the horizontal scrolling, and the display table. But `vertical-motion` always operates on the current buffer, even if window currently displays some other buffer. The optional argument cur-col specifies the current column when the function is called. This is the window-relative horizontal coordinate of point, measured in units of font width of the frame’s default face. Providing it speeds up the function, especially in very long lines, because the function doesn’t have to go back in the buffer in order to determine the current column. Note that cur-col is also counted from the visual start of the line. Function: **count-screen-lines** *&optional beg end count-final-newline window* This function returns the number of screen lines in the text from beg to end. The number of screen lines may be different from the number of actual lines, due to line continuation, the display table, etc. If beg and end are `nil` or omitted, they default to the beginning and end of the accessible portion of the buffer. If the region ends with a newline, that is ignored unless the optional third argument count-final-newline is non-`nil`. The optional fourth argument window specifies the window for obtaining parameters such as width, horizontal scrolling, and so on. The default is to use the selected window’s parameters. Like `vertical-motion`, `count-screen-lines` always uses the current buffer, regardless of which buffer is displayed in window. This makes possible to use `count-screen-lines` in any buffer, whether or not it is currently displayed in some window. Command: **move-to-window-line** *count* This function moves point with respect to the text currently displayed in the selected window. It moves point to the beginning of the screen line count screen lines from the top of the window; zero means the topmost line. If count is negative, that specifies a position -count lines from the bottom (or the last line of the buffer, if the buffer ends above the specified screen position); thus, count of -1 specifies the last fully visible screen line of the window. If count is `nil`, then point moves to the beginning of the line in the middle of the window. If the absolute value of count is greater than the size of the window, then point moves to the place that would appear on that screen line if the window were tall enough. This will probably cause the next redisplay to scroll to bring that location onto the screen. In an interactive call, count is the numeric prefix argument. The value returned is the screen line number point has moved to, relative to the top line of the window. Function: **move-to-window-group-line** *count* This function is like `move-to-window-line`, except that when the selected window is a part of a group of windows (see [Window Group](selecting-windows#Window-Group)), `move-to-window-group-line` will move to a position with respect to the entire group, not just the single window. This condition holds when the buffer local variable `move-to-window-group-line-function` is set to a function. In this case, `move-to-window-group-line` calls the function with the argument count, then returns its result. Function: **compute-motion** *from frompos to topos width offsets window* This function scans the current buffer, calculating screen positions. It scans the buffer forward from position from, assuming that is at screen coordinates frompos, to position to or coordinates topos, whichever comes first. It returns the ending buffer position and screen coordinates. The coordinate arguments frompos and topos are cons cells of the form `(hpos . vpos)`. The argument width is the number of columns available to display text; this affects handling of continuation lines. `nil` means the actual number of usable text columns in the window, which is equivalent to the value returned by `(window-width window)`. The argument offsets is either `nil` or a cons cell of the form `(hscroll . tab-offset)`. Here hscroll is the number of columns not being displayed at the left margin; most callers get this by calling `window-hscroll`. Meanwhile, tab-offset is the offset between column numbers on the screen and column numbers in the buffer. This can be nonzero in a continuation line, when the previous screen lines’ widths do not add up to a multiple of `tab-width`. It is always zero in a non-continuation line. The window window serves only to specify which display table to use. `compute-motion` always operates on the current buffer, regardless of what buffer is displayed in window. The return value is a list of five elements: ``` (pos hpos vpos prevhpos contin) ``` Here pos is the buffer position where the scan stopped, vpos is the vertical screen position, and hpos is the horizontal screen position. The result prevhpos is the horizontal position one character back from pos. The result contin is `t` if the last line was continued after (or within) the previous character. For example, to find the buffer position of column col of screen line line of a certain window, pass the window’s display start location as from and the window’s upper-left coordinates as frompos. Pass the buffer’s `(point-max)` as to, to limit the scan to the end of the accessible portion of the buffer, and pass line and col as topos. Here’s a function that does this: ``` (defun coordinates-of-position (col line) (car (compute-motion (window-start) '(0 . 0) (point-max) (cons col line) (window-width) (cons (window-hscroll) 0) (selected-window)))) ``` When you use `compute-motion` for the minibuffer, you need to use `minibuffer-prompt-width` to get the horizontal position of the beginning of the first screen line. See [Minibuffer Contents](minibuffer-contents).
programming_docs
elisp None Evaluation ---------- The *evaluation* of expressions in Emacs Lisp is performed by the *Lisp interpreter*—a program that receives a Lisp object as input and computes its *value as an expression*. How it does this depends on the data type of the object, according to rules described in this chapter. The interpreter runs automatically to evaluate portions of your program, but can also be called explicitly via the Lisp primitive function `eval`. | | | | | --- | --- | --- | | • [Intro Eval](intro-eval) | | Evaluation in the scheme of things. | | • [Forms](forms) | | How various sorts of objects are evaluated. | | • [Quoting](quoting) | | Avoiding evaluation (to put constants in the program). | | • [Backquote](backquote) | | Easier construction of list structure. | | • [Eval](eval) | | How to invoke the Lisp interpreter explicitly. | | • [Deferred Eval](deferred-eval) | | Deferred and lazy evaluation of forms. | elisp None #### Meta-Character Syntax A *meta character* is a character typed with the META modifier key. The integer that represents such a character has the 2\*\*27 bit set. We use high bits for this and other modifiers to make possible a wide range of basic character codes. In a string, the 2\*\*7 bit attached to an ASCII character indicates a meta character; thus, the meta characters that can fit in a string have codes in the range from 128 to 255, and are the meta versions of the ordinary ASCII characters. See [Strings of Events](strings-of-events), for details about META-handling in strings. The read syntax for meta characters uses ‘`\M-`’. For example, ‘`?\M-A`’ stands for `M-A`. You can use ‘`\M-`’ together with octal character codes (see below), with ‘`\C-`’, or with any other syntax for a character. Thus, you can write `M-A` as ‘`?\M-A`’, or as ‘`?\M-\101`’. Likewise, you can write `C-M-b` as ‘`?\M-\C-b`’, ‘`?\C-\M-b`’, or ‘`?\M-\002`’. elisp None ### Splitting Windows This section describes functions for creating a new window by *splitting* an existing one. Note that some windows are special in the sense that these functions may fail to split them as described here. Examples of such windows are side windows (see [Side Windows](side-windows)) and atomic windows (see [Atomic Windows](atomic-windows)). Function: **split-window** *&optional window size side pixelwise* This function creates a new live window next to the window window. If window is omitted or `nil`, it defaults to the selected window. That window is split, and reduced in size. The space is taken up by the new window, which is returned. The optional second argument size determines the sizes of window and/or the new window. If it is omitted or `nil`, both windows are given equal sizes; if there is an odd line, it is allocated to the new window. If size is a positive number, window is given size lines (or columns, depending on the value of side). If size is a negative number, the new window is given -size lines (or columns). If size is `nil`, this function obeys the variables `window-min-height` and `window-min-width` (see [Window Sizes](window-sizes)). Thus, it signals an error if splitting would result in making a window smaller than those variables specify. However, a non-`nil` value for size causes those variables to be ignored; in that case, the smallest allowable window is considered to be one that has space for a text that is one line tall and/or two columns wide. Hence, if size is specified, it’s the caller’s responsibility to check whether the emanating windows are large enough to encompass all of their decorations like a mode line or a scroll bar. The function `window-min-size` (see [Window Sizes](window-sizes)) can be used to determine the minimum requirements of window in this regard. Since the new window usually inherits areas like the mode line or the scroll bar from window, that function is also a good guess for the minimum size of the new window. The caller should specify a smaller size only if it correspondingly removes an inherited area before the next redisplay. The optional third argument side determines the position of the new window relative to window. If it is `nil` or `below`, the new window is placed below window. If it is `above`, the new window is placed above window. In both these cases, size specifies a total window height, in lines. If side is `t` or `right`, the new window is placed on the right of window. If side is `left`, the new window is placed on the left of window. In both these cases, size specifies a total window width, in columns. The optional fourth argument pixelwise, if non-`nil`, means to interpret size in units of pixels, instead of lines and columns. If window is a live window, the new window inherits various properties from it, including margins and scroll bars. If window is an internal window, the new window inherits the properties of the window selected within window’s frame. The behavior of this function may be altered by the window parameters of window, so long as the variable `ignore-window-parameters` is `nil`. If the value of the `split-window` window parameter is `t`, this function ignores all other window parameters. Otherwise, if the value of the `split-window` window parameter is a function, that function is called with the arguments window, size, and side, in lieu of the usual action of `split-window`. Otherwise, this function obeys the `window-atom` or `window-side` window parameter, if any. See [Window Parameters](window-parameters). As an example, here is a sequence of `split-window` calls that yields the window configuration discussed in [Windows and Frames](windows-and-frames). This example demonstrates splitting a live window as well as splitting an internal window. We begin with a frame containing a single window (a live root window), which we denote by W4. Calling `(split-window W4)` yields this window configuration: ``` ______________________________________ | ____________________________________ | || || || || || || ||_________________W4_________________|| | ____________________________________ | || || || || || || ||_________________W5_________________|| |__________________W3__________________| ``` The `split-window` call has created a new live window, denoted by W5. It has also created a new internal window, denoted by W3, which becomes the root window and the parent of both W4 and W5. Next, we call `(split-window W3 nil 'left)`, passing the internal window W3 as the argument. The result: ``` ______________________________________ | ______ ____________________________ | || || __________________________ || || ||| ||| || ||| ||| || ||| ||| || |||____________W4____________||| || || __________________________ || || ||| ||| || ||| ||| || |||____________W5____________||| ||__W2__||_____________W3_____________ | |__________________W1__________________| ``` A new live window W2 is created, to the left of the internal window W3. A new internal window W1 is created, becoming the new root window. For interactive use, Emacs provides two commands which always split the selected window. These call `split-window` internally. Command: **split-window-right** *&optional size* This function splits the selected window into two side-by-side windows, putting the selected window on the left. If size is positive, the left window gets size columns; if size is negative, the right window gets -size columns. Command: **split-window-below** *&optional size* This function splits the selected window into two windows, one above the other, leaving the upper window selected. If size is positive, the upper window gets size lines; if size is negative, the lower window gets -size lines. User Option: **split-window-keep-point** If the value of this variable is non-`nil` (the default), `split-window-below` behaves as described above. If it is `nil`, `split-window-below` adjusts point in each of the two windows to minimize redisplay. (This is useful on slow terminals.) It selects whichever window contains the screen line that point was previously on. Note that this only affects `split-window-below`, not the lower-level `split-window` function. elisp None ### Library Search When Emacs loads a Lisp library, it searches for the library in a list of directories specified by the variable `load-path`. Variable: **load-path** The value of this variable is a list of directories to search when loading files with `load`. Each element is a string (which must be a directory) or `nil` (which stands for the current working directory). When Emacs starts up, it sets up the value of `load-path` in several steps. First, it initializes `load-path` using default locations set when Emacs was compiled. Normally, this is a directory something like ``` "/usr/local/share/emacs/version/lisp" ``` (In this and the following examples, replace `/usr/local` with the installation prefix appropriate for your Emacs.) These directories contain the standard Lisp files that come with Emacs. If Emacs cannot find them, it will not start correctly. If you run Emacs from the directory where it was built—that is, an executable that has not been formally installed—Emacs instead initializes `load-path` using the `lisp` directory in the directory containing the sources from which it was built. If you built Emacs in a separate directory from the sources, it also adds the lisp directories from the build directory. (In all cases, elements are represented as absolute file names.) Unless you start Emacs with the `--no-site-lisp` option, it then adds two more `site-lisp` directories to the front of `load-path`. These are intended for locally installed Lisp files, and are normally of the form: ``` "/usr/local/share/emacs/version/site-lisp" ``` and ``` "/usr/local/share/emacs/site-lisp" ``` The first one is for locally installed files for a specific Emacs version; the second is for locally installed files meant for use with all installed Emacs versions. (If Emacs is running uninstalled, it also adds `site-lisp` directories from the source and build directories, if they exist. Normally these directories do not contain `site-lisp` directories.) If the environment variable `EMACSLOADPATH` is set, it modifies the above initialization procedure. Emacs initializes `load-path` based on the value of the environment variable. The syntax of `EMACSLOADPATH` is the same as used for `PATH`; directories are separated by ‘`:`’ (or ‘`;`’, on some operating systems). Here is an example of how to set `EMACSLOADPATH` variable (from a `sh`-style shell): ``` export EMACSLOADPATH=/home/foo/.emacs.d/lisp: ``` An empty element in the value of the environment variable, whether trailing (as in the above example), leading, or embedded, is replaced by the default value of `load-path` as determined by the standard initialization procedure. If there are no such empty elements, then `EMACSLOADPATH` specifies the entire `load-path`. You must include either an empty element, or the explicit path to the directory containing the standard Lisp files, else Emacs will not function. (Another way to modify `load-path` is to use the `-L` command-line option when starting Emacs; see below.) For each directory in `load-path`, Emacs then checks to see if it contains a file `subdirs.el`, and if so, loads it. The `subdirs.el` file is created when Emacs is built/installed, and contains code that causes Emacs to add any subdirectories of those directories to `load-path`. Both immediate subdirectories and subdirectories multiple levels down are added. But it excludes subdirectories whose names do not start with a letter or digit, and subdirectories named `RCS` or `CVS`, and subdirectories containing a file named `.nosearch`. Next, Emacs adds any extra load directories that you specify using the `-L` command-line option (see [Action Arguments](https://www.gnu.org/software/emacs/manual/html_node/emacs/Action-Arguments.html#Action-Arguments) in The GNU Emacs Manual). It also adds the directories where optional packages are installed, if any (see [Packaging Basics](packaging-basics)). It is common to add code to one’s init file (see [Init File](init-file)) to add one or more directories to `load-path`. For example: ``` (push "~/.emacs.d/lisp" load-path) ``` Dumping Emacs uses a special value of `load-path`. If you use a `site-load.el` or `site-init.el` file to customize the dumped Emacs (see [Building Emacs](building-emacs)), any changes to `load-path` that these files make will be lost after dumping. Command: **locate-library** *library &optional nosuffix path interactive-call* This command finds the precise file name for library library. It searches for the library in the same way `load` does, and the argument nosuffix has the same meaning as in `load`: don’t add suffixes ‘`.elc`’ or ‘`.el`’ to the specified name library. If the path is non-`nil`, that list of directories is used instead of `load-path`. When `locate-library` is called from a program, it returns the file name as a string. When the user runs `locate-library` interactively, the argument interactive-call is `t`, and this tells `locate-library` to display the file name in the echo area. Command: **list-load-path-shadows** *&optional stringp* This command shows a list of *shadowed* Emacs Lisp files. A shadowed file is one that will not normally be loaded, despite being in a directory on `load-path`, due to the existence of another similarly-named file in a directory earlier on `load-path`. For instance, suppose `load-path` is set to ``` ("/opt/emacs/site-lisp" "/usr/share/emacs/23.3/lisp") ``` and that both these directories contain a file named `foo.el`. Then `(require 'foo)` never loads the file in the second directory. Such a situation might indicate a problem in the way Emacs was installed. When called from Lisp, this function prints a message listing the shadowed files, instead of displaying them in a buffer. If the optional argument `stringp` is non-`nil`, it instead returns the shadowed files as a string. If Emacs was compiled with support for native compilation (see [Native Compilation](native-compilation)), then when a ‘`.elc`’ byte-compiled file is found by searching `load-path`, Emacs will try to look for a corresponding ‘`.eln`’ file holding the corresponding natively-compiled code. The natively-compiled files are looked up in the directories listed by the `native-comp-eln-load-path`. Variable: **native-comp-eln-load-path** This variable holds a list of directories where Emacs looks for natively-compiled ‘`.eln`’ files. File names in the list that are not absolute are interpreted as relative to `invocation-directory` (see [System Environment](system-environment)). The last directory in the list is the system directory, i.e. the directory with ‘`.eln`’ files installed by the Emacs build and installation procedure. In each of the directories in the list, Emacs looks for ‘`.eln`’ files in a subdirectory whose name is constructed from the Emacs version and an 8-character hash that depends on the current native-compilation ABI; the name of this subdirectory is stored in the variable `comp-native-version-dir`. elisp None ### Buttons The Button package defines functions for inserting and manipulating *buttons* that can be activated with the mouse or via keyboard commands. These buttons are typically used for various kinds of hyperlinks. A button is essentially a set of text or overlay properties, attached to a stretch of text in a buffer. These properties are called *button properties*. One of these properties, the *action property*, specifies a function which is called when the user invokes the button using the keyboard or the mouse. The action function may examine the button and use its other properties as desired. In some ways, the Button package duplicates the functionality in the Widget package. See [Introduction](https://www.gnu.org/software/emacs/manual/html_node/widget/index.html#Top) in The Emacs Widget Library. The advantage of the Button package is that it is faster, smaller, and simpler to program. From the point of view of the user, the interfaces produced by the two packages are very similar. | | | | | --- | --- | --- | | • [Button Properties](button-properties) | | Button properties with special meanings. | | • [Button Types](button-types) | | Defining common properties for classes of buttons. | | • [Making Buttons](making-buttons) | | Adding buttons to Emacs buffers. | | • [Manipulating Buttons](manipulating-buttons) | | Getting and setting properties of buttons. | | • [Button Buffer Commands](button-buffer-commands) | | Buffer-wide commands and bindings for buttons. | elisp None ### Displaying a Buffer in a Suitable Window This section describes lower-level functions Emacs uses to find or create a window for displaying a specified buffer. The common workhorse of these functions is `display-buffer` which eventually handles all incoming requests for buffer display (see [Choosing Window](choosing-window)). `display-buffer` delegates the task of finding a suitable window to so-called action functions (see [Buffer Display Action Functions](buffer-display-action-functions)). First, `display-buffer` compiles a so-called action alist—a special association list that action functions can use to fine-tune their behavior. Then it passes that alist on to each action function it calls (see [Buffer Display Action Alists](buffer-display-action-alists)). The behavior of `display-buffer` is highly customizable. To understand how customizations are used in practice, you may wish to study examples illustrating the order of precedence which `display-buffer` uses to call action functions (see [Precedence of Action Functions](precedence-of-action-functions)). To avoid conflicts between Lisp programs calling `display-buffer` and user customizations of its behavior, it may make sense to follow a number of guidelines which are sketched in the final part of this section (see [The Zen of Buffer Display](the-zen-of-buffer-display)). | | | | | --- | --- | --- | | • [Choosing Window](choosing-window) | | How to choose a window for displaying a buffer. | | • [Buffer Display Action Functions](buffer-display-action-functions) | | Support functions for buffer display. | | • [Buffer Display Action Alists](buffer-display-action-alists) | | Alists for fine-tuning buffer display. | | • [Choosing Window Options](choosing-window-options) | | Extra options affecting how buffers are displayed. | | • [Precedence of Action Functions](precedence-of-action-functions) | | Examples to explain the precedence of action functions. | | • [The Zen of Buffer Display](the-zen-of-buffer-display) | | How to avoid that buffers get lost in between windows. | elisp None ### Checksum/Hash Emacs has built-in support for computing *cryptographic hashes*. A cryptographic hash, or *checksum*, is a digital fingerprint of a piece of data (e.g., a block of text) which can be used to check that you have an unaltered copy of that data. Emacs supports several common cryptographic hash algorithms: MD5, SHA-1, SHA-2, SHA-224, SHA-256, SHA-384 and SHA-512. MD5 is the oldest of these algorithms, and is commonly used in *message digests* to check the integrity of messages transmitted over a network. MD5 and SHA-1 are not collision resistant (i.e., it is possible to deliberately design different pieces of data which have the same MD5 or SHA-1 hash), so you should not use them for anything security-related. For security-related applications you should use the other hash types, such as SHA-2 (e.g. `sha256` or `sha512`). Function: **secure-hash-algorithms** This function returns a list of symbols representing algorithms that `secure-hash` can use. Function: **secure-hash** *algorithm object &optional start end binary* This function returns a hash for object. The argument algorithm is a symbol stating which hash to compute: one of `md5`, `sha1`, `sha224`, `sha256`, `sha384` or `sha512`. The argument object should be a buffer or a string. The optional arguments start and end are character positions specifying the portion of object to compute the message digest for. If they are `nil` or omitted, the hash is computed for the whole of object. If the argument binary is omitted or `nil`, the function returns the *text form* of the hash, as an ordinary Lisp string. If binary is non-`nil`, it returns the hash in *binary form*, as a sequence of bytes stored in a unibyte string. This function does not compute the hash directly from the internal representation of object’s text (see [Text Representations](text-representations)). Instead, it encodes the text using a coding system (see [Coding Systems](coding-systems)), and computes the hash from that encoded text. If object is a buffer, the coding system used is the one which would be chosen by default for writing the text into a file. If object is a string, the user’s preferred coding system is used (see [Recognize Coding](https://www.gnu.org/software/emacs/manual/html_node/emacs/Recognize-Coding.html#Recognize-Coding) in GNU Emacs Manual). Function: **md5** *object &optional start end coding-system noerror* This function returns an MD5 hash. It is semi-obsolete, since for most purposes it is equivalent to calling `secure-hash` with `md5` as the algorithm argument. The object, start and end arguments have the same meanings as in `secure-hash`. If coding-system is non-`nil`, it specifies a coding system to use to encode the text; if omitted or `nil`, the default coding system is used, like in `secure-hash`. Normally, `md5` signals an error if the text can’t be encoded using the specified or chosen coding system. However, if noerror is non-`nil`, it silently uses `raw-text` coding instead. Function: **buffer-hash** *&optional buffer-or-name* Return a hash of buffer-or-name. If `nil`, this defaults to the current buffer. As opposed to `secure-hash`, this function computes the hash based on the internal representation of the buffer, disregarding any coding systems. It’s therefore only useful when comparing two buffers running in the same Emacs, and is not guaranteed to return the same hash between different Emacs versions. It should be somewhat more efficient on larger buffers than `secure-hash` is, and should not allocate more memory.
programming_docs
elisp None #### Marker Type A *marker* denotes a position in a specific buffer. Markers therefore have two components: one for the buffer, and one for the position. Changes in the buffer’s text automatically relocate the position value as necessary to ensure that the marker always points between the same two characters in the buffer. Markers have no read syntax. They print in hash notation, giving the current character position and the name of the buffer. ``` (point-marker) ⇒ #<marker at 10779 in objects.texi> ``` See [Markers](markers), for information on how to test, create, copy, and move markers. elisp None ### Frame Titles Every frame has a `name` parameter; this serves as the default for the frame title which window systems typically display at the top of the frame. You can specify a name explicitly by setting the `name` frame property. Normally you don’t specify the name explicitly, and Emacs computes the frame name automatically based on a template stored in the variable `frame-title-format`. Emacs recomputes the name each time the frame is redisplayed. Variable: **frame-title-format** This variable specifies how to compute a name for a frame when you have not explicitly specified one. The variable’s value is actually a mode line construct, just like `mode-line-format`, except that the ‘`%c`’, ‘`%C`’, and ‘`%l`’ constructs are ignored. See [Mode Line Data](mode-line-data). Variable: **icon-title-format** This variable specifies how to compute the name for an iconified frame, when you have not explicitly specified the frame title. This title appears in the icon itself. Variable: **multiple-frames** This variable is set automatically by Emacs. Its value is `t` when there are two or more frames (not counting minibuffer-only frames or invisible frames). The default value of `frame-title-format` uses `multiple-frames` so as to put the buffer name in the frame title only when there is more than one frame. The value of this variable is not guaranteed to be accurate except while processing `frame-title-format` or `icon-title-format`. elisp None ### Adjusting Point After Commands Emacs cannot display the cursor when point is in the middle of a sequence of text that has the `display` or `composition` property, or is invisible. Therefore, after a command finishes and returns to the command loop, if point is within such a sequence, the command loop normally moves point to the edge of the sequence, making this sequence effectively intangible. A command can inhibit this feature by setting the variable `disable-point-adjustment`: Variable: **disable-point-adjustment** If this variable is non-`nil` when a command returns to the command loop, then the command loop does not check for those text properties, and does not move point out of sequences that have them. The command loop sets this variable to `nil` before each command, so if a command sets it, the effect applies only to that command. Variable: **global-disable-point-adjustment** If you set this variable to a non-`nil` value, the feature of moving point out of these sequences is completely turned off. elisp None ### Completion *Completion* is a feature that fills in the rest of a name starting from an abbreviation for it. Completion works by comparing the user’s input against a list of valid names and determining how much of the name is determined uniquely by what the user has typed. For example, when you type `C-x b` (`switch-to-buffer`) and then type the first few letters of the name of the buffer to which you wish to switch, and then type TAB (`minibuffer-complete`), Emacs extends the name as far as it can. Standard Emacs commands offer completion for names of symbols, files, buffers, and processes; with the functions in this section, you can implement completion for other kinds of names. The `try-completion` function is the basic primitive for completion: it returns the longest determined completion of a given initial string, with a given set of strings to match against. The function `completing-read` provides a higher-level interface for completion. A call to `completing-read` specifies how to determine the list of valid names. The function then activates the minibuffer with a local keymap that binds a few keys to commands useful for completion. Other functions provide convenient simple interfaces for reading certain kinds of names with completion. | | | | | --- | --- | --- | | • [Basic Completion](basic-completion) | | Low-level functions for completing strings. | | • [Minibuffer Completion](minibuffer-completion) | | Invoking the minibuffer with completion. | | • [Completion Commands](completion-commands) | | Minibuffer commands that do completion. | | • [High-Level Completion](high_002dlevel-completion) | | Convenient special cases of completion (reading buffer names, variable names, etc.). | | • [Reading File Names](reading-file-names) | | Using completion to read file names and shell commands. | | • [Completion Variables](completion-variables) | | Variables controlling completion behavior. | | • [Programmed Completion](programmed-completion) | | Writing your own completion function. | | • [Completion in Buffers](completion-in-buffers) | | Completing text in ordinary buffers. | elisp None ### Editing Types The types in the previous section are used for general programming purposes, and most of them are common to most Lisp dialects. Emacs Lisp provides several additional data types for purposes connected with editing. | | | | | --- | --- | --- | | • [Buffer Type](buffer-type) | | The basic object of editing. | | • [Marker Type](marker-type) | | A position in a buffer. | | • [Window Type](window-type) | | Buffers are displayed in windows. | | • [Frame Type](frame-type) | | Windows subdivide frames. | | • [Terminal Type](terminal-type) | | A terminal device displays frames. | | • [Window Configuration Type](window-configuration-type) | | Recording the way a frame is subdivided. | | • [Frame Configuration Type](frame-configuration-type) | | Recording the status of all frames. | | • [Process Type](process-type) | | A subprocess of Emacs running on the underlying OS. | | • [Thread Type](thread-type) | | A thread of Emacs Lisp execution. | | • [Mutex Type](mutex-type) | | An exclusive lock for thread synchronization. | | • [Condition Variable Type](condition-variable-type) | | Condition variable for thread synchronization. | | • [Stream Type](stream-type) | | Receive or send characters. | | • [Keymap Type](keymap-type) | | What function a keystroke invokes. | | • [Overlay Type](overlay-type) | | How an overlay is represented. | | • [Font Type](font-type) | | Fonts for displaying text. | elisp None #### File Name Completion This section describes low-level subroutines for completing a file name. For higher level functions, see [Reading File Names](reading-file-names). Function: **file-name-all-completions** *partial-filename directory* This function returns a list of all possible completions for a file whose name starts with partial-filename in directory directory. The order of the completions is the order of the files in the directory, which is unpredictable and conveys no useful information. The argument partial-filename must be a file name containing no directory part and no slash (or backslash on some systems). The current buffer’s default directory is prepended to directory, if directory is not absolute. In the following example, suppose that `~rms/lewis` is the current default directory, and has five files whose names begin with ‘`f`’: `foo`, `file~`, `file.c`, `file.c.~1~`, and `file.c.~2~`. ``` (file-name-all-completions "f" "") ⇒ ("foo" "file~" "file.c.~2~" "file.c.~1~" "file.c") ``` ``` (file-name-all-completions "fo" "") ⇒ ("foo") ``` Function: **file-name-completion** *filename directory &optional predicate* This function completes the file name filename in directory directory. It returns the longest prefix common to all file names in directory directory that start with filename. If predicate is non-`nil` then it ignores possible completions that don’t satisfy predicate, after calling that function with one argument, the expanded absolute file name. If only one match exists and filename matches it exactly, the function returns `t`. The function returns `nil` if directory directory contains no name starting with filename. In the following example, suppose that the current default directory has five files whose names begin with ‘`f`’: `foo`, `file~`, `file.c`, `file.c.~1~`, and `file.c.~2~`. ``` (file-name-completion "fi" "") ⇒ "file" ``` ``` (file-name-completion "file.c.~1" "") ⇒ "file.c.~1~" ``` ``` (file-name-completion "file.c.~1~" "") ⇒ t ``` ``` (file-name-completion "file.c.~3" "") ⇒ nil ``` User Option: **completion-ignored-extensions** `file-name-completion` usually ignores file names that end in any string in this list. It does not ignore them when all the possible completions end in one of these suffixes. This variable has no effect on `file-name-all-completions`. A typical value might look like this: ``` completion-ignored-extensions ⇒ (".o" ".elc" "~" ".dvi") ``` If an element of `completion-ignored-extensions` ends in a slash ‘`/`’, it signals a directory. The elements which do *not* end in a slash will never match a directory; thus, the above value will not filter out a directory named `foo.elc`. elisp None #### Encoding and I/O The principal purpose of coding systems is for use in reading and writing files. The function `insert-file-contents` uses a coding system to decode the file data, and `write-region` uses one to encode the buffer contents. You can specify the coding system to use either explicitly (see [Specifying Coding Systems](specifying-coding-systems)), or implicitly using a default mechanism (see [Default Coding Systems](default-coding-systems)). But these methods may not completely specify what to do. For example, they may choose a coding system such as `undecided` which leaves the character code conversion to be determined from the data. In these cases, the I/O operation finishes the job of choosing a coding system. Very often you will want to find out afterwards which coding system was chosen. Variable: **buffer-file-coding-system** This buffer-local variable records the coding system used for saving the buffer and for writing part of the buffer with `write-region`. If the text to be written cannot be safely encoded using the coding system specified by this variable, these operations select an alternative encoding by calling the function `select-safe-coding-system` (see [User-Chosen Coding Systems](user_002dchosen-coding-systems)). If selecting a different encoding requires to ask the user to specify a coding system, `buffer-file-coding-system` is updated to the newly selected coding system. `buffer-file-coding-system` does *not* affect sending text to a subprocess. Variable: **save-buffer-coding-system** This variable specifies the coding system for saving the buffer (by overriding `buffer-file-coding-system`). Note that it is not used for `write-region`. When a command to save the buffer starts out to use `buffer-file-coding-system` (or `save-buffer-coding-system`), and that coding system cannot handle the actual text in the buffer, the command asks the user to choose another coding system (by calling `select-safe-coding-system`). After that happens, the command also updates `buffer-file-coding-system` to represent the coding system that the user specified. Variable: **last-coding-system-used** I/O operations for files and subprocesses set this variable to the coding system name that was used. The explicit encoding and decoding functions (see [Explicit Encoding](explicit-encoding)) set it too. **Warning:** Since receiving subprocess output sets this variable, it can change whenever Emacs waits; therefore, you should copy the value shortly after the function call that stores the value you are interested in. The variable `selection-coding-system` specifies how to encode selections for the window system. See [Window System Selections](window-system-selections). Variable: **file-name-coding-system** The variable `file-name-coding-system` specifies the coding system to use for encoding file names. Emacs encodes file names using that coding system for all file operations. If `file-name-coding-system` is `nil`, Emacs uses a default coding system determined by the selected language environment. In the default language environment, any non-ASCII characters in file names are not encoded specially; they appear in the file system using the internal Emacs representation. **Warning:** if you change `file-name-coding-system` (or the language environment) in the middle of an Emacs session, problems can result if you have already visited files whose names were encoded using the earlier coding system and are handled differently under the new coding system. If you try to save one of these buffers under the visited file name, saving may use the wrong file name, or it may get an error. If such a problem happens, use `C-x C-w` to specify a new file name for that buffer. On Windows 2000 and later, Emacs by default uses Unicode APIs to pass file names to the OS, so the value of `file-name-coding-system` is largely ignored. Lisp applications that need to encode or decode file names on the Lisp level should use `utf-8` coding-system when `system-type` is `windows-nt`; the conversion of UTF-8 encoded file names to the encoding appropriate for communicating with the OS is performed internally by Emacs. elisp None ### Text Quoting Style Typically, grave accents and apostrophes are treated specially in documentation strings and diagnostic messages, and translate to matching single quotation marks (also called “curved quotes”). For example, the documentation string "Alias for `foo'." and the function call `(message "Alias for `foo'.")` both translate to "Alias for ‘foo’.". Less commonly, Emacs displays grave accents and apostrophes as themselves, or as apostrophes only (e.g., "Alias for 'foo'."). Documentation strings and message formats should be written so that they display well with any of these styles. For example, the documentation string "Alias for 'foo'." is probably not what you want, as it can display as "Alias for ’foo’.", an unusual style in English. Sometimes you may need to display a grave accent or apostrophe without translation, regardless of text quoting style. In a documentation string, you can do this with escapes. For example, in the documentation string "\\=`(a ,(sin 0)) ==> (a 0.0)" the grave accent is intended to denote Lisp code, so it is escaped and displays as itself regardless of quoting style. In a call to `message` or `error`, you can avoid translation by using a format "%s" with an argument that is a call to `format`. For example, `(message "%s" (format "`(a ,(sin %S)) ==> (a %S)" x (sin x)))` displays a message that starts with grave accent regardless of text quoting style. User Option: **text-quoting-style** The value of this user option is a symbol that specifies the style Emacs should use for single quotes in the wording of help and messages. If the option’s value is `curve`, the style is ‘like this’ with curved single quotes. If the value is `straight`, the style is 'like this' with straight apostrophes. If the value is `grave`, quotes are not translated and the style is `like this' with grave accent and apostrophe, the standard style before Emacs version 25. The default value `nil` acts like `curve` if curved single quotes seem to be displayable, and like `grave` otherwise. This option is useful on platforms that have problems with curved quotes. You can customize it freely according to your personal preference. elisp None #### Customizing Fringe Bitmaps Function: **define-fringe-bitmap** *bitmap bits &optional height width align* This function defines the symbol bitmap as a new fringe bitmap, or replaces an existing bitmap with that name. The argument bits specifies the image to use. It should be either a string or a vector of integers, where each element (an integer) corresponds to one row of the bitmap. Each bit of an integer corresponds to one pixel of the bitmap, where the low bit corresponds to the rightmost pixel of the bitmap. (Note that this order of bits is opposite of the order in XBM images; see [XBM Images](xbm-images).) The height is normally the length of bits. However, you can specify a different height with non-`nil` height. The width is normally 8, but you can specify a different width with non-`nil` width. The width must be an integer between 1 and 16. The argument align specifies the positioning of the bitmap relative to the range of rows where it is used; the default is to center the bitmap. The allowed values are `top`, `center`, or `bottom`. The align argument may also be a list `(align periodic)` where align is interpreted as described above. If periodic is non-`nil`, it specifies that the rows in `bits` should be repeated enough times to reach the specified height. Function: **destroy-fringe-bitmap** *bitmap* This function destroys the fringe bitmap identified by bitmap. If bitmap identifies a standard fringe bitmap, it actually restores the standard definition of that bitmap, instead of eliminating it entirely. Function: **set-fringe-bitmap-face** *bitmap &optional face* This sets the face for the fringe bitmap bitmap to face. If face is `nil`, it selects the `fringe` face. The bitmap’s face controls the color to draw it in. face is merged with the `fringe` face, so normally face should specify only the foreground color. elisp None #### Basic Major Modes Apart from Fundamental mode, there are three major modes that other major modes commonly derive from: Text mode, Prog mode, and Special mode. While Text mode is useful in its own right (e.g., for editing files ending in `.txt`), Prog mode and Special mode exist mainly to let other modes derive from them. As far as possible, new major modes should be derived, either directly or indirectly, from one of these three modes. One reason is that this allows users to customize a single mode hook (e.g., `prog-mode-hook`) for an entire family of relevant modes (e.g., all programming language modes). Command: **text-mode** Text mode is a major mode for editing human languages. It defines the ‘`"`’ and ‘`\`’ characters as having punctuation syntax (see [Syntax Class Table](syntax-class-table)), and binds `M-TAB` to `ispell-complete-word` (see [Spelling](https://www.gnu.org/software/emacs/manual/html_node/emacs/Spelling.html#Spelling) in The GNU Emacs Manual). An example of a major mode derived from Text mode is HTML mode. See [SGML and HTML Modes](https://www.gnu.org/software/emacs/manual/html_node/emacs/HTML-Mode.html#HTML-Mode) in The GNU Emacs Manual. Command: **prog-mode** Prog mode is a basic major mode for buffers containing programming language source code. Most of the programming language major modes built into Emacs are derived from it. Prog mode binds `parse-sexp-ignore-comments` to `t` (see [Motion via Parsing](motion-via-parsing)) and `bidi-paragraph-direction` to `left-to-right` (see [Bidirectional Display](bidirectional-display)). Command: **special-mode** Special mode is a basic major mode for buffers containing text that is produced specially by Emacs, rather than directly from a file. Major modes derived from Special mode are given a `mode-class` property of `special` (see [Major Mode Conventions](major-mode-conventions)). Special mode sets the buffer to read-only. Its keymap defines several common bindings, including `q` for `quit-window` and `g` for `revert-buffer` (see [Reverting](reverting)). An example of a major mode derived from Special mode is Buffer Menu mode, which is used by the `\*Buffer List\*` buffer. See [Listing Existing Buffers](https://www.gnu.org/software/emacs/manual/html_node/emacs/List-Buffers.html#List-Buffers) in The GNU Emacs Manual. In addition, modes for buffers of tabulated data can inherit from Tabulated List mode, which is in turn derived from Special mode. See [Tabulated List Mode](tabulated-list-mode).
programming_docs
elisp None ### Defining Hash Comparisons You can define new methods of key lookup by means of `define-hash-table-test`. In order to use this feature, you need to understand how hash tables work, and what a *hash code* means. You can think of a hash table conceptually as a large array of many slots, each capable of holding one association. To look up a key, `gethash` first computes an integer, the hash code, from the key. It can reduce this integer modulo the length of the array, to produce an index in the array. Then it looks in that slot, and if necessary in other nearby slots, to see if it has found the key being sought. Thus, to define a new method of key lookup, you need to specify both a function to compute the hash code from a key, and a function to compare two keys directly. The two functions should be consistent with each other: that is, two keys’ hash codes should be the same if the keys compare as equal. Also, since the two functions can be called at any time (such as by the garbage collector), the functions should be free of side effects and should return quickly, and their behavior should depend on only on properties of the keys that do not change. Function: **define-hash-table-test** *name test-fn hash-fn* This function defines a new hash table test, named name. After defining name in this way, you can use it as the test argument in `make-hash-table`. When you do that, the hash table will use test-fn to compare key values, and hash-fn to compute a hash code from a key value. The function test-fn should accept two arguments, two keys, and return non-`nil` if they are considered the same. The function hash-fn should accept one argument, a key, and return an integer that is the hash code of that key. For good results, the function should use the whole range of fixnums for hash codes, including negative fixnums. The specified functions are stored in the property list of name under the property `hash-table-test`; the property value’s form is `(test-fn hash-fn)`. Function: **sxhash-equal** *obj* This function returns a hash code for Lisp object obj. This is an integer that reflects the contents of obj and the other Lisp objects it points to. If two objects obj1 and obj2 are `equal`, then `(sxhash-equal obj1)` and `(sxhash-equal obj2)` are the same integer. If the two objects are not `equal`, the values returned by `sxhash-equal` are usually different, but not always; once in a rare while, by luck, you will encounter two distinct-looking objects that give the same result from `sxhash-equal`. **Common Lisp note:** In Common Lisp a similar function is called `sxhash`. Emacs provides this name as a compatibility alias for `sxhash-equal`. Function: **sxhash-eq** *obj* This function returns a hash code for Lisp object obj. Its result reflects identity of obj, but not its contents. If two objects obj1 and obj2 are `eq`, then `(sxhash-eq obj1)` and `(sxhash-eq obj2)` are the same integer. Function: **sxhash-eql** *obj* This function returns a hash code for Lisp object obj suitable for `eql` comparison. I.e. it reflects identity of obj except for the case where the object is a bignum or a float number, in which case a hash code is generated for the value. If two objects obj1 and obj2 are `eql`, then `(sxhash-eql obj1)` and `(sxhash-eql obj2)` are the same integer. This example creates a hash table whose keys are strings that are compared case-insensitively. ``` (defun case-fold-string= (a b) (eq t (compare-strings a nil nil b nil nil t))) (defun case-fold-string-hash (a) (sxhash-equal (upcase a))) (define-hash-table-test 'case-fold 'case-fold-string= 'case-fold-string-hash) (make-hash-table :test 'case-fold) ``` Here is how you could define a hash table test equivalent to the predefined test value `equal`. The keys can be any Lisp object, and equal-looking objects are considered the same key. ``` (define-hash-table-test 'contents-hash 'equal 'sxhash-equal) (make-hash-table :test 'contents-hash) ``` Lisp programs should *not* rely on hash codes being preserved between Emacs sessions, as the implementation of the hash functions uses some details of the object storage that can change between sessions and between different architectures. elisp None Control Structures ------------------ A Lisp program consists of a set of *expressions*, or *forms* (see [Forms](forms)). We control the order of execution of these forms by enclosing them in *control structures*. Control structures are special forms which control when, whether, or how many times to execute the forms they contain. The simplest order of execution is sequential execution: first form a, then form b, and so on. This is what happens when you write several forms in succession in the body of a function, or at top level in a file of Lisp code—the forms are executed in the order written. We call this *textual order*. For example, if a function body consists of two forms a and b, evaluation of the function evaluates first a and then b. The result of evaluating b becomes the value of the function. Explicit control structures make possible an order of execution other than sequential. Emacs Lisp provides several kinds of control structure, including other varieties of sequencing, conditionals, iteration, and (controlled) jumps—all discussed below. The built-in control structures are special forms since their subforms are not necessarily evaluated or not evaluated sequentially. You can use macros to define your own control structure constructs (see [Macros](macros)). | | | | | --- | --- | --- | | • [Sequencing](sequencing) | | Evaluation in textual order. | | • [Conditionals](conditionals) | | `if`, `cond`, `when`, `unless`. | | • [Combining Conditions](combining-conditions) | | `and`, `or`, `not`, and friends. | | • [Pattern-Matching Conditional](pattern_002dmatching-conditional) | | How to use `pcase` and friends. | | • [Iteration](iteration) | | `while` loops. | | • [Generators](generators) | | Generic sequences and coroutines. | | • [Nonlocal Exits](nonlocal-exits) | | Jumping out of a sequence. | elisp None #### Printing Notation Many of the examples in this manual print text when they are evaluated. If you execute example code in a Lisp Interaction buffer (such as the buffer `\*scratch\*`) by typing `C-j` after the closing parenthesis of the example, the printed text is inserted into the buffer. If you execute the example by other means (such as by evaluating the function `eval-region`), the printed text is displayed in the echo area. Examples in this manual indicate printed text with ‘`-|`’, irrespective of where that text goes. The value returned by evaluating the form follows on a separate line with ‘`⇒`’. ``` (progn (prin1 'foo) (princ "\n") (prin1 'bar)) -| foo -| bar ⇒ bar ``` elisp None ### Child Frames Child frames are objects halfway between windows (see [Windows](windows)) and “normal” frames. Like windows, they are attached to an owning frame. Unlike windows, they may overlap each other—changing the size or position of one child frame does not change the size or position of any of its sibling child frames. By design, operations to make or modify child frames are implemented with the help of frame parameters (see [Frame Parameters](frame-parameters)) without any specialized functions or customizable variables. Note that child frames are meaningful on graphical terminals only. To create a new child frame or to convert a normal frame into a child frame, set that frame’s `parent-frame` parameter (see [Frame Interaction Parameters](frame-interaction-parameters)) to that of an already existing frame. The frame specified by that parameter will then be the frame’s parent frame as long as the parameter is not changed or reset. Technically, this makes the child frame’s window-system window a child window of the parent frame’s window-system window. The `parent-frame` parameter can be changed at any time. Setting it to another frame *reparents* the child frame. Setting it to another child frame makes the frame a *nested* child frame. Setting it to `nil` restores the frame’s status as a top-level frame—a frame whose window-system window is a child of its display’s root window. Since child frames can be arbitrarily nested, a frame can be both a child and a parent frame. Also, the relative roles of child and parent frame may be reversed at any time (though it’s usually a good idea to keep the size of a child frame sufficiently smaller than that of its parent). An error will be signaled for the attempt to make a frame an ancestor of itself. Most window-systems clip a child frame at the native edges (see [Frame Geometry](frame-geometry)) of its parent frame—everything outside these edges is usually invisible. A child frame’s `left` and `top` parameters specify a position relative to the top-left corner of its parent’s native frame. When the parent frame is resized, this position remains conceptually unaltered. NS builds do not clip child frames at the parent frame’s edges, allowing them to be positioned so they do not obscure the parent frame while still being visible themselves. Usually, moving a parent frame moves along all its child frames and their descendants as well, keeping their relative positions unaltered. Note that the hook `move-frame-functions` (see [Frame Position](frame-position)) is run for a child frame only when the position of the child frame relative to its parent frame changes. When a parent frame is resized, its child frames conceptually retain their previous sizes and their positions relative to the left upper corner of the parent. This means that a child frame may become (partially) invisible when its parent frame shrinks. The parameter `keep-ratio` (see [Frame Interaction Parameters](frame-interaction-parameters)) can be used to resize and reposition a child frame proportionally whenever its parent frame is resized. This may avoid obscuring parts of a frame when its parent frame is shrunk. A visible child frame always appears on top of its parent frame thus obscuring parts of it, except on NS builds where it may be positioned beneath the parent. This is comparable to the window-system window of a top-level frame which also always appears on top of its parent window—the desktop’s root window. When a parent frame is iconified or made invisible (see [Visibility of Frames](visibility-of-frames)), its child frames are made invisible. When a parent frame is deiconified or made visible, its child frames are made visible. When a parent frame is about to be deleted (see [Deleting Frames](deleting-frames)), its child frames are recursively deleted before it. There is one exception to this rule: When the child frame serves as a surrogate minibuffer frame (see [Minibuffers and Frames](minibuffers-and-frames)) for another frame, it is retained until the parent frame has been deleted. If, at this time, no remaining frame uses the child frame as its minibuffer frame, Emacs will try to delete the child frame too. If that deletion fails for whatever reason, the child frame is made a top-level frame. Whether a child frame can have a menu or tool bar is window-system or window manager dependent. Most window-systems explicitly disallow menu bars for child frames. It seems advisable to disable both, menu and tool bars, via the frame’s initial parameters settings. Usually, child frames do not exhibit window manager decorations like a title bar or external borders (see [Frame Geometry](frame-geometry)). When the child frame does not show a menu or tool bar, any other of the frame’s borders (see [Layout Parameters](layout-parameters)) can be used instead of the external borders. In particular, under X (but not when building with GTK+), the frame’s outer border can be used. On MS-Windows, specifying a non-zero outer border width will show a one-pixel wide external border. Under all window-systems, the internal border can be used. In either case, it’s advisable to disable a child frame’s window manager decorations with the `undecorated` frame parameter (see [Management Parameters](management-parameters)). To resize or move an undecorated child frame with the mouse, special frame parameters (see [Mouse Dragging Parameters](mouse-dragging-parameters)) have to be used. The internal border of a child frame, if present, can be used to resize the frame with the mouse, provided that frame has a non-`nil` `drag-internal-border` parameter. If set, the `snap-width` parameter indicates the number of pixels where the frame *snaps* at the respective edge or corner of its parent frame. There are two ways to drag an entire child frame with the mouse: The `drag-with-mode-line` parameter, if non-`nil`, allows to drag a frame without minibuffer window (see [Minibuffer Windows](minibuffer-windows)) via the mode line area of its bottommost window. The `drag-with-header-line` parameter, if non-`nil`, allows to drag the frame via the header line area of its topmost window. In order to give a child frame a draggable header or mode line, the window parameters `mode-line-format` and `header-line-format` are handy (see [Window Parameters](window-parameters)). These allow to remove an unwanted mode line (when `drag-with-header-line` is chosen) and to remove mouse-sensitive areas which might interfere with frame dragging. When the user drags a frame with a mouse and overshoots, it’s easy to drag a frame out of the screen area of its parent. Retrieving such a frame can be hairy once the mouse button has been released. To prevent such a situation, it is advisable to set the frame’s `top-visible` or `bottom-visible` parameter (see [Mouse Dragging Parameters](mouse-dragging-parameters)). Set the `top-visible` parameter of a child frame to a number when you intend to allow the user dragging that frame by its header line. Setting `top-visible` to a number inhibits dragging the top edge of the child frame above the top edge of its parent. Set the `bottom-visible` parameter to a number when you intend to drag that frame via its mode line; this inhibits dragging the bottom edge of the child frame beneath the bottom edge of its parent. In either case, that number also specifies width and height (in pixels) of the area of the child frame that remains visible during dragging. When a child frame is used for displaying a buffer via `display-buffer-in-child-frame` (see [Buffer Display Action Functions](buffer-display-action-functions)), the frame’s `auto-hide-function` parameter (see [Frame Interaction Parameters](frame-interaction-parameters)) can be set to a function, in order to appropriately deal with the frame when the window displaying the buffer shall be quit. When a child frame is used during minibuffer interaction, for example, to display completions in a separate window, the `minibuffer-exit` parameter (see [Frame Interaction Parameters](frame-interaction-parameters)) is useful in order to deal with the frame when the minibuffer is exited. The behavior of child frames deviates from that of top-level frames in a number of other ways as well. Here we sketch a few of them: * The semantics of maximizing and iconifying child frames is highly window-system dependent. As a rule, applications should never invoke these operations on child frames. By default, invoking `iconify-frame` on a child frame will try to iconify the top-level frame corresponding to that child frame instead. To obtain a different behavior, users may customize the option `iconify-child-frame` described below. * Raising, lowering and restacking child frames (see [Raising and Lowering](raising-and-lowering)) or changing the `z-group` (see [Position Parameters](position-parameters)) of a child frame changes only the stacking order of child frames with the same parent. * Many window-systems are not able to change the opacity (see [Font and Color Parameters](font-and-color-parameters)) of child frames. * Transferring focus from a child frame to an ancestor that is not its parent by clicking with the mouse in a visible part of that ancestor’s window may fail with some window-systems. You may have to click into the direct parent’s window-system window first. * Window managers might not bother to extend their focus follows mouse policy to child frames. Customizing `mouse-autoselect-window` can help in this regard (see [Mouse Window Auto-selection](mouse-window-auto_002dselection)). * Dropping (see [Drag and Drop](drag-and-drop)) on child frames is not guaranteed to work on all window-systems. Some will drop the object on the parent frame or on some ancestor instead. The following two functions can be useful when working with child and parent frames: Function: **frame-parent** *&optional frame* This function returns the parent frame of frame. The parent frame of frame is the Emacs frame whose window-system window is the parent window of frame’s window-system window. If such a frame exists, frame is considered a child frame of that frame. This function returns `nil` if frame has no parent frame. Function: **frame-ancestor-p** *ancestor descendant* This functions returns non-`nil` if ancestor is an ancestor of descendant. ancestor is an ancestor of descendant when it is either descendant’s parent frame or it is an ancestor of descendant’s parent frame. Both, ancestor and descendant must specify live frames. Note also the function `window-largest-empty-rectangle` (see [Coordinates and Windows](coordinates-and-windows)) which can be used to inscribe a child frame in the largest empty area of an existing window. This can be useful to avoid that a child frame obscures any text shown in that window. Customizing the following option can be useful to tweak the behavior of `iconify-frame` for child frames. User Option: **iconify-child-frame** This option tells Emacs how to proceed when it is asked to iconify a child frame. If it is `nil`, `iconify-frame` will do nothing when invoked on a child frame. If it is `iconify-top-level`, Emacs will try to iconify the top-level frame that is the ancestor of this child frame instead. If it is `make-invisible`, Emacs will try to make this child frame invisible instead of iconifying it. Any other value means to try iconifying the child frame. Since such an attempt may not be honored by all window managers and can even lead to making the child frame unresponsive to user actions, the default is to iconify the top level frame instead. elisp None #### Macro Type A *Lisp macro* is a user-defined construct that extends the Lisp language. It is represented as an object much like a function, but with different argument-passing semantics. A Lisp macro has the form of a list whose first element is the symbol `macro` and whose CDR is a Lisp function object, including the `lambda` symbol. Lisp macro objects are usually defined with the built-in `defmacro` macro, but any list that begins with `macro` is a macro as far as Emacs is concerned. See [Macros](macros), for an explanation of how to write a macro. **Warning**: Lisp macros and keyboard macros (see [Keyboard Macros](keyboard-macros)) are entirely different things. When we use the word “macro” without qualification, we mean a Lisp macro, not a keyboard macro. elisp None #### Internals of the Debugger This section describes functions and variables used internally by the debugger. Variable: **debugger** The value of this variable is the function to call to invoke the debugger. Its value must be a function of any number of arguments, or, more typically, the name of a function. This function should invoke some kind of debugger. The default value of the variable is `debug`. The first argument that Lisp hands to the function indicates why it was called. The convention for arguments is detailed in the description of `debug` (see [Invoking the Debugger](invoking-the-debugger)). Function: **backtrace** This function prints a trace of Lisp function calls currently active. The trace is identical to the one that `debug` would show in the `\*Backtrace\*` buffer. The return value is always nil. In the following example, a Lisp expression calls `backtrace` explicitly. This prints the backtrace to the stream `standard-output`, which, in this case, is the buffer ‘`backtrace-output`’. Each line of the backtrace represents one function call. The line shows the function followed by a list of the values of the function’s arguments if they are all known; if they are still being computed, the line consists of a list containing the function and its unevaluated arguments. Long lists or deeply nested structures may be elided. ``` (with-output-to-temp-buffer "backtrace-output" (let ((var 1)) (save-excursion (setq var (eval '(progn (1+ var) (list 'testing (backtrace)))))))) ⇒ (testing nil) ``` ``` ----------- Buffer: backtrace-output ------------ backtrace() (list 'testing (backtrace)) ``` ``` (progn ...) eval((progn (1+ var) (list 'testing (backtrace)))) (setq ...) (save-excursion ...) (let ...) (with-output-to-temp-buffer ...) eval((with-output-to-temp-buffer ...)) eval-last-sexp-1(nil) ``` ``` eval-last-sexp(nil) call-interactively(eval-last-sexp) ----------- Buffer: backtrace-output ------------ ``` User Option: **debugger-stack-frame-as-list** If this variable is non-`nil`, every stack frame of the backtrace is displayed as a list. This aims at improving the backtrace readability at the cost of special forms no longer being visually different from regular function calls. With `debugger-stack-frame-as-list` non-`nil`, the above example would look as follows: ``` ----------- Buffer: backtrace-output ------------ (backtrace) (list 'testing (backtrace)) ``` ``` (progn ...) (eval (progn (1+ var) (list 'testing (backtrace)))) (setq ...) (save-excursion ...) (let ...) (with-output-to-temp-buffer ...) (eval (with-output-to-temp-buffer ...)) (eval-last-sexp-1 nil) ``` ``` (eval-last-sexp nil) (call-interactively eval-last-sexp) ----------- Buffer: backtrace-output ------------ ``` Variable: **debug-on-next-call** If this variable is non-`nil`, it says to call the debugger before the next `eval`, `apply` or `funcall`. Entering the debugger sets `debug-on-next-call` to `nil`. The `d` command in the debugger works by setting this variable. Function: **backtrace-debug** *level flag* This function sets the debug-on-exit flag of the stack frame level levels down the stack, giving it the value flag. If flag is non-`nil`, this will cause the debugger to be entered when that frame later exits. Even a nonlocal exit through that frame will enter the debugger. This function is used only by the debugger. Variable: **command-debug-status** This variable records the debugging status of the current interactive command. Each time a command is called interactively, this variable is bound to `nil`. The debugger can set this variable to leave information for future debugger invocations during the same command invocation. The advantage of using this variable rather than an ordinary global variable is that the data will never carry over to a subsequent command invocation. This variable is obsolete and will be removed in future versions. Function: **backtrace-frame** *frame-number &optional base* The function `backtrace-frame` is intended for use in Lisp debuggers. It returns information about what computation is happening in the stack frame frame-number levels down. If that frame has not evaluated the arguments yet, or is a special form, the value is `(nil function arg-forms…)`. If that frame has evaluated its arguments and called its function already, the return value is `(t function arg-values…)`. In the return value, function is whatever was supplied as the CAR of the evaluated list, or a `lambda` expression in the case of a macro call. If the function has a `&rest` argument, that is represented as the tail of the list arg-values. If base is specified, frame-number counts relative to the topmost frame whose function is base. If frame-number is out of range, `backtrace-frame` returns `nil`. Function: **mapbacktrace** *function &optional base* The function `mapbacktrace` calls function once for each frame in the backtrace, starting at the first frame whose function is base (or from the top if base is omitted or `nil`). function is called with four arguments: evald, func, args, and flags. If a frame has not evaluated its arguments yet or is a special form, evald is `nil` and args is a list of forms. If a frame has evaluated its arguments and called its function already, evald is `t` and args is a list of values. flags is a plist of properties of the current frame: currently, the only supported property is `:debug-on-exit`, which is `t` if the stack frame’s `debug-on-exit` flag is set.
programming_docs
elisp None ### Deleting Windows *Deleting* a window removes it from the frame’s window tree. If the window is a live window, it disappears from the screen. If the window is an internal window, its child windows are deleted too. Even after a window is deleted, it continues to exist as a Lisp object, until there are no more references to it. Window deletion can be reversed, by restoring a saved window configuration (see [Window Configurations](window-configurations)). Command: **delete-window** *&optional window* This function removes window from display and returns `nil`. If window is omitted or `nil`, it defaults to the selected window. If deleting the window would leave no more windows in the window tree (e.g., if it is the only live window in the frame) or all remaining windows on window’s frame are side windows (see [Side Windows](side-windows)), an error is signaled. If window is part of an atomic window (see [Atomic Windows](atomic-windows)), this function tries to delete the root of that atomic window instead. By default, the space taken up by window is given to one of its adjacent sibling windows, if any. However, if the variable `window-combination-resize` is non-`nil`, the space is proportionally distributed among any remaining windows in the same window combination. See [Recombining Windows](recombining-windows). The behavior of this function may be altered by the window parameters of window, so long as the variable `ignore-window-parameters` is `nil`. If the value of the `delete-window` window parameter is `t`, this function ignores all other window parameters. Otherwise, if the value of the `delete-window` window parameter is a function, that function is called with the argument window, in lieu of the usual action of `delete-window`. See [Window Parameters](window-parameters). When `delete-window` deletes the selected window of its frame, it has to make another window the new selected window of that frame. The following option allows configuring which window is chosen. User Option: **delete-window-choose-selected** This option allows specifying which window should become a frame’s selected window after `delete-window` has deleted the previously selected one. Possible choices are * `mru` (the default) choose the most recently used window on that frame. * `pos` choose the window comprising the frame coordinates of point of the previously selected window on that frame. * `nil` choose the first window (the window returned by `frame-first-window`) on that frame. A window with a non-`nil` `no-other-window` parameter is chosen only if all other windows on that frame have that parameter set to a non-`nil` value too. Command: **delete-other-windows** *&optional window* This function makes window fill its frame, deleting other windows as necessary. If window is omitted or `nil`, it defaults to the selected window. An error is signaled if window is a side window (see [Side Windows](side-windows)). If window is part of an atomic window (see [Atomic Windows](atomic-windows)), this function tries to make the root of that atomic window fill its frame. The return value is `nil`. The behavior of this function may be altered by the window parameters of window, so long as the variable `ignore-window-parameters` is `nil`. If the value of the `delete-other-windows` window parameter is `t`, this function ignores all other window parameters. Otherwise, if the value of the `delete-other-windows` window parameter is a function, that function is called with the argument window, in lieu of the usual action of `delete-other-windows`. See [Window Parameters](window-parameters). Also, if `ignore-window-parameters` is `nil`, this function does not delete any window whose `no-delete-other-windows` parameter is non-`nil`. Command: **delete-windows-on** *&optional buffer-or-name frame* This function deletes all windows showing buffer-or-name, by calling `delete-window` on those windows. buffer-or-name should be a buffer, or the name of a buffer; if omitted or `nil`, it defaults to the current buffer. If there are no windows showing the specified buffer, this function does nothing. If the specified buffer is a minibuffer, an error is signaled. If there is a dedicated window showing the buffer, and that window is the only one on its frame, this function also deletes that frame if it is not the only frame on the terminal. The optional argument frame specifies which frames to operate on: * `nil` means operate on all frames. * `t` means operate on the selected frame. * `visible` means operate on all visible frames. * `0` means operate on all visible or iconified frames. * A frame means operate on that frame. Note that this argument does not have the same meaning as in other functions which scan all live windows (see [Cyclic Window Ordering](cyclic-window-ordering)). Specifically, the meanings of `t` and `nil` here are the opposite of what they are in those other functions. elisp None ### Controlling the Active Keymaps Variable: **global-map** This variable contains the default global keymap that maps Emacs keyboard input to commands. The global keymap is normally this keymap. The default global keymap is a full keymap that binds `self-insert-command` to all of the printing characters. It is normal practice to change the bindings in the global keymap, but you should not assign this variable any value other than the keymap it starts out with. Function: **current-global-map** This function returns the current global keymap. This is the same as the value of `global-map` unless you change one or the other. The return value is a reference, not a copy; if you use `define-key` or other functions on it you will alter global bindings. ``` (current-global-map) ⇒ (keymap [set-mark-command beginning-of-line … delete-backward-char]) ``` Function: **current-local-map** This function returns the current buffer’s local keymap, or `nil` if it has none. In the following example, the keymap for the `\*scratch\*` buffer (using Lisp Interaction mode) is a sparse keymap in which the entry for ESC, ASCII code 27, is another sparse keymap. ``` (current-local-map) ⇒ (keymap (10 . eval-print-last-sexp) (9 . lisp-indent-line) (127 . backward-delete-char-untabify) ``` ``` (27 keymap (24 . eval-defun) (17 . indent-sexp))) ``` `current-local-map` returns a reference to the local keymap, not a copy of it; if you use `define-key` or other functions on it you will alter local bindings. Function: **current-minor-mode-maps** This function returns a list of the keymaps of currently enabled minor modes. Function: **use-global-map** *keymap* This function makes keymap the new current global keymap. It returns `nil`. It is very unusual to change the global keymap. Function: **use-local-map** *keymap* This function makes keymap the new local keymap of the current buffer. If keymap is `nil`, then the buffer has no local keymap. `use-local-map` returns `nil`. Most major mode commands use this function. Variable: **minor-mode-map-alist** This variable is an alist describing keymaps that may or may not be active according to the values of certain variables. Its elements look like this: ``` (variable . keymap) ``` The keymap keymap is active whenever variable has a non-`nil` value. Typically variable is the variable that enables or disables a minor mode. See [Keymaps and Minor Modes](keymaps-and-minor-modes). Note that elements of `minor-mode-map-alist` do not have the same structure as elements of `minor-mode-alist`. The map must be the CDR of the element; a list with the map as the second element will not do. The CDR can be either a keymap (a list) or a symbol whose function definition is a keymap. When more than one minor mode keymap is active, the earlier one in `minor-mode-map-alist` takes priority. But you should design minor modes so that they don’t interfere with each other. If you do this properly, the order will not matter. See [Keymaps and Minor Modes](keymaps-and-minor-modes), for more information about minor modes. See also `minor-mode-key-binding` (see [Functions for Key Lookup](functions-for-key-lookup)). Variable: **minor-mode-overriding-map-alist** This variable allows major modes to override the key bindings for particular minor modes. The elements of this alist look like the elements of `minor-mode-map-alist`: `(variable . keymap)`. If a variable appears as an element of `minor-mode-overriding-map-alist`, the map specified by that element totally replaces any map specified for the same variable in `minor-mode-map-alist`. `minor-mode-overriding-map-alist` is automatically buffer-local in all buffers. Variable: **overriding-local-map** If non-`nil`, this variable holds a keymap to use instead of the buffer’s local keymap, any text property or overlay keymaps, and any minor mode keymaps. This keymap, if specified, overrides all other maps that would have been active, except for the current global map. Variable: **overriding-terminal-local-map** If non-`nil`, this variable holds a keymap to use instead of `overriding-local-map`, the buffer’s local keymap, text property or overlay keymaps, and all the minor mode keymaps. This variable is always local to the current terminal and cannot be buffer-local. See [Multiple Terminals](multiple-terminals). It is used to implement incremental search mode. Variable: **overriding-local-map-menu-flag** If this variable is non-`nil`, the value of `overriding-local-map` or `overriding-terminal-local-map` can affect the display of the menu bar. The default value is `nil`, so those map variables have no effect on the menu bar. Note that these two map variables do affect the execution of key sequences entered using the menu bar, even if they do not affect the menu bar display. So if a menu bar key sequence comes in, you should clear the variables before looking up and executing that key sequence. Modes that use the variables would typically do this anyway; normally they respond to events that they do not handle by “unreading” them and exiting. Variable: **special-event-map** This variable holds a keymap for special events. If an event type has a binding in this keymap, then it is special, and the binding for the event is run directly by `read-event`. See [Special Events](special-events). Variable: **emulation-mode-map-alists** This variable holds a list of keymap alists to use for emulation modes. It is intended for modes or packages using multiple minor-mode keymaps. Each element is a keymap alist which has the same format and meaning as `minor-mode-map-alist`, or a symbol with a variable binding which is such an alist. The active keymaps in each alist are used before `minor-mode-map-alist` and `minor-mode-overriding-map-alist`. Function: **set-transient-map** *keymap &optional keep-pred on-exit* This function adds keymap as a *transient* keymap, which takes precedence over other keymaps for one (or more) subsequent keys. Normally, keymap is used just once, to look up the very next key. If the optional argument keep-pred is `t`, the map stays active as long as the user types keys defined in keymap; when the user types a key that is not in keymap, the transient keymap is deactivated and normal key lookup continues for that key. The keep-pred argument can also be a function. In that case, the function is called with no arguments, prior to running each command, while keymap is active; it should return non-`nil` if keymap should stay active. The optional argument on-exit, if non-`nil`, specifies a function that is called, with no arguments, after keymap is deactivated. This function works by adding and removing keymap from the variable `overriding-terminal-local-map`, which takes precedence over all other active keymaps (see [Searching Keymaps](searching-keymaps)). elisp None #### Adjustable Tab Stops This section explains the mechanism for user-specified tab stops and the mechanisms that use and set them. The name “tab stops” is used because the feature is similar to that of the tab stops on a typewriter. The feature works by inserting an appropriate number of spaces and tab characters to reach the next tab stop column; it does not affect the display of tab characters in the buffer (see [Usual Display](usual-display)). Note that the TAB character as input uses this tab stop feature only in a few major modes, such as Text mode. See [Tab Stops](https://www.gnu.org/software/emacs/manual/html_node/emacs/Tab-Stops.html#Tab-Stops) in The GNU Emacs Manual. Command: **tab-to-tab-stop** This command inserts spaces or tabs before point, up to the next tab stop column defined by `tab-stop-list`. User Option: **tab-stop-list** This variable defines the tab stop columns used by `tab-to-tab-stop`. It should be either `nil`, or a list of increasing integers, which need not be evenly spaced. The list is implicitly extended to infinity through repetition of the interval between the last and penultimate elements (or `tab-width` if the list has fewer than two elements). A value of `nil` means a tab stop every `tab-width` columns. Use `M-x edit-tab-stops` to edit the location of tab stops interactively. elisp None ### Mouse Tracking Sometimes it is useful to *track* the mouse, which means to display something to indicate where the mouse is and move the indicator as the mouse moves. For efficient mouse tracking, you need a way to wait until the mouse actually moves. The convenient way to track the mouse is to ask for events to represent mouse motion. Then you can wait for motion by waiting for an event. In addition, you can easily handle any other sorts of events that may occur. That is useful, because normally you don’t want to track the mouse forever—only until some other event, such as the release of a button. Macro: **track-mouse** *body…* This macro executes body, with generation of mouse motion events enabled. Typically, body would use `read-event` to read the motion events and modify the display accordingly. See [Motion Events](motion-events), for the format of mouse motion events. The value of `track-mouse` is that of the last form in body. You should design body to return when it sees the up-event that indicates the release of the button, or whatever kind of event means it is time to stop tracking. The `track-mouse` form causes Emacs to generate mouse motion events by binding the variable `track-mouse` to a non-`nil` value. If that variable has the special value `dragging`, it additionally instructs the display engine to refrain from changing the shape of the mouse pointer. This is desirable in Lisp programs that require mouse dragging across large portions of Emacs display, which might otherwise cause the mouse pointer to change its shape according to the display portion it hovers on (see [Pointer Shape](pointer-shape)). Therefore, Lisp programs that need the mouse pointer to retain its original shape during dragging should bind `track-mouse` to the value `dragging` at the beginning of their body. The usual purpose of tracking mouse motion is to indicate on the screen the consequences of pushing or releasing a button at the current position. In many cases, you can avoid the need to track the mouse by using the `mouse-face` text property (see [Special Properties](special-properties)). That works at a much lower level and runs more smoothly than Lisp-level mouse tracking. elisp None ### Syntax Properties When the syntax table is not flexible enough to specify the syntax of a language, you can override the syntax table for specific character occurrences in the buffer, by applying a `syntax-table` text property. See [Text Properties](text-properties), for how to apply text properties. The valid values of `syntax-table` text property are: syntax-table If the property value is a syntax table, that table is used instead of the current buffer’s syntax table to determine the syntax for the underlying text character. `(syntax-code . matching-char)` A cons cell of this format is a raw syntax descriptor (see [Syntax Table Internals](syntax-table-internals)), which directly specifies a syntax class for the underlying text character. `nil` If the property is `nil`, the character’s syntax is determined from the current syntax table in the usual way. Variable: **parse-sexp-lookup-properties** If this is non-`nil`, the syntax scanning functions, like `forward-sexp`, pay attention to `syntax-table` text properties. Otherwise they use only the current syntax table. Variable: **syntax-propertize-function** This variable, if non-`nil`, should store a function for applying `syntax-table` properties to a specified stretch of text. It is intended to be used by major modes to install a function which applies `syntax-table` properties in some mode-appropriate way. The function is called by `syntax-ppss` (see [Position Parse](position-parse)), and by Font Lock mode during syntactic fontification (see [Syntactic Font Lock](syntactic-font-lock)). It is called with two arguments, start and end, which are the starting and ending positions of the text on which it should act. It is allowed to arbitrarily move point within the region delimited by start and end; such motions don’t need to use `save-excursion` (see [Excursions](excursions)). It is also allowed to call `syntax-ppss` on any position before end, but if a Lisp program calls `syntax-ppss` on some position and later modifies the buffer at some earlier position, then it is that program’s responsibility to call `syntax-ppss-flush-cache` to flush the now obsolete info from the cache. **Caution:** When this variable is non-`nil`, Emacs removes `syntax-table` text properties arbitrarily and relies on `syntax-propertize-function` to reapply them. Thus if this facility is used at all, the function must apply **all** `syntax-table` text properties used by the major mode. In particular, Modes derived from a CC Mode mode must not use this variable, since CC Mode uses other means to apply and remove these text properties. Variable: **syntax-propertize-extend-region-functions** This abnormal hook is run by the syntax parsing code prior to calling `syntax-propertize-function`. Its role is to help locate safe starting and ending buffer positions for passing to `syntax-propertize-function`. For example, a major mode can add a function to this hook to identify multi-line syntactic constructs, and ensure that the boundaries do not fall in the middle of one. Each function in this hook should accept two arguments, start and end. It should return either a cons cell of two adjusted buffer positions, `(new-start . new-end)`, or `nil` if no adjustment is necessary. The hook functions are run in turn, repeatedly, until they all return `nil`. elisp None #### Action Alists for Buffer Display An *action alist* is an association list mapping predefined symbols recognized by action functions to values these functions are supposed to interpret accordingly. In each call, `display-buffer` constructs a new, possibly empty action alist and passes that entire list on to any action function it calls. By design, action functions are free in their interpretation of action alist entries. In fact, some entries like `allow-no-window` or `previous-window` have a meaning only for one or a few action functions, and are ignored by the rest. Other entries, like `inhibit-same-window` or `window-parameters`, are supposed to be respected by most action functions, including those provided by application programs and external packages. In the previous subsection we have described in detail how individual action functions interpret the action alist entries they care about. Here we give a reference list of all known action alist entries according to their symbols, together with their values and action functions (see [Buffer Display Action Functions](buffer-display-action-functions)) that recognize them. Throughout this list, the terms “buffer” will refer to the buffer `display-buffer` is supposed to display, and “value” refers to the entry’s value. `inhibit-same-window` If the value is non-`nil`, this signals that the selected window must not be used for displaying the buffer. All action functions that (re-)use an existing window should respect this entry. `previous-window` The value must specify a window that may have displayed the buffer previously. `display-buffer-in-previous-window` will give preference to such a window provided it is still live and not dedicated to another buffer. `mode` The value is either a major mode or a list of major modes. `display-buffer-reuse-mode-window` may reuse a window whenever the value specified by this entry matches the major mode of that window’s buffer. Other action functions ignore such entries. `frame-predicate` The value must be a function taking one argument (a frame), supposed to return non-`nil` if that frame is a candidate for displaying the buffer. This entry is used by `display-buffer-use-some-frame`. `reusable-frames` The value specifies the set of frames to search for a window that can be reused because it already displays the buffer. It can be set as follows: * `nil` means consider only windows on the selected frame. (Actually, the last frame used that is not a minibuffer-only frame.) * `t` means consider windows on all frames. * `visible` means consider windows on all visible frames. * 0 means consider windows on all visible or iconified frames. * A frame means consider windows on that frame only. Note that the meaning of `nil` differs slightly from that of the all-frames argument to `next-window` (see [Cyclic Window Ordering](cyclic-window-ordering)). A major client of this is `display-buffer-reuse-window`, but all other action functions that try to reuse a window are affected as well. `display-buffer-in-previous-window` consults it when searching for a window that previously displayed the buffer on another frame. `inhibit-switch-frame` A non-`nil` value prevents another frame from being raised or selected, if the window chosen by `display-buffer` is displayed there. Primarily affected by this are `display-buffer-use-some-frame` and `display-buffer-reuse-window`. Ideally, `display-buffer-pop-up-frame` should be affected as well, but there is no guarantee that the window manager will comply. `window-parameters` The value specifies an alist of window parameters to give the chosen window. All action functions that choose a window should process this entry. `window-min-height` The value specifies a minimum height of the window used, in lines. If a window is not or cannot be made as high as specified by this entry, the window is not considered for use. The only client of this entry is presently `display-buffer-below-selected`. Note that providing such an entry alone does not necessarily make the window as tall as specified by its value. To actually resize an existing window or make a new window as tall as specified by that value, a `window-height` entry specifying that value should be provided as well. Such a `window-height` entry can, however, specify a completely different value or ask the window height to be fit to that of its buffer in which case the `window-min-height` entry provides the guaranteed minimum height of the window used. `window-height` The value specifies whether and how to adjust the height of the chosen window and can be one of the following: * `nil` means to leave the height of the chosen window alone. * An integer number specifies the desired total height of the chosen window in lines. * A floating-point number specifies the fraction of the chosen window’s desired total height with respect to the total height of its frame’s root window. * If the value specifies a function, that function is called with one argument—the chosen window. The function is supposed to adjust the height of the window; its return value is ignored. Suitable functions are `fit-window-to-buffer` and `shrink-window-if-larger-than-buffer`, see [Resizing Windows](resizing-windows). By convention, the height of the chosen window is adjusted only if the window is part of a vertical combination (see [Windows and Frames](windows-and-frames)) to avoid changing the height of other, unrelated windows. Also, this entry should be processed only under certain conditions which are specified right below this list. `window-width` This entry is similar to the `window-height` entry described before, but used to adjust the chosen window’s width instead. The value can be one of the following: * `nil` means to leave the width of the chosen window alone. * An integer specifies the desired total width of the chosen window in columns. * A floating-point number specifies the fraction of the chosen window’s desired total width with respect to the total width of the frame’s root window. * If the value specifies a function, that function is called with one argument—the chosen window. The function is supposed to adjust the width of the window; its return value is ignored. By convention, the width of the chosen window is adjusted only if the window is part of a horizontal combination (see [Windows and Frames](windows-and-frames)) to avoid changing the width of other, unrelated windows. Also, this entry should be processed under only certain conditions which are specified right below this list. `dedicated` If non-`nil`, such an entry tells `display-buffer` to mark any window it creates as dedicated to its buffer (see [Dedicated Windows](dedicated-windows)). It does that by calling `set-window-dedicated-p` with the chosen window as first argument and the entry’s value as second. Side windows are by default dedicated with the value `side` ((see [Side Window Options and Functions](side-window-options-and-functions)). `preserve-size` If non-`nil` such an entry tells Emacs to preserve the size of the window chosen (see [Preserving Window Sizes](preserving-window-sizes)). The value should be either `(t . nil)` to preserve the width of the window, `(nil . t)` to preserve its height or `(t . t)` to preserve both, its width and its height. This entry should be processed only under certain conditions which are specified right after this list. `pop-up-frame-parameters` The value specifies an alist of frame parameters to give a new frame, if one is created. `display-buffer-pop-up-frame` is its one and only addressee. `parent-frame` The value specifies the parent frame to be used when the buffer is displayed on a child frame. This entry is used only by `display-buffer-in-child-frame`. `child-frame-parameters` The value specifies an alist of frame parameters to use when the buffer is displayed on a child frame. This entry is used only by `display-buffer-in-child-frame`. `side` The value denotes the side of the frame or window where a new window displaying the buffer shall be created. This entry is used by `display-buffer-in-side-window` to indicate the side of the frame where a new side window shall be placed (see [Displaying Buffers in Side Windows](displaying-buffers-in-side-windows)). It is also used by `display-buffer-in-atom-window` to indicate the side of an existing window where the new window shall be located (see [Atomic Windows](atomic-windows)). `slot` If non-`nil`, the value specifies the slot of the side window supposed to display the buffer. This entry is used only by `display-buffer-in-side-window`. `direction` The value specifies a direction which, together with a `window` entry, allows `display-buffer-in-direction` to determine the location of the window to display the buffer. `window` The value specifies a window that is in some way related to the window chosen by `display-buffer`. This entry is currently used by `display-buffer-in-atom-window` to indicate the window on whose side the new window shall be created. It is also used by `display-buffer-in-direction` to specify the reference window on whose side the resulting window shall appear. `allow-no-window` If the value is non-`nil`, `display-buffer` does not necessarily have to display the buffer and the caller is prepared to accept that. This entry is not intended for user customizations, since there is no guarantee that an arbitrary caller of `display-buffer` will be able to handle the case that no window will display the buffer. `display-buffer-no-window` is the only action function that cares about this entry. `body-function` The value must be a function taking one argument (a displayed window). This function can be used to fill the displayed window’s body with some contents that might depend on dimensions of the displayed window. It is called *after* the buffer is displayed, and *before* the entries `window-height`, `window-width` and `preserve-size` are applied that could resize the window to fit it to the inserted contents. By convention, the entries `window-height`, `window-width` and `preserve-size` are applied after the chosen window’s buffer has been set up and if and only if that window never showed another buffer before. More precisely, the latter means that the window must have been either created by the current `display-buffer` call or the window was created earlier by `display-buffer` to show the buffer and never was used to show another buffer until it was reused by the current invocation of `display-buffer`.
programming_docs
elisp None #### Network Options The following network options can be specified when you create a network process. Except for `:reuseaddr`, you can also set or modify these options later, using `set-network-process-option`. For a server process, the options specified with `make-network-process` are not inherited by the client connections, so you will need to set the necessary options for each child connection as it is created. :bindtodevice device-name If device-name is a non-empty string identifying a network interface name (see `network-interface-list`), only handle packets received on that interface. If device-name is `nil` (the default), handle packets received on any interface. Using this option may require special privileges on some systems. :broadcast broadcast-flag If broadcast-flag is non-`nil` for a datagram process, the process will receive datagram packet sent to a broadcast address, and be able to send packets to a broadcast address. This is ignored for a stream connection. :dontroute dontroute-flag If dontroute-flag is non-`nil`, the process can only send to hosts on the same network as the local host. :keepalive keepalive-flag If keepalive-flag is non-`nil` for a stream connection, enable exchange of low-level keep-alive messages. :linger linger-arg If linger-arg is non-`nil`, wait for successful transmission of all queued packets on the connection before it is deleted (see `delete-process`). If linger-arg is an integer, it specifies the maximum time in seconds to wait for queued packets to be sent before closing the connection. The default is `nil`, which means to discard unsent queued packets when the process is deleted. :oobinline oobinline-flag If oobinline-flag is non-`nil` for a stream connection, receive out-of-band data in the normal data stream. Otherwise, ignore out-of-band data. :priority priority Set the priority for packets sent on this connection to the integer priority. The interpretation of this number is protocol specific; such as setting the TOS (type of service) field on IP packets sent on this connection. It may also have system dependent effects, such as selecting a specific output queue on the network interface. :reuseaddr reuseaddr-flag If reuseaddr-flag is non-`nil` (the default) for a stream server process, allow this server to reuse a specific port number (see `:service`), unless another process on this host is already listening on that port. If reuseaddr-flag is `nil`, there may be a period of time after the last use of that port (by any process on the host) where it is not possible to make a new server on that port. Function: **set-network-process-option** *process option value &optional no-error* This function sets or modifies a network option for network process process. The accepted options and values are as for `make-network-process`. If no-error is non-`nil`, this function returns `nil` instead of signaling an error if option is not a supported option. If the function successfully completes, it returns `t`. The current setting of an option is available via the `process-contact` function. elisp None ### Conventions This section explains the notational conventions that are used in this manual. You may want to skip this section and refer back to it later. | | | | | --- | --- | --- | | • [Some Terms](some-terms) | | Explanation of terms we use in this manual. | | • [nil and t](nil-and-t) | | How the symbols `nil` and `t` are used. | | • [Evaluation Notation](evaluation-notation) | | The format we use for examples of evaluation. | | • [Printing Notation](printing-notation) | | The format we use when examples print text. | | • [Error Messages](error-messages) | | The format we use for examples of errors. | | • [Buffer Text Notation](buffer-text-notation) | | The format we use for buffer contents in examples. | | • [Format of Descriptions](format-of-descriptions) | | Notation for describing functions, variables, etc. | elisp None Text ---- This chapter describes the functions that deal with the text in a buffer. Most examine, insert, or delete text in the current buffer, often operating at point or on text adjacent to point. Many are interactive. All the functions that change the text provide for undoing the changes (see [Undo](undo)). Many text-related functions operate on a region of text defined by two buffer positions passed in arguments named start and end. These arguments should be either markers (see [Markers](markers)) or numeric character positions (see [Positions](positions)). The order of these arguments does not matter; it is all right for start to be the end of the region and end the beginning. For example, `(delete-region 1 10)` and `(delete-region 10 1)` are equivalent. An `args-out-of-range` error is signaled if either start or end is outside the accessible portion of the buffer. In an interactive call, point and the mark are used for these arguments. Throughout this chapter, “text” refers to the characters in the buffer, together with their properties (when relevant). Keep in mind that point is always between two characters, and the cursor appears on the character after point. | | | | | --- | --- | --- | | • [Near Point](near-point) | | Examining text in the vicinity of point. | | • [Buffer Contents](buffer-contents) | | Examining text in a general fashion. | | • [Comparing Text](comparing-text) | | Comparing substrings of buffers. | | • [Insertion](insertion) | | Adding new text to a buffer. | | • [Commands for Insertion](commands-for-insertion) | | User-level commands to insert text. | | • [Deletion](deletion) | | Removing text from a buffer. | | • [User-Level Deletion](user_002dlevel-deletion) | | User-level commands to delete text. | | • [The Kill Ring](the-kill-ring) | | Where removed text sometimes is saved for later use. | | • [Undo](undo) | | Undoing changes to the text of a buffer. | | • [Maintaining Undo](maintaining-undo) | | How to enable and disable undo information. How to control how much information is kept. | | • [Filling](filling) | | Functions for explicit filling. | | • [Margins](margins) | | How to specify margins for filling commands. | | • [Adaptive Fill](adaptive-fill) | | Adaptive Fill mode chooses a fill prefix from context. | | • [Auto Filling](auto-filling) | | How auto-fill mode is implemented to break lines. | | • [Sorting](sorting) | | Functions for sorting parts of the buffer. | | • [Columns](columns) | | Computing horizontal positions, and using them. | | • [Indentation](indentation) | | Functions to insert or adjust indentation. | | • [Case Changes](case-changes) | | Case conversion of parts of the buffer. | | • [Text Properties](text-properties) | | Assigning Lisp property lists to text characters. | | • [Substitution](substitution) | | Replacing a given character wherever it appears. | | • [Registers](registers) | | How registers are implemented. Accessing the text or position stored in a register. | | • [Transposition](transposition) | | Swapping two portions of a buffer. | | • [Replacing](replacing) | | Replacing the text of one buffer with the text of another buffer. | | • [Decompression](decompression) | | Dealing with compressed data. | | • [Base 64](base-64) | | Conversion to or from base 64 encoding. | | • [Checksum/Hash](checksum_002fhash) | | Computing cryptographic hashes. | | • [GnuTLS Cryptography](gnutls-cryptography) | | Cryptographic algorithms imported from GnuTLS. | | • [Parsing HTML/XML](parsing-html_002fxml) | | Parsing HTML and XML. | | • [Parsing JSON](parsing-json) | | Parsing and generating JSON values. | | • [JSONRPC](jsonrpc) | | JSON Remote Procedure Call protocol | | • [Atomic Changes](atomic-changes) | | Installing several buffer changes atomically. | | • [Change Hooks](change-hooks) | | Supplying functions to be run when text is changed. | elisp None #### Defining New Types In the previous sections we have described how to construct elaborate type specifications for `defcustom`. In some cases you may want to give such a type specification a name. The obvious case is when you are using the same type for many user options: rather than repeat the specification for each option, you can give the type specification a name, and use that name each `defcustom`. The other case is when a user option’s value is a recursive data structure. To make it possible for a datatype to refer to itself, it needs to have a name. Since custom types are implemented as widgets, the way to define a new customize type is to define a new widget. We are not going to describe the widget interface here in details, see [Introduction](https://www.gnu.org/software/emacs/manual/html_node/widget/index.html#Top) in The Emacs Widget Library, for that. Instead we are going to demonstrate the minimal functionality needed for defining new customize types by a simple example. ``` (define-widget 'binary-tree-of-string 'lazy "A binary tree made of cons-cells and strings." :offset 4 :tag "Node" :type '(choice (string :tag "Leaf" :value "") (cons :tag "Interior" :value ("" . "") binary-tree-of-string binary-tree-of-string))) (defcustom foo-bar "" "Sample variable holding a binary tree of strings." :type 'binary-tree-of-string) ``` The function to define a new widget is called `define-widget`. The first argument is the symbol we want to make a new widget type. The second argument is a symbol representing an existing widget, the new widget is going to be defined in terms of difference from the existing widget. For the purpose of defining new customization types, the `lazy` widget is perfect, because it accepts a `:type` keyword argument with the same syntax as the keyword argument to `defcustom` with the same name. The third argument is a documentation string for the new widget. You will be able to see that string with the `M-x widget-browse RET binary-tree-of-string RET` command. After these mandatory arguments follow the keyword arguments. The most important is `:type`, which describes the data type we want to match with this widget. Here a `binary-tree-of-string` is described as being either a string, or a cons-cell whose car and cdr are themselves both `binary-tree-of-string`. Note the reference to the widget type we are currently in the process of defining. The `:tag` attribute is a string to name the widget in the user interface, and the `:offset` argument is there to ensure that child nodes are indented four spaces relative to the parent node, making the tree structure apparent in the customization buffer. The `defcustom` shows how the new widget can be used as an ordinary customization type. The reason for the name `lazy` is that the other composite widgets convert their inferior widgets to internal form when the widget is instantiated in a buffer. This conversion is recursive, so the inferior widgets will convert *their* inferior widgets. If the data structure is itself recursive, this conversion is an infinite recursion. The `lazy` widget prevents the recursion: it convert its `:type` argument only when needed. elisp None #### Features of Argument Lists Our simple sample function, `(lambda (a b c) (+ a b c))`, specifies three argument variables, so it must be called with three arguments: if you try to call it with only two arguments or four arguments, you get a `wrong-number-of-arguments` error (see [Errors](errors)). It is often convenient to write a function that allows certain arguments to be omitted. For example, the function `substring` accepts three arguments—a string, the start index and the end index—but the third argument defaults to the length of the string if you omit it. It is also convenient for certain functions to accept an indefinite number of arguments, as the functions `list` and `+` do. To specify optional arguments that may be omitted when a function is called, simply include the keyword `&optional` before the optional arguments. To specify a list of zero or more extra arguments, include the keyword `&rest` before one final argument. Thus, the complete syntax for an argument list is as follows: ``` (required-vars… [&optional [optional-vars…]] [&rest rest-var]) ``` The square brackets indicate that the `&optional` and `&rest` clauses, and the variables that follow them, are optional. A call to the function requires one actual argument for each of the required-vars. There may be actual arguments for zero or more of the optional-vars, and there cannot be any actual arguments beyond that unless the lambda list uses `&rest`. In that case, there may be any number of extra actual arguments. If actual arguments for the optional and rest variables are omitted, then they always default to `nil`. There is no way for the function to distinguish between an explicit argument of `nil` and an omitted argument. However, the body of the function is free to consider `nil` an abbreviation for some other meaningful value. This is what `substring` does; `nil` as the third argument to `substring` means to use the length of the string supplied. > **Common Lisp note:** Common Lisp allows the function to specify what default value to use when an optional argument is omitted; Emacs Lisp always uses `nil`. Emacs Lisp does not support `supplied-p` variables that tell you whether an argument was explicitly passed. > > > For example, an argument list that looks like this: ``` (a b &optional c d &rest e) ``` binds `a` and `b` to the first two actual arguments, which are required. If one or two more arguments are provided, `c` and `d` are bound to them respectively; any arguments after the first four are collected into a list and `e` is bound to that list. Thus, if there are only two arguments, `c`, `d` and `e` are `nil`; if two or three arguments, `d` and `e` are `nil`; if four arguments or fewer, `e` is `nil`. Note that exactly five arguments with an explicit `nil` argument provided for `e` will cause that `nil` argument to be passed as a list with one element, `(nil)`, as with any other single value for `e`. There is no way to have required arguments following optional ones—it would not make sense. To see why this must be so, suppose that `c` in the example were optional and `d` were required. Suppose three actual arguments are given; which variable would the third argument be for? Would it be used for the c, or for d? One can argue for both possibilities. Similarly, it makes no sense to have any more arguments (either required or optional) after a `&rest` argument. Here are some examples of argument lists and proper calls: ``` (funcall (lambda (n) (1+ n)) ; One required: 1) ; requires exactly one argument. ⇒ 2 (funcall (lambda (n &optional n1) ; One required and one optional: (if n1 (+ n n1) (1+ n))) ; 1 or 2 arguments. 1 2) ⇒ 3 (funcall (lambda (n &rest ns) ; One required and one rest: (+ n (apply '+ ns))) ; 1 or more arguments. 1 2 3 4 5) ⇒ 15 ``` elisp None ### Side Windows Side windows are special windows positioned at any of the four sides of a frame’s root window (see [Windows and Frames](windows-and-frames)). In practice, this means that the area of the frame’s root window is subdivided into a main window and a number of side windows surrounding that main window. The main window is either a “normal” live window or specifies the area containing all the normal windows. In their most simple form of use, side windows allow to display specific buffers always in the same area of a frame. Hence they can be regarded as a generalization of the concept provided by `display-buffer-at-bottom` (see [Buffer Display Action Functions](buffer-display-action-functions)) to the remaining sides of a frame. With suitable customizations, however, side windows can be also used to provide frame layouts similar to those found in so-called integrated development environments (IDEs). | | | | | --- | --- | --- | | • [Displaying Buffers in Side Windows](displaying-buffers-in-side-windows) | | An action function for displaying buffers in side windows. | | • [Side Window Options and Functions](side-window-options-and-functions) | | Further tuning of side windows. | | • [Frame Layouts with Side Windows](frame-layouts-with-side-windows) | | Setting up frame layouts with side windows. | elisp None ### Reading Lisp Objects with the Minibuffer This section describes functions for reading Lisp objects with the minibuffer. Function: **read-minibuffer** *prompt &optional initial* This function reads a Lisp object using the minibuffer, and returns it without evaluating it. The arguments prompt and initial are used as in `read-from-minibuffer`. This is a simplified interface to the `read-from-minibuffer` function: ``` (read-minibuffer prompt initial) ≡ (let (minibuffer-allow-text-properties) (read-from-minibuffer prompt initial nil t)) ``` Here is an example in which we supply the string `"(testing)"` as initial input: ``` (read-minibuffer "Enter an expression: " (format "%s" '(testing))) ;; Here is how the minibuffer is displayed: ``` ``` ---------- Buffer: Minibuffer ---------- Enter an expression: (testing)∗ ---------- Buffer: Minibuffer ---------- ``` The user can type RET immediately to use the initial input as a default, or can edit the input. Function: **eval-minibuffer** *prompt &optional initial* This function reads a Lisp expression using the minibuffer, evaluates it, then returns the result. The arguments prompt and initial are used as in `read-from-minibuffer`. This function simply evaluates the result of a call to `read-minibuffer`: ``` (eval-minibuffer prompt initial) ≡ (eval (read-minibuffer prompt initial)) ``` Function: **edit-and-eval-command** *prompt form* This function reads a Lisp expression in the minibuffer, evaluates it, then returns the result. The difference between this command and `eval-minibuffer` is that here the initial form is not optional and it is treated as a Lisp object to be converted to printed representation rather than as a string of text. It is printed with `prin1`, so if it is a string, double-quote characters (‘`"`’) appear in the initial text. See [Output Functions](output-functions). In the following example, we offer the user an expression with initial text that is already a valid form: ``` (edit-and-eval-command "Please edit: " '(forward-word 1)) ;; After evaluation of the preceding expression, ;; the following appears in the minibuffer: ``` ``` ---------- Buffer: Minibuffer ---------- Please edit: (forward-word 1)∗ ---------- Buffer: Minibuffer ---------- ``` Typing RET right away would exit the minibuffer and evaluate the expression, thus moving point forward one word. elisp None ### Functions for Vectors Here are some functions that relate to vectors: Function: **vectorp** *object* This function returns `t` if object is a vector. ``` (vectorp [a]) ⇒ t (vectorp "asdf") ⇒ nil ``` Function: **vector** *&rest objects* This function creates and returns a vector whose elements are the arguments, objects. ``` (vector 'foo 23 [bar baz] "rats") ⇒ [foo 23 [bar baz] "rats"] (vector) ⇒ [] ``` Function: **make-vector** *length object* This function returns a new vector consisting of length elements, each initialized to object. ``` (setq sleepy (make-vector 9 'Z)) ⇒ [Z Z Z Z Z Z Z Z Z] ``` Function: **vconcat** *&rest sequences* This function returns a new vector containing all the elements of sequences. The arguments sequences may be proper lists, vectors, strings or bool-vectors. If no sequences are given, the empty vector is returned. The value is either the empty vector, or is a newly constructed nonempty vector that is not `eq` to any existing vector. ``` (setq a (vconcat '(A B C) '(D E F))) ⇒ [A B C D E F] (eq a (vconcat a)) ⇒ nil ``` ``` (vconcat) ⇒ [] (vconcat [A B C] "aa" '(foo (6 7))) ⇒ [A B C 97 97 foo (6 7)] ``` The `vconcat` function also allows byte-code function objects as arguments. This is a special feature to make it easy to access the entire contents of a byte-code function object. See [Byte-Code Objects](byte_002dcode-objects). For other concatenation functions, see `mapconcat` in [Mapping Functions](mapping-functions), `concat` in [Creating Strings](creating-strings), and `append` in [Building Lists](building-lists). The `append` function also provides a way to convert a vector into a list with the same elements: ``` (setq avector [1 two (quote (three)) "four" [five]]) ⇒ [1 two '(three) "four" [five]] (append avector nil) ⇒ (1 two '(three) "four" [five]) ```
programming_docs
elisp None Sequences, Arrays, and Vectors ------------------------------ The *sequence* type is the union of two other Lisp types: lists and arrays. In other words, any list is a sequence, and any array is a sequence. The common property that all sequences have is that each is an ordered collection of elements. An *array* is a fixed-length object with a slot for each of its elements. All the elements are accessible in constant time. The four types of arrays are strings, vectors, char-tables and bool-vectors. A list is a sequence of elements, but it is not a single primitive object; it is made of cons cells, one cell per element. Finding the nth element requires looking through n cons cells, so elements farther from the beginning of the list take longer to access. But it is possible to add elements to the list, or remove elements. The following diagram shows the relationship between these types: ``` _____________________________________________ | | | Sequence | | ______ ________________________________ | | | | | | | | | List | | Array | | | | | | ________ ________ | | | |______| | | | | | | | | | | Vector | | String | | | | | |________| |________| | | | | ____________ _____________ | | | | | | | | | | | | | Char-table | | Bool-vector | | | | | |____________| |_____________| | | | |________________________________| | |_____________________________________________| ``` | | | | | --- | --- | --- | | • [Sequence Functions](sequence-functions) | | Functions that accept any kind of sequence. | | • [Arrays](arrays) | | Characteristics of arrays in Emacs Lisp. | | • [Array Functions](array-functions) | | Functions specifically for arrays. | | • [Vectors](vectors) | | Special characteristics of Emacs Lisp vectors. | | • [Vector Functions](vector-functions) | | Functions specifically for vectors. | | • [Char-Tables](char_002dtables) | | How to work with char-tables. | | • [Bool-Vectors](bool_002dvectors) | | How to work with bool-vectors. | | • [Rings](rings) | | Managing a fixed-size ring of objects. | elisp None ### Shell Arguments Lisp programs sometimes need to run a shell and give it a command that contains file names that were specified by the user. These programs ought to be able to support any valid file name. But the shell gives special treatment to certain characters, and if these characters occur in the file name, they will confuse the shell. To handle these characters, use the function `shell-quote-argument`: Function: **shell-quote-argument** *argument* This function returns a string that represents, in shell syntax, an argument whose actual contents are argument. It should work reliably to concatenate the return value into a shell command and then pass it to a shell for execution. Precisely what this function does depends on your operating system. The function is designed to work with the syntax of your system’s standard shell; if you use an unusual shell, you will need to redefine this function. See [Security Considerations](security-considerations). ``` ;; This example shows the behavior on GNU and Unix systems. (shell-quote-argument "foo > bar") ⇒ "foo\\ \\>\\ bar" ;; This example shows the behavior on MS-DOS and MS-Windows. (shell-quote-argument "foo > bar") ⇒ "\"foo > bar\"" ``` Here’s an example of using `shell-quote-argument` to construct a shell command: ``` (concat "diff -u " (shell-quote-argument oldfile) " " (shell-quote-argument newfile)) ``` The following two functions are useful for combining a list of individual command-line argument strings into a single string, and taking a string apart into a list of individual command-line arguments. These functions are mainly intended for converting user input in the minibuffer, a Lisp string, into a list of string arguments to be passed to `make-process`, `call-process` or `start-process`, or for converting such lists of arguments into a single Lisp string to be presented in the minibuffer or echo area. Note that if a shell is involved (e.g., if using `call-process-shell-command`), arguments should still be protected by `shell-quote-argument`; `combine-and-quote-strings` is *not* intended to protect special characters from shell evaluation. Function: **split-string-shell-command** *string* This function splits string into substrings, respecting double and single quotes, as well as backslash quoting. ``` (split-string-shell-command "ls /tmp/'foo bar'") ⇒ ("ls" "/tmp/foo bar") ``` Function: **split-string-and-unquote** *string &optional separators* This function splits string into substrings at matches for the regular expression separators, like `split-string` does (see [Creating Strings](creating-strings)); in addition, it removes quoting from the substrings. It then makes a list of the substrings and returns it. If separators is omitted or `nil`, it defaults to `"\\s-+"`, which is a regular expression that matches one or more characters with whitespace syntax (see [Syntax Class Table](syntax-class-table)). This function supports two types of quoting: enclosing a whole string in double quotes `"…"`, and quoting individual characters with a backslash escape ‘`\`’. The latter is also used in Lisp strings, so this function can handle those as well. Function: **combine-and-quote-strings** *list-of-strings &optional separator* This function concatenates list-of-strings into a single string, quoting each string as necessary. It also sticks the separator string between each pair of strings; if separator is omitted or `nil`, it defaults to `" "`. The return value is the resulting string. The strings in list-of-strings that need quoting are those that include separator as their substring. Quoting a string encloses it in double quotes `"…"`. In the simplest case, if you are consing a command from the individual command-line arguments, every argument that includes embedded blanks will be quoted. elisp None #### Window Internals The fields of a window (for a complete list, see the definition of `struct window` in `window.h`) include: `frame` The frame that this window is on, as a Lisp object. `mini` Non-zero if this window is a minibuffer window, a window showing the minibuffer or the echo area. `pseudo_window_p` Non-zero if this window is a *pseudo window*. A pseudo window is either a window used to display the menu bar or the tool bar (when Emacs uses toolkits that don’t display their own menu bar and tool bar) or the tab bar or a window showing a tooltip on a tooltip frame. Pseudo windows are in general not accessible from Lisp code. `parent` Internally, Emacs arranges windows in a tree; each group of siblings has a parent window whose area includes all the siblings. This field points to the window’s parent in that tree, as a Lisp object. For the root window of the tree and a minibuffer window this is always `nil`. Parent windows do not display buffers, and play little role in display except to shape their child windows. Emacs Lisp programs cannot directly manipulate parent windows; they operate on the windows at the leaves of the tree, which actually display buffers. `contents` For a leaf window and windows showing a tooltip, this is the buffer, as a Lisp object, that the window is displaying. For an internal (“parent”) window, this is its first child window. For a pseudo window showing a menu or tool bar this is `nil`. It is also `nil` for a window that has been deleted. `next` `prev` The next and previous sibling of this window as Lisp objects. `next` is `nil` if the window is the right-most or bottom-most in its group; `prev` is `nil` if it is the left-most or top-most in its group. Whether the sibling is left/right or up/down is determined by the `horizontal` field of the sibling’s parent: if it’s non-zero, the siblings are arranged horizontally. As a special case, `next` of a frame’s root window points to the frame’s minibuffer window, provided this is not a minibuffer-only or minibuffer-less frame. On such frames `prev` of the minibuffer window points to that frame’s root window. In any other case, the root window’s `next` and the minibuffer window’s (if present) `prev` fields are `nil`. `left_col` The left-hand edge of the window, measured in columns, relative to the leftmost column (column 0) of the window’s native frame. `top_line` The top edge of the window, measured in lines, relative to the topmost line (line 0) of the window’s native frame. `pixel_left` `pixel_top` The left-hand and top edges of this window, measured in pixels, relative to the top-left corner (0, 0) of the window’s native frame. `total_cols` `total_lines` The total width and height of the window, measured in columns and lines respectively. The values include scroll bars and fringes, dividers and/or the separator line on the right of the window (if any). `pixel_width;` `pixel_height;` The total width and height of the window measured in pixels. `start` A marker pointing to the position in the buffer that is the first character (in the logical order, see [Bidirectional Display](bidirectional-display)) displayed in the window. `pointm` This is the value of point in the current buffer when this window is selected; when it is not selected, it retains its previous value. `old_pointm` The value of `pointm` at the last redisplay time. `force_start` If this flag is non-`nil`, it says that the window has been scrolled explicitly by the Lisp program, and the value of the window’s `start` was set for redisplay to honor. This affects what the next redisplay does if point is off the screen: instead of scrolling the window to show the text around point, it moves point to a location that is on the screen. `optional_new_start` This is similar to `force_start`, but the next redisplay will only obey it if point stays visible. `start_at_line_beg` Non-`nil` means current value of `start` was the beginning of a line when it was chosen. `use_time` This is the last time that the window was selected. The function `get-lru-window` uses this field. `sequence_number` A unique number assigned to this window when it was created. `last_modified` The `modiff` field of the window’s buffer, as of the last time a redisplay completed in this window. `last_overlay_modified` The `overlay_modiff` field of the window’s buffer, as of the last time a redisplay completed in this window. `last_point` The buffer’s value of point, as of the last time a redisplay completed in this window. `last_had_star` A non-zero value means the window’s buffer was modified when the window was last updated. `vertical_scroll_bar_type` `horizontal_scroll_bar_type` The types of this window’s vertical and horizontal scroll bars. `scroll_bar_width` `scroll_bar_height` The width of this window’s vertical scroll bar and the height of this window’s horizontal scroll bar, in pixels. `left_margin_cols` `right_margin_cols` The widths of the left and right margins in this window. A value of zero means no margin. `left_fringe_width` `right_fringe_width` The pixel widths of the left and right fringes in this window. A value of -1 means use the values of the frame. `fringes_outside_margins` A non-zero value means the fringes outside the display margins; othersize they are between the margin and the text. `window_end_pos` This is computed as `z` minus the buffer position of the last glyph in the current matrix of the window. The value is only valid if `window_end_valid` is non-zero. `window_end_bytepos` The byte position corresponding to `window_end_pos`. `window_end_vpos` The window-relative vertical position of the line containing `window_end_pos`. `window_end_valid` This field is set to a non-zero value if `window_end_pos` and `window_end_vpos` are truly valid. This is zero if nontrivial redisplay is pre-empted, since in that case the display that `window_end_pos` was computed for did not get onto the screen. `cursor` A structure describing where the cursor is in this window. `last_cursor_vpos` The window-relative vertical position of the line showing the cursor as of the last redisplay that finished. `phys_cursor` A structure describing where the cursor of this window physically is. `phys_cursor_type` `phys_cursor_height` `phys_cursor_width` The type, height, and width of the cursor that was last displayed on this window. `phys_cursor_on_p` This field is non-zero if the cursor is physically on. `cursor_off_p` Non-zero means the cursor in this window is logically off. This is used for blinking the cursor. `last_cursor_off_p` This field contains the value of `cursor_off_p` as of the time of the last redisplay. `must_be_updated_p` This is set to 1 during redisplay when this window must be updated. `hscroll` This is the number of columns that the display in the window is scrolled horizontally to the left. Normally, this is 0. When only the current line is hscrolled, this describes how much the current line is scrolled. `min_hscroll` Minimum value of `hscroll`, set by the user via `set-window-hscroll` (see [Horizontal Scrolling](horizontal-scrolling)). When only the current line is hscrolled, this describes the horizontal scrolling of lines other than the current one. `vscroll` Vertical scroll amount, in pixels. Normally, this is 0. `dedicated` Non-`nil` if this window is dedicated to its buffer. `combination_limit` This window’s combination limit, meaningful only for a parent window. If this is `t`, then it is not allowed to delete this window and recombine its child windows with other siblings of this window. `window_parameters` The alist of this window’s parameters. `display_table` The window’s display table, or `nil` if none is specified for it. `update_mode_line` Non-zero means this window’s mode line needs to be updated. `mode_line_height` `header_line_height` The height in pixels of the mode line and the header line, or -1 if not known. `base_line_number` The line number of a certain position in the buffer, or zero. This is used for displaying the line number of point in the mode line. `base_line_pos` The position in the buffer for which the line number is known, or zero meaning none is known. If it is -1, don’t display the line number as long as the window shows that buffer. `column_number_displayed` The column number currently displayed in this window’s mode line, or -1 if column numbers are not being displayed. `current_matrix` `desired_matrix` Glyph matrices describing the current and desired display of this window. elisp None #### Drawing Lists as Box Diagrams A list can be illustrated by a diagram in which the cons cells are shown as pairs of boxes, like dominoes. (The Lisp reader cannot read such an illustration; unlike the textual notation, which can be understood by both humans and computers, the box illustrations can be understood only by humans.) This picture represents the three-element list `(rose violet buttercup)`: ``` --- --- --- --- --- --- | | |--> | | |--> | | |--> nil --- --- --- --- --- --- | | | | | | --> rose --> violet --> buttercup ``` In this diagram, each box represents a slot that can hold or refer to any Lisp object. Each pair of boxes represents a cons cell. Each arrow represents a reference to a Lisp object, either an atom or another cons cell. In this example, the first box, which holds the CAR of the first cons cell, refers to or holds `rose` (a symbol). The second box, holding the CDR of the first cons cell, refers to the next pair of boxes, the second cons cell. The CAR of the second cons cell is `violet`, and its CDR is the third cons cell. The CDR of the third (and last) cons cell is `nil`. Here is another diagram of the same list, `(rose violet buttercup)`, sketched in a different manner: ``` --------------- ---------------- ------------------- | car | cdr | | car | cdr | | car | cdr | | rose | o-------->| violet | o-------->| buttercup | nil | | | | | | | | | | --------------- ---------------- ------------------- ``` A list with no elements in it is the *empty list*; it is identical to the symbol `nil`. In other words, `nil` is both a symbol and a list. Here is the list `(A ())`, or equivalently `(A nil)`, depicted with boxes and arrows: ``` --- --- --- --- | | |--> | | |--> nil --- --- --- --- | | | | --> A --> nil ``` Here is a more complex illustration, showing the three-element list, `((pine needles) oak maple)`, the first element of which is a two-element list: ``` --- --- --- --- --- --- | | |--> | | |--> | | |--> nil --- --- --- --- --- --- | | | | | | | --> oak --> maple | | --- --- --- --- --> | | |--> | | |--> nil --- --- --- --- | | | | --> pine --> needles ``` The same list represented in the second box notation looks like this: ``` -------------- -------------- -------------- | car | cdr | | car | cdr | | car | cdr | | o | o------->| oak | o------->| maple | nil | | | | | | | | | | | -- | --------- -------------- -------------- | | | -------------- ---------------- | | car | cdr | | car | cdr | ------>| pine | o------->| needles | nil | | | | | | | -------------- ---------------- ``` elisp None #### Changing Text Properties The primitives for changing properties apply to a specified range of text in a buffer or string. The function `set-text-properties` (see end of section) sets the entire property list of the text in that range; more often, it is useful to add, change, or delete just certain properties specified by name. Since text properties are considered part of the contents of the buffer (or string), and can affect how a buffer looks on the screen, any change in buffer text properties marks the buffer as modified. Buffer text property changes are undoable also (see [Undo](undo)). Positions in a string start from 0, whereas positions in a buffer start from 1. Function: **put-text-property** *start end prop value &optional object* This function sets the prop property to value for the text between start and end in the string or buffer object. If object is `nil`, it defaults to the current buffer. Function: **add-text-properties** *start end props &optional object* This function adds or overrides text properties for the text between start and end in the string or buffer object. If object is `nil`, it defaults to the current buffer. The argument props specifies which properties to add. It should have the form of a property list (see [Property Lists](property-lists)): a list whose elements include the property names followed alternately by the corresponding values. The return value is `t` if the function actually changed some property’s value; `nil` otherwise (if props is `nil` or its values agree with those in the text). For example, here is how to set the `comment` and `face` properties of a range of text: ``` (add-text-properties start end '(comment t face highlight)) ``` Function: **remove-text-properties** *start end props &optional object* This function deletes specified text properties from the text between start and end in the string or buffer object. If object is `nil`, it defaults to the current buffer. The argument props specifies which properties to delete. It should have the form of a property list (see [Property Lists](property-lists)): a list whose elements are property names alternating with corresponding values. But only the names matter—the values that accompany them are ignored. For example, here’s how to remove the `face` property. ``` (remove-text-properties start end '(face nil)) ``` The return value is `t` if the function actually changed some property’s value; `nil` otherwise (if props is `nil` or if no character in the specified text had any of those properties). To remove all text properties from certain text, use `set-text-properties` and specify `nil` for the new property list. Function: **remove-list-of-text-properties** *start end list-of-properties &optional object* Like `remove-text-properties` except that list-of-properties is a list of property names only, not an alternating list of property names and values. Function: **set-text-properties** *start end props &optional object* This function completely replaces the text property list for the text between start and end in the string or buffer object. If object is `nil`, it defaults to the current buffer. The argument props is the new property list. It should be a list whose elements are property names alternating with corresponding values. After `set-text-properties` returns, all the characters in the specified range have identical properties. If props is `nil`, the effect is to get rid of all properties from the specified range of text. Here’s an example: ``` (set-text-properties start end nil) ``` Do not rely on the return value of this function. Function: **add-face-text-property** *start end face &optional appendp object* This function acts on the text between start and end, adding the face face to the `face` text property. face should be a valid value for the `face` property (see [Special Properties](special-properties)), such as a face name or an anonymous face (see [Faces](faces)). If any text in the region already has a non-`nil` `face` property, those face(s) are retained. This function sets the `face` property to a list of faces, with face as the first element (by default) and the pre-existing faces as the remaining elements. If the optional argument appendp is non-`nil`, face is appended to the end of the list instead. Note that in a face list, the first occurring value for each attribute takes precedence. For example, the following code would assign an italicized green face to the text between start and end: ``` (add-face-text-property start end 'italic) (add-face-text-property start end '(:foreground "red")) (add-face-text-property start end '(:foreground "green")) ``` The optional argument object, if non-`nil`, specifies a buffer or string to act on, rather than the current buffer. If object is a string, then start and end are zero-based indices into the string. The easiest way to make a string with text properties is with `propertize`: Function: **propertize** *string &rest properties* This function returns a copy of string with the text properties properties added. These properties apply to all the characters in the string that is returned. Here is an example that constructs a string with a `face` property and a `mouse-face` property: ``` (propertize "foo" 'face 'italic 'mouse-face 'bold-italic) ⇒ #("foo" 0 3 (mouse-face bold-italic face italic)) ``` To put different properties on various parts of a string, you can construct each part with `propertize` and then combine them with `concat`: ``` (concat (propertize "foo" 'face 'italic 'mouse-face 'bold-italic) " and " (propertize "bar" 'face 'italic 'mouse-face 'bold-italic)) ⇒ #("foo and bar" 0 3 (face italic mouse-face bold-italic) 3 8 nil 8 11 (face italic mouse-face bold-italic)) ``` See [Buffer Contents](buffer-contents), for the function `buffer-substring-no-properties`, which copies text from the buffer but does not copy its properties. If you wish to add text properties to a buffer or remove them without marking the buffer as modified, you can wrap the calls above in the `with-silent-modifications` macro. See [Buffer Modification](buffer-modification).
programming_docs
elisp None #### Low-Level Parsing The most basic way to use the expression parser is to tell it to start at a given position with a certain state, and parse up to a specified end position. Function: **parse-partial-sexp** *start limit &optional target-depth stop-before state stop-comment* This function parses a sexp in the current buffer starting at start, not scanning past limit. It stops at position limit or when certain criteria described below are met, and sets point to the location where parsing stops. It returns a parser state describing the status of the parse at the point where it stops. If the third argument target-depth is non-`nil`, parsing stops if the depth in parentheses becomes equal to target-depth. The depth starts at 0, or at whatever is given in state. If the fourth argument stop-before is non-`nil`, parsing stops when it comes to any character that starts a sexp. If stop-comment is non-`nil`, parsing stops after the start of an unnested comment. If stop-comment is the symbol `syntax-table`, parsing stops after the start of an unnested comment or a string, or after the end of an unnested comment or a string, whichever comes first. If state is `nil`, start is assumed to be at the top level of parenthesis structure, such as the beginning of a function definition. Alternatively, you might wish to resume parsing in the middle of the structure. To do this, you must provide a state argument that describes the initial status of parsing. The value returned by a previous call to `parse-partial-sexp` will do nicely. elisp None ### Recombining Windows When deleting the last sibling of a window W, its parent window is deleted too, with W replacing it in the window tree. This means that W must be recombined with its parent’s siblings to form a new window combination (see [Windows and Frames](windows-and-frames)). In some occasions, deleting a live window may even entail the deletion of two internal windows. ``` ______________________________________ | ______ ____________________________ | || || __________________________ || || ||| ___________ ___________ ||| || |||| || |||| || ||||____W6_____||_____W7____|||| || |||____________W4____________||| || || __________________________ || || ||| ||| || ||| ||| || |||____________W5____________||| ||__W2__||_____________W3_____________ | |__________________W1__________________| ``` Deleting W5 in this configuration normally causes the deletion of W3 and W4. The remaining live windows W2, W6 and W7 are recombined to form a new horizontal combination with parent W1. Sometimes, however, it makes sense to not delete a parent window like W4. In particular, a parent window should not be removed when it was used to preserve a combination embedded in a combination of the same type. Such embeddings make sense to assure that when you split a window and subsequently delete the new window, Emacs reestablishes the layout of the associated frame as it existed before the splitting. Consider a scenario starting with two live windows W2 and W3 and their parent W1. ``` ______________________________________ | ____________________________________ | || || || || || || || || || || || || ||_________________W2_________________|| | ____________________________________ | || || || || ||_________________W3_________________|| |__________________W1__________________| ``` Split W2 to make a new window W4 as follows. ``` ______________________________________ | ____________________________________ | || || || || ||_________________W2_________________|| | ____________________________________ | || || || || ||_________________W4_________________|| | ____________________________________ | || || || || ||_________________W3_________________|| |__________________W1__________________| ``` Now, when enlarging a window vertically, Emacs tries to obtain the corresponding space from its lower sibling, provided such a window exists. In our scenario, enlarging W4 will steal space from W3. ``` ______________________________________ | ____________________________________ | || || || || ||_________________W2_________________|| | ____________________________________ | || || || || || || || || ||_________________W4_________________|| | ____________________________________ | ||_________________W3_________________|| |__________________W1__________________| ``` Deleting W4 will now give its entire space to W2, including the space earlier stolen from W3. ``` ______________________________________ | ____________________________________ | || || || || || || || || || || || || || || || || ||_________________W2_________________|| | ____________________________________ | ||_________________W3_________________|| |__________________W1__________________| ``` This can be counterintuitive, in particular if W4 were used for displaying a buffer only temporarily (see [Temporary Displays](temporary-displays)), and you want to continue working with the initial layout. The behavior can be fixed by making a new parent window when splitting W2. The variable described next allows that to be done. User Option: **window-combination-limit** This variable controls whether splitting a window shall make a new parent window. The following values are recognized: `nil` This means that the new live window is allowed to share the existing parent window, if one exists, provided the split occurs in the same direction as the existing window combination (otherwise, a new internal window is created anyway). `window-size` This means that `display-buffer` makes a new parent window when it splits a window and is passed a `window-height` or `window-width` entry in the alist argument (see [Buffer Display Action Functions](buffer-display-action-functions)). Otherwise, window splitting behaves as for a value of `nil`. `temp-buffer-resize` In this case `with-temp-buffer-window` makes a new parent window when it splits a window and `temp-buffer-resize-mode` is enabled (see [Temporary Displays](temporary-displays)). Otherwise, window splitting behaves as for `nil`. `temp-buffer` In this case `with-temp-buffer-window` always makes a new parent window when it splits an existing window (see [Temporary Displays](temporary-displays)). Otherwise, window splitting behaves as for `nil`. `display-buffer` This means that when `display-buffer` (see [Choosing Window](choosing-window)) splits a window it always makes a new parent window. Otherwise, window splitting behaves as for `nil`. `t` This means that splitting a window always creates a new parent window. Thus, if the value of this variable is at all times `t`, then at all times every window tree is a binary tree (a tree where each window except the root window has exactly one sibling). The default is `window-size`. Other values are reserved for future use. If, as a consequence of this variable’s setting, `split-window` makes a new parent window, it also calls `set-window-combination-limit` (see below) on the newly-created internal window. This affects how the window tree is rearranged when the child windows are deleted (see below). If `window-combination-limit` is `t`, splitting W2 in the initial configuration of our scenario would have produced this: ``` ______________________________________ | ____________________________________ | || __________________________________ || ||| ||| |||________________W2________________||| || __________________________________ || ||| ||| |||________________W4________________||| ||_________________W5_________________|| | ____________________________________ | || || || || ||_________________W3_________________|| |__________________W1__________________| ``` A new internal window W5 has been created; its children are W2 and the new live window W4. Now, W2 is the only sibling of W4, so enlarging W4 will try to shrink W2, leaving W3 unaffected. Observe that W5 represents a vertical combination of two windows embedded in the vertical combination W1. Function: **set-window-combination-limit** *window limit* This function sets the *combination limit* of the window window to limit. This value can be retrieved via the function `window-combination-limit`. See below for its effects; note that it is only meaningful for internal windows. The `split-window` function automatically calls this function, passing it `t` as limit, provided the value of the variable `window-combination-limit` is `t` when it is called. Function: **window-combination-limit** *window* This function returns the combination limit for window. The combination limit is meaningful only for an internal window. If it is `nil`, then Emacs is allowed to automatically delete window, in response to a window deletion, in order to group the child windows of window with its sibling windows to form a new window combination. If the combination limit is `t`, the child windows of window are never automatically recombined with its siblings. If, in the configuration shown at the beginning of this section, the combination limit of W4 (the parent window of W6 and W7) is `t`, deleting W5 will not implicitly delete W4 too. Alternatively, the problems sketched above can be avoided by always resizing all windows in the same combination whenever one of its windows is split or deleted. This also permits splitting windows that would be otherwise too small for such an operation. User Option: **window-combination-resize** If this variable is `nil`, `split-window` can only split a window (denoted by window) if window’s screen area is large enough to accommodate both itself and the new window. If this variable is `t`, `split-window` tries to resize all windows that are part of the same combination as window, in order to accommodate the new window. In particular, this may allow `split-window` to succeed even if window is a fixed-size window or too small to ordinarily split. Furthermore, subsequently resizing or deleting window may resize all other windows in its combination. The default is `nil`. Other values are reserved for future use. A specific split operation may ignore the value of this variable if it is affected by a non-`nil` value of `window-combination-limit`. To illustrate the effect of `window-combination-resize`, consider the following frame layout. ``` ______________________________________ | ____________________________________ | || || || || || || || || ||_________________W2_________________|| | ____________________________________ | || || || || || || || || ||_________________W3_________________|| |__________________W1__________________| ``` If `window-combination-resize` is `nil`, splitting window W3 leaves the size of W2 unchanged: ``` ______________________________________ | ____________________________________ | || || || || || || || || ||_________________W2_________________|| | ____________________________________ | || || ||_________________W3_________________|| | ____________________________________ | || || ||_________________W4_________________|| |__________________W1__________________| ``` If `window-combination-resize` is `t`, splitting W3 instead leaves all three live windows with approximately the same height: ``` ______________________________________ | ____________________________________ | || || || || ||_________________W2_________________|| | ____________________________________ | || || || || ||_________________W3_________________|| | ____________________________________ | || || || || ||_________________W4_________________|| |__________________W1__________________| ``` Deleting any of the live windows W2, W3 or W4 will distribute its space proportionally among the two remaining live windows. elisp None ### Minibuffer Contents These functions access the minibuffer prompt and contents. Function: **minibuffer-prompt** This function returns the prompt string of the currently active minibuffer. If no minibuffer is active, it returns `nil`. Function: **minibuffer-prompt-end** This function returns the current position of the end of the minibuffer prompt, if a minibuffer is current. Otherwise, it returns the minimum valid buffer position. Function: **minibuffer-prompt-width** This function returns the current display-width of the minibuffer prompt, if a minibuffer is current. Otherwise, it returns zero. Function: **minibuffer-contents** This function returns the editable contents of the minibuffer (that is, everything except the prompt) as a string, if a minibuffer is current. Otherwise, it returns the entire contents of the current buffer. Function: **minibuffer-contents-no-properties** This is like `minibuffer-contents`, except that it does not copy text properties, just the characters themselves. See [Text Properties](text-properties). Command: **delete-minibuffer-contents** This command erases the editable contents of the minibuffer (that is, everything except the prompt), if a minibuffer is current. Otherwise, it erases the entire current buffer. elisp None #### Coding Systems in Lisp Here are the Lisp facilities for working with coding systems: Function: **coding-system-list** *&optional base-only* This function returns a list of all coding system names (symbols). If base-only is non-`nil`, the value includes only the base coding systems. Otherwise, it includes alias and variant coding systems as well. Function: **coding-system-p** *object* This function returns `t` if object is a coding system name or `nil`. Function: **check-coding-system** *coding-system* This function checks the validity of coding-system. If that is valid, it returns coding-system. If coding-system is `nil`, the function returns `nil`. For any other values, it signals an error whose `error-symbol` is `coding-system-error` (see [signal](signaling-errors)). Function: **coding-system-eol-type** *coding-system* This function returns the type of end-of-line (a.k.a. *eol*) conversion used by coding-system. If coding-system specifies a certain eol conversion, the return value is an integer 0, 1, or 2, standing for `unix`, `dos`, and `mac`, respectively. If coding-system doesn’t specify eol conversion explicitly, the return value is a vector of coding systems, each one with one of the possible eol conversion types, like this: ``` (coding-system-eol-type 'latin-1) ⇒ [latin-1-unix latin-1-dos latin-1-mac] ``` If this function returns a vector, Emacs will decide, as part of the text encoding or decoding process, what eol conversion to use. For decoding, the end-of-line format of the text is auto-detected, and the eol conversion is set to match it (e.g., DOS-style CRLF format will imply `dos` eol conversion). For encoding, the eol conversion is taken from the appropriate default coding system (e.g., default value of `buffer-file-coding-system` for `buffer-file-coding-system`), or from the default eol conversion appropriate for the underlying platform. Function: **coding-system-change-eol-conversion** *coding-system eol-type* This function returns a coding system which is like coding-system except for its eol conversion, which is specified by `eol-type`. eol-type should be `unix`, `dos`, `mac`, or `nil`. If it is `nil`, the returned coding system determines the end-of-line conversion from the data. eol-type may also be 0, 1 or 2, standing for `unix`, `dos` and `mac`, respectively. Function: **coding-system-change-text-conversion** *eol-coding text-coding* This function returns a coding system which uses the end-of-line conversion of eol-coding, and the text conversion of text-coding. If text-coding is `nil`, it returns `undecided`, or one of its variants according to eol-coding. Function: **find-coding-systems-region** *from to* This function returns a list of coding systems that could be used to encode a text between from and to. All coding systems in the list can safely encode any multibyte characters in that portion of the text. If the text contains no multibyte characters, the function returns the list `(undecided)`. Function: **find-coding-systems-string** *string* This function returns a list of coding systems that could be used to encode the text of string. All coding systems in the list can safely encode any multibyte characters in string. If the text contains no multibyte characters, this returns the list `(undecided)`. Function: **find-coding-systems-for-charsets** *charsets* This function returns a list of coding systems that could be used to encode all the character sets in the list charsets. Function: **check-coding-systems-region** *start end coding-system-list* This function checks whether coding systems in the list `coding-system-list` can encode all the characters in the region between start and end. If all of the coding systems in the list can encode the specified text, the function returns `nil`. If some coding systems cannot encode some of the characters, the value is an alist, each element of which has the form `(coding-system1 pos1 pos2 …)`, meaning that coding-system1 cannot encode characters at buffer positions pos1, pos2, .... start may be a string, in which case end is ignored and the returned value references string indices instead of buffer positions. Function: **detect-coding-region** *start end &optional highest* This function chooses a plausible coding system for decoding the text from start to end. This text should be a byte sequence, i.e., unibyte text or multibyte text with only ASCII and eight-bit characters (see [Explicit Encoding](explicit-encoding)). Normally this function returns a list of coding systems that could handle decoding the text that was scanned. They are listed in order of decreasing priority. But if highest is non-`nil`, then the return value is just one coding system, the one that is highest in priority. If the region contains only ASCII characters except for such ISO-2022 control characters ISO-2022 as `ESC`, the value is `undecided` or `(undecided)`, or a variant specifying end-of-line conversion, if that can be deduced from the text. If the region contains null bytes, the value is `no-conversion`, even if the region contains text encoded in some coding system. Function: **detect-coding-string** *string &optional highest* This function is like `detect-coding-region` except that it operates on the contents of string instead of bytes in the buffer. Variable: **inhibit-null-byte-detection** If this variable has a non-`nil` value, null bytes are ignored when detecting the encoding of a region or a string. This allows the encoding of text that contains null bytes to be correctly detected, such as Info files with Index nodes. Variable: **inhibit-iso-escape-detection** If this variable has a non-`nil` value, ISO-2022 escape sequences are ignored when detecting the encoding of a region or a string. The result is that no text is ever detected as encoded in some ISO-2022 encoding, and all escape sequences become visible in a buffer. **Warning:** *Use this variable with extreme caution, because many files in the Emacs distribution use ISO-2022 encoding.* Function: **coding-system-charset-list** *coding-system* This function returns the list of character sets (see [Character Sets](character-sets)) supported by coding-system. Some coding systems that support too many character sets to list them all yield special values: * If coding-system supports all Emacs characters, the value is `(emacs)`. * If coding-system supports all Unicode characters, the value is `(unicode)`. * If coding-system supports all ISO-2022 charsets, the value is `iso-2022`. * If coding-system supports all the characters in the internal coding system used by Emacs version 21 (prior to the implementation of internal Unicode support), the value is `emacs-mule`. See [Process Information](process-information#Coding-systems-for-a-subprocess), in particular the description of the functions `process-coding-system` and `set-process-coding-system`, for how to examine or set the coding systems used for I/O to a subprocess.
programming_docs
elisp None ### Defining Customization Groups Each Emacs Lisp package should have one main customization group which contains all the options, faces and other groups in the package. If the package has a small number of options and faces, use just one group and put everything in it. When there are more than twenty or so options and faces, then you should structure them into subgroups, and put the subgroups under the package’s main customization group. It is OK to put some of the options and faces in the package’s main group alongside the subgroups. The package’s main or only group should be a member of one or more of the standard customization groups. (To display the full list of them, use `M-x customize`.) Choose one or more of them (but not too many), and add your group to each of them using the `:group` keyword. The way to declare new customization groups is with `defgroup`. Macro: **defgroup** *group members doc [keyword value]…* Declare group as a customization group containing members. Do not quote the symbol group. The argument doc specifies the documentation string for the group. The argument members is a list specifying an initial set of customization items to be members of the group. However, most often members is `nil`, and you specify the group’s members by using the `:group` keyword when defining those members. If you want to specify group members through members, each element should have the form `(name widget)`. Here name is a symbol, and widget is a widget type for editing that symbol. Useful widgets are `custom-variable` for a variable, `custom-face` for a face, and `custom-group` for a group. When you introduce a new group into Emacs, use the `:version` keyword in the `defgroup`; then you need not use it for the individual members of the group. In addition to the common keywords (see [Common Keywords](common-keywords)), you can also use this keyword in `defgroup`: `:prefix prefix` If the name of an item in the group starts with prefix, and the customizable variable `custom-unlispify-remove-prefixes` is non-`nil`, the item’s tag will omit prefix. A group can have any number of prefixes. The variables and subgroups of a group are stored in the `custom-group` property of the group’s symbol. See [Symbol Plists](symbol-plists). The value of that property is a list of pairs whose `car` is the variable or subgroup symbol and the `cdr` is either `custom-variable` or `custom-group`. User Option: **custom-unlispify-remove-prefixes** If this variable is non-`nil`, the prefixes specified by a group’s `:prefix` keyword are omitted from tag names, whenever the user customizes the group. The default value is `nil`, i.e., the prefix-discarding feature is disabled. This is because discarding prefixes often leads to confusing names for options and faces. elisp None ### Pure Storage Emacs Lisp uses two kinds of storage for user-created Lisp objects: *normal storage* and *pure storage*. Normal storage is where all the new data created during an Emacs session are kept (see [Garbage Collection](garbage-collection)). Pure storage is used for certain data in the preloaded standard Lisp files—data that should never change during actual use of Emacs. Pure storage is allocated only while `temacs` is loading the standard preloaded Lisp libraries. In the file `emacs`, it is marked as read-only (on operating systems that permit this), so that the memory space can be shared by all the Emacs jobs running on the machine at once. Pure storage is not expandable; a fixed amount is allocated when Emacs is compiled, and if that is not sufficient for the preloaded libraries, `temacs` allocates dynamic memory for the part that didn’t fit. If Emacs will be dumped using the `pdump` method (see [Building Emacs](building-emacs)), the pure-space overflow is of no special importance (it just means some of the preloaded stuff cannot be shared with other Emacs jobs). However, if Emacs will be dumped using the now obsolete `unexec` method, the resulting image will work, but garbage collection (see [Garbage Collection](garbage-collection)) is disabled in this situation, causing a memory leak. Such an overflow normally won’t happen unless you try to preload additional libraries or add features to the standard ones. Emacs will display a warning about the overflow when it starts, if it was dumped using `unexec`. If this happens, you should increase the compilation parameter `SYSTEM_PURESIZE_EXTRA` in the file `src/puresize.h` and rebuild Emacs. Function: **purecopy** *object* This function makes a copy in pure storage of object, and returns it. It copies a string by simply making a new string with the same characters, but without text properties, in pure storage. It recursively copies the contents of vectors and cons cells. It does not make copies of other objects such as symbols, but just returns them unchanged. It signals an error if asked to copy markers. This function is a no-op except while Emacs is being built and dumped; it is usually called only in preloaded Lisp files. Variable: **pure-bytes-used** The value of this variable is the number of bytes of pure storage allocated so far. Typically, in a dumped Emacs, this number is very close to the total amount of pure storage available—if it were not, we would preallocate less. Variable: **purify-flag** This variable determines whether `defun` should make a copy of the function definition in pure storage. If it is non-`nil`, then the function definition is copied into pure storage. This flag is `t` while loading all of the basic functions for building Emacs initially (allowing those functions to be shareable and non-collectible). Dumping Emacs as an executable always writes `nil` in this variable, regardless of the value it actually has before and after dumping. You should not change this flag in a running Emacs. elisp None ### Starting Up Emacs This section describes what Emacs does when it is started, and how you can customize these actions. | | | | | --- | --- | --- | | • [Startup Summary](startup-summary) | | Sequence of actions Emacs performs at startup. | | • [Init File](init-file) | | Details on reading the init file. | | • [Terminal-Specific](terminal_002dspecific) | | How the terminal-specific Lisp file is read. | | • [Command-Line Arguments](command_002dline-arguments) | | How command-line arguments are processed, and how you can customize them. | elisp None #### Frame Layouts with Side Windows Side windows can be used to create more complex frame layouts like those provided by integrated development environments (IDEs). In such layouts, the area of the main window is where the normal editing activities take place. Side windows are not conceived for editing in the usual sense. Rather, they are supposed to display information complementary to the current editing activity, like lists of files, tags or buffers, help information, search or grep results or shell output. The layout of such a frame might appear as follows: ``` ___________________________________ | *Buffer List* | |___________________________________| | | | | | * | | * | | d | | T | | i | | a | | r | Main Window Area | g | | e | | s | | d | | * | | * | | | |_____|_______________________|_____| | *help*/*grep*/ | *shell*/ | | *Completions* | *compilation* | |_________________|_________________| | Echo Area | |___________________________________| ``` The following example illustrates how window parameters (see [Window Parameters](window-parameters)) can be used with `display-buffer-in-side-window` (see [Displaying Buffers in Side Windows](displaying-buffers-in-side-windows)) to set up code for producing the frame layout sketched above. ``` (defvar parameters '(window-parameters . ((no-other-window . t) (no-delete-other-windows . t)))) (setq fit-window-to-buffer-horizontally t) (setq window-resize-pixelwise t) (setq display-buffer-alist `(("\\*Buffer List\\*" display-buffer-in-side-window (side . top) (slot . 0) (window-height . fit-window-to-buffer) (preserve-size . (nil . t)) ,parameters) ("\\*Tags List\\*" display-buffer-in-side-window (side . right) (slot . 0) (window-width . fit-window-to-buffer) (preserve-size . (t . nil)) ,parameters) ("\\*\\(?:help\\|grep\\|Completions\\)\\*" display-buffer-in-side-window (side . bottom) (slot . -1) (preserve-size . (nil . t)) ,parameters) ("\\*\\(?:shell\\|compilation\\)\\*" display-buffer-in-side-window (side . bottom) (slot . 1) (preserve-size . (nil . t)) ,parameters))) ``` This specifies `display-buffer-alist` entries (see [Choosing Window](choosing-window)) for buffers with fixed names. In particular, it asks for showing `\*Buffer List\*` with adjustable height at the top of the frame and `\*Tags List\*` with adjustable width on the frame’s right. It also asks for having the `\*help\*`, `\*grep\*` and `\*Completions\*` buffers share a window on the bottom left side of the frame and the `\*shell\*` and `\*compilation\*` buffers appear in a window on the bottom right side of the frame. Note that the option `fit-window-to-buffer-horizontally` must have a non-`nil` value in order to allow horizontal adjustment of windows. Entries are also added that ask for preserving the height of side windows at the top and bottom of the frame and the width of side windows at the left or right of the frame. To assure that side windows retain their respective sizes when maximizing the frame, the variable `window-resize-pixelwise` is set to a non-`nil` value. See [Resizing Windows](resizing-windows). The last form also makes sure that none of the created side windows are accessible via `C-x o` by installing the `no-other-window` parameter for each of these windows. In addition, it makes sure that side windows are not deleted via `C-x 1` by installing the `no-delete-other-windows` parameter for each of these windows. Since `dired` buffers have no fixed names, we use a special function `dired-default-directory-on-left` in order to display a lean directory buffer on the left side of the frame. ``` (defun dired-default-directory-on-left () "Display `default-directory' in side window on left, hiding details." (interactive) (let ((buffer (dired-noselect default-directory))) (with-current-buffer buffer (dired-hide-details-mode t)) (display-buffer-in-side-window buffer `((side . left) (slot . 0) (window-width . fit-window-to-buffer) (preserve-size . (t . nil)) ,parameters)))) ``` Evaluating the preceding forms and typing, in any order, `M-x list-buffers`, `C-h f`, `M-x shell`, `M-x list-tags`, and `M-x dired-default-directory-on-left` should now reproduce the frame layout sketched above. elisp None #### Functions that Expand Filenames *Expanding* a file name means converting a relative file name to an absolute one. Since this is done relative to a default directory, you must specify the default directory as well as the file name to be expanded. It also involves expanding abbreviations like `~/` (see [abbreviate-file-name](directory-names#abbreviate_002dfile_002dname)), and eliminating redundancies like `./` and `name/../`. Function: **expand-file-name** *filename &optional directory* This function converts filename to an absolute file name. If directory is supplied, it is the default directory to start with if filename is relative and does not start with ‘`~`’. (The value of directory should itself be an absolute directory name or directory file name; it may start with ‘`~`’.) Otherwise, the current buffer’s value of `default-directory` is used. For example: ``` (expand-file-name "foo") ⇒ "/xcssun/users/rms/lewis/foo" ``` ``` (expand-file-name "../foo") ⇒ "/xcssun/users/rms/foo" ``` ``` (expand-file-name "foo" "/usr/spool/") ⇒ "/usr/spool/foo" ``` If the part of filename before the first slash is ‘`~`’, it expands to your home directory, which is typically specified by the value of the `HOME` environment variable (see [General Variables](https://www.gnu.org/software/emacs/manual/html_node/emacs/General-Variables.html#General-Variables) in The GNU Emacs Manual). If the part before the first slash is ‘`~user`’ and if user is a valid login name, it expands to user’s home directory. If you do not want this expansion for a relative filename that might begin with a literal ‘`~`’, you can use `(concat (file-name-as-directory directory) filename)` instead of `(expand-file-name filename directory)`. File names containing ‘`.`’ or ‘`..`’ are simplified to their canonical form: ``` (expand-file-name "bar/../foo") ⇒ "/xcssun/users/rms/lewis/foo" ``` In some cases, a leading ‘`..`’ component can remain in the output: ``` (expand-file-name "../home" "/") ⇒ "/../home" ``` This is for the sake of filesystems that have the concept of a superroot above the root directory `/`. On other filesystems, `/../` is interpreted exactly the same as `/`. Expanding `.` or the empty string returns the default directory: ``` (expand-file-name "." "/usr/spool/") ⇒ "/usr/spool" (expand-file-name "" "/usr/spool/") ⇒ "/usr/spool" ``` Note that `expand-file-name` does *not* expand environment variables; only `substitute-in-file-name` does that: ``` (expand-file-name "$HOME/foo") ⇒ "/xcssun/users/rms/lewis/$HOME/foo" ``` Note also that `expand-file-name` does not follow symbolic links at any level. This results in a difference between the way `file-truename` and `expand-file-name` treat ‘`..`’. Assuming that ‘`/tmp/bar`’ is a symbolic link to the directory ‘`/tmp/foo/bar`’ we get: ``` (file-truename "/tmp/bar/../myfile") ⇒ "/tmp/foo/myfile" ``` ``` (expand-file-name "/tmp/bar/../myfile") ⇒ "/tmp/myfile" ``` If you may need to follow symbolic links preceding ‘`..`’, you should make sure to call `file-truename` without prior direct or indirect calls to `expand-file-name`. See [Truenames](truenames). Variable: **default-directory** The value of this buffer-local variable is the default directory for the current buffer. It should be an absolute directory name; it may start with ‘`~`’. This variable is buffer-local in every buffer. `expand-file-name` uses the default directory when its second argument is `nil`. The value is always a string ending with a slash. ``` default-directory ⇒ "/user/lewis/manual/" ``` Function: **substitute-in-file-name** *filename* This function replaces environment variable references in filename with the environment variable values. Following standard Unix shell syntax, ‘`$`’ is the prefix to substitute an environment variable value. If the input contains ‘`$$`’, that is converted to ‘`$`’; this gives the user a way to quote a ‘`$`’. The environment variable name is the series of alphanumeric characters (including underscores) that follow the ‘`$`’. If the character following the ‘`$`’ is a ‘`{`’, then the variable name is everything up to the matching ‘`}`’. Calling `substitute-in-file-name` on output produced by `substitute-in-file-name` tends to give incorrect results. For instance, use of ‘`$$`’ to quote a single ‘`$`’ won’t work properly, and ‘`$`’ in an environment variable’s value could lead to repeated substitution. Therefore, programs that call this function and put the output where it will be passed to this function need to double all ‘`$`’ characters to prevent subsequent incorrect results. Here we assume that the environment variable `HOME`, which holds the user’s home directory, has value ‘`/xcssun/users/rms`’. ``` (substitute-in-file-name "$HOME/foo") ⇒ "/xcssun/users/rms/foo" ``` After substitution, if a ‘`~`’ or a ‘`/`’ appears immediately after another ‘`/`’, the function discards everything before it (up through the immediately preceding ‘`/`’). ``` (substitute-in-file-name "bar/~/foo") ⇒ "~/foo" ``` ``` (substitute-in-file-name "/usr/local/$HOME/foo") ⇒ "/xcssun/users/rms/foo" ;; `/usr/local/` has been discarded. ``` Sometimes, it is not desired to expand file names. In such cases, the file name can be quoted to suppress the expansion, and to handle the file name literally. Quoting happens by prefixing the file name with ‘`/:`’. Macro: **file-name-quote** *name* This macro adds the quotation prefix ‘`/:`’ to the file name. For a local file name, it prefixes name with ‘`/:`’. If name is a remote file name, the local part of name (see [Magic File Names](magic-file-names)) is quoted. If name is already a quoted file name, name is returned unchanged. ``` (substitute-in-file-name (file-name-quote "bar/~/foo")) ⇒ "/:bar/~/foo" ``` ``` (substitute-in-file-name (file-name-quote "/ssh:host:bar/~/foo")) ⇒ "/ssh:host:/:bar/~/foo" ``` The macro cannot be used to suppress file name handlers from magic file names (see [Magic File Names](magic-file-names)). Macro: **file-name-unquote** *name* This macro removes the quotation prefix ‘`/:`’ from the file name, if any. If name is a remote file name, the local part of name is unquoted. Macro: **file-name-quoted-p** *name* This macro returns non-`nil`, when name is quoted with the prefix ‘`/:`’. If name is a remote file name, the local part of name is checked. elisp None #### Debugging Infinite Loops When a program loops infinitely and fails to return, your first problem is to stop the loop. On most operating systems, you can do this with `C-g`, which causes a *quit*. See [Quitting](quitting). Ordinary quitting gives no information about why the program was looping. To get more information, you can set the variable `debug-on-quit` to non-`nil`. Once you have the debugger running in the middle of the infinite loop, you can proceed from the debugger using the stepping commands. If you step through the entire loop, you may get enough information to solve the problem. Quitting with `C-g` is not considered an error, and `debug-on-error` has no effect on the handling of `C-g`. Likewise, `debug-on-quit` has no effect on errors. User Option: **debug-on-quit** This variable determines whether the debugger is called when `quit` is signaled and not handled. If `debug-on-quit` is non-`nil`, then the debugger is called whenever you quit (that is, type `C-g`). If `debug-on-quit` is `nil` (the default), then the debugger is not called when you quit. elisp None ### Backup Files A *backup file* is a copy of the old contents of a file you are editing. Emacs makes a backup file the first time you save a buffer into its visited file. Thus, normally, the backup file contains the contents of the file as it was before the current editing session. The contents of the backup file normally remain unchanged once it exists. Backups are usually made by renaming the visited file to a new name. Optionally, you can specify that backup files should be made by copying the visited file. This choice makes a difference for files with multiple names; it also can affect whether the edited file remains owned by the original owner or becomes owned by the user editing it. By default, Emacs makes a single backup file for each file edited. You can alternatively request numbered backups; then each new backup file gets a new name. You can delete old numbered backups when you don’t want them any more, or Emacs can delete them automatically. For performance, the operating system may not write the backup file’s contents to secondary storage immediately, or may alias the backup data with the original until one or the other is later modified. See [Files and Storage](files-and-storage). | | | | | --- | --- | --- | | • [Making Backups](making-backups) | | How Emacs makes backup files, and when. | | • [Rename or Copy](rename-or-copy) | | Two alternatives: renaming the old file or copying it. | | • [Numbered Backups](numbered-backups) | | Keeping multiple backups for each source file. | | • [Backup Names](backup-names) | | How backup file names are computed; customization. |
programming_docs
elisp None ### Line Height The total height of each display line consists of the height of the contents of the line, plus optional additional vertical line spacing above or below the display line. The height of the line contents is the maximum height of any character or image on that display line, including the final newline if there is one. (A display line that is continued doesn’t include a final newline.) That is the default line height, if you do nothing to specify a greater height. (In the most common case, this equals the height of the corresponding frame’s default font, see [Frame Font](frame-font).) There are several ways to explicitly specify a larger line height, either by specifying an absolute height for the display line, or by specifying vertical space. However, no matter what you specify, the actual line height can never be less than the default. A newline can have a `line-height` text or overlay property that controls the total height of the display line ending in that newline. The property value can be one of several forms: `t` If the property value is `t`, the newline character has no effect on the displayed height of the line—the visible contents alone determine the height. The `line-spacing` property, described below, is also ignored in this case. This is useful for tiling small images (or image slices) without adding blank areas between the images. `(height total)` If the property value is a list of the form shown, that adds extra space *below* the display line. First Emacs uses height as a height spec to control extra space *above* the line; then it adds enough space *below* the line to bring the total line height up to total. In this case, any value of `line-spacing` property for the newline is ignored. Any other kind of property value is a height spec, which translates into a number—the specified line height. There are several ways to write a height spec; here’s how each of them translates into a number: `integer` If the height spec is a positive integer, the height value is that integer. `float` If the height spec is a float, float, the numeric height value is float times the frame’s default line height. `(face . ratio)` If the height spec is a cons of the format shown, the numeric height is ratio times the height of face face. ratio can be any type of number, or `nil` which means a ratio of 1. If face is `t`, it refers to the current face. `(nil . ratio)` If the height spec is a cons of the format shown, the numeric height is ratio times the height of the contents of the line. Thus, any valid height spec determines the height in pixels, one way or another. If the line contents’ height is less than that, Emacs adds extra vertical space above the line to achieve the specified total height. If you don’t specify the `line-height` property, the line’s height consists of the contents’ height plus the line spacing. There are several ways to specify the line spacing for different parts of Emacs text. On graphical terminals, you can specify the line spacing for all lines in a frame, using the `line-spacing` frame parameter (see [Layout Parameters](layout-parameters)). However, if the default value of `line-spacing` is non-`nil`, it overrides the frame’s `line-spacing` parameter. An integer specifies the number of pixels put below lines. A floating-point number specifies the spacing relative to the frame’s default line height. You can specify the line spacing for all lines in a buffer via the buffer-local `line-spacing` variable. An integer specifies the number of pixels put below lines. A floating-point number specifies the spacing relative to the default frame line height. This overrides line spacings specified for the frame. Finally, a newline can have a `line-spacing` text or overlay property that can enlarge the default frame line spacing and the buffer local `line-spacing` variable: if its value is larger than the buffer or frame defaults, that larger value is used instead, for the display line ending in that newline. One way or another, these mechanisms specify a Lisp value for the spacing of each line. The value is a height spec, and it translates into a Lisp value as described above. However, in this case the numeric height value specifies the line spacing, rather than the line height. On text terminals, the line spacing cannot be altered. elisp None #### Buffer Type A *buffer* is an object that holds text that can be edited (see [Buffers](buffers)). Most buffers hold the contents of a disk file (see [Files](files)) so they can be edited, but some are used for other purposes. Most buffers are also meant to be seen by the user, and therefore displayed, at some time, in a window (see [Windows](windows)). But a buffer need not be displayed in any window. Each buffer has a designated position called *point* (see [Positions](positions)); most editing commands act on the contents of the current buffer in the neighborhood of point. At any time, one buffer is the *current buffer*. The contents of a buffer are much like a string, but buffers are not used like strings in Emacs Lisp, and the available operations are different. For example, you can insert text efficiently into an existing buffer, altering the buffer’s contents, whereas inserting text into a string requires concatenating substrings, and the result is an entirely new string object. Many of the standard Emacs functions manipulate or test the characters in the current buffer; a whole chapter in this manual is devoted to describing these functions (see [Text](text)). Several other data structures are associated with each buffer: * a local syntax table (see [Syntax Tables](syntax-tables)); * a local keymap (see [Keymaps](keymaps)); and, * a list of buffer-local variable bindings (see [Buffer-Local Variables](buffer_002dlocal-variables)). * overlays (see [Overlays](overlays)). * text properties for the text in the buffer (see [Text Properties](text-properties)). The local keymap and variable list contain entries that individually override global bindings or values. These are used to customize the behavior of programs in different buffers, without actually changing the programs. A buffer may be *indirect*, which means it shares the text of another buffer, but presents it differently. See [Indirect Buffers](indirect-buffers). Buffers have no read syntax. They print in hash notation, showing the buffer name. ``` (current-buffer) ⇒ #<buffer objects.texi> ``` elisp None ### Eval Most often, forms are evaluated automatically, by virtue of their occurrence in a program being run. On rare occasions, you may need to write code that evaluates a form that is computed at run time, such as after reading a form from text being edited or getting one from a property list. On these occasions, use the `eval` function. Often `eval` is not needed and something else should be used instead. For example, to get the value of a variable, while `eval` works, `symbol-value` is preferable; or rather than store expressions in a property list that then need to go through `eval`, it is better to store functions instead that are then passed to `funcall`. The functions and variables described in this section evaluate forms, specify limits to the evaluation process, or record recently returned values. Loading a file also does evaluation (see [Loading](loading)). It is generally cleaner and more flexible to store a function in a data structure, and call it with `funcall` or `apply`, than to store an expression in the data structure and evaluate it. Using functions provides the ability to pass information to them as arguments. Function: **eval** *form &optional lexical* This is the basic function for evaluating an expression. It evaluates form in the current environment, and returns the result. The type of the form object determines how it is evaluated. See [Forms](forms). The argument lexical specifies the scoping rule for local variables (see [Variable Scoping](variable-scoping)). If it is omitted or `nil`, that means to evaluate form using the default dynamic scoping rule. If it is `t`, that means to use the lexical scoping rule. The value of lexical can also be a non-empty alist specifying a particular *lexical environment* for lexical bindings; however, this feature is only useful for specialized purposes, such as in Emacs Lisp debuggers. See [Lexical Binding](lexical-binding). Since `eval` is a function, the argument expression that appears in a call to `eval` is evaluated twice: once as preparation before `eval` is called, and again by the `eval` function itself. Here is an example: ``` (setq foo 'bar) ⇒ bar ``` ``` (setq bar 'baz) ⇒ baz ;; Here `eval` receives argument `foo` (eval 'foo) ⇒ bar ;; Here `eval` receives argument `bar`, which is the value of `foo` (eval foo) ⇒ baz ``` The number of currently active calls to `eval` is limited to `max-lisp-eval-depth` (see below). Command: **eval-region** *start end &optional stream read-function* This function evaluates the forms in the current buffer in the region defined by the positions start and end. It reads forms from the region and calls `eval` on them until the end of the region is reached, or until an error is signaled and not handled. By default, `eval-region` does not produce any output. However, if stream is non-`nil`, any output produced by output functions (see [Output Functions](output-functions)), as well as the values that result from evaluating the expressions in the region are printed using stream. See [Output Streams](output-streams). If read-function is non-`nil`, it should be a function, which is used instead of `read` to read expressions one by one. This function is called with one argument, the stream for reading input. You can also use the variable `load-read-function` (see [How Programs Do Loading](how-programs-do-loading#Definition-of-load_002dread_002dfunction)) to specify this function, but it is more robust to use the read-function argument. `eval-region` does not move point. It always returns `nil`. Command: **eval-buffer** *&optional buffer-or-name stream filename unibyte print* This is similar to `eval-region`, but the arguments provide different optional features. `eval-buffer` operates on the entire accessible portion of buffer buffer-or-name (see [Narrowing](https://www.gnu.org/software/emacs/manual/html_node/emacs/Narrowing.html#Narrowing) in The GNU Emacs Manual). buffer-or-name can be a buffer, a buffer name (a string), or `nil` (or omitted), which means to use the current buffer. stream is used as in `eval-region`, unless stream is `nil` and print non-`nil`. In that case, values that result from evaluating the expressions are still discarded, but the output of the output functions is printed in the echo area. filename is the file name to use for `load-history` (see [Unloading](unloading)), and defaults to `buffer-file-name` (see [Buffer File Name](buffer-file-name)). If unibyte is non-`nil`, `read` converts strings to unibyte whenever possible. `eval-current-buffer` is an alias for this command. User Option: **max-lisp-eval-depth** This variable defines the maximum depth allowed in calls to `eval`, `apply`, and `funcall` before an error is signaled (with error message `"Lisp nesting exceeds max-lisp-eval-depth"`). This limit, with the associated error when it is exceeded, is one way Emacs Lisp avoids infinite recursion on an ill-defined function. If you increase the value of `max-lisp-eval-depth` too much, such code can cause stack overflow instead. On some systems, this overflow can be handled. In that case, normal Lisp evaluation is interrupted and control is transferred back to the top level command loop (`top-level`). Note that there is no way to enter Emacs Lisp debugger in this situation. See [Error Debugging](error-debugging). The depth limit counts internal uses of `eval`, `apply`, and `funcall`, such as for calling the functions mentioned in Lisp expressions, and recursive evaluation of function call arguments and function body forms, as well as explicit calls in Lisp code. The default value of this variable is 800. If you set it to a value less than 100, Lisp will reset it to 100 if the given value is reached. Entry to the Lisp debugger increases the value, if there is little room left, to make sure the debugger itself has room to execute. `max-specpdl-size` provides another limit on nesting. See [Local Variables](local-variables#Definition-of-max_002dspecpdl_002dsize). Variable: **values** The value of this variable is a list of the values returned by all the expressions that were read, evaluated, and printed from buffers (including the minibuffer) by the standard Emacs commands which do this. (Note that this does *not* include evaluation in `\*ielm\*` buffers, nor evaluation using `C-j`, `C-x C-e`, and similar evaluation commands in `lisp-interaction-mode`.) This variable is obsolete, and will be removed in a future version, since it constantly enlarges the memory footprint of the Emacs process. For that reason, we recommend against using it. The elements of `values` are ordered most recent first. ``` (setq x 1) ⇒ 1 ``` ``` (list 'A (1+ 2) auto-save-default) ⇒ (A 3 t) ``` ``` values ⇒ ((A 3 t) 1 …) ``` This variable could be useful for referring back to values of forms recently evaluated. It is generally a bad idea to print the value of `values` itself, since this may be very long. Instead, examine particular elements, like this: ``` ;; Refer to the most recent evaluation result. (nth 0 values) ⇒ (A 3 t) ``` ``` ;; That put a new element on, ;; so all elements move back one. (nth 1 values) ⇒ (A 3 t) ``` ``` ;; This gets the element that was next-to-most-recent ;; before this example. (nth 3 values) ⇒ 1 ``` elisp None ### Creating Hash Tables The principal function for creating a hash table is `make-hash-table`. Function: **make-hash-table** *&rest keyword-args* This function creates a new hash table according to the specified arguments. The arguments should consist of alternating keywords (particular symbols recognized specially) and values corresponding to them. Several keywords make sense in `make-hash-table`, but the only two that you really need to know about are `:test` and `:weakness`. `:test test` This specifies the method of key lookup for this hash table. The default is `eql`; `eq` and `equal` are other alternatives: `eql` Keys which are numbers are the same if they are `equal`, that is, if they are equal in value and either both are integers or both are floating point; otherwise, two distinct objects are never the same. `eq` Any two distinct Lisp objects are different as keys. `equal` Two Lisp objects are the same, as keys, if they are equal according to `equal`. You can use `define-hash-table-test` (see [Defining Hash](defining-hash)) to define additional possibilities for test. `:weakness weak` The weakness of a hash table specifies whether the presence of a key or value in the hash table preserves it from garbage collection. The value, weak, must be one of `nil`, `key`, `value`, `key-or-value`, `key-and-value`, or `t` which is an alias for `key-and-value`. If weak is `key` then the hash table does not prevent its keys from being collected as garbage (if they are not referenced anywhere else); if a particular key does get collected, the corresponding association is removed from the hash table. If weak is `value`, then the hash table does not prevent values from being collected as garbage (if they are not referenced anywhere else); if a particular value does get collected, the corresponding association is removed from the hash table. If weak is `key-and-value` or `t`, both the key and the value must be live in order to preserve the association. Thus, the hash table does not protect either keys or values from garbage collection; if either one is collected as garbage, that removes the association. If weak is `key-or-value`, either the key or the value can preserve the association. Thus, associations are removed from the hash table when both their key and value would be collected as garbage (if not for references from weak hash tables). The default for weak is `nil`, so that all keys and values referenced in the hash table are preserved from garbage collection. `:size size` This specifies a hint for how many associations you plan to store in the hash table. If you know the approximate number, you can make things a little more efficient by specifying it this way. If you specify too small a size, the hash table will grow automatically when necessary, but doing that takes some extra time. The default size is 65. `:rehash-size rehash-size` When you add an association to a hash table and the table is full, it grows automatically. This value specifies how to make the hash table larger, at that time. If rehash-size is an integer, it should be positive, and the hash table grows by adding approximately that much to the nominal size. If rehash-size is floating point, it had better be greater than 1, and the hash table grows by multiplying the old size by approximately that number. The default value is 1.5. `:rehash-threshold threshold` This specifies the criterion for when the hash table is full (so it should be made larger). The value, threshold, should be a positive floating-point number, no greater than 1. The hash table is full whenever the actual number of entries exceeds the nominal size multiplied by an approximation to this value. The default for threshold is 0.8125. You can also create a hash table using the printed representation for hash tables. The Lisp reader can read this printed representation, provided each element in the specified hash table has a valid read syntax (see [Printed Representation](printed-representation)). For instance, the following specifies a hash table containing the keys `key1` and `key2` (both symbols) associated with `val1` (a symbol) and `300` (a number) respectively. ``` #s(hash-table size 30 data (key1 val1 key2 300)) ``` Note, however, that when using this in Emacs Lisp code, it’s undefined whether this creates a new hash table or not. If you want to create a new hash table, you should always use `make-hash-table` (see [Self-Evaluating Forms](self_002devaluating-forms)). The printed representation for a hash table consists of ‘`#s`’ followed by a list beginning with ‘`hash-table`’. The rest of the list should consist of zero or more property-value pairs specifying the hash table’s properties and initial contents. The properties and values are read literally. Valid property names are `size`, `test`, `weakness`, `rehash-size`, `rehash-threshold`, and `data`. The `data` property should be a list of key-value pairs for the initial contents; the other properties have the same meanings as the matching `make-hash-table` keywords (`:size`, `:test`, etc.), described above. Note that you cannot specify a hash table whose initial contents include objects that have no read syntax, such as buffers and frames. Such objects may be added to the hash table after it is created. elisp None #### Source Breakpoints All breakpoints in a definition are forgotten each time you reinstrument it. If you wish to make a breakpoint that won’t be forgotten, you can write a *source breakpoint*, which is simply a call to the function `edebug` in your source code. You can, of course, make such a call conditional. For example, in the `fac` function, you can insert the first line as shown below, to stop when the argument reaches zero: ``` (defun fac (n) (if (= n 0) (edebug)) (if (< 0 n) (* n (fac (1- n))) 1)) ``` When the `fac` definition is instrumented and the function is called, the call to `edebug` acts as a breakpoint. Depending on the execution mode, Edebug stops or pauses there. If no instrumented code is being executed when `edebug` is called, that function calls `debug`.
programming_docs
elisp None ### Conversion of Characters and Strings This section describes functions for converting between characters, strings and integers. `format` (see [Formatting Strings](formatting-strings)) and `prin1-to-string` (see [Output Functions](output-functions)) can also convert Lisp objects into strings. `read-from-string` (see [Input Functions](input-functions)) can convert a string representation of a Lisp object into an object. The functions `string-to-multibyte` and `string-to-unibyte` convert the text representation of a string (see [Converting Representations](converting-representations)). See [Documentation](documentation), for functions that produce textual descriptions of text characters and general input events (`single-key-description` and `text-char-description`). These are used primarily for making help messages. Function: **number-to-string** *number* This function returns a string consisting of the printed base-ten representation of number. The returned value starts with a minus sign if the argument is negative. ``` (number-to-string 256) ⇒ "256" ``` ``` (number-to-string -23) ⇒ "-23" ``` ``` (number-to-string -23.5) ⇒ "-23.5" ``` `int-to-string` is a semi-obsolete alias for this function. See also the function `format` in [Formatting Strings](formatting-strings). Function: **string-to-number** *string &optional base* This function returns the numeric value of the characters in string. If base is non-`nil`, it must be an integer between 2 and 16 (inclusive), and integers are converted in that base. If base is `nil`, then base ten is used. Floating-point conversion only works in base ten; we have not implemented other radices for floating-point numbers, because that would be much more work and does not seem useful. The parsing skips spaces and tabs at the beginning of string, then reads as much of string as it can interpret as a number in the given base. (On some systems it ignores other whitespace at the beginning, not just spaces and tabs.) If string cannot be interpreted as a number, this function returns 0. ``` (string-to-number "256") ⇒ 256 (string-to-number "25 is a perfect square.") ⇒ 25 (string-to-number "X256") ⇒ 0 (string-to-number "-4.5") ⇒ -4.5 (string-to-number "1e5") ⇒ 100000.0 ``` `string-to-int` is an obsolete alias for this function. Function: **char-to-string** *character* This function returns a new string containing one character, character. This function is semi-obsolete because the function `string` is more general. See [Creating Strings](creating-strings). Function: **string-to-char** *string* This function returns the first character in string. This mostly identical to `(aref string 0)`, except that it returns 0 if the string is empty. (The value is also 0 when the first character of string is the null character, ASCII code 0.) This function may be eliminated in the future if it does not seem useful enough to retain. Here are some other functions that can convert to or from a string: `concat` This function converts a vector or a list into a string. See [Creating Strings](creating-strings). `vconcat` This function converts a string into a vector. See [Vector Functions](vector-functions). `append` This function converts a string into a list. See [Building Lists](building-lists). `byte-to-string` This function converts a byte of character data into a unibyte string. See [Converting Representations](converting-representations). elisp None #### Using interactive This section describes how to write the `interactive` form that makes a Lisp function an interactively-callable command, and how to examine a command’s `interactive` form. Special Form: **interactive** *&optional arg-descriptor &rest modes* This special form declares that a function is a command, and that it may therefore be called interactively (via `M-x` or by entering a key sequence bound to it). The argument arg-descriptor declares how to compute the arguments to the command when the command is called interactively. A command may be called from Lisp programs like any other function, but then the caller supplies the arguments and arg-descriptor has no effect. The `interactive` form must be located at top-level in the function body, or in the function symbol’s `interactive-form` property (see [Symbol Properties](symbol-properties)). It has its effect because the command loop looks for it before calling the function (see [Interactive Call](interactive-call)). Once the function is called, all its body forms are executed; at this time, if the `interactive` form occurs within the body, the form simply returns `nil` without even evaluating its argument. The modes list allows specifying which modes the command is meant to be used in. See [Command Modes](command-modes) for more details about the effect of specifying modes, and when to use it. By convention, you should put the `interactive` form in the function body, as the first top-level form. If there is an `interactive` form in both the `interactive-form` symbol property and the function body, the former takes precedence. The `interactive-form` symbol property can be used to add an interactive form to an existing function, or change how its arguments are processed interactively, without redefining the function. There are three possibilities for the argument arg-descriptor: * It may be omitted or `nil`; then the command is called with no arguments. This leads quickly to an error if the command requires one or more arguments. * It may be a string; its contents are a sequence of elements separated by newlines, one for each argument[15](#FOOT15). Each element consists of a code character (see [Interactive Codes](interactive-codes)) optionally followed by a prompt (which some code characters use and some ignore). Here is an example: ``` (interactive "P\nbFrobnicate buffer: ") ``` The code letter ‘`P`’ sets the command’s first argument to the raw command prefix (see [Prefix Command Arguments](prefix-command-arguments)). ‘`bFrobnicate buffer:` ’ prompts the user with ‘`Frobnicate buffer:` ’ to enter the name of an existing buffer, which becomes the second and final argument. The prompt string can use ‘`%`’ to include previous argument values (starting with the first argument) in the prompt. This is done using `format-message` (see [Formatting Strings](formatting-strings)). For example, here is how you could read the name of an existing buffer followed by a new name to give to that buffer: ``` (interactive "bBuffer to rename: \nsRename buffer %s to: ") ``` If ‘`\*`’ appears at the beginning of the string, then an error is signaled if the buffer is read-only. If ‘`@`’ appears at the beginning of the string, and if the key sequence used to invoke the command includes any mouse events, then the window associated with the first of those events is selected before the command is run. If ‘`^`’ appears at the beginning of the string, and if the command was invoked through *shift-translation*, set the mark and activate the region temporarily, or extend an already active region, before the command is run. If the command was invoked without shift-translation, and the region is temporarily active, deactivate the region before the command is run. Shift-translation is controlled on the user level by `shift-select-mode`; see [Shift Selection](https://www.gnu.org/software/emacs/manual/html_node/emacs/Shift-Selection.html#Shift-Selection) in The GNU Emacs Manual. You can use ‘`\*`’, ‘`@`’, and `^` together; the order does not matter. Actual reading of arguments is controlled by the rest of the prompt string (starting with the first character that is not ‘`\*`’, ‘`@`’, or ‘`^`’). * It may be a Lisp expression that is not a string; then it should be a form that is evaluated to get a list of arguments to pass to the command. Usually this form will call various functions to read input from the user, most often through the minibuffer (see [Minibuffers](minibuffers)) or directly from the keyboard (see [Reading Input](reading-input)). Providing point or the mark as an argument value is also common, but if you do this *and* read input (whether using the minibuffer or not), be sure to get the integer values of point or the mark after reading. The current buffer may be receiving subprocess output; if subprocess output arrives while the command is waiting for input, it could relocate point and the mark. Here’s an example of what *not* to do: ``` (interactive (list (region-beginning) (region-end) (read-string "Foo: " nil 'my-history))) ``` Here’s how to avoid the problem, by examining point and the mark after reading the keyboard input: ``` (interactive (let ((string (read-string "Foo: " nil 'my-history))) (list (region-beginning) (region-end) string))) ``` **Warning:** the argument values should not include any data types that can’t be printed and then read. Some facilities save `command-history` in a file to be read in the subsequent sessions; if a command’s arguments contain a data type that prints using ‘`#<…>`’ syntax, those facilities won’t work. There are, however, a few exceptions: it is ok to use a limited set of expressions such as `(point)`, `(mark)`, `(region-beginning)`, and `(region-end)`, because Emacs recognizes them specially and puts the expression (rather than its value) into the command history. To see whether the expression you wrote is one of these exceptions, run the command, then examine `(car command-history)`. Function: **interactive-form** *function* This function returns the `interactive` form of function. If function is an interactively callable function (see [Interactive Call](interactive-call)), the value is the command’s `interactive` form `(interactive spec)`, which specifies how to compute its arguments. Otherwise, the value is `nil`. If function is a symbol, its function definition is used. elisp None #### Trace Buffer Edebug can record an execution trace, storing it in a buffer named `\*edebug-trace\*`. This is a log of function calls and returns, showing the function names and their arguments and values. To enable trace recording, set `edebug-trace` to a non-`nil` value. Making a trace buffer is not the same thing as using trace execution mode (see [Edebug Execution Modes](edebug-execution-modes)). When trace recording is enabled, each function entry and exit adds lines to the trace buffer. A function entry record consists of ‘`::::{`’, followed by the function name and argument values. A function exit record consists of ‘`::::}`’, followed by the function name and result of the function. The number of ‘`:`’s in an entry shows its recursion depth. You can use the braces in the trace buffer to find the matching beginning or end of function calls. You can customize trace recording for function entry and exit by redefining the functions `edebug-print-trace-before` and `edebug-print-trace-after`. Macro: **edebug-tracing** *string body…* This macro requests additional trace information around the execution of the body forms. The argument string specifies text to put in the trace buffer, after the ‘`{`’ or ‘`}`’. All the arguments are evaluated, and `edebug-tracing` returns the value of the last form in body. Function: **edebug-trace** *format-string &rest format-args* This function inserts text in the trace buffer. It computes the text with `(apply 'format format-string format-args)`. It also appends a newline to separate entries. `edebug-tracing` and `edebug-trace` insert lines in the trace buffer whenever they are called, even if Edebug is not active. Adding text to the trace buffer also scrolls its window to show the last lines inserted. elisp None ### Memory Usage These functions and variables give information about the total amount of memory allocation that Emacs has done, broken down by data type. Note the difference between these and the values returned by `garbage-collect`; those count objects that currently exist, but these count the number or size of all allocations, including those for objects that have since been freed. Variable: **cons-cells-consed** The total number of cons cells that have been allocated so far in this Emacs session. Variable: **floats-consed** The total number of floats that have been allocated so far in this Emacs session. Variable: **vector-cells-consed** The total number of vector cells that have been allocated so far in this Emacs session. This includes vector-like objects such as markers and overlays, plus certain objects not visible to users. Variable: **symbols-consed** The total number of symbols that have been allocated so far in this Emacs session. Variable: **string-chars-consed** The total number of string characters that have been allocated so far in this session. Variable: **intervals-consed** The total number of intervals that have been allocated so far in this Emacs session. Variable: **strings-consed** The total number of strings that have been allocated so far in this Emacs session. elisp None ### Low-Level Network Access You can also create network connections by operating at a lower level than that of `open-network-stream`, using `make-network-process`. | | | | | --- | --- | --- | | • [Proc](network-processes) | | Using `make-network-process`. | | • [Options](network-options) | | Further control over network connections. | | • [Features](network-feature-testing) | | Determining which network features work on the machine you are using. | elisp None ### Inheritance and Keymaps A keymap can inherit the bindings of another keymap, which we call the *parent keymap*. Such a keymap looks like this: ``` (keymap elements… . parent-keymap) ``` The effect is that this keymap inherits all the bindings of parent-keymap, whatever they may be at the time a key is looked up, but can add to them or override them with elements. If you change the bindings in parent-keymap using `define-key` or other key-binding functions, these changed bindings are visible in the inheriting keymap, unless shadowed by the bindings made by elements. The converse is not true: if you use `define-key` to change bindings in the inheriting keymap, these changes are recorded in elements, but have no effect on parent-keymap. The proper way to construct a keymap with a parent is to use `set-keymap-parent`; if you have code that directly constructs a keymap with a parent, please convert the program to use `set-keymap-parent` instead. Function: **keymap-parent** *keymap* This returns the parent keymap of keymap. If keymap has no parent, `keymap-parent` returns `nil`. Function: **set-keymap-parent** *keymap parent* This sets the parent keymap of keymap to parent, and returns parent. If parent is `nil`, this function gives keymap no parent at all. If keymap has submaps (bindings for prefix keys), they too receive new parent keymaps that reflect what parent specifies for those prefix keys. Here is an example showing how to make a keymap that inherits from `text-mode-map`: ``` (let ((map (make-sparse-keymap))) (set-keymap-parent map text-mode-map) map) ``` A non-sparse keymap can have a parent too, but this is not very useful. A non-sparse keymap always specifies something as the binding for every numeric character code without modifier bits, even if it is `nil`, so these character’s bindings are never inherited from the parent keymap. Sometimes you want to make a keymap that inherits from more than one map. You can use the function `make-composed-keymap` for this. Function: **make-composed-keymap** *maps &optional parent* This function returns a new keymap composed of the existing keymap(s) maps, and optionally inheriting from a parent keymap parent. maps can be a single keymap or a list of more than one. When looking up a key in the resulting new map, Emacs searches in each of the maps in turn, and then in parent, stopping at the first match. A `nil` binding in any one of maps overrides any binding in parent, but it does not override any non-`nil` binding in any other of the maps. For example, here is how Emacs sets the parent of `help-mode-map`, such that it inherits from both `button-buffer-map` and `special-mode-map`: ``` (defvar help-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map (make-composed-keymap button-buffer-map special-mode-map)) ... map) ... ) ``` elisp None ### Swapping Text Between Two Buffers Specialized modes sometimes need to let the user access from the same buffer several vastly different types of text. For example, you may need to display a summary of the buffer text, in addition to letting the user access the text itself. This could be implemented with multiple buffers (kept in sync when the user edits the text), or with narrowing (see [Narrowing](narrowing)). But these alternatives might sometimes become tedious or prohibitively expensive, especially if each type of text requires expensive buffer-global operations in order to provide correct display and editing commands. Emacs provides another facility for such modes: you can quickly swap buffer text between two buffers with `buffer-swap-text`. This function is very fast because it doesn’t move any text, it only changes the internal data structures of the buffer object to point to a different chunk of text. Using it, you can pretend that a group of two or more buffers are actually a single virtual buffer that holds the contents of all the individual buffers together. Function: **buffer-swap-text** *buffer* This function swaps the text of the current buffer and that of its argument buffer. It signals an error if one of the two buffers is an indirect buffer (see [Indirect Buffers](indirect-buffers)) or is a base buffer of an indirect buffer. All the buffer properties that are related to the buffer text are swapped as well: the positions of point and mark, all the markers, the overlays, the text properties, the undo list, the value of the `enable-multibyte-characters` flag (see [enable-multibyte-characters](text-representations)), etc. **Warning:** If this function is called from within a `save-excursion` form, the current buffer will be set to buffer upon leaving the form, since the marker used by `save-excursion` to save the position and buffer will be swapped as well. If you use `buffer-swap-text` on a file-visiting buffer, you should set up a hook to save the buffer’s original text rather than what it was swapped with. `write-region-annotate-functions` works for this purpose. You should probably set `buffer-saved-size` to -2 in the buffer, so that changes in the text it is swapped with will not interfere with auto-saving. elisp None #### Mouse Events Emacs supports four kinds of mouse events: click events, drag events, button-down events, and motion events. All mouse events are represented as lists. The CAR of the list is the event type; this says which mouse button was involved, and which modifier keys were used with it. The event type can also distinguish double or triple button presses (see [Repeat Events](repeat-events)). The rest of the list elements give position and time information. For key lookup, only the event type matters: two events of the same type necessarily run the same command. The command can access the full values of these events using the ‘`e`’ interactive code. See [Interactive Codes](interactive-codes). A key sequence that starts with a mouse event is read using the keymaps of the buffer in the window that the mouse was in, not the current buffer. This does not imply that clicking in a window selects that window or its buffer—that is entirely under the control of the command binding of the key sequence. elisp Emacs Lisp Emacs Lisp ========== The GNU Emacs website is at <https://www.gnu.org/software/emacs/>. For information on using Emacs, refer to the [Emacs Manual](https://www.gnu.org/software/emacs/manual/emacs.html). To view this manual in other formats, click [here](https://www.gnu.org/software/emacs/manual/elisp.html). This is the GNU Emacs Lisp Reference Manual corresponding to Emacs version 28.2. | | | | --- | --- | | [Introduction](https://www.gnu.org/software/emacs/manual/html_node/elisp/Introduction.html) | Introduction and conventions used. | | | | [Lisp Data Types](lisp-data-types) | Data types of objects in Emacs Lisp. | | [Numbers](numbers) | Numbers and arithmetic functions. | | [Strings and Characters](strings-and-characters) | Strings, and functions that work on them. | | [Lists](lists) | Lists, cons cells, and related functions. | | [Sequences Arrays Vectors](sequences-arrays-vectors) | Lists, strings and vectors are called sequences. Certain functions act on any kind of sequence. The description of vectors is here as well. | | [Records](records) | Compound objects with programmer-defined types. | | [Hash Tables](hash-tables) | Very fast lookup-tables. | | [Symbols](symbols) | Symbols represent names, uniquely. | | | | [Evaluation](evaluation) | How Lisp expressions are evaluated. | | [Control Structures](control-structures) | Conditionals, loops, nonlocal exits. | | [Variables](variables) | Using symbols in programs to stand for values. | | [Functions](functions) | A function is a Lisp program that can be invoked from other functions. | | [Macros](macros) | Macros are a way to extend the Lisp language. | | [Customization](customization) | Making variables and faces customizable. | | | | [Loading](loading) | Reading files of Lisp code into Lisp. | | [Byte Compilation](byte-compilation) | Compilation makes programs run faster. | | [Native Compilation](native-compilation) | Compile Lisp into native machine code. | | [Debugging](debugging) | Tools and tips for debugging Lisp programs. | | | | [Read and Print](read-and-print) | Converting Lisp objects to text and back. | | [Minibuffers](minibuffers) | Using the minibuffer to read input. | | [Command Loop](command-loop) | How the editor command loop works, and how you can call its subroutines. | | [Keymaps](keymaps) | Defining the bindings from keys to commands. | | [Modes](modes) | Defining major and minor modes. | | [Documentation](documentation) | Writing and using documentation strings. | | | | [Files](files) | Accessing files. | | [Backups and Auto-Saving](backups-and-auto_002dsaving) | Controlling how backups and auto-save files are made. | | [Buffers](buffers) | Creating and using buffer objects. | | [Windows](windows) | Manipulating windows and displaying buffers. | | [Frames](frames) | Making multiple system-level windows. | | [Positions](positions) | Buffer positions and motion functions. | | [Markers](markers) | Markers represent positions and update automatically when the text is changed. | | | | [Text](text) | Examining and changing text in buffers. | | [Non-ASCII Characters](non_002dascii-characters) | Non-ASCII text in buffers and strings. | | [Searching and Matching](searching-and-matching) | Searching buffers for strings or regexps. | | [Syntax Tables](syntax-tables) | The syntax table controls word and list parsing. | | [Abbrevs](abbrevs) | How Abbrev mode works, and its data structures. | | | | [Threads](threads) | Concurrency in Emacs Lisp. | | [Processes](processes) | Running and communicating with subprocesses. | | [Display](display) | Features for controlling the screen display. | | [System Interface](system-interface) | Getting the user id, system type, environment variables, and other such things. | | | | [Packaging](packaging) | Preparing Lisp code for distribution. | | Appendices | | [Antinews](https://www.gnu.org/software/emacs/manual/html_node/elisp/Antinews.html) | Info for users downgrading to Emacs 27. | | [GNU Free Documentation License](https://www.gnu.org/software/emacs/manual/html_node/elisp/GNU-Free-Documentation-License.html) | The license for this documentation. | | [GPL](https://www.gnu.org/software/emacs/manual/html_node/elisp/GPL.html) | Conditions for copying and changing GNU Emacs. | | [Tips](https://www.gnu.org/software/emacs/manual/html_node/elisp/Tips.html) | Advice and coding conventions for Emacs Lisp. | | [GNU Emacs Internals](gnu-emacs-internals) | Building and dumping Emacs; internal data structures. | | [Standard Errors](standard-errors) | List of some standard error symbols. | | [Standard Keymaps](standard-keymaps) | List of some standard keymaps. | | [Standard Hooks](standard-hooks) | List of some standard hook variables. | | | | [Index](index) | Index including concepts, functions, variables, and other terms. | | | ---
programming_docs
elisp None #### Specified Spaces To display a space of specified width and/or height, use a display specification of the form `(space . props)`, where props is a property list (a list of alternating properties and values). You can put this property on one or more consecutive characters; a space of the specified height and width is displayed in place of *all* of those characters. These are the properties you can use in props to specify the weight of the space: `:width width` If width is a number, it specifies that the space width should be width times the normal character width. width can also be a *pixel width* specification (see [Pixel Specification](pixel-specification)). `:relative-width factor` Specifies that the width of the stretch should be computed from the first character in the group of consecutive characters that have the same `display` property. The space width is the pixel width of that character, multiplied by factor. (On text-mode terminals, the “pixel width” of a character is usually 1, but it could be more for TABs and double-width CJK characters.) `:align-to hpos` Specifies that the space should be wide enough to reach hpos. If hpos is a number, it is measured in units of the normal character width. hpos can also be a *pixel width* specification (see [Pixel Specification](pixel-specification)). You should use one and only one of the above properties. You can also specify the height of the space, with these properties: `:height height` Specifies the height of the space. If height is a number, it specifies that the space height should be height times the normal character height. The height may also be a *pixel height* specification (see [Pixel Specification](pixel-specification)). `:relative-height factor` Specifies the height of the space, multiplying the ordinary height of the text having this display specification by factor. `:ascent ascent` If the value of ascent is a non-negative number no greater than 100, it specifies that ascent percent of the height of the space should be considered as the ascent of the space—that is, the part above the baseline. The ascent may also be specified in pixel units with a *pixel ascent* specification (see [Pixel Specification](pixel-specification)). Don’t use both `:height` and `:relative-height` together. The `:width` and `:align-to` properties are supported on non-graphic terminals, but the other space properties in this section are not. Note that space properties are treated as paragraph separators for the purposes of reordering bidirectional text for display. See [Bidirectional Display](bidirectional-display), for the details. elisp None #### Constructs in rx regexps The various forms in `rx` regexps are described below. The shorthand rx represents any `rx` form, and rx… means zero or more `rx` forms. These are all valid arguments to the `rx` macro. Where the corresponding string regexp syntax is given, A, B, … are string regexp subexpressions. #### Literals `"some-string"` Match the string ‘`some-string`’ literally. There are no characters with special meaning, unlike in string regexps. `?C` Match the character ‘`C`’ literally. #### Sequence and alternative `(seq rx…)` `(sequence rx…)` `(: rx…)` `(and rx…)` Match the rxs in sequence. Without arguments, the expression matches the empty string. Corresponding string regexp: ‘`AB…`’ (subexpressions in sequence). `(or rx…)` `(| rx…)` Match exactly one of the rxs. If all arguments are strings, characters, or `or` forms so constrained, the longest possible match will always be used. Otherwise, either the longest match or the first (in left-to-right order) will be used. Without arguments, the expression will not match anything at all. Corresponding string regexp: ‘`A\|B\|…`’. `unmatchable` Refuse any match. Equivalent to `(or)`. See [regexp-unmatchable](regexp-functions#regexp_002dunmatchable). #### Repetition Normally, repetition forms are greedy, in that they attempt to match as many times as possible. Some forms are non-greedy; they try to match as few times as possible (see [Non-greedy repetition](regexp-special#Non_002dgreedy-repetition)). `(zero-or-more rx…)` `(0+ rx…)` Match the rxs zero or more times. Greedy by default. Corresponding string regexp: ‘`A\*`’ (greedy), ‘`A\*?`’ (non-greedy) `(one-or-more rx…)` `(1+ rx…)` Match the rxs one or more times. Greedy by default. Corresponding string regexp: ‘`A+`’ (greedy), ‘`A+?`’ (non-greedy) `(zero-or-one rx…)` `(optional rx…)` `(opt rx…)` Match the rxs once or an empty string. Greedy by default. Corresponding string regexp: ‘`A?`’ (greedy), ‘`A??`’ (non-greedy). `(* rx…)` Match the rxs zero or more times. Greedy. Corresponding string regexp: ‘`A\*`’ `(+ rx…)` Match the rxs one or more times. Greedy. Corresponding string regexp: ‘`A+`’ `(? rx…)` Match the rxs once or an empty string. Greedy. Corresponding string regexp: ‘`A?`’ `(*? rx…)` Match the rxs zero or more times. Non-greedy. Corresponding string regexp: ‘`A\*?`’ `(+? rx…)` Match the rxs one or more times. Non-greedy. Corresponding string regexp: ‘`A+?`’ `(?? rx…)` Match the rxs or an empty string. Non-greedy. Corresponding string regexp: ‘`A??`’ `(= n rx…)` `(repeat n rx)` Match the rxs exactly n times. Corresponding string regexp: ‘`A\{n\}`’ `(>= n rx…)` Match the rxs n or more times. Greedy. Corresponding string regexp: ‘`A\{n,\}`’ `(** n m rx…)` `(repeat n m rx…)` Match the rxs at least n but no more than m times. Greedy. Corresponding string regexp: ‘`A\{n,m\}`’ The greediness of some repetition forms can be controlled using the following constructs. However, it is usually better to use the explicit non-greedy forms above when such matching is required. `(minimal-match rx)` Match rx, with `zero-or-more`, `0+`, `one-or-more`, `1+`, `zero-or-one`, `opt` and `optional` using non-greedy matching. `(maximal-match rx)` Match rx, with `zero-or-more`, `0+`, `one-or-more`, `1+`, `zero-or-one`, `opt` and `optional` using greedy matching. This is the default. #### Matching single characters `(any set…)` `(char set…)` `(in set…)` Match a single character from one of the sets. Each set is a character, a string representing the set of its characters, a range or a character class (see below). A range is either a hyphen-separated string like `"A-Z"`, or a cons of characters like `(?A . ?Z)`. Note that hyphen (`-`) is special in strings in this construct, since it acts as a range separator. To include a hyphen, add it as a separate character or single-character string. Corresponding string regexp: ‘`[…]`’ `(not charspec)` Match a character not included in charspec. charspec can be a character, a single-character string, an `any`, `not`, `or`, `intersection`, `syntax` or `category` form, or a character class. If charspec is an `or` form, its arguments have the same restrictions as those of `intersection`; see below. Corresponding string regexp: ‘`[^…]`’, ‘`\Scode`’, ‘`\Ccode`’ `(intersection charset…)` Match a character included in all of the charsets. Each charset can be a character, a single-character string, an `any` form without character classes, or an `intersection`, `or` or `not` form whose arguments are also charsets. `not-newline`, `nonl` Match any character except a newline. Corresponding string regexp: ‘`.`’ (dot) `anychar`, `anything` Match any character. Corresponding string regexp: ‘`.\|\n`’ (for example) character class Match a character from a named character class: `alpha`, `alphabetic`, `letter` Match alphabetic characters. More precisely, match characters whose Unicode ‘`general-category`’ property indicates that they are alphabetic. `alnum`, `alphanumeric` Match alphabetic characters and digits. More precisely, match characters whose Unicode ‘`general-category`’ property indicates that they are alphabetic or decimal digits. `digit`, `numeric`, `num` Match the digits ‘`0`’–‘`9`’. `xdigit`, `hex-digit`, `hex` Match the hexadecimal digits ‘`0`’–‘`9`’, ‘`A`’–‘`F`’ and ‘`a`’–‘`f`’. `cntrl`, `control` Match any character whose code is in the range 0–31. `blank` Match horizontal whitespace. More precisely, match characters whose Unicode ‘`general-category`’ property indicates that they are spacing separators. `space`, `whitespace`, `white` Match any character that has whitespace syntax (see [Syntax Class Table](syntax-class-table)). `lower`, `lower-case` Match anything lower-case, as determined by the current case table. If `case-fold-search` is non-nil, this also matches any upper-case letter. `upper`, `upper-case` Match anything upper-case, as determined by the current case table. If `case-fold-search` is non-nil, this also matches any lower-case letter. `graph`, `graphic` Match any character except whitespace, ASCII and non-ASCII control characters, surrogates, and codepoints unassigned by Unicode, as indicated by the Unicode ‘`general-category`’ property. `print`, `printing` Match whitespace or a character matched by `graph`. `punct`, `punctuation` Match any punctuation character. (At present, for multibyte characters, anything that has non-word syntax.) `word`, `wordchar` Match any character that has word syntax (see [Syntax Class Table](syntax-class-table)). `ascii` Match any ASCII character (codes 0–127). `nonascii` Match any non-ASCII character (but not raw bytes). Corresponding string regexp: ‘`[[:class:]]`’ `(syntax syntax)` Match a character with syntax syntax, being one of the following names: | Syntax name | Syntax character | | --- | --- | | `whitespace` | `-` | | `punctuation` | `.` | | `word` | `w` | | `symbol` | `_` | | `open-parenthesis` | `(` | | `close-parenthesis` | `)` | | `expression-prefix` | `'` | | `string-quote` | `"` | | `paired-delimiter` | `$` | | `escape` | `\` | | `character-quote` | `/` | | `comment-start` | `<` | | `comment-end` | `>` | | `string-delimiter` | `|` | | `comment-delimiter` | `!` | For details, see [Syntax Class Table](syntax-class-table). Please note that `(syntax punctuation)` is *not* equivalent to the character class `punctuation`. Corresponding string regexp: ‘`\schar`’ where char is the syntax character. `(category category)` Match a character in category category, which is either one of the names below or its category character. | Category name | Category character | | --- | --- | | `space-for-indent` | space | | `base` | `.` | | `consonant` | `0` | | `base-vowel` | `1` | | `upper-diacritical-mark` | `2` | | `lower-diacritical-mark` | `3` | | `tone-mark` | `4` | | `symbol` | `5` | | `digit` | `6` | | `vowel-modifying-diacritical-mark` | `7` | | `vowel-sign` | `8` | | `semivowel-lower` | `9` | | `not-at-end-of-line` | `<` | | `not-at-beginning-of-line` | `>` | | `alpha-numeric-two-byte` | `A` | | `chinese-two-byte` | `C` | | `greek-two-byte` | `G` | | `japanese-hiragana-two-byte` | `H` | | `indian-two-byte` | `I` | | `japanese-katakana-two-byte` | `K` | | `strong-left-to-right` | `L` | | `korean-hangul-two-byte` | `N` | | `strong-right-to-left` | `R` | | `cyrillic-two-byte` | `Y` | | `combining-diacritic` | `^` | | `ascii` | `a` | | `arabic` | `b` | | `chinese` | `c` | | `ethiopic` | `e` | | `greek` | `g` | | `korean` | `h` | | `indian` | `i` | | `japanese` | `j` | | `japanese-katakana` | `k` | | `latin` | `l` | | `lao` | `o` | | `tibetan` | `q` | | `japanese-roman` | `r` | | `thai` | `t` | | `vietnamese` | `v` | | `hebrew` | `w` | | `cyrillic` | `y` | | `can-break` | `|` | For more information about currently defined categories, run the command `M-x describe-categories RET`. For how to define new categories, see [Categories](categories). Corresponding string regexp: ‘`\cchar`’ where char is the category character. #### Zero-width assertions These all match the empty string, but only in specific places. `line-start`, `bol` Match at the beginning of a line. Corresponding string regexp: ‘`^`’ `line-end`, `eol` Match at the end of a line. Corresponding string regexp: ‘`$`’ `string-start`, `bos`, `buffer-start`, `bot` Match at the start of the string or buffer being matched against. Corresponding string regexp: ‘`\``’ `string-end`, `eos`, `buffer-end`, `eot` Match at the end of the string or buffer being matched against. Corresponding string regexp: ‘`\'`’ `point` Match at point. Corresponding string regexp: ‘`\=`’ `word-start`, `bow` Match at the beginning of a word. Corresponding string regexp: ‘`\<`’ `word-end`, `eow` Match at the end of a word. Corresponding string regexp: ‘`\>`’ `word-boundary` Match at the beginning or end of a word. Corresponding string regexp: ‘`\b`’ `not-word-boundary` Match anywhere but at the beginning or end of a word. Corresponding string regexp: ‘`\B`’ `symbol-start` Match at the beginning of a symbol. Corresponding string regexp: ‘`\\_<`’ `symbol-end` Match at the end of a symbol. Corresponding string regexp: ‘`\\_>`’ #### Capture groups `(group rx…)` `(submatch rx…)` Match the rxs, making the matched text and position accessible in the match data. The first group in a regexp is numbered 1; subsequent groups will be numbered one above the previously highest-numbered group in the pattern so far. Corresponding string regexp: ‘`\(…\)`’ `(group-n n rx…)` `(submatch-n n rx…)` Like `group`, but explicitly assign the group number n. n must be positive. Corresponding string regexp: ‘`\(?n:…\)`’ `(backref n)` Match the text previously matched by group number n. n must be in the range 1–9. Corresponding string regexp: ‘`\n`’ #### Dynamic inclusion `(literal expr)` Match the literal string that is the result from evaluating the Lisp expression expr. The evaluation takes place at call time, in the current lexical environment. `(regexp expr)` `(regex expr)` Match the string regexp that is the result from evaluating the Lisp expression expr. The evaluation takes place at call time, in the current lexical environment. `(eval expr)` Match the rx form that is the result from evaluating the Lisp expression expr. The evaluation takes place at macro-expansion time for `rx`, at call time for `rx-to-string`, in the current global environment. elisp None ### Symbol Components Each symbol has four components (or “cells”), each of which references another object: Print name The symbol’s name. Value The symbol’s current value as a variable. Function The symbol’s function definition. It can also hold a symbol, a keymap, or a keyboard macro. Property list The symbol’s property list. The print name cell always holds a string, and cannot be changed. Each of the other three cells can be set to any Lisp object. The print name cell holds the string that is the name of a symbol. Since symbols are represented textually by their names, it is important not to have two symbols with the same name. The Lisp reader ensures this: every time it reads a symbol, it looks for an existing symbol with the specified name before it creates a new one. To get a symbol’s name, use the function `symbol-name` (see [Creating Symbols](creating-symbols)). However, although each symbol has only one unique *print name*, it is nevertheless possible to refer to that same symbol via different alias names called “shorthands” (see [Shorthands](shorthands)). The value cell holds a symbol’s value as a variable, which is what you get if the symbol itself is evaluated as a Lisp expression. See [Variables](variables), for details about how values are set and retrieved, including complications such as *local bindings* and *scoping rules*. Most symbols can have any Lisp object as a value, but certain special symbols have values that cannot be changed; these include `nil` and `t`, and any symbol whose name starts with ‘`:`’ (those are called *keywords*). See [Constant Variables](constant-variables). The function cell holds a symbol’s function definition. Often, we refer to “the function `foo`” when we really mean the function stored in the function cell of `foo`; we make the distinction explicit only when necessary. Typically, the function cell is used to hold a function (see [Functions](functions)) or a macro (see [Macros](macros)). However, it can also be used to hold a symbol (see [Function Indirection](function-indirection)), keyboard macro (see [Keyboard Macros](keyboard-macros)), keymap (see [Keymaps](keymaps)), or autoload object (see [Autoloading](autoloading)). To get the contents of a symbol’s function cell, use the function `symbol-function` (see [Function Cells](function-cells)). The property list cell normally should hold a correctly formatted property list. To get a symbol’s property list, use the function `symbol-plist`. See [Symbol Properties](symbol-properties). The function cell or the value cell may be *void*, which means that the cell does not reference any object. (This is not the same thing as holding the symbol `void`, nor the same as holding the symbol `nil`.) Examining a function or value cell that is void results in an error, such as ‘`Symbol's value as variable is void`’. Because each symbol has separate value and function cells, variables names and function names do not conflict. For example, the symbol `buffer-file-name` has a value (the name of the file being visited in the current buffer) as well as a function definition (a primitive function that returns the name of the file): ``` buffer-file-name ⇒ "/gnu/elisp/symbols.texi" (symbol-function 'buffer-file-name) ⇒ #<subr buffer-file-name> ``` elisp None #### Process-based JSONRPC connections For convenience, the `jsonrpc` library comes with a built-in `jsonrpc-process-connection` transport implementation that can talk to local subprocesses (using the standard input and standard output); or TCP hosts (using sockets); or any other remote endpoint that Emacs’s process object can represent (see [Processes](processes)). Using this transport, the JSONRPC messages are encoded on the wire as plain text and prefaced by some basic HTTP-style enveloping headers, such as “Content-Length”. For an example of an application using this transport scheme on top of JSONRPC, see the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/specification). Along with the mandatory `:request-dispatcher` and `:notification-dispatcher` initargs, users of the `jsonrpc-process-connection` class should pass the following initargs as keyword-value pairs to `make-instance`: `:process` Value must be a live process object or a function of no arguments producing one such object. If passed a process object, the object is expected to contain a pre-established connection; otherwise, the function is called immediately after the object is made. `:on-shutdown` Value must be a function of a single argument, the `jsonrpc-process-connection` object. The function is called after the underlying process object has been deleted (either deliberately by `jsonrpc-shutdown`, or unexpectedly, because of some external cause). elisp None Positions --------- A *position* is the index of a character in the text of a buffer. More precisely, a position identifies the place between two characters (or before the first character, or after the last character), so we can speak of the character before or after a given position. However, we often speak of the character “at” a position, meaning the character after that position. Positions are usually represented as integers starting from 1, but can also be represented as *markers*—special objects that relocate automatically when text is inserted or deleted so they stay with the surrounding characters. Functions that expect an argument to be a position (an integer), but accept a marker as a substitute, normally ignore which buffer the marker points into; they convert the marker to an integer, and use that integer, exactly as if you had passed the integer as the argument, even if the marker points to the wrong buffer. A marker that points nowhere cannot convert to an integer; using it instead of an integer causes an error. See [Markers](markers). See also the field feature (see [Fields](fields)), which provides functions that are used by many cursor-motion commands. | | | | | --- | --- | --- | | • [Point](point) | | The special position where editing takes place. | | • [Motion](motion) | | Changing point. | | • [Excursions](excursions) | | Temporary motion and buffer changes. | | • [Narrowing](narrowing) | | Restricting editing to a portion of the buffer. |
programming_docs
elisp None #### The Top Level of Mode Line Control The variable in overall control of the mode line is `mode-line-format`. User Option: **mode-line-format** The value of this variable is a mode line construct that controls the contents of the mode-line. It is always buffer-local in all buffers. If you set this variable to `nil` in a buffer, that buffer does not have a mode line. (A window that is just one line tall also does not display a mode line.) The default value of `mode-line-format` is designed to use the values of other variables such as `mode-line-position` and `mode-line-modes` (which in turn incorporates the values of the variables `mode-name` and `minor-mode-alist`). Very few modes need to alter `mode-line-format` itself. For most purposes, it is sufficient to alter some of the variables that `mode-line-format` either directly or indirectly refers to. If you do alter `mode-line-format` itself, the new value should use the same variables that appear in the default value (see [Mode Line Variables](mode-line-variables)), rather than duplicating their contents or displaying the information in another fashion. This way, customizations made by the user or by Lisp programs (such as `display-time` and major modes) via changes to those variables remain effective. Here is a hypothetical example of a `mode-line-format` that might be useful for Shell mode (in reality, Shell mode does not set `mode-line-format`): ``` (setq mode-line-format (list "-" 'mode-line-mule-info 'mode-line-modified 'mode-line-frame-identification "%b--" ``` ``` ;; Note that this is evaluated while making the list. ;; It makes a mode line construct which is just a string. (getenv "HOST") ``` ``` ":" 'default-directory " " 'global-mode-string " %[(" '(:eval (format-time-string "%F")) 'mode-line-process 'minor-mode-alist "%n" ")%]--" ``` ``` '(which-function-mode ("" which-func-format "--")) '(line-number-mode "L%l--") '(column-number-mode "C%c--") '(-3 "%p"))) ``` (The variables `line-number-mode`, `column-number-mode` and `which-function-mode` enable particular minor modes; as usual, these variable names are also the minor mode command names.) elisp None #### Defining Minor Modes The macro `define-minor-mode` offers a convenient way of implementing a mode in one self-contained definition. Macro: **define-minor-mode** *mode doc keyword-args… body…* This macro defines a new minor mode whose name is mode (a symbol). It defines a command named mode to toggle the minor mode, with doc as its documentation string. The toggle command takes one optional (prefix) argument. If called interactively with no argument it toggles the mode on or off. A positive prefix argument enables the mode, any other prefix argument disables it. From Lisp, an argument of `toggle` toggles the mode, whereas an omitted or `nil` argument enables the mode. This makes it easy to enable the minor mode in a major mode hook, for example. If doc is `nil`, the macro supplies a default documentation string explaining the above. By default, it also defines a variable named mode, which is set to `t` or `nil` by enabling or disabling the mode. The keyword-args consist of keywords followed by corresponding values. A few keywords have special meanings: `:global global` If non-`nil`, this specifies that the minor mode should be global rather than buffer-local. It defaults to `nil`. One of the effects of making a minor mode global is that the mode variable becomes a customization variable. Toggling it through the Customize interface turns the mode on and off, and its value can be saved for future Emacs sessions (see [Saving Customizations](https://www.gnu.org/software/emacs/manual/html_node/emacs/Saving-Customizations.html#Saving-Customizations) in The GNU Emacs Manual. For the saved variable to work, you should ensure that the minor mode function is available each time Emacs starts; usually this is done by marking the `define-minor-mode` form as autoloaded. `:init-value init-value` This is the value to which the mode variable is initialized. Except in unusual circumstances (see below), this value must be `nil`. `:lighter lighter` The string lighter says what to display in the mode line when the mode is enabled; if it is `nil`, the mode is not displayed in the mode line. `:keymap keymap` The optional argument keymap specifies the keymap for the minor mode. If non-`nil`, it should be a variable name (whose value is a keymap), a keymap, or an alist of the form ``` (key-sequence . definition) ``` where each key-sequence and definition are arguments suitable for passing to `define-key` (see [Changing Key Bindings](changing-key-bindings)). If keymap is a keymap or an alist, this also defines the variable `mode-map`. `:variable place` This replaces the default variable mode, used to store the state of the mode. If you specify this, the mode variable is not defined, and any init-value argument is unused. place can be a different named variable (which you must define yourself), or anything that can be used with the `setf` function (see [Generalized Variables](generalized-variables)). place can also be a cons `(get . set)`, where get is an expression that returns the current state, and set is a function of one argument (a state) which should be assigned to place. `:after-hook after-hook` This defines a single Lisp form which is evaluated after the mode hooks have run. It should not be quoted. `:interactive value` Minor modes are interactive commands by default. If value is `nil`, this is inhibited. If value is a list of symbols, it’s used to say which major modes this minor mode is useful in. Any other keyword arguments are passed directly to the `defcustom` generated for the variable mode. The command named mode first performs the standard actions such as setting the variable named mode and then executes the body forms, if any. It then runs the mode hook variable `mode-hook` and finishes by evaluating any form in `:after-hook`. (Note that all of this, including running the hook, is done both when the mode is enabled and disabled.) The initial value must be `nil` except in cases where (1) the mode is preloaded in Emacs, or (2) it is painless for loading to enable the mode even though the user did not request it. For instance, if the mode has no effect unless something else is enabled, and will always be loaded by that time, enabling it by default is harmless. But these are unusual circumstances. Normally, the initial value must be `nil`. The name `easy-mmode-define-minor-mode` is an alias for this macro. Here is an example of using `define-minor-mode`: ``` (define-minor-mode hungry-mode "Toggle Hungry mode. Interactively with no argument, this command toggles the mode. A positive prefix argument enables the mode, any other prefix argument disables it. From Lisp, argument omitted or nil enables the mode, `toggle' toggles the state. When Hungry mode is enabled, the control delete key gobbles all preceding whitespace except the last. See the command \\[hungry-electric-delete]." ;; The initial value. nil ;; The indicator for the mode line. " Hungry" ;; The minor mode bindings. '(([C-backspace] . hungry-electric-delete))) ``` This defines a minor mode named “Hungry mode”, a command named `hungry-mode` to toggle it, a variable named `hungry-mode` which indicates whether the mode is enabled, and a variable named `hungry-mode-map` which holds the keymap that is active when the mode is enabled. It initializes the keymap with a key binding for `C-DEL`. There are no body forms—many minor modes don’t need any. Here’s an equivalent way to write it: ``` (define-minor-mode hungry-mode "Toggle Hungry mode. ...rest of documentation as before..." ;; The initial value. :init-value nil ;; The indicator for the mode line. :lighter " Hungry" ;; The minor mode bindings. :keymap '(([C-backspace] . hungry-electric-delete) ([C-M-backspace] . (lambda () (interactive) (hungry-electric-delete t))))) ``` Macro: **define-globalized-minor-mode** *global-mode mode turn-on keyword-args… body…* This defines a global toggle named global-mode whose meaning is to enable or disable the buffer-local minor mode mode in all (or some; see below) buffers. It also executes the body forms. To turn on the minor mode in a buffer, it uses the function turn-on; to turn off the minor mode, it calls mode with -1 as argument. Globally enabling the mode also affects buffers subsequently created by visiting files, and buffers that use a major mode other than Fundamental mode; but it does not detect the creation of a new buffer in Fundamental mode. This defines the customization option global-mode (see [Customization](customization)), which can be toggled in the Customize interface to turn the minor mode on and off. As with `define-minor-mode`, you should ensure that the `define-globalized-minor-mode` form is evaluated each time Emacs starts, for example by providing a `:require` keyword. Use `:group group` in keyword-args to specify the custom group for the mode variable of the global minor mode. By default, the buffer-local minor mode variable that says whether the mode is switched on or off is the same as the name of the mode itself. Use `:variable variable` if that’s not the case–some minor modes use a different variable to store this state information. Generally speaking, when you define a globalized minor mode, you should also define a non-globalized version, so that people can use (or disable) it in individual buffers. This also allows them to disable a globally enabled minor mode in a specific major mode, by using that mode’s hook. If given a `:predicate` keyword, a user option called the same as the global mode variable, but with `-modes` instead of `-mode` at the end will be created. The variable is used as a predicate that specifies which major modes the minor mode should be activated in. Valid values include `t` (use in all major modes, `nil` (use in no major modes), or a list of mode names (or `(not mode-name ...)`) elements (as well as `t` and `nil`). ``` (c-mode (not mail-mode message-mode) text-mode) ``` This means “use in modes derived from `c-mode`, and not in modes derived from `message-mode` or `mail-mode`, but do use in modes derived from `text-mode`, and otherwise no other modes”. ``` ((not c-mode) t) ``` This means “don’t use modes derived from `c-mode`, but use everywhere else”. ``` (text-mode) ``` This means “use in modes derived from `text-mode`, but nowhere else”. (There’s an implicit `nil` element at the end.) elisp None Functions --------- A Lisp program is composed mainly of Lisp functions. This chapter explains what functions are, how they accept arguments, and how to define them. | | | | | --- | --- | --- | | • [What Is a Function](what-is-a-function) | | Lisp functions vs. primitives; terminology. | | • [Lambda Expressions](lambda-expressions) | | How functions are expressed as Lisp objects. | | • [Function Names](function-names) | | A symbol can serve as the name of a function. | | • [Defining Functions](defining-functions) | | Lisp expressions for defining functions. | | • [Calling Functions](calling-functions) | | How to use an existing function. | | • [Mapping Functions](mapping-functions) | | Applying a function to each element of a list, etc. | | • [Anonymous Functions](anonymous-functions) | | Lambda expressions are functions with no names. | | • [Generic Functions](generic-functions) | | Polymorphism, Emacs-style. | | • [Function Cells](function-cells) | | Accessing or setting the function definition of a symbol. | | • [Closures](closures) | | Functions that enclose a lexical environment. | | • [Advising Functions](advising-functions) | | Adding to the definition of a function. | | • [Obsolete Functions](obsolete-functions) | | Declaring functions obsolete. | | • [Inline Functions](inline-functions) | | Functions that the compiler will expand inline. | | • [Declare Form](declare-form) | | Adding additional information about a function. | | • [Declaring Functions](declaring-functions) | | Telling the compiler that a function is defined. | | • [Function Safety](function-safety) | | Determining whether a function is safe to call. | | • [Related Topics](related-topics) | | Cross-references to specific Lisp primitives that have a special bearing on how functions work. | elisp None ### Forcing Redisplay Emacs normally tries to redisplay the screen whenever it waits for input. With the following function, you can request an immediate attempt to redisplay, in the middle of Lisp code, without actually waiting for input. Function: **redisplay** *&optional force* This function tries immediately to redisplay. The optional argument force, if non-`nil`, forces the redisplay to be performed, instead of being preempted if input is pending. The function returns `t` if it actually tried to redisplay, and `nil` otherwise. A value of `t` does not mean that redisplay proceeded to completion; it could have been preempted by newly arriving input. Although `redisplay` tries immediately to redisplay, it does not change how Emacs decides which parts of its frame(s) to redisplay. By contrast, the following function adds certain windows to the pending redisplay work (as if their contents had completely changed), but does not immediately try to perform redisplay. Function: **force-window-update** *&optional object* This function forces some or all windows to be updated the next time Emacs does a redisplay. If object is a window, that window is to be updated. If object is a buffer or buffer name, all windows displaying that buffer are to be updated. If object is `nil` (or omitted), all windows are to be updated. This function does not do a redisplay immediately; Emacs does that as it waits for input, or when the function `redisplay` is called. Variable: **pre-redisplay-function** A function run just before redisplay. It is called with one argument, the set of windows to be redisplayed. The set can be `nil`, meaning only the selected window, or `t`, meaning all the windows. Variable: **pre-redisplay-functions** This hook is run just before redisplay. It is called once in each window that is about to be redisplayed, with `current-buffer` set to the buffer displayed in that window. elisp None ### The Echo Area The *echo area* is used for displaying error messages (see [Errors](errors)), for messages made with the `message` primitive, and for echoing keystrokes. It is not the same as the minibuffer, despite the fact that the minibuffer appears (when active) in the same place on the screen as the echo area. See [The Minibuffer](https://www.gnu.org/software/emacs/manual/html_node/emacs/Minibuffer.html#Minibuffer) in The GNU Emacs Manual. Apart from the functions documented in this section, you can print Lisp objects to the echo area by specifying `t` as the output stream. See [Output Streams](output-streams). | | | | | --- | --- | --- | | • [Displaying Messages](displaying-messages) | | Explicitly displaying text in the echo area. | | • [Progress](progress) | | Informing user about progress of a long operation. | | • [Logging Messages](logging-messages) | | Echo area messages are logged for the user. | | • [Echo Area Customization](echo-area-customization) | | Controlling the echo area. | elisp None #### Using the Debugger When the debugger is entered, it displays the previously selected buffer in one window and a buffer named `\*Backtrace\*` in another window. The backtrace buffer contains one line for each level of Lisp function execution currently going on. At the beginning of this buffer is a message describing the reason that the debugger was invoked (such as the error message and associated data, if it was invoked due to an error). The backtrace buffer is read-only and uses a special major mode, Debugger mode, in which letters are defined as debugger commands. The usual Emacs editing commands are available; thus, you can switch windows to examine the buffer that was being edited at the time of the error, switch buffers, visit files, or do any other sort of editing. However, the debugger is a recursive editing level (see [Recursive Editing](recursive-editing)) and it is wise to go back to the backtrace buffer and exit the debugger (with the `q` command) when you are finished with it. Exiting the debugger gets out of the recursive edit and buries the backtrace buffer. (You can customize what the `q` command does with the backtrace buffer by setting the variable `debugger-bury-or-kill`. For example, set it to `kill` if you prefer to kill the buffer rather than bury it. Consult the variable’s documentation for more possibilities.) When the debugger has been entered, the `debug-on-error` variable is temporarily set according to `eval-expression-debug-on-error`. If the latter variable is non-`nil`, `debug-on-error` will temporarily be set to `t`. This means that any further errors that occur while doing a debugging session will (by default) trigger another backtrace. If this is not what you want, you can either set `eval-expression-debug-on-error` to `nil`, or set `debug-on-error` to `nil` in `debugger-mode-hook`. The debugger itself must be run byte-compiled, since it makes assumptions about the state of the Lisp interpreter. These assumptions are false if the debugger is running interpreted. elisp None ### Global Variables The simplest way to use a variable is *globally*. This means that the variable has just one value at a time, and this value is in effect (at least for the moment) throughout the Lisp system. The value remains in effect until you specify a new one. When a new value replaces the old one, no trace of the old value remains in the variable. You specify a value for a symbol with `setq`. For example, ``` (setq x '(a b)) ``` gives the variable `x` the value `(a b)`. Note that `setq` is a special form (see [Special Forms](special-forms)); it does not evaluate its first argument, the name of the variable, but it does evaluate the second argument, the new value. Once the variable has a value, you can refer to it by using the symbol itself as an expression. Thus, ``` x ⇒ (a b) ``` assuming the `setq` form shown above has already been executed. If you do set the same variable again, the new value replaces the old one: ``` x ⇒ (a b) ``` ``` (setq x 4) ⇒ 4 ``` ``` x ⇒ 4 ``` elisp None #### Processes and Threads Because threads were a relatively late addition to Emacs Lisp, and due to the way dynamic binding was sometimes used in conjunction with `accept-process-output`, by default a process is locked to the thread that created it. When a process is locked to a thread, output from the process can only be accepted by that thread. A Lisp program can specify to which thread a process is to be locked, or instruct Emacs to unlock a process, in which case its output can be processed by any thread. Only a single thread will wait for output from a given process at one time—once one thread begins waiting for output, the process is temporarily locked until `accept-process-output` or `sit-for` returns. If the thread exits, all the processes locked to it are unlocked. Function: **process-thread** *process* Return the thread to which process is locked. If process is unlocked, return `nil`. Function: **set-process-thread** *process thread* Set the locking thread of process to thread. thread may be `nil`, in which case the process is unlocked. elisp None ### Expansion of a Macro Call A macro call looks just like a function call in that it is a list which starts with the name of the macro. The rest of the elements of the list are the arguments of the macro. Evaluation of the macro call begins like evaluation of a function call except for one crucial difference: the macro arguments are the actual expressions appearing in the macro call. They are not evaluated before they are given to the macro definition. By contrast, the arguments of a function are results of evaluating the elements of the function call list. Having obtained the arguments, Lisp invokes the macro definition just as a function is invoked. The argument variables of the macro are bound to the argument values from the macro call, or to a list of them in the case of a `&rest` argument. And the macro body executes and returns its value just as a function body does. The second crucial difference between macros and functions is that the value returned by the macro body is an alternate Lisp expression, also known as the *expansion* of the macro. The Lisp interpreter proceeds to evaluate the expansion as soon as it comes back from the macro. Since the expansion is evaluated in the normal manner, it may contain calls to other macros. It may even be a call to the same macro, though this is unusual. Note that Emacs tries to expand macros when loading an uncompiled Lisp file. This is not always possible, but if it is, it speeds up subsequent execution. See [How Programs Do Loading](how-programs-do-loading). You can see the expansion of a given macro call by calling `macroexpand`. Function: **macroexpand** *form &optional environment* This function expands form, if it is a macro call. If the result is another macro call, it is expanded in turn, until something which is not a macro call results. That is the value returned by `macroexpand`. If form is not a macro call to begin with, it is returned as given. Note that `macroexpand` does not look at the subexpressions of form (although some macro definitions may do so). Even if they are macro calls themselves, `macroexpand` does not expand them. The function `macroexpand` does not expand calls to inline functions. Normally there is no need for that, since a call to an inline function is no harder to understand than a call to an ordinary function. If environment is provided, it specifies an alist of macro definitions that shadow the currently defined macros. Byte compilation uses this feature. ``` (defmacro inc (var) (list 'setq var (list '1+ var))) ``` ``` (macroexpand '(inc r)) ⇒ (setq r (1+ r)) ``` ``` (defmacro inc2 (var1 var2) (list 'progn (list 'inc var1) (list 'inc var2))) ``` ``` (macroexpand '(inc2 r s)) ⇒ (progn (inc r) (inc s)) ; `inc` not expanded here. ``` Function: **macroexpand-all** *form &optional environment* `macroexpand-all` expands macros like `macroexpand`, but will look for and expand all macros in form, not just at the top-level. If no macros are expanded, the return value is `eq` to form. Repeating the example used for `macroexpand` above with `macroexpand-all`, we see that `macroexpand-all` *does* expand the embedded calls to `inc`: ``` (macroexpand-all '(inc2 r s)) ⇒ (progn (setq r (1+ r)) (setq s (1+ s))) ``` Function: **macroexpand-1** *form &optional environment* This function expands macros like `macroexpand`, but it only performs one step of the expansion: if the result is another macro call, `macroexpand-1` will not expand it.
programming_docs
elisp None ### Output Functions This section describes the Lisp functions for printing Lisp objects—converting objects into their printed representation. Some of the Emacs printing functions add quoting characters to the output when necessary so that it can be read properly. The quoting characters used are ‘`"`’ and ‘`\`’; they distinguish strings from symbols, and prevent punctuation characters in strings and symbols from being taken as delimiters when reading. See [Printed Representation](printed-representation), for full details. You specify quoting or no quoting by the choice of printing function. If the text is to be read back into Lisp, then you should print with quoting characters to avoid ambiguity. Likewise, if the purpose is to describe a Lisp object clearly for a Lisp programmer. However, if the purpose of the output is to look nice for humans, then it is usually better to print without quoting. Lisp objects can refer to themselves. Printing a self-referential object in the normal way would require an infinite amount of text, and the attempt could cause infinite recursion. Emacs detects such recursion and prints ‘`#level`’ instead of recursively printing an object already being printed. For example, here ‘`#0`’ indicates a recursive reference to the object at level 0 of the current print operation: ``` (setq foo (list nil)) ⇒ (nil) (setcar foo foo) ⇒ (#0) ``` In the functions below, stream stands for an output stream. (See the previous section for a description of output streams. Also See [external-debugging-output](output-streams#external_002ddebugging_002doutput), a useful stream value for debugging.) If stream is `nil` or omitted, it defaults to the value of `standard-output`. Function: **print** *object &optional stream* The `print` function is a convenient way of printing. It outputs the printed representation of object to stream, printing in addition one newline before object and another after it. Quoting characters are used. `print` returns object. For example: ``` (progn (print 'The\ cat\ in) (print "the hat") (print " came back")) -| -| The\ cat\ in -| -| "the hat" -| -| " came back" ⇒ " came back" ``` Function: **prin1** *object &optional stream* This function outputs the printed representation of object to stream. It does not print newlines to separate output as `print` does, but it does use quoting characters just like `print`. It returns object. ``` (progn (prin1 'The\ cat\ in) (prin1 "the hat") (prin1 " came back")) -| The\ cat\ in"the hat"" came back" ⇒ " came back" ``` Function: **princ** *object &optional stream* This function outputs the printed representation of object to stream. It returns object. This function is intended to produce output that is readable by people, not by `read`, so it doesn’t insert quoting characters and doesn’t put double-quotes around the contents of strings. It does not add any spacing between calls. ``` (progn (princ 'The\ cat) (princ " in the \"hat\"")) -| The cat in the "hat" ⇒ " in the \"hat\"" ``` Function: **terpri** *&optional stream ensure* This function outputs a newline to stream. The name stands for “terminate print”. If ensure is non-`nil` no newline is printed if stream is already at the beginning of a line. Note in this case stream can not be a function and an error is signaled if it is. This function returns `t` if a newline is printed. Function: **write-char** *character &optional stream* This function outputs character to stream. It returns character. Function: **prin1-to-string** *object &optional noescape* This function returns a string containing the text that `prin1` would have printed for the same argument. ``` (prin1-to-string 'foo) ⇒ "foo" ``` ``` (prin1-to-string (mark-marker)) ⇒ "#<marker at 2773 in strings.texi>" ``` If noescape is non-`nil`, that inhibits use of quoting characters in the output. (This argument is supported in Emacs versions 19 and later.) ``` (prin1-to-string "foo") ⇒ "\"foo\"" ``` ``` (prin1-to-string "foo" t) ⇒ "foo" ``` See `format`, in [Formatting Strings](formatting-strings), for other ways to obtain the printed representation of a Lisp object as a string. Macro: **with-output-to-string** *body…* This macro executes the body forms with `standard-output` set up to feed output into a string. Then it returns that string. For example, if the current buffer name is ‘`foo`’, ``` (with-output-to-string (princ "The buffer is ") (princ (buffer-name))) ``` returns `"The buffer is foo"`. Function: **pp** *object &optional stream* This function outputs object to stream, just like `prin1`, but does it in a prettier way. That is, it’ll indent and fill the object to make it more readable for humans. If you need to use binary I/O in batch mode, e.g., use the functions described in this section to write out arbitrary binary data or avoid conversion of newlines on non-POSIX hosts, see [set-binary-mode](input-functions). elisp None #### Click Events When the user presses a mouse button and releases it at the same location, that generates a *click* event. Depending on how your window-system reports mouse-wheel events, turning the mouse wheel can generate either a mouse click or a mouse-wheel event. All mouse event share the same format: ``` (event-type position click-count) ``` event-type This is a symbol that indicates which mouse button was used. It is one of the symbols `mouse-1`, `mouse-2`, …, where the buttons are numbered left to right. For mouse-wheel event, it can be `wheel-up` or `wheel-down`. You can also use prefixes ‘`A-`’, ‘`C-`’, ‘`H-`’, ‘`M-`’, ‘`S-`’ and ‘`s-`’ for modifiers alt, control, hyper, meta, shift and super, just as you would with function keys. This symbol also serves as the event type of the event. Key bindings describe events by their types; thus, if there is a key binding for `mouse-1`, that binding would apply to all events whose event-type is `mouse-1`. position This is a *mouse position list* specifying where the mouse event occurred; see below for details. click-count This is the number of rapid repeated presses so far of the same mouse button or the number of repeated turns of the wheel. See [Repeat Events](repeat-events). To access the contents of a mouse position list in the position slot of a mouse event, you should typically use the functions documented in [Accessing Mouse](accessing-mouse). The explicit format of the list depends on where the event occurred. For clicks in the text area, mode line, header line, tab line, or in the fringe or marginal areas, the mouse position list has the form ``` (window pos-or-area (x . y) timestamp object text-pos (col . row) image (dx . dy) (width . height)) ``` The meanings of these list elements are as follows: window The window in which the mouse event occurred. pos-or-area The buffer position of the character clicked on in the text area; or, if the event was outside the text area, the window area where it occurred. It is one of the symbols `mode-line`, `header-line`, `tab-line`, `vertical-line`, `left-margin`, `right-margin`, `left-fringe`, or `right-fringe`. In one special case, pos-or-area is a list containing a symbol (one of the symbols listed above) instead of just the symbol. This happens after the imaginary prefix keys for the event are registered by Emacs. See [Key Sequence Input](key-sequence-input). x, y The relative pixel coordinates of the event. For events in the text area of a window, the coordinate origin `(0 . 0)` is taken to be the top left corner of the text area. See [Window Sizes](window-sizes). For events in a mode line, header line or tab line, the coordinate origin is the top left corner of the window itself. For fringes, margins, and the vertical border, x does not have meaningful data. For fringes and margins, y is relative to the bottom edge of the header line. In all cases, the x and y coordinates increase rightward and downward respectively. timestamp The time at which the event occurred, as an integer number of milliseconds since a system-dependent initial time. object Either `nil`, which means the event occurred on buffer text, or a cons cell of the form (string . string-pos) if there is a string from a text property or an overlay at the event position. string The string which was clicked on, including any properties. string-pos The position in the string where the click occurred. text-pos For clicks on a marginal area or on a fringe, this is the buffer position of the first visible character in the corresponding line in the window. For clicks on the mode line, the header line or the tab line, this is `nil`. For other events, it is the buffer position closest to the click. col, row These are the actual column and row coordinate numbers of the glyph under the x, y position. If x lies beyond the last column of actual text on its line, col is reported by adding fictional extra columns that have the default character width. Row 0 is taken to be the header line if the window has one, or Row 1 if the window also has the tab line, or the topmost row of the text area otherwise. Column 0 is taken to be the leftmost column of the text area for clicks on a window text area, or the leftmost mode line or header line column for clicks there. For clicks on fringes or vertical borders, these have no meaningful data. For clicks on margins, col is measured from the left edge of the margin area and row is measured from the top of the margin area. image If there is an image at the click location, this is the image object as returned by `find-image` (see [Defining Images](defining-images)); otherwise this is `nil`. dx, dy These are the pixel coordinates of the click, relative to the top left corner of object, which is `(0 . 0)`. If object is `nil`, which stands for a buffer, the coordinates are relative to the top left corner of the character glyph clicked on. width, height If the click is on a character, either from buffer text or from overlay or display string, these are the pixel width and height of that character’s glyph; otherwise they are dimensions of object clicked on. For clicks on a scroll bar, position has this form: ``` (window area (portion . whole) timestamp part) ``` window The window whose scroll bar was clicked on. area This is the symbol `vertical-scroll-bar`. portion The number of pixels from the top of the scroll bar to the click position. On some toolkits, including GTK+, Emacs cannot extract this data, so the value is always `0`. whole The total length, in pixels, of the scroll bar. On some toolkits, including GTK+, Emacs cannot extract this data, so the value is always `0`. timestamp The time at which the event occurred, in milliseconds. On some toolkits, including GTK+, Emacs cannot extract this data, so the value is always `0`. part The part of the scroll bar on which the click occurred. It is one of the symbols `handle` (the scroll bar handle), `above-handle` (the area above the handle), `below-handle` (the area below the handle), `up` (the up arrow at one end of the scroll bar), or `down` (the down arrow at one end of the scroll bar). For clicks on the frame’s internal border (see [Frame Layout](frame-layout)), the frame’s tool bar (see [Tool Bar](tool-bar)) or tab bar, position has this form: ``` (frame part (X . Y) timestamp) ``` frame The frame whose internal border or tool bar or tab bar was clicked on. part The part of the frame which was clicked on. This can be one of the following: `tool-bar` The frame has a tool bar, and the event was in the tool-bar area. `tab-bar` The frame has a tab bar, and the event was in the tab-bar area. `left-edge` `top-edge` `right-edge` `bottom-edge` The click was on the corresponding border at an offset of at least one canonical character from the border’s nearest corner. `top-left-corner` `top-right-corner` `bottom-right-corner` `bottom-left-corner` The click was on the corresponding corner of the internal border. `nil` The frame does not have an internal border, and the event was not on the tab bar or the tool bar. This usually happens on text-mode frames. This can also happen on GUI frames with internal border if the frame doesn’t have its `drag-internal-border` parameter (see [Mouse Dragging Parameters](mouse-dragging-parameters)) set to a non-`nil` value. elisp None #### The Data Structure of the Mode Line The mode line contents are controlled by a data structure called a *mode line construct*, made up of lists, strings, symbols, and numbers kept in buffer-local variables. Each data type has a specific meaning for the mode line appearance, as described below. The same data structure is used for constructing frame titles (see [Frame Titles](frame-titles)) and header lines (see [Header Lines](header-lines)). A mode line construct may be as simple as a fixed string of text, but it usually specifies how to combine fixed strings with variables’ values to construct the text. Many of these variables are themselves defined to have mode line constructs as their values. Here are the meanings of various data types as mode line constructs: `string` A string as a mode line construct appears verbatim except for *`%`-constructs* in it. These stand for substitution of other data; see [%-Constructs](_0025_002dconstructs). If parts of the string have `face` properties, they control display of the text just as they would text in the buffer. Any characters which have no `face` properties are displayed, by default, in the face `mode-line` or `mode-line-inactive` (see [Standard Faces](https://www.gnu.org/software/emacs/manual/html_node/emacs/Standard-Faces.html#Standard-Faces) in The GNU Emacs Manual). The `help-echo` and `keymap` properties in string have special meanings. See [Properties in Mode](properties-in-mode). `symbol` A symbol as a mode line construct stands for its value. The value of symbol is used as a mode line construct, in place of symbol. However, the symbols `t` and `nil` are ignored, as is any symbol whose value is void. There is one exception: if the value of symbol is a string, it is displayed verbatim: the `%`-constructs are not recognized. Unless symbol is marked as risky (i.e., it has a non-`nil` `risky-local-variable` property), all text properties specified in symbol’s value are ignored. This includes the text properties of strings in symbol’s value, as well as all `:eval` and `:propertize` forms in it. (The reason for this is security: non-risky variables could be set automatically from file variables without prompting the user.) `(string rest…)` `(list rest…)` A list whose first element is a string or list means to process all the elements recursively and concatenate the results. This is the most common form of mode line construct. (Note that text properties are handled specially (for reasons of efficiency) when displaying strings in the mode line: Only the text property on the first character of the string are considered, and they are then used over the entire string. If you need a string with different text properties, you have to use the special `:propertize` mode line construct.) `(:eval form)` A list whose first element is the symbol `:eval` says to evaluate form, and use the result as a string to display. Make sure this evaluation cannot load any files, as doing so could cause infinite recursion. `(:propertize elt props…)` A list whose first element is the symbol `:propertize` says to process the mode line construct elt recursively, then add the text properties specified by props to the result. The argument props should consist of zero or more pairs text-property value. If elt is or produces a string with text properties, all the characters of that string should have the same properties, or else some of them might be removed by `:propertize`. `(symbol then else)` A list whose first element is a symbol that is not a keyword specifies a conditional. Its meaning depends on the value of symbol. If symbol has a non-`nil` value, the second element, then, is processed recursively as a mode line construct. Otherwise, the third element, else, is processed recursively. You may omit else; then the mode line construct displays nothing if the value of symbol is `nil` or void. `(width rest…)` A list whose first element is an integer specifies truncation or padding of the results of rest. The remaining elements rest are processed recursively as mode line constructs and concatenated together. When width is positive, the result is space filled on the right if its width is less than width. When width is negative, the result is truncated on the right to -width columns if its width exceeds -width. For example, the usual way to show what percentage of a buffer is above the top of the window is to use a list like this: `(-3 "%p")`. elisp None GNU Emacs Internals -------------------- This chapter describes how the runnable Emacs executable is dumped with the preloaded Lisp libraries in it, how storage is allocated, and some internal aspects of GNU Emacs that may be of interest to C programmers. | | | | | --- | --- | --- | | • [Building Emacs](building-emacs) | | How the dumped Emacs is made. | | • [Pure Storage](pure-storage) | | Kludge to make preloaded Lisp functions shareable. | | • [Garbage Collection](garbage-collection) | | Reclaiming space for Lisp objects no longer used. | | • [Stack-allocated Objects](stack_002dallocated-objects) | | Temporary conses and strings on C stack. | | • [Memory Usage](memory-usage) | | Info about total size of Lisp objects made so far. | | • [C Dialect](c-dialect) | | What C variant Emacs is written in. | | • [Writing Emacs Primitives](writing-emacs-primitives) | | Writing C code for Emacs. | | • [Writing Dynamic Modules](writing-dynamic-modules) | | Writing loadable modules for Emacs. | | • [Object Internals](object-internals) | | Data formats of buffers, windows, processes. | | • [C Integer Types](c-integer-types) | | How C integer types are used inside Emacs. | elisp None #### Sample Indentation Rules Here is an example of an indentation function: ``` (defun sample-smie-rules (kind token) (pcase (cons kind token) (`(:elem . basic) sample-indent-basic) (`(,_ . ",") (smie-rule-separator kind)) (`(:after . ":=") sample-indent-basic) (`(:before . ,(or `"begin" `"(" `"{")) (if (smie-rule-hanging-p) (smie-rule-parent))) (`(:before . "if") (and (not (smie-rule-bolp)) (smie-rule-prev-p "else") (smie-rule-parent))))) ``` A few things to note: * The first case indicates the basic indentation increment to use. If `sample-indent-basic` is `nil`, then SMIE uses the global setting `smie-indent-basic`. The major mode could have set `smie-indent-basic` buffer-locally instead, but that is discouraged. * The rule for the token `","` make SMIE try to be more clever when the comma separator is placed at the beginning of lines. It tries to outdent the separator so as to align the code after the comma; for example: ``` x = longfunctionname ( arg1 , arg2 ); ``` * The rule for indentation after `":="` exists because otherwise SMIE would treat `":="` as an infix operator and would align the right argument with the left one. * The rule for indentation before `"begin"` is an example of the use of virtual indentation: This rule is used only when `"begin"` is hanging, which can happen only when `"begin"` is not at the beginning of a line. So this is not used when indenting `"begin"` itself but only when indenting something relative to this `"begin"`. Concretely, this rule changes the indentation from: ``` if x > 0 then begin dosomething(x); end ``` to ``` if x > 0 then begin dosomething(x); end ``` * The rule for indentation before `"if"` is similar to the one for `"begin"`, but where the purpose is to treat `"else if"` as a single unit, so as to align a sequence of tests rather than indent each test further to the right. This function does this only in the case where the `"if"` is not placed on a separate line, hence the `smie-rule-bolp` test. If we know that the `"else"` is always aligned with its `"if"` and is always at the beginning of a line, we can use a more efficient rule: ``` ((equal token "if") (and (not (smie-rule-bolp)) (smie-rule-prev-p "else") (save-excursion (sample-smie-backward-token) (cons 'column (current-column))))) ``` The advantage of this formulation is that it reuses the indentation of the previous `"else"`, rather than going all the way back to the first `"if"` of the sequence.
programming_docs