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.

ColorPicker

繼承: VBoxContainer < BoxContainer < Container < Control < CanvasItem < Node < Object

提供用於選擇或修改顏色的介面的小工具。

說明

提供用於選擇或修改顏色的介面的小工具。還可以提供取色器(吸管)、顏色模式、預設等功能。

注意:這個控制項就是取色器本身。如果你需要一個能夠彈出 ColorPicker 窗口的按鈕,可以改用 ColorPickerButton

教學

屬性

bool

can_add_swatches

true

Color

color

Color(1, 1, 1, 1)

ColorModeType

color_mode

0

bool

color_modes_visible

true

bool

deferred_mode

false

bool

edit_alpha

true

bool

edit_intensity

true

bool

hex_visible

true

PickerShapeType

picker_shape

0

bool

presets_visible

true

bool

sampler_visible

true

bool

sliders_visible

true

方法

void

add_preset(color: Color)

void

add_recent_preset(color: Color)

void

erase_preset(color: Color)

void

erase_recent_preset(color: Color)

PackedColorArray

get_presets() const

PackedColorArray

get_recent_presets() const

主題屬性

Color

focused_not_editing_cursor_color

Color(1, 1, 1, 0.275)

int

center_slider_grabbers

1

int

h_width

30

int

label_width

10

int

margin

4

int

sv_height

256

int

sv_width

256

Texture2D

add_preset

Texture2D

bar_arrow

Texture2D

color_copy

Texture2D

color_hue

Texture2D

color_script

Texture2D

expanded_arrow

Texture2D

folded_arrow

Texture2D

menu_option

Texture2D

overbright_indicator

Texture2D

picker_cursor

Texture2D

picker_cursor_bg

Texture2D

sample_bg

Texture2D

sample_revert

Texture2D

screen_picker

Texture2D

shape_circle

Texture2D

shape_rect

Texture2D

shape_rect_wheel

StyleBox

picker_focus_circle

StyleBox

picker_focus_rectangle

StyleBox

sample_focus


訊號

color_changed(color: Color) 🔗

更改顏色時發出。


preset_added(color: Color) 🔗

新增預設時發出。


preset_removed(color: Color) 🔗

移除預設時發出。


列舉

enum ColorModeType: 🔗

ColorModeType MODE_RGB = 0

Allows editing the color with Red/Green/Blue sliders in sRGB color space.

ColorModeType MODE_HSV = 1

允許使用色相、飽和度、明度滑桿編輯顏色。

ColorModeType MODE_RAW = 2

已棄用: This is replaced by MODE_LINEAR.

ColorModeType MODE_LINEAR = 2

Allows editing the color with Red/Green/Blue sliders in linear color space.

ColorModeType MODE_OKHSL = 3

允許使用色相/飽和度/亮度滑桿編輯顏色。

OKHSL 是一種類似於 HSL 的新色彩空間,但通過利用設計簡單易用的 Oklab 色彩空間更好地配對感知,同時在預測感知亮度、色度和色調方面做得很好。

Okhsv 和 Okhsl 色彩空間


enum PickerShapeType: 🔗

PickerShapeType SHAPE_HSV_RECTANGLE = 0

HSV 色彩模型矩形色彩空間。

PickerShapeType SHAPE_HSV_WHEEL = 1

HSV 色彩模型矩形色彩空間,帶輪。

PickerShapeType SHAPE_VHS_CIRCLE = 2

HSV 色彩模型圓形色彩空間。半徑為飽和度。

PickerShapeType SHAPE_OKHSL_CIRCLE = 3

HSL OK 色彩模型圓形色彩空間。

PickerShapeType SHAPE_NONE = 4

色彩空間形狀和形狀選擇按鈕被隱藏。不能從形狀快顯視窗中選擇。

PickerShapeType SHAPE_OK_HS_RECTANGLE = 5

OKHSL Color Model rectangle with constant lightness.

PickerShapeType SHAPE_OK_HL_RECTANGLE = 6

OKHSL Color Model rectangle with constant saturation.


屬性說明

bool can_add_swatches = true 🔗

  • void set_can_add_swatches(value: bool)

  • bool are_swatches_enabled()

如果為 true,則可以在色板下新增預設。如果為 false,新增預設的按鈕將被禁用。


Color color = Color(1, 1, 1, 1) 🔗

  • void set_pick_color(value: Color)

  • Color get_pick_color()

目前選擇的顏色。


ColorModeType color_mode = 0 🔗

The currently selected color mode.


bool color_modes_visible = true 🔗

  • void set_modes_visible(value: bool)

  • bool are_modes_visible()

如果為 true,則顏色模式按鈕可見。


bool deferred_mode = false 🔗

  • void set_deferred_mode(value: bool)

  • bool is_deferred_mode()

如果為 true,只有在使用者鬆開滑鼠按鈕後才會套用顏色,否則即使在鼠標移動事件中也會立即套用(會造成性能問題)。


bool edit_alpha = true 🔗

  • void set_edit_alpha(value: bool)

  • bool is_editing_alpha()

如果為 true,則顯示 Alpha 通道滑動條(不透明度)。


bool edit_intensity = true 🔗

  • void set_edit_intensity(value: bool)

  • bool is_editing_intensity()

If true, shows an intensity slider. The intensity is applied as follows: convert the color to linear encoding, multiply it by 2 ** intensity, and then convert it back to nonlinear sRGB encoding.


bool hex_visible = true 🔗

  • void set_hex_visible(value: bool)

  • bool is_hex_visible()

如果為 true,則十六進位顏色程式碼輸入框可見。


PickerShapeType picker_shape = 0 🔗

The shape of the color space view.


bool presets_visible = true 🔗

  • void set_presets_visible(value: bool)

  • bool are_presets_visible()

如果為 true,則色板和近期顏色預設可見。


bool sampler_visible = true 🔗

  • void set_sampler_visible(value: bool)

  • bool is_sampler_visible()

如果為 true,則顏色取樣器和顏色預覽可見。


bool sliders_visible = true 🔗

  • void set_sliders_visible(value: bool)

  • bool are_sliders_visible()

如果為 true,則顏色滑桿可見。


方法說明

void add_preset(color: Color) 🔗

將給定的顏色新增到顏色預設列表中。預設會顯示在取色器中,可以被使用者選擇。

注意:預設列表僅適用於這個取色器。


void add_recent_preset(color: Color) 🔗

將給定的顏色新增到近期顏色預設列表中,以便以後可以選擇它。近期預設是最近選擇的顏色,當選擇新顏色時,會自動建立新的預設並將其新增到近期預設中。

注意:近期預設列表僅適用於這個取色器。


void erase_preset(color: Color) 🔗

從這個取色器的顏色預設列表中移除給定的顏色。


void erase_recent_preset(color: Color) 🔗

從這個取色器的顏色近期預設列表中移除給定的顏色。


PackedColorArray get_presets() const 🔗

返回取色器的預設顏色列表。


PackedColorArray get_recent_presets() const 🔗

返回取色器的近期預設中的顏色列表。


主題屬性說明

Color focused_not_editing_cursor_color = Color(1, 1, 1, 0.275) 🔗

Color of rectangle or circle drawn when a picker shape part is focused but not editable via keyboard or joypad. Displayed over the picker shape, so a partially transparent color should be used to ensure the picker shape remains visible.


int center_slider_grabbers = 1 🔗

覆蓋滑桿的 Slider.center_grabber 主題屬性。


int h_width = 30 🔗

色相選擇滑桿的寬度。


int label_width = 10 🔗

滑桿旁顏色標籤的最小寬度。


int margin = 4 🔗

ColorPicker 周圍的邊距。


int sv_height = 256 🔗

飽和值選擇框的高度。


int sv_width = 256 🔗

飽和度選擇框的寬度。


Texture2D add_preset 🔗

“新增預設”按鈕的圖示。


Texture2D bar_arrow 🔗

箭頭抓取器的紋理。


Texture2D color_copy 🔗

The icon for the button that copies the color in text format to the clipboard.


Texture2D color_hue 🔗

右側的色相選擇滑桿的自訂紋理。


Texture2D color_script 🔗

The icon for the button that switches color text to hexadecimal.


Texture2D expanded_arrow 🔗

顏色預設下拉式功能表展開時使用的圖示。


Texture2D folded_arrow 🔗

顏色預設下拉式功能表折疊時使用的圖示。


Texture2D menu_option 🔗

The icon for color preset option menu.


Texture2D overbright_indicator 🔗

該指示器用於指示顏色值在 0-1 範圍之外。


Texture2D picker_cursor 🔗

顯示在色塊/圓(取決於 picker_shape)上的圖像,標記目前選擇的顏色。


Texture2D picker_cursor_bg 🔗

The fill image displayed behind the picker cursor.


Texture2D sample_bg 🔗

顏色預覽框的背景面板(顏色為半透明時可見)。


Texture2D sample_revert 🔗

The icon for the revert button (visible on the middle of the "old" color when it differs from the currently selected color). This icon is modulated with a dark color if the "old" color is bright enough, so the icon should be bright to ensure visibility in both scenarios.


Texture2D screen_picker 🔗

螢幕取色器按鈕的圖示。


Texture2D shape_circle 🔗

圓形拾取器形狀的圖示。


Texture2D shape_rect 🔗

矩形拾取器形狀的圖示。


Texture2D shape_rect_wheel 🔗

矩形輪拾取器形狀的圖示。


StyleBox picker_focus_circle 🔗

The StyleBox used when the circle-shaped part of the picker is focused. Displayed over the picker shape, so a partially transparent StyleBox should be used to ensure the picker shape remains visible. A StyleBox that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a StyleBoxEmpty resource. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.


StyleBox picker_focus_rectangle 🔗

The StyleBox used when the rectangle-shaped part of the picker is focused. Displayed over the picker shape, so a partially transparent StyleBox should be used to ensure the picker shape remains visible. A StyleBox that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a StyleBoxEmpty resource. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.


StyleBox sample_focus 🔗

The StyleBox used for the old color sample part when it is focused. Displayed over the sample, so a partially transparent StyleBox should be used to ensure the picker shape remains visible. A StyleBox that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a StyleBoxEmpty resource. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.