# Class: FillPattern

A class that represents a fill pattern for use in Text and Graphics fills.
It allows for textures to be used as patterns, with optional repetition modes.

Patterns default to [\`textureSpace: 'global'\`](scene.FillStyle.html#texturespace),
meaning tiles repeat continuously across world space and adjacent shapes share
the same tiling grid. Pass `textureSpace: 'local'` to map a single tile to each
shape's bounds instead.

## Example

```ts
const txt = await Assets.load('https://pixijs.com/assets/bg_scene_rotate.jpg');

// global tiling (default) — pattern continues across shapes
const pat = new FillPattern({ texture: txt, repetition: 'repeat' });

// legacy positional form is still supported
const pat2 = new FillPattern(txt, 'repeat');

const textPattern = new Text({
    text: 'PixiJS',
    style: {
        fontSize: 36,
        fill: 0xffffff,
        stroke: { fill: pat, width: 10 },
    },
});
```

## Implements

- [`CanvasPattern`](https://developer.mozilla.org/docs/Web/API/CanvasPattern)

## Constructors

### Constructor

> **new FillPattern**(`options`): `FillPattern`

Creates a new fill pattern.

#### Parameters

##### options

[`FillPatternOptions`](scene.FillPatternOptions.html.md)

The options for the fill pattern.

#### Returns

`FillPattern`

### Constructor

> **new FillPattern**(`texture`, `repetition?`): `FillPattern`

Creates a new fill pattern from a texture and optional repetition mode.

#### Parameters

##### texture

[`Texture`](rendering.Texture.html.md)

The texture to tile.

##### repetition?

[`PatternRepetition`](scene.PatternRepetition.html.md)

How the pattern should repeat.

#### Returns

`FillPattern`

## Properties

### textureSpace

> **textureSpace**: [`TextureSpace`](scene.TextureSpace.html.md)

Whether pattern coordinates are evaluated in local or global space.

#### Default

```ts
'global'
```

***

### transform

> **transform**: [`Matrix`](maths.Matrix.html.md)

The transform matrix applied to the pattern

## Accessors

### styleKey

#### Get Signature

> **get** **styleKey**(): `string`

Returns a unique key for this instance.
This key is used for caching.

##### Returns

`string`

Unique key for the instance

***

### texture

#### Get Signature

> **get** **texture**(): [`Texture`](rendering.Texture.html.md)\<[`TextureSource`](rendering.TextureSource.html.md)\<`any`\>\>

Internal texture used to render the gradient

##### Returns

[`Texture`](rendering.Texture.html.md)\<[`TextureSource`](rendering.TextureSource.html.md)\<`any`\>\>

#### Set Signature

> **set** **texture**(`value`): `void`

##### Parameters

###### value

[`Texture`](rendering.Texture.html.md)

##### Returns

`void`

## Methods

### destroy()

> **destroy**(): `void`

Destroys the fill pattern, releasing resources. This will also destroy the internal texture.

#### Returns

`void`

***

### setTransform()

> **setTransform**(`transform?`): `void`

Sets the transform for the pattern

#### Parameters

##### transform?

[`Matrix`](maths.Matrix.html.md)

The transform matrix to apply to the pattern.
If not provided, the pattern will use the default transform.

#### Returns

`void`

#### Implementation of

`CanvasPattern.setTransform`
