import Texture from "./Texture"; import SubTexture from "./SubTexture"; import Rectangle from "openfl/geom/Rectangle"; import Vector from "openfl/Vector"; declare namespace starling.textures { /** * A texture atlas is a collection of many smaller textures in one big image. This class * * is used to access textures from such an atlas. * * * *
Using a texture atlas for your textures solves two problems:
* * * *By using a texture atlas, you avoid both texture switches and the power-of-two * * limitation. All textures are within one big "super-texture", and Starling takes care that * * the correct part of this texture is displayed.
* * * *There are several ways to create a texture atlas. One is to use the atlas generator * * script that is bundled with Starling's sibling, the * * Sparrow framework. It was only tested in Mac OS X, though. A great multi-platform * * alternative is the commercial tool * * Texture Packer.
* * * *Whatever tool you use, Starling expects the following file format:
* * * *If your images have transparent areas at their edges, you can make use of the
* * frame property of the Texture class. Trim the texture by removing the
* * transparent edges and specify the original texture size like this:
Some atlas generators can optionally rotate individual textures to optimize the texture
* * distribution. This is supported via the boolean attribute "rotated". If it is set to
* * true for a certain subtexture, this means that the texture on the atlas
* * has been rotated by 90 degrees, clockwise. Starling will undo that rotation by rotating
* * it counter-clockwise.
In this case, the positional coordinates (x, y, width, height)
* * are expected to point at the subtexture as it is present on the atlas (in its rotated
* * form), while the "frame" properties must describe the texture in its upright form.
null if it is not found.
*/
getTexture(name: string): Texture;
/**
* Returns all textures that start with a certain string, sorted alphabetically
* * (especially useful for "MovieClip").
*/
getTextures(prefix?: string, result?: Vectornull
* * if no region with that name has been registered.
*/
getRegion(name: string): Rectangle;
/**
* Returns the frame rectangle of a specific region, or null if that region
* * has no frame.
*/
getFrame(name: string): Rectangle;
/**
* If true, the specified region in the atlas is rotated by 90 degrees (clockwise). The
* * SubTexture is thus rotated counter-clockwise to cancel out that transformation.
*/
getRotation(name: string): boolean;
/**
* Adds a named region for a SubTexture (described by rectangle with coordinates in
* * points) with an optional frame.
*/
addRegion(name: string, region: Rectangle, frame?: Rectangle, rotated?: boolean): void;
/**
* Adds a named region for an instance of SubTexture or an instance of its sub-classes.
*/
addSubTexture(name: string, subTexture: SubTexture): void;
/**
* Removes a region with a certain name.
*/
removeRegion(name: string): void;
/**
* Removes all regions with names that start with the given prefix.
* * If no arguments are given, all regions will be removed.
*/
removeRegions(prefix?: string): void;
/**
* The base texture that makes up the atlas.
*/
get texture(): Texture;
}
}
export default starling.textures.TextureAtlas;