Difference between revisions of "love.graphics (简体中文)"

(Created page with "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 responsibi...")
 
Line 37: Line 37:
 
{{#set:Description=Drawing of shapes and images, management of screen geometry.绘制图形图片,管理屏幕显示}}
 
{{#set:Description=Drawing of shapes and images, management of screen geometry.绘制图形图片,管理屏幕显示}}
 
== See Also ==
 
== See Also ==
* [[parent::love]]
+
* [[parent::love (简体中文)]]
 
{{#set:Since=000}}
 
{{#set:Since=000}}
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|love.graphics}}
 
{{i18n|love.graphics}}

Revision as of 02:44, 15 April 2012

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

CanvasOff-screen render target.
DrawableSuperclass for all things that can be drawn on screen.
FontDefines the shape of characters than can be drawn onto the screen.
FramebufferOff-screen render target.
ImageDrawable image type.
MeshA 2D polygon mesh used for drawing arbitrary textured shapes.
ParticleSystemUsed to create cool effects, like fire.
PixelEffectPixel shader effect.
QuadA quadrilateral with texture coordinate information.
ShaderShader effect.
SpriteBatchStore image positions in a buffer, and draw it in one call.
TextDrawable text.
TextureSuperclass for drawable objects which represent a texture.
VideoA drawable video.

Functions

love.graphics.applyTransformApplies the given Transform object to the current coordinate transformation.
love.graphics.arcDraws an arc.
love.graphics.captureScreenshotCreates a screenshot once the current frame is done.
love.graphics.checkModeChecks if a display mode is supported.
love.graphics.circleDraws a circle.
love.graphics.clearClears the screen or active Canvas to the specified color.
love.graphics.discardDiscards the contents of the screen or active Canvas.
love.graphics.drawDraws objects on screen.
love.graphics.drawInstancedDraws many instances of a Mesh with a single draw call, using hardware geometry instancing.
love.graphics.drawLayerDraws a layer of an Array Texture.
love.graphics.drawqDraw a Quad with the specified Image on screen.
love.graphics.ellipseDraws an ellipse.
love.graphics.flushBatchImmediately renders any pending automatically batched draws.
love.graphics.getBackgroundColorGets the current background color.
love.graphics.getBlendModeGets the blending mode.
love.graphics.getCanvasReturns the current target Canvas.
love.graphics.getCanvasFormatsGets the available Canvas formats, and whether each is supported.
love.graphics.getCaptionGets the window caption.
love.graphics.getColorGets the current color.
love.graphics.getColorMaskGets the active color components used when drawing.
love.graphics.getColorModeGets the color mode (which controls how images are affected by the current color).
love.graphics.getCompressedImageFormatsGets the available compressed image formats, and whether each is supported.
love.graphics.getDPIScaleGets the DPI scale factor of the window.
love.graphics.getDefaultFilterReturns the default scaling filters used with Images, Canvases, and Fonts.
love.graphics.getDefaultImageFilterReturns the default scaling filters.
love.graphics.getDepthModeGets the current depth test mode and whether writing to the depth buffer is enabled.
love.graphics.getDimensionsGets the width and height of the window.
love.graphics.getFontGets the current Font object.
love.graphics.getFrontFaceWindingGets whether triangles with clockwise- or counterclockwise-ordered vertices are considered front-facing.
love.graphics.getHeightGets the height in pixels of the window.
love.graphics.getImageFormatsGets the pixel formats usable for Images, and whether each is supported.
love.graphics.getLineJoinGets the line join style.
love.graphics.getLineStippleGets the current line stipple.
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.
love.graphics.getMaxPointSizeGets the max supported point size.
love.graphics.getMeshCullModeGets whether back-facing triangles in a Mesh are culled.
love.graphics.getModeReturns the current display mode.
love.graphics.getModesGets a list of supported fullscreen modes.
love.graphics.getPixelDimensionsGets the width and height in pixels of the window.
love.graphics.getPixelEffectReturns the current PixelEffect.
love.graphics.getPixelHeightGets the height in pixels of the window.
love.graphics.getPixelWidthGets the width in pixels of the window.
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.
love.graphics.getScissorGets the current scissor box.
love.graphics.getShaderGets the current Shader.
love.graphics.getStackDepthGets the current depth of the transform / state stack (the number of pushes without corresponding pops).
love.graphics.getStatsGets performance-related rendering statistics.
love.graphics.getStencilTestGets the current stencil test configuration.
love.graphics.getSupportedGets the optional graphics features and whether they're supported.
love.graphics.getSystemLimitGets the system-dependent maximum value for a love.graphics feature.
love.graphics.getSystemLimitsGets the system-dependent maximum values for love.graphics features.
love.graphics.getTextureTypesGets the available texture types, and whether each is supported.
love.graphics.getWidthGets the width in pixels of the window.
love.graphics.hasFocusChecks if the game window has keyboard focus.
love.graphics.intersectScissorSets the scissor to the rectangle created by the intersection of the specified rectangle with the existing scissor.
love.graphics.inverseTransformPointConverts the given 2D position from screen-space into global coordinates.
love.graphics.isActiveGets whether the graphics module is able to be used.
love.graphics.isCreatedChecks if the window has been created.
love.graphics.isGammaCorrectGets whether gamma-correct rendering is enabled.
love.graphics.isSupportedChecks for the support of graphics related functions.
love.graphics.isWireframeGets whether wireframe mode is used when drawing.
love.graphics.lineDraws lines between points.
love.graphics.newArrayImageCreates a new array Image.
love.graphics.newCanvasCreates a new Canvas.
love.graphics.newCubeImageCreates a new cubemap Image.
love.graphics.newFontCreates a new Font from a TrueType Font or BMFont file.
love.graphics.newFramebufferCreates a new Framebuffer.
love.graphics.newImageCreates a new Image.
love.graphics.newImageFontCreates a new Font by loading a specifically formatted image.
love.graphics.newMeshCreates a new Mesh.
love.graphics.newParticleSystemCreates a new ParticleSystem.
love.graphics.newPixelEffectCreates a new PixelEffect.
love.graphics.newQuadCreates a new Quad.
love.graphics.newScreenshotCreates a screenshot and returns the ImageData.
love.graphics.newShaderCreates a new Shader.
love.graphics.newSpriteBatchCreates a new SpriteBatch.
love.graphics.newStencilCreates a new stencil.
love.graphics.newTextCreates a new drawable Text object.
love.graphics.newVideoCreates a new Video.
love.graphics.newVolumeImageCreates a new volume Image.
love.graphics.originResets the current coordinate transformation.
love.graphics.pointDraws a point.
love.graphics.pointsDraws one or more points.
love.graphics.polygonDraw a polygon.
love.graphics.popPops the current coordinate transformation from the transformation stack.
love.graphics.presentDisplays the results of drawing operations on the screen.
love.graphics.printDraws text on screen. If no Font is set, one will be created and set (once) if needed.
love.graphics.printfDraws formatted text, with word wrap and alignment.
love.graphics.pushCopies and pushes the current coordinate transformation to the transformation stack.
love.graphics.quadDraws a quadrilateral shape.
love.graphics.rectangleDraws a rectangle.
love.graphics.replaceTransformReplaces the current coordinate transformation with the given Transform object.
love.graphics.resetResets the current graphics settings.
love.graphics.rotateRotates the coordinate system in two dimensions.
love.graphics.scaleScales the coordinate system in two dimensions.
love.graphics.setBackgroundColorSets the background color.
love.graphics.setBlendModeSets the blending mode.
love.graphics.setCanvasCaptures drawing operations to a Canvas
love.graphics.setCaptionSets the window caption.
love.graphics.setColorSets the color used for drawing.
love.graphics.setColorMaskSets the color mask. Enables or disables specific color components when rendering.
love.graphics.setColorModeSets the color mode (which controls how images are affected by the current color).
love.graphics.setDefaultFilterSets the default scaling filters used with Images, Canvases, and Fonts.
love.graphics.setDefaultImageFilterSets the default scaling filters.
love.graphics.setDepthModeConfigures depth testing and writing to the depth buffer.
love.graphics.setFontSet an already-loaded Font as the current font.
love.graphics.setFrontFaceWindingSets whether triangles with clockwise- or counterclockwise-ordered vertices are considered front-facing.
love.graphics.setIconSet window icon.
love.graphics.setInvertedStencilDefines an inverted stencil.
love.graphics.setLineSets the line width and style.
love.graphics.setLineJoinSets the line join style.
love.graphics.setLineStippleSets the line stipple pattern.
love.graphics.setLineStyleSets the line style.
love.graphics.setLineWidthSets the line width.
love.graphics.setMeshCullModeSets whether back-facing triangles in a Mesh are culled.
love.graphics.setModeChanges the display mode.
love.graphics.setNewFontCreates and sets a new Font.
love.graphics.setPixelEffectRoutes drawing operations through a pixel shader.
love.graphics.setPointSets the point size and style.
love.graphics.setPointSizeSets the point size.
love.graphics.setPointStyleSets the point style.
love.graphics.setRenderTargetCaptures drawing operations to a Framebuffer
love.graphics.setScissorSets or disables scissor.
love.graphics.setShaderRoutes drawing operations through a shader.
love.graphics.setStencilDefines or releases a stencil.
love.graphics.setStencilTestConfigures or disables stencil testing.
love.graphics.setWireframeSets whether wireframe lines will be used when drawing.
love.graphics.shearShears the coordinate system.
love.graphics.stencilDraws geometry as a stencil.
love.graphics.toggleFullscreenToggles fullscreen.
love.graphics.transformPointConverts the given 2D position from global coordinates into screen-space.
love.graphics.translateTranslates the coordinate system in two dimensions.
love.graphics.triangleDraws a triangle.
love.graphics.validateShaderValidates shader code.

Enums

AlignModeText alignment.
ArcTypeDifferent types of arcs that can be drawn.
AttributeDataTypeData types used in a Mesh's vertex format.
BlendAlphaModeDifferent ways alpha affects color blending.
BlendModeDifferent ways to do color blending.
BufferDataUsageUsage hints for SpriteBatches, Meshes, and GraphicsBuffers to optimize data storage and access.
CanvasFormatCanvas texture formats.
ColorModeControls how drawn images are affected by current color.
CompareModeDifferent types of stencil test and depth test comparisons.
CullModeHow Mesh geometry is culled when rendering.
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.getSupported.
GraphicsLimitTypes of system-dependent graphics limits.
IndexDataTypeVertex map datatype.
LineJoinLine join style.
LineStyleThe styles in which lines are drawn.
MeshDrawModeHow a Mesh's vertices are used when drawing.
MipmapModeControls whether a Canvas has mipmaps, and its behaviour when it does.
PixelFormatPixel formats for Textures, ImageData, and CompressedImageData.
PointStyleHow points should be drawn.
StackTypeGraphics state stack types used with love.graphics.push.
StencilActionHow a stencil function modifies the stencil values of pixels it touches.
TextureFormatControls the canvas texture format.
TextureTypeTypes of textures (2D, cubemap, etc.)
VertexAttributeStepThe frequency at which a vertex shader fetches the vertex attribute's data from the Mesh when it's drawn.
VertexWindingVertex winding.
WrapModeHow the image wraps inside a large Quad.

See Also

Other Languages