SubTexture
public class
loom2d.textures.SubTexture
Description
A SubTexture represents a section of another texture. This is achieved solely by manipulation of texture coordinates, making the class very efficient.
Note that it is OK to create subtextures of subtextures.
API overview
Constructor
SubTexture
(
parentTexture: Texture
,
region: Rectangle
,
ownsParent: Boolean
= false
)
Creates a new subtexture containing the specified region (in points) of a parent
texture
Attributes
Public attributes
| clipping: Rectangle |
read-only
The clipping rectangle, which is the region provided on initialization scaled into [0.0, 1.0] |
| format: String | read-only |
| ownsParent: Boolean |
read-only
Indicates if the parent texture is disposed when this object is disposed |
| parent: Texture |
read-only
The texture which the subtexture is based on |
Protected attributes
Functions
Public functions
| setTextureInfo ( ti: TextureInfo ): Void | |
| updateFrameAndClipping ( region: Rectangle , frame: Rectangle ): Void |
Called by TextureAtlas to update SubTexture state |
Constructor
Attributes
asyncLoadComplete: TextureAsyncLoadCompleteDelegate
Inherited from Texture
For asynchonously loaded Textures, fired when the texture has completed loading its data. Note that if texture.dispose() is called before the async load has completed, the texture will be destroyed and 'asyncLoadComplete' will NOT get called.
clipping: Rectangle
read-only
The clipping rectangle, which is the region provided on initialization scaled into [0.0, 1.0].
format: String
read-only
frameReadOnly: Rectangle
Inherited from Texture
read-only
The texture frame as a read only temporary Rectangle The returned Rectangle is only valid between calls.
httpLoadFail: TextureHTTPFailDelegate
Inherited from Texture
For HTTP requested Textures, fired if the texture has failed to load.
nativeHeight: Number
Inherited from Texture
read-only
The height of the texture in pixels (without scale adjustment).
nativeWidth: Number
Inherited from Texture
read-only
The width of the texture in pixels (without scale adjustment).
ownsParent: Boolean
read-only
Indicates if the parent texture is disposed when this object is disposed.
premultipliedAlpha: Boolean
Inherited from Texture
read-only
Indicates if the alpha values are premultiplied into the RGB values.
root: ConcreteTexture
Inherited from Texture
read-only
The concrete (power-of-two) texture the texture is based on.
scale: Number
Inherited from Texture
read-only
The scale factor, which influences width and height properties.
smoothing: Number
Inherited from Texture
The default value is TextureSmoothing.BILINEAR
Indicates if the texture do smooth filtering when it is scaled (BILINEAR) or just choose the nearest pixel (NONE)
wrapU: Number
Inherited from Texture
The default value is TextureWrap.CLAMP
Indicates if the texture should repeat like a wallpaper or stretch the outermost horizontal pixels. Note: this only works in textures with dimensions that are powers of two and that are not loaded from a texture atlas (i.e. no subtextures).
wrapV: Number
Inherited from Texture
The default value is TextureWrap.CLAMP
Indicates if the texture should repeat like a wallpaper or stretch the outermost vertical pixels. Note: this only works in textures with dimensions that are powers of two and that are not loaded from a texture atlas (i.e. no subtextures).
Protected attributes
Functions
adjustVertexData
(
vertexData: VertexData
,
vertexID: Number
,
count: Number
): Void
Inherited from Texture
Converts texture coordinates and vertex positions of raw vertex data into the format required for rendering.
Parameters
| vertexData: VertexData | |
| vertexID: Number | |
| count: Number |
cancelHTTPRequest
(): Void
Inherited from Texture
Called to indicate that an HTTP texture load via fromHTTP() should be cancelled at the 1st possible opportunity. NOTE that this will also dipose the Texture returned by fromHTTP(), so consider it invalid after calling this.
dispose
(): Void
Inherited from Texture
Disposes the underlying texture data. Note that not all textures need to be disposed: SubTextures (created with 'Texture.fromTexture') just reference other textures and and do not take up resources themselves; this is also true for textures from an atlas.
empty
(
width: Number
,
height: Number
,
premultipliedAlpha: Boolean
= true
,
mipMapping: Boolean
= true
,
optimizeForRenderToTexture: Boolean
= false
,
scale: Number
=
,
format: String
= bgra
,
repeat: Boolean
= false
): Texture
Inherited from Texture
static
Creates an empty texture of a certain size. Beware that the texture can only be used after you either upload some color data ("texture.root.upload...") or clear the texture ("texture.root.clear()").
use the texture for bitmap data, use "true"; for ATF data, use "false".
bitmap data, this decides if mipmaps will be created; when you upload ATF data, this decides if mipmaps inside the ATF file will be displayed.
compressed formats to save memory (at the price of reduced image quality).
Parameters
| width: Number | in points; number of pixels depends on scale parameter |
| height: Number | in points; number of pixels depends on scale parameter |
| premultipliedAlpha: Boolean = true | the PMA format you will use the texture with. If you will |
| mipMapping: Boolean = true | indicates if mipmaps should be used for this texture. When you upload |
| optimizeForRenderToTexture: Boolean = false | indicates if this texture will be used as render target |
| scale: Number = | if you omit this parameter, 'Starling.contentScaleFactor' will be used. |
| format: String = bgra | the context3D texture format to use. Pass one of the packed or |
| repeat: Boolean = false | the repeat mode of the texture. Only useful for power-of-two textures. |
fromAsset
(
path: String
): Texture
Inherited from Texture
static
Blocking function that creates a texture object from a bitmap on disk.
Parameters
| path: String |
fromAssetAsync
(
path: String
,
cb: TextureAsyncLoadCompleteDelegate
,
highPriority: Boolean
= false
): Texture
Inherited from Texture
static
Non-blocking function that creates a texture object from a bitmap file on disk.
Parameters
| path: String | |
| cb: TextureAsyncLoadCompleteDelegate | |
| highPriority: Boolean = false |
fromBytes
(
bytes: ByteArray
,
uniqueName: String
= null
): Texture
Inherited from Texture
static
Creates a texture object from compressed image bytes. An optional unique name string can be supplied if you wish the resulting image to be cacheable, otherwise null can be specified.
The supported image types are JPEG (baseline), PNG (8-bit), TGA, BMP (non-1bpp, non-RLE), PSD (composited only), GIF, HDR (radiance rgbE), PIC (Softimage).
Parameters
| bytes: ByteArray | |
| uniqueName: String = null |
fromHTTP
(
url: String
,
onSuccess: TextureAsyncLoadCompleteDelegate
,
onFailure: TextureHTTPFailDelegate
,
cacheOnDisk: Boolean
= true
,
highPriority: Boolean
= false
,
existingTexture: Texture
= null
): Texture
Inherited from Texture
static
Non-blocking function that creates a texture object from a remote bitmap file via HTTP.
Parameters
| url: String | |
| onSuccess: TextureAsyncLoadCompleteDelegate | |
| onFailure: TextureHTTPFailDelegate | |
| cacheOnDisk: Boolean = true | |
| highPriority: Boolean = false | |
| existingTexture: Texture = null |
fromTexture
(
texture: Texture
,
region: Rectangle
= null
,
frame: Rectangle
= null
): Texture
Inherited from Texture
static
Creates a texture that contains a region (in pixels) of another texture. The new texture will reference the base texture; no data is duplicated.
Parameters
| texture: Texture | |
| region: Rectangle = null | |
| frame: Rectangle = null |
getFullTypeName
(): String
Inherited from Object
native
Gets the fully qualified type name of the Object. The fully qualified type name includes the package of the type.
Returns
| String | fully qualified type name of the Object. |
getType
(): Type
Inherited from Object
native
Gets the Type that describes the Object.
Returns
| Type | The Type that describes the object. |
getTypeName
(): String
Inherited from Object
native
Gets the type name of the Object.
Returns
| String | type name of the Object. |
isTextureValid
(): Boolean
Inherited from Texture
Checks the handle ID of the textureInfo to see if the texture is valid and ready for use.
toString
(): String
Inherited from Object
native
Returns a String that describes the Object. This can be overriden to provide extra details when printing objects using trace().
Returns
| String | String that described the Object. |
updateFrameAndClipping ( region: Rectangle , frame: Rectangle ): Void
Called by TextureAtlas to update SubTexture state. Be careful!
Parameters
| region: Rectangle | |
| frame: Rectangle |
updateFromHTTP
(
url: String
,
onSuccess: TextureAsyncLoadCompleteDelegate
,
onFailure: TextureHTTPFailDelegate
,
cacheOnDisk: Boolean
= true
,
highPriority: Boolean
= false
): Void
Inherited from Texture
Parameters
| url: String | |
| onSuccess: TextureAsyncLoadCompleteDelegate | |
| onFailure: TextureHTTPFailDelegate | |
| cacheOnDisk: Boolean = true | |
| highPriority: Boolean = false |