Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

GradientTexture2D

Inherits: Texture2D < Texture < Resource < RefCounted < Object

A 2D texture that creates a pattern with colors obtained from a Gradient.

Description

A 2D texture that obtains colors from a Gradient to fill the texture data. This texture is able to transform a color transition into different patterns such as a linear or a radial gradient. The gradient is sampled individually for each pixel so it does not necessarily represent an exact copy of the gradient(see width and height). See also GradientTexture1D, CurveTexture and CurveXYZTexture.

Properties

Fill

fill

0

Vector2

fill_from

Vector2(0, 0)

Vector2

fill_to

Vector2(1, 0)

Gradient

gradient

int

height

64

Repeat

repeat

0

bool

resource_local_to_scene

false (overrides Resource)

bool

use_hdr

false

int

width

64


Enumerations

enum Fill:

Fill FILL_LINEAR = 0

The colors are linearly interpolated in a straight line.

Fill FILL_RADIAL = 1

The colors are linearly interpolated in a circular pattern.

Fill FILL_SQUARE = 2

The colors are linearly interpolated in a square pattern.


enum Repeat:

Repeat REPEAT_NONE = 0

The gradient fill is restricted to the range defined by fill_from to fill_to offsets.

Repeat REPEAT = 1

The texture is filled starting from fill_from to fill_to offsets, repeating the same pattern in both directions.

Repeat REPEAT_MIRROR = 2

The texture is filled starting from fill_from to fill_to offsets, mirroring the pattern in both directions.


Property Descriptions

Fill fill = 0

  • void set_fill ( Fill value )

  • Fill get_fill ( )

The gradient fill type, one of the Fill values. The texture is filled by interpolating colors starting from fill_from to fill_to offsets.


Vector2 fill_from = Vector2(0, 0)

The initial offset used to fill the texture specified in UV coordinates.


Vector2 fill_to = Vector2(1, 0)

The final offset used to fill the texture specified in UV coordinates.


Gradient gradient

The Gradient used to fill the texture.


int height = 64