dsfml.graphics

2D graphics module: sprites, text, shapes, etc.

Modules

blendmode
module dsfml.graphics.blendmode

$(U BlendMode) is a structure that represents a blend mode. A blend mode determines how the colors of an object you draw are mixed with the colors that are already in the buffer.

circleshape
module dsfml.graphics.circleshape

This class inherits all the functions of $(TRANSFORMABLE_LINK) (position, rotation, scale, bounds, ...) as well as the functions of $(SHAPE_LINK) (outline, color, texture, ...).

color
module dsfml.graphics.color

$(U Color) is a simple color class composed of 4 components:

  • Red
  • Green
  • Blue
  • Alpha (opacity)
convexshape
module dsfml.graphics.convexshape

This class inherits all the functions of $(TRANSFORMABLE_LINK) (position, rotation, scale, bounds, ...) as well as the functions of $(SHAPE_LINK) (outline, color, texture, ...).

drawable
module dsfml.graphics.drawable

$(U Drawable) is a very simple base interface that allows objects of derived classes to be drawn to a RenderTarget.

font
module dsfml.graphics.font

Fonts can be loaded from a file, from memory or from a custom stream, and supports the most common types of fonts. See the loadFromFile function for the complete list of supported formats.

glsl
module dsfml.graphics.glsl

The glsl module contains types that match their equivalents in GLSL, the OpenGL shading language. These types are exclusively used by the $(SHADER_LINK) class.

glyph
module dsfml.graphics.glyph

A glyph is the visual representation of a character.

image
module dsfml.graphics.image

$(U Image) is an abstraction to manipulate images as bidimensional arrays of pixels. The class provides functions to load, read, write and save pixels, as well as many other useful functions.

primitivetype
module dsfml.graphics.primitivetype

The module containing the list of usable primitives for drawing.

rect
module dsfml.graphics.rect

A rectangle is defined by its top-left corner and its size. It is a very simple class defined for convenience, so its member variables (left, top, width, and height) are public and can be accessed directly, just like the vector classes ($(VECTOR2_LINK) and $(VECTOR3_LINK)).

rectangleshape
module dsfml.graphics.rectangleshape

This class inherits all the functions of $(TRANSFORMABLE_LINK) (position, rotation, scale, bounds, ...) as well as the functions of $(SHAPE_LINK) (outline, color, texture, ...).

renderstates
module dsfml.graphics.renderstates

There are four global states that can be applied to the drawn objects:

  • the blend mode: how pixels of the object are blended with the background
  • the transform: how the object is positioned/rotated/scaled
  • the texture: what image is mapped to the object
  • the shader: what custom effect is applied to the object
rendertarget
module dsfml.graphics.rendertarget

$(U RenderTarget) defines the common behaviour of all the 2D render targets usable in the graphics module. It makes it possible to draw 2D entities like sprites, shapes, text without using any OpenGL command directly.

rendertexture
module dsfml.graphics.rendertexture

$(U RenderTexture) is the little brother of $(RENDERWINDOW_LINK). It implements the same 2D drawing and OpenGL-related functions (see their base class $(RENDERTARGET_LINK) for more details), the difference is that the result is stored in an off-screen texture rather than being show in a window.

renderwindow
module dsfml.graphics.renderwindow

$(U RenderWindow) is the main class of the Graphics package. It defines an OS window that can be painted using the other classes of the graphics module.

shader
module dsfml.graphics.shader

Shaders are programs written using a specific language, executed directly by the graphics card and allowing one to apply real-time operations to the rendered entities.

shape
module dsfml.graphics.shape

$(U Shape) is a drawable class that allows to define and display a custom convex shape on a render target.

sprite
module dsfml.graphics.sprite

$(U Sprite) is a drawable class that allows to easily display a texture (or a part of it) on a render target.

text
module dsfml.graphics.text

$(U Text) is a drawable class that allows one to easily display some text with a custom style and color on a render target.

texture
module dsfml.graphics.texture

$(U Texture) stores pixels that can be drawn, with a sprite for example. A texture lives in the graphics card memory, therefore it is very fast to draw a texture to a render target, or copy a render target to a texture (the graphics card can access both directly). * Being stored in the graphics card memory has some drawbacks. A texture cannot be manipulated as freely as a $(IMAGE_LINK), you need to prepare the pixels first and then upload them to the texture in a single operation (see Texture.update). * $(U Texture) makes it easy to convert from/to Image, but keep in mind that these calls require transfers between the graphics card and the central memory, therefore they are slow operations. * A texture can be loaded from an image, but also directly from a file/memory/stream. The necessary shortcuts are defined so that you don't need an image first for the most common cases. However, if you want to perform some modifications on the pixels before creating the final texture, you can load your file to a $(IMAGE_LINK), do whatever you need with the pixels, and then call Texture.loadFromImage. * Since they live in the graphics card memory, the pixels of a texture cannot be accessed without a slow copy first. And they cannot be accessed individually. Therefore, if you need to read the texture's pixels (like for pixel-perfect collisions), it is recommended to store the collision information separately, for example in an array of booleans. * Like $(IMAGE_LINK), $(U Texture) can handle a unique internal representation of pixels, which is RGBA 32 bits. This means that a pixel must be composed of 8 bits red, green, blue and alpha channels – just like a $(COLOR_LINK). *

transform
module dsfml.graphics.transform

A $(U Transform) specifies how to translate, rotate, scale, shear, project, whatever things. In mathematical terms, it defines how to transform a coordinate system into another.

transformable
module dsfml.graphics.transformable

The interface and template are provided for convenience, on top of $(TRANSFORM_LINK).

vertex
module dsfml.graphics.vertex

A vertex is an improved point. It has a position and other extra attributes that will be used for drawing: in DSFML, vertices also have a color and a pair of texture coordinates.

vertexarray
module dsfml.graphics.vertexarray

$(U VertexArray) is a very simple wrapper around a dynamic array of vertices *and a primitives type.

view
module dsfml.graphics.view

$(U View) defines a camera in the 2D scene. This is a very powerful concept: you can scroll, rotate or zoom the entire scene without altering the way that your drawable objects are drawn.

Meta