#

API Docs for: 1.4.3
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

- addTextureToCache static
- destroy
- fromCanvas static
- fromFrame static
- fromImage static
- onBaseTextureLoaded
- removeTextureFromCache static
- setFrame

### Properties

- baseTexture
- frame
- trim

## Methods

### `addTextureToCache`

(

- `texture`
- `id`

)
static

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

Adds a texture to the textureCache.

#### Parameters:

- `texture` Texture
- `id` String

  the id that the texture will be stored against.

### `destroy`

(

- `destroyBase`

)

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

Destroys this texture

#### Parameters:

- `destroyBase` Boolean

  Whether to destroy the base texture as well

### `fromCanvas`

(

- `canvas`

)
static

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

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

#### Returns:

Texture

### `fromFrame`

(

- `frameId`

)
static

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

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`

)
static

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

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

#### Returns:

Texture

### `onBaseTextureLoaded`

(

- `event`

)
private

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

Called when the base texture is loaded

#### Parameters:

- `event` Object

### `removeTextureFromCache`

(

- `id`

)
Texture static

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

Remove a texture from the textureCache.

#### Parameters:

- `id` String

  the id of the texture to be removed

#### Returns:

Texture:

the texture that was removed

### `setFrame`

(

- `frame`

)

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

Specifies the rectangle region of the baseTexture

#### Parameters:

- `frame` Rectangle

  The frame of the texture to set it to

## Properties

### `baseTexture`

BaseTexture

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

The base texture of this texture

### `frame`

Rectangle

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

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

### `trim`

Point

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

The trim point