A texture is an image ready to be drawn.

Static methods

@:value({ density : 1 })staticfromPixels(width:Float, height:Float, pixels:UInt8Array, density:Float = 1):Texture

Create a new texture from the given pixels buffer

Parameters:

width

Width of the texture

height

Height of the texture

pixels

A pixel buffer in integer RGBA format

density

(optional) density of the texture

Returns:

Texture

@:value({ density : 1 })staticfromBytes(bytes:Bytes, density:Float = 1, ?options:Null<LoadTextureOptions>, done:(texture:Texture) ‑> Void):Void

Create a new texture from the given bytes. The bytes must be PNG or JPEG data

Parameters:

bytes

The PNG or JPEG data as bytes

density

(optional) Density of the texture

options

(optional) Additional options when loading texture (could depend on backend)

done

A callback receiving the loaded texture, or null if it failed

Constructor

@:value({ density : -1 })new(backendItem:Texture, density:Float = -1)

Variables

@:value(false)read onlyisRenderTexture:Bool = false

@:value(null)read onlyasRenderTexture:RenderTexture = null

read onlytextureId:TextureId

The texture ID used by the underlying backend (OpenGL etc...)

read onlynativeWidth:Int

The native width of the texture, not depending on texture density

read onlynativeHeight:Int

The native height of the texture, not depending on texture density

read onlynativeWidthActual:Int

The native actual width of the texture. Same as native width unless underlying backend needs pot (power of two) sizes.

read onlynativeHeightActual:Int

The native actual height of the texture. Same as native height unless underlying backend needs pot (power of two) sizes.

read onlywidth:Float

read onlyheight:Float

@:value(LINEAR)filter:TextureFilter = LINEAR

@:value(CLAMP)wrapS:TextureWrap = CLAMP

Horizontal texture wrap mode

@:value(CLAMP)wrapT:TextureWrap = CLAMP

Vertical texture wrapping mode

@:value(null)asset:ImageAsset = null

Methods

setWrap(wrapS:TextureWrap, ?wrapT:TextureWrap):Void

Shorthand for setting both wrapS and wrapT at the same time. Possible values: CLAMP, REPEAT, MIRROR

Parameters:

wrapS

horizontal wrap mode

wrapT

vertical wrap mode

@:value({ reversePremultiplyAlpha : true })inlinetoPng(path:String, reversePremultiplyAlpha:Bool = true, done:() ‑> Void):Void

@:value({ reversePremultiplyAlpha : true })inlinetoPng(reversePremultiplyAlpha:Bool = true, done:(data:Bytes) ‑> Void):Void

Export texture as PNG data and save it to the given file path

Parameters:

path

The png file path where to save the image ('/path/to/image.png')

done

Called when the png has been exported

Inherited Events

Defined by Entity

@:dox(show)dispose(entity:Entity):Void

@:dox(show)destroy(entity:Entity):Void

Inherited Variables

Defined by Entity

read onlyhasData:Bool

@:value(null)id:String = null

read onlydestroyed:Bool

read onlydisposed:Bool

@:value(null)read onlyautoruns:Array<Autorun> = null

@editablecomponents:ReadOnlyMap<String, Component>

Public components mapping. Contain components created separately with component() or macro-based components as well.

scriptContent:ScriptContent

Available with script plugin

script:Script

Available with script plugin

Inherited Methods

Defined by Entity

dispose():Void

Schedules destroy, at the end of the current frame.

unbindEvents():Void

Remove all events handlers from this entity.

autorun(run:() ‑> Void, ?afterRun:() ‑> Void):Autorun

Creates a new Autorun instance with the given callback associated with the current entity.

Parameters:

run

The run callback

Returns:

The autorun instance

tween(?easing:Easing, duration:Float, fromValue:Float, toValue:Float, update:(Float, Float) ‑> Void):Tween

component<C>(?name:String, ?component:Null<C>):C