GTextureAtlas class
Represents a texture atlas, which is a collection of sub-textures that can be used for rendering 2D graphics efficiently. A GTextureAtlas is composed of a single image file and an optional data file that describes the sub-texture regions and other properties to be rendered.
Constructors
- GTextureAtlas(GTexture? texture, [Object? data, double adjustXmlSizesRatio = 1])
-
Creates a new GTextureAtlas object with the provided
texture
and optionaldata
andadjustXmlSizesRatio
parameters. - GTextureAtlas.fixedSizeTile(GTexture texture, {required double tileWidth, double? tileHeight, double tilePadding = 0, String namePrefix = ''})
-
Constructs a new instance of GTextureAtlas with the provided tile size
and texture.
factory
Properties
Methods
-
addRegion(
String? name, GRect region, [GRect? frame, bool rotated = false]) → void - Adds a new sub-texture region to the atlas using the provided name, region and optional frame and rotation values.
-
addSubTexture(
String? name, GSubTexture subTexture) → void -
Adds a GSubTexture with the given
name
to the atlas. -
dispose(
) → void - Disposes the atlas and all its sub-textures.
-
getFrame(
String name) → GRect? -
Returns the frame of the sub-texture with the given
name
. -
getNames(
{String? prefix, List< String?> ? out}) → List<String?> -
Gets a list of texture names that match the given
prefix
. -
getRegion(
String name) → GRect? -
Returns the region of the sub-texture with the given
name
. -
getRotation(
String name) → bool -
Returns
true
if the sub-texture with the givenname
is rotated. -
getTexture(
String? name) → GSubTexture? -
Returns the GSubTexture instance with the given
name
. -
getTextures(
{String? prefix, List< GTexture?> ? out}) → List<GTexture?> -
Gets a list of
GTexture
s that match the givenprefix
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
parseAtlasData(
Object data) → void -
Parses the given
data
to create the texture atlas. The method tries to determine the format of the data by checking if it contains a closing tag for the TextureAtlas element, and if it is not an XML document, an error is thrown. If the data is XML, the parseAtlasXml method is called with the parsed XML document, otherwise an error is thrown. -
parseAtlasXml(
XmlDocument atlasXml) → void - Parses the provided XmlDocument and constructs the atlas.
-
removeRegion(
String name) → void -
Removes the sub-texture reference with the specified
name
from the texture atlas. If the region exists, its corresponding GSubTexture object will be disposed and removed from the atlas. If the region doesn't exist, nothing happens. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited