#

API Docs for: 1.6.0
Show: Inherited Protected Private Deprecated

# Texture Class

Uses

- EventTarget

Defined in: `src/pixi/textures/Texture.js:10`
Module: PIXI

A texture stores the information that represents an image or part of an image. It cannot be added to the display list directly. To do this use PIXI.Sprite. If no frame is provided then the whole image is used

## Constructor

### `Texture`

(

- `baseTexture`
- `frame`

)

Defined in `src/pixi/textures/Texture.js:10`

#### Parameters:

- `baseTexture` BaseTexture

  The base texture source to create the texture from

- `frame` Rectangle

  The rectangle frame of the texture to show

- Index
- Methods
- Properties

## Item Index

### Methods

- _updateWebGLuvs
- addEventListener
- addTextureToCache static
- clear
- destroy
- dispatchEvent
- fromCanvas static
- fromFrame static
- fromImage static
- onBaseTextureLoaded
- removeAllEventListeners
- removeEventListener
- removeTextureFromCache static
- renderCanvas
- renderWebGL
- resize
- setFrame

### Properties

- _uvs
- baseTexture
- baseTexture
- crop
- crop
- frame
- frame
- height
- height
- listeners
- noFrame
- scope
- trim
- valid
- width
- width

## Methods

### `_updateWebGLuvs`

() private

Defined in `src/pixi/textures/Texture.js:201`

Updates the internal WebGL UV cache.

### `addEventListener`

(

- `type`
- `listener`

)

Inherited from EventTarget: `src/pixi/utils/EventTarget.js:32`

Adds a listener for a specific event

#### Parameters:

- `type` String

  A string representing the event type to listen for.

- `listener` Function

  The callback function that will be fired when the event occurs

### `addTextureToCache`

(

- `texture`
- `id`

)
static

Defined in `src/pixi/textures/Texture.js:288`

Adds a texture to the textureCache.

#### Parameters:

- `texture` Texture
- `id` String

  the id that the texture will be stored against.

### `clear`

()

Defined in `src/pixi/textures/RenderTexture.js:149`

Clears the RenderTexture.

### `destroy`

(

- `destroyBase`

)

Defined in `src/pixi/textures/Texture.js:150`

Destroys this texture

#### Parameters:

- `destroyBase` Boolean

  Whether to destroy the base texture as well

### `dispatchEvent`

(

- `event`

)

Inherited from EventTarget: `src/pixi/utils/EventTarget.js:55`

Fires the event, ie pretends that the event has happened

#### Parameters:

- `event` Event

  the event object

### `fromCanvas`

(

- `canvas`
- `scaleMode`

)
static

Defined in `src/pixi/textures/Texture.js:269`

Helper function that returns a texture based on a canvas element If the canvas is not in the texture cache it will be created and loaded

#### Parameters:

- `canvas` Canvas

  The canvas element source of the texture

- `scaleMode` Number

  Should be one of the PIXI.scaleMode consts

#### Returns:

Texture

### `fromFrame`

(

- `frameId`

)
static

Defined in `src/pixi/textures/Texture.js:253`

Helper function that returns a texture based on a frame id If the frame id is not in the texture cache an error will be thrown

#### Parameters:

- `frameId` String

  The frame id of the texture

#### Returns:

Texture

### `fromImage`

(

- `imageUrl`
- `crossorigin`
- `scaleMode`

)
static

Defined in `src/pixi/textures/Texture.js:229`

Helper function that returns a texture based on an image url If the image is not in the texture cache it will be created and loaded

#### Parameters:

- `imageUrl` String

  The image url of the texture

- `crossorigin` Boolean

  Whether requests should be treated as crossorigin

- `scaleMode` Number

  Should be one of the PIXI.scaleMode consts

#### Returns:

Texture

### `onBaseTextureLoaded`

(

- `event`

)
private

Defined in `src/pixi/textures/Texture.js:131`

Called when the base texture is loaded

#### Parameters:

- `event` Object

### `removeAllEventListeners`

(

- `type`

)

Inherited from EventTarget: `src/pixi/utils/EventTarget.js:101`

Removes all the listeners that were active for the specified event type

#### Parameters:

- `type` String

  A string representing the event type which will have all its listeners removed

### `removeEventListener`

(

- `type`
- `listener`

)

Inherited from EventTarget: `src/pixi/utils/EventTarget.js:80`

Removes the specified listener that was assigned to the specified event type

#### Parameters:

- `type` String

  A string representing the event type which will have its listener removed

- `listener` Function

  The callback function that was be fired when the event occured

### `removeTextureFromCache`

(

- `id`

)
Texture static

Defined in `src/pixi/textures/Texture.js:301`

Remove a texture from the textureCache.

#### Parameters:

- `id` String

  the id of the texture to be removed

#### Returns:

Texture:

the texture that was removed

### `renderCanvas`

(

- `displayObject`
- `clear`

)
private

Defined in `src/pixi/textures/RenderTexture.js:220`

This function will draw the display object to the texture.

#### Parameters:

- `displayObject` DisplayObject

  The display object to render this texture on

- `clear` Boolean

  If true the texture will be cleared before the displayObject is drawn

### `renderWebGL`

(

- `displayObject`
- `clear`

)
private

Defined in `src/pixi/textures/RenderTexture.js:164`

This function will draw the display object to the texture.

#### Parameters:

- `displayObject` DisplayObject

  The display object to render this texture on

- `clear` Boolean

  If true the texture will be cleared before the displayObject is drawn

### `resize`

(

- `width`
- `height`
- `updateBase`

)

Defined in `src/pixi/textures/RenderTexture.js:113`

Resize the RenderTexture.

#### Parameters:

- `width` Number

  The width to resize to.

- `height` Number

  The height to resize to.

- `updateBase` Boolean

  Should the baseTexture.width and height values be resized as well?

### `setFrame`

(

- `frame`

)

Defined in `src/pixi/textures/Texture.js:163`

Specifies the region of the baseTexture that this texture will use.

#### Parameters:

- `frame` Rectangle

  The frame of the texture to set it to

## Properties

### `_uvs`

Object private

Defined in `src/pixi/textures/Texture.js:83`

The WebGL UV data cache.

### `baseTexture`

BaseTexture

Defined in `src/pixi/textures/RenderTexture.js:70`

The base texture object that this texture uses

### `baseTexture`

BaseTexture

Defined in `src/pixi/textures/Texture.js:43`

The base texture that this texture uses.

### `crop`

Rectangle

Defined in `src/pixi/textures/RenderTexture.js:61`

This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering, irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases)

### `crop`

Rectangle

Defined in `src/pixi/textures/Texture.js:108`

This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering, irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases)

### `frame`

Rectangle

Defined in `src/pixi/textures/Texture.js:51`

The frame specifies the region of the base texture that this texture uses

### `frame`

Rectangle

Defined in `src/pixi/textures/RenderTexture.js:53`

The framing rectangle of the render texture

### `height`

Number

Defined in `src/pixi/textures/RenderTexture.js:45`

The height of the render texture

### `height`

Number

Defined in `src/pixi/textures/Texture.js:100`

The height of the Texture in pixels.

### `listeners`

Object

Inherited from EventTarget: `src/pixi/utils/EventTarget.js:24`

Holds all the listeners

### `noFrame`

Boolean

Defined in `src/pixi/textures/Texture.js:24`

Does this Texture have any frame data assigned to it?

### `scope`

Object

Defined in `src/pixi/textures/Texture.js:75`

The context scope under which events are run.

### `trim`

Rectangle

Defined in `src/pixi/textures/Texture.js:59`

The trim point

### `valid`

Boolean

Defined in `src/pixi/textures/Texture.js:67`

This will let the renderer know if the texture is valid. If its not then it cannot be rendered.

### `width`

Number

Defined in `src/pixi/textures/Texture.js:92`

The width of the Texture in pixels.

### `width`

Number

Defined in `src/pixi/textures/RenderTexture.js:38`

The with of the render texture