Indicates that texture-based rendering or sprite creation is wanted.
Indicates that software-based rendering or sprite creation is wanted.
A simple 2D object, implemented as abstract base class.
A simple, visible, pixel-based 2D object, implemented on top of SDL2 software surfaces.
The sdl2.SDL_Surface containing the pixel data.
The size of the SoftwareSprite as tuple.
A simple, visible, pixel-based 2D object, implemented on top of SDL2 textures.
The size of the TextureSprite as tuple.
The sdl2.SDL_Texture containing the texture data.
A rendering system for Sprite components. This is a base class for rendering systems capable of drawing and displaying Sprite based objects. Inheriting classes need to implement the rendering capability by overriding the render() method.
Sort function for the component processing order. The default sort order is based on the depth attribute of every sprite. Lower depth values will cause sprites to be drawn below sprites with higher depth values. If sortfunc shall be overriden, it must match thre callback requirements for sorted().
A rendering system for SoftwareSprite components. The SoftwareSpriteRenderer class uses a sdl2.SDL_Window as drawing device to display SoftwareSprite surfaces. It uses the internal SDL surface of the window as drawing context, so that GL operations, such as texture handling or the usage of SDL renderers is not possible.
window can be either a sdl2.ext.Window or sdl2.SDL_Window instance.
The sdl2.SDL_Window that is used as drawing device.
Draws the passed sprites on the sdl2.ext.Window surface. x and y are optional arguments that can be used as relative drawing location for sprites. If set to None, the location information of the sprites are used. If set and sprites is an iterable, such as a list of SoftwareSprite objects, x and y are relative location values that will be added to each individual sprite’s position. If sprites is a single SoftwareSprite, x and y denote the absolute position of the SoftwareSprite, if set.
A rendering system for TextureSprite components. The TextureSpriteRenderer class uses a sdl2.SDL_Renderer as drawing device to display Sprite surfaces.
target can be a sdl2.ext.Window, sdl2.SDL_Window, a:class:sdl2.ext.RenderContext or a sdl2.SDL_Renderer. If it is a sdl2.ext.Window or sdl2.SDL_Window instance, it will try to create a sdl2.SDL_Renderer with hardware acceleration for it.
The sdl2.SDL_Renderer that is used as drawing context.
Renders the passed sprites via the renderer. x and y are optional arguments that can be used as relative drawing location for sprites. If set to None, the location information of the sprites are used. If set and sprites is an iterable, such as a list of TextureSprite objects, x and y are relative location values that will be added to each individual sprite’s position. If sprites is a single TextureSprite, x and y denote the absolute position of the TextureSprite, if set.
A factory class for creating Sprite objects. The SpriteFactory can create TextureSprite or SoftwareSprite instances, depending on the sprite_type being passed to it, which can be SOFTWARE or TEXTURE. The additional kwargs are used as default arguments for creating sprites within the factory methods.
The sprite type created by the factory. This will be either SOFTWARE for SoftwareSprite or TEXTURE for TextureSprite objects.
The default arguments to use for creating new sprites.
Creates a software sprite. A size tuple containing the width and height of the sprite and a bpp value, indicating the bits per pixel to be used, need to be provided.
Creates a Sprite. Depending on the sprite_type, this will return a SoftwareSprite or TextureSprite.
kwargs are the arguments to be passed for the sprite construction and can vary depending on the sprite type. Usually they have to follow the create_software_sprite() and create_texture_sprite() method signatures. kwargs however will be mixed with the set default_args so that one does not necessarily have to provide all arguments, if they are set within the default_args. If kwargs and default_args contain the same keys, the key-value pair of kwargs is chosen.
Creates a new SpriteRenderer, based on the set sprite_type. If sprite_type is TEXTURE, a TextureSpriteRenderer is created with the the renderer from the default_args. Other keyword arguments are ignored in that case.
Otherwise a SoftwareSpriteRenderer is created and args and kwargs are passed to it.
Creates a texture sprite. A size tuple containing the width and height of the sprite needs to be provided.
TextureSprite objects are assumed to be static by default, making it impossible to access their pixel buffer in favour for faster copy operations. If you need to update the pixel data frequently or want to use the texture as target for rendering operations, access can be set to the relevant SDL_TEXTUREACCESS_* flag.
Creates a Sprite with a certain color.
Creates a Sprite from an image file. The image must be loadable via sdl2.ext.load_image().
Creates a Sprite from an object. The object will be passed through sdl2.rwops_from_object() in order to try to load image data from it.
Creates a Sprite from the passed sdl2.SDL_Surface. If free is set to True, the passed surface will be freed automatically.
Creates a Sprite from a string of text. This method requires a sdl2.ext.FontManager to be in kwargs or default_args.
A rendering context for windows and sprites that can use hardware or software-accelerated graphics drivers.
If target is a sdl2.ext.Window or sdl2.SDL_Window, index and flags are passed to the relevant sdl2.SDL_CreateRenderer() call. If target is a SoftwareSprite or sdl2.SDL_Surface, the index and flags arguments are ignored.
The underlying sdl2.SDL_Renderer.
The target for which the RenderContext was created.
The sdl2.ext.Color to use for draw and fill operations.
The blend mode used for drawing operations (fill and line). This can be a value of
Clears the rendering context with the currently set or passed color.
Copies (blits) the passed src, which can be a TextureSprite or sdl2.SDL_Texture, to the target of the RenderContext. srcrect is the source rectangle to be used for clipping portions of src. dstrect is the destination rectangle.
Draws one or multiple lines on the rendering context.
Draws one or multiple points on the rendering context.
Draws one or multiple rectangles on the rendering context.
Fills one or multiple rectangular areas on the rendering context with the current set or passed color.
Refreshes the rendering context, causing changes to the render buffers to be shown.