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 中獲得的顏色樣本的數量。

說明

2D 紋理,從 Gradient 中取得顏色來填充紋理資料。該紋理能夠將顏色過渡轉換為不同的圖案,例如線性漸變或徑向漸變。填充紋理時,預設會從偏移 fill_from 的位置到偏移 fill_to 的位置對顏色進行插值,但漸變填充也可以在整張紋理上重複。

漸變是針對每個像素單獨取樣的,因此不一定代表漸變的精確副本(見 width 和 height)。另見 GradientTexture1D、CurveTexture、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

顏色會以錐形圖案進行線性插值。


enum Repeat: 🔗

Repeat REPEAT_NONE = 0

漸變填充限制在由 fill_from 到 fill_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()

漸變的填充型別。


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 🔗

漸變的重複型別。


bool use_hdr = false 🔗

  • void set_use_hdr(value: bool)

  • bool is_using_hdr()

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


int width = 64 🔗

  • void set_width(value: int)

  • int get_width()

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