love.graphics (Tiếng Việt)

Nhiệm vụ chính của module love.graphics là vẽ các đường nét, hình dạng, chữ, các Image (ảnh) cùng những đối tượng Drawable (vẽ được) khác lên mành hình. Nhiệm vụ thứ hai bao gồm việc nạp các file ngoài (các ImageFont) vào bộ nhớ, tạo ra các đối tượng riêng (như ParticleSystem hoặc Canvas) và quản lý những vị trí trên màn hình.

Hệ tọa độ của LÖVE có gốc đặt tại góc bên trái phía trên màn hình, tức là vị trí (0, 0). Trục x nằm ngang, hướng sang phải. Trục y thẳng đứng, hướng xuống dưới.

Hệ tọa độ trong LÖVE

Trong nhiều trường hợp, bạn vẽ lên các ảnh hoặc hình tính từ vị trí góc trên bên trái (Xem hình trên).

Nhiều hàm được dùng để thao tác trên hệ tọa độ đồ họa, chính là cách mà những tọa độ này tương ứng với màn hình. Bạn có thể thay đổi vị trí, co giãn, và thậm chí xoay hình theo cách này.


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

Ngôn ngữ khác