LogoPixi’VN
pixi-jsType aliases

Type Alias: GenerateTextureOptions

> GenerateTextureOptions = object

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/extract/GenerateTextureSystem.d.ts:48

Options for generating a texture from a container. Used to create reusable textures from display objects, which can improve performance when the same content needs to be rendered multiple times.

Example

// Basic texture generation
const sprite = new Sprite(texture);
const generatedTexture = renderer.generateTexture({
    target: sprite
});

// Generate with custom region and resolution
const texture = renderer.generateTexture({
    target: container,
    frame: new Rectangle(0, 0, 100, 100),
    resolution: 2
});

// Generate with background color and anti-aliasing
const highQualityTexture = renderer.generateTexture({
    target: graphics,
    clearColor: '#ff0000',
    antialias: true,
    textureSourceOptions: {
        scaleMode: 'linear'
    }
});

Advanced

Properties

antialias?

> optional antialias?: boolean

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/extract/GenerateTextureSystem.d.ts:122

Whether to enable anti-aliasing. This may affect performance.

Default

false

Example

// Generate a smooth texture
const texture = renderer.generateTexture({
    target: graphics,
    antialias: true
});

clearColor?

> optional clearColor?: ColorSource

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/extract/GenerateTextureSystem.d.ts:109

The color used to clear the texture before rendering. Can be a hex number, string, or array of numbers.

Example

// Clear with red background
const texture = renderer.generateTexture({
    target: sprite,
    clearColor: '#ff0000'
});

// Clear with semi-transparent black
const texture = renderer.generateTexture({
    target: sprite,
    clearColor: [0, 0, 0, 0.5]
});

defaultAnchor?

> optional defaultAnchor?: object

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/extract/GenerateTextureSystem.d.ts:133

Default anchor point for the generated texture.

x

> x: number

y

> y: number

Example

const texture = renderer.generateTexture({
    target: sprite,
    defaultAnchor: { x: 0.5, y: 0.5 } // Center the anchor
});

frame?

> optional frame?: Rectangle

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/extract/GenerateTextureSystem.d.ts:76

The region of the container that should be rendered. If not specified, defaults to the local bounds of the container.

Example

// Extract only a portion of the container
const texture = renderer.generateTexture({
    target: container,
    frame: new Rectangle(10, 10, 100, 100)
});

resolution?

> optional resolution?: number

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/extract/GenerateTextureSystem.d.ts:90

The resolution of the texture being generated. Higher values create sharper textures at the cost of memory.

Default

renderer.resolution

Example

// Generate a high-resolution texture
const hiResTexture = renderer.generateTexture({
    target: sprite,
    resolution: 2 // 2x resolution
});

target

> target: Container

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/extract/GenerateTextureSystem.d.ts:63

The container to generate the texture from. This can be any display object like Sprite, Container, or Graphics.

Example

const graphics = new Graphics()
    .circle(0, 0, 50)
    .fill('red');

const texture = renderer.generateTexture({
    target: graphics
});

textureSourceOptions?

> optional textureSourceOptions?: GenerateTextureSourceOptions

Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/extract/GenerateTextureSystem.d.ts:151

Advanced options for configuring the texture source. Controls texture properties like scale mode and filtering.

Advanced

Example

const texture = renderer.generateTexture({
    target: sprite,
    textureSourceOptions: {
        scaleMode: 'linear',
    }
});