love.graphics (简体中文)

The primary responsibility for the love.graphics module is the drawing of lines, shapes, text, Images and other Drawable objects onto the screen. Its secondary responsibilities include loading external files (including Images and Fonts) into memory, creating specialized objects (such as ParticleSystems or Framebuffers) and managing screen geometry.

love.graphics模块的主要功能是绘制图像(文字、形状、线、图片Image、其他Drawable)到屏幕上。次要功能是将外部文件(图片Image、字体Font)加载到内存中。建立专门的对象进行管理(比如ParticleSystemFramebuffer)。

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.

LÖVE的坐标系统如下图所示,以左上角为原点,横向延伸为X轴,纵向延伸为Y轴。

The LÖVE coordinate system

In many cases, you draw images or shapes in terms of their upper-left corner (See the picture above).

在许多情况下,你绘制的图片和图形都是以它们的左上角为起点。 (如上图)

Many of the functions are used to manipulate the graphics coordinate system, which is essentially the the way coordinates are mapped to the display. You can change the position, scale, and even rotation in this way.

我们提供许多函数来用于操作“图形坐标系统”,坐标系统是图像显示的本质。通过操作坐标,你可以改变位置、大小、甚至旋转。

Types

Canvas Off-screen render target.
Drawable Superclass for all things that can be drawn on screen.
Font Defines the shape of characters than can be drawn onto the screen.
Framebuffer Off-screen render target.
Image Drawable image type.
Mesh A 2D polygon mesh used for drawing arbitrary textured shapes.
ParticleSystem Used to create cool effects, like fire.
PixelEffect Pixel shader effect.
Quad A quadrilateral with texture coordinate information.
Shader Shader effect.
SpriteBatch Store image positions in a buffer, and draw it in one call.
Texture Superclass for drawable objects which represent a texture.

Functions

Drawing

love.graphics.arc (简体中文)Draws an arc.绘制一段弧.Added since 0.8.0
love.graphics.checkMode (简体中文)Checks if a display mode is supported.检查是否支持这种显示模式.
love.graphics.circle (简体中文)Draws a circle.绘制一个圆形.
love.graphics.draw (简体中文)Draws objects on screen.在屏幕上绘制物件。
love.graphics.printf (简体中文)Draws text on screen. If no Font is set, one will be created and set (once) if needed.绘制格式化过的文本,可折行显示、对齐。

Object Creation

love.graphics.newCanvas创建一个新的画布
love.graphics.newFont加载一个新的字体
love.graphics.newFramebuffer创建一个新的帧缓冲区
love.graphics.newImage加载一个新的图像
love.graphics.newImageFont通过加载一个特定格式的图像创建一个新的字体
love.graphics.newParticleSystem创建一个新的粒子系统.好帅的哦!
love.graphics.newPixelEffect创建一个新的PixelEffect,像素影响力?囧
love.graphics.newQuad创建一个新的批发小图~
love.graphics.newScreenshot创建一个截图并返回数据,好东东.
love.graphics.newSpriteBatch创建一个新的精灵组.╮(╯_╰)╭不懂
love.graphics.newStencil创建一个新的模板
love.graphics.setNewFont创建并设置一个新的字体

Graphics State

love.graphics.getBackgroundColorGets the current background color.
love.graphics.getBlendModeGets the blending mode.Added since 0.2.0
love.graphics.getCanvasReturns the current target Canvas.Added since 0.8.0
love.graphics.getColorGets the current color.
love.graphics.getColorMaskGets the active color components used when drawing.Added since 0.9.0
love.graphics.getColorModeGets the color mode (which controls how images are affected by the current color).Added since 0.2.0 Removed in 0.9.0
love.graphics.getDefaultFilterReturns the default scaling filters used with Images, Canvases, and Fonts.Added since 0.9.0
love.graphics.getDefaultImageFilterReturns the default scaling filters.Added since 0.8.0 Removed in 0.9.0
love.graphics.getFontGets the current Font object.
love.graphics.getLineJoinGets the line join style.
love.graphics.getLineStippleGets the current line stipple. Removed in 0.8.0
love.graphics.getLineStyleGets the line style.
love.graphics.getLineWidthGets the current line width.
love.graphics.getMaxImageSizeGets the max supported width or height of Images and Canvases.Added since 0.9.0
love.graphics.getMaxPointSizeGets the max supported point size.
love.graphics.getPixelEffectReturns the current PixelEffect.Added since 0.8.0 Removed in 0.9.0
love.graphics.getPointSizeGets the point size.
love.graphics.getPointStyleGets the current point style.
love.graphics.getRendererInfoGets information about the system's video card and drivers.Added since 0.9.0
love.graphics.getScissorGets the current scissor box.Added since 0.4.0
love.graphics.getShaderGets the current Shader.Added since 0.9.0
love.graphics.getSystemLimitGets the system-dependent maximum value for a love.graphics feature.Added since 0.9.1
love.graphics.isSupportedChecks for the support of graphics related functions.Added since 0.8.0
love.graphics.isWireframeGets whether wireframe mode is used when drawing.Added since 0.9.1
love.graphics.resetResets the current graphics settings.
love.graphics.setBackgroundColorSets the background color.
love.graphics.setBlendModeSets the blending mode.Added since 0.2.0
love.graphics.setCanvasCaptures drawing operations to a CanvasAdded since 0.8.0
love.graphics.setColorSets the color used for drawing.
love.graphics.setColorMaskSets the color mask. Enables or disables specific color components when rendering.Added since 0.9.0
love.graphics.setColorModeSets the color mode (which controls how images are affected by the current color).Added since 0.2.0 Removed in 0.9.0
love.graphics.setDefaultFilterSets the default scaling filters used with Images, Canvases, and Fonts.Added since 0.9.0
love.graphics.setDefaultImageFilterSets the default scaling filters.Added since 0.8.0 Removed in 0.9.0
love.graphics.setFontSet an already-loaded Font as the current font.
love.graphics.setInvertedStencilDefines an inverted stencil.Added since 0.8.0
love.graphics.setLineSets the line width and style. Removed in 0.9.0
love.graphics.setLineJoinSets the line join style.
love.graphics.setLineStippleSets the line stipple pattern. Removed in 0.8.0
love.graphics.setLineStyleSets the line style.
love.graphics.setLineWidthSets the line width.
love.graphics.setPixelEffectRoutes drawing operations through a pixel shader.Added since 0.8.0 Removed in 0.9.0
love.graphics.setPointSets the point size and style. Removed in 0.9.0
love.graphics.setPointSizeSets the point size.
love.graphics.setPointStyleSets the point style.
love.graphics.setRenderTargetCaptures drawing operations to a FramebufferAdded since 0.7.0 Removed in 0.8.0
love.graphics.setScissorSets or disables scissor.Added since 0.4.0
love.graphics.setShaderRoutes drawing operations through a shader.Added since 0.9.0
love.graphics.setStencilDefines or releases a stencil.Added since 0.8.0
love.graphics.setWireframeSets whether wireframe lines will be used when drawing.Added since 0.9.1

Coordinate System

love.graphics.originResets the current coordinate transformation.Added since 0.9.0
love.graphics.popPops the current coordinate transformation from the transformation stack.
love.graphics.pushCopies and pushes the current coordinate transformation to the transformation stack.
love.graphics.rotateRotates the coordinate system in two dimensions.
love.graphics.scaleScales the coordinate system in two dimensions.
love.graphics.shearShears the coordinate system.Added since 0.8.0
love.graphics.translateTranslates the coordinate system in two dimensions.

Window

love.graphics.checkModeChecks if a display mode is supported. Removed in 0.9.0
love.graphics.getCaptionGets the window caption. Removed in 0.9.0
love.graphics.getDimensionsGets the width and height of the window.Added since 0.9.0
love.graphics.getHeightGets the height in pixels of the window.Added since 0.2.1
love.graphics.getModeReturns the current display mode.Added since 0.8.0 Removed in 0.9.0
love.graphics.getModesGets a list of supported fullscreen modes. Removed in 0.9.0
love.graphics.getWidthGets the width in pixels of the window.Added since 0.2.1
love.graphics.hasFocusChecks if the game window has keyboard focus.Added since 0.8.0 Removed in 0.9.0
love.graphics.isCreatedChecks if the display has been set. Removed in 0.9.0
love.graphics.setCaptionSets the window caption. Removed in 0.9.0
love.graphics.setIconSet window icon.Added since 0.7.0 Removed in 0.9.0
love.graphics.setModeChanges the display mode. Removed in 0.9.0
love.graphics.toggleFullscreenToggles fullscreen. Removed in 0.9.0

Enums

AlignModeText alignment.
BlendModeDifferent ways you do alpha blending.Added since 0.2.0
ColorModeControls how drawn images are affected by current color.Added since 0.2.0 Removed in 0.9.0
DrawModeControls whether shapes are drawn as an outline, or filled.
FilterModeHow the image is filtered when scaling.
GraphicsFeatureGraphics features that can be checked for with love.graphics.isSupported.Added since 0.8.0
GraphicsLimitTypes of system-dependent graphics limits.Added since 0.9.1
LineJoinLine join style.
LineStyleThe styles in which lines are drawn.
MeshDrawModeHow a Mesh's vertices are used when drawing.Added since 0.9.0
PointStyleHow points should be drawn.
SpriteBatchUsageUsage hints for SpriteBatches.Added since 0.8.0
TextureFormatControls the canvas texture format.Added since 0.9.0
WrapModeHow the image wraps inside a large Quad.

See Also

Other Languages

Personal tools