Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

GradientTexture2D

繼承: Texture2D < Texture < Resource < RefCounted < Object

將從 Gradient 中獲得的顏色樣本的數量。

說明

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 texture is filled by interpolating colors starting from fill_from to fill_to offsets by default, but the gradient fill can be repeated to cover the entire texture.

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.

屬性

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


列舉

enum Fill: 🔗

Fill FILL_LINEAR = 0

顏色按照直線進行線性插值。

Fill FILL_RADIAL = 1

顏色按照圓形模式進行線性插值。

Fill FILL_SQUARE = 2

顏色按照方形模式進行線性插值。

Fill FILL_CONIC = 3

The colors are linearly interpolated in a cone pattern.


enum Repeat: 🔗

Repeat REPEAT_NONE = 0

漸變填充限制在由 fill_fromfill_to 的偏移量範圍內。

Repeat REPEAT = 1

紋理的填充從偏移量 fill_from 開始到 fill_to,兩個方向都按照相同的模式重複。

Repeat REPEAT_MIRROR = 2

紋理的填充從偏移量 fill_from 開始到 fill_to,兩個方向都按照相同的模式鏡像重複。


屬性說明

Fill fill = 0 🔗

  • void set_fill(value: Fill)

  • Fill get_fill()

The gradient's fill type.


Vector2 fill_from = Vector2(0, 0) 🔗

用於填充紋理的初始偏移量,使用 UV 座標。


Vector2 fill_to = Vector2(1, 0) 🔗

用於填充紋理的結束偏移量,使用 UV 座標。


Gradient gradient 🔗

用於填充紋理的 Gradient


int height = 64 🔗

  • void set_height(value: int)

  • int get_height()

Gradient 上獲取的垂直顏色取樣數,也表示紋理的高度。


Repeat repeat = 0 🔗

The gradient's repeat type.


bool use_hdr = false 🔗

  • void set_use_hdr(value: bool)

  • bool is_using_hdr()

如果為 true,則生成的紋理會支援高動態範圍(Image.FORMAT_RGBAF 格式)。可以在 Environment.glow_enabledtrue 時實作輝光效果。如果為 false,則生成的紋理會使用低動態範圍;過亮的顏色會被鉗制(Image.FORMAT_RGBA8 格式)。


int width = 64 🔗

  • void set_width(value: int)

  • int get_width()

Gradient 上獲取的水平顏色取樣數,也表示紋理的寬度。