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.
Checking the stable version of the documentation...
ColorPicker
繼承: VBoxContainer < BoxContainer < Container < Control < CanvasItem < Node < Object
提供用於選擇或修改顏色的介面的小工具。
說明
提供用於選擇或修改顏色的介面的小工具。還可以提供取色器(吸管)、顏色模式、預設等功能。
注意:這個控制項就是取色器本身。如果你需要一個能夠彈出 ColorPicker 窗口的按鈕,可以改用 ColorPickerButton。
教學
屬性
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
方法
void |
add_preset(color: Color) |
void |
add_recent_preset(color: Color) |
void |
erase_preset(color: Color) |
void |
erase_recent_preset(color: Color) |
get_presets() const |
|
get_recent_presets() const |
主題屬性
|
||
|
||
|
||
|
||
|
||
|
||
|
||
訊號
更改顏色時發出。
新增預設時發出。
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 色彩空間更好地配對感知,同時在預測感知亮度、色度和色調方面做得很好。
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 🔗
如果為 true,則可以在色板下新增預設。如果為 false,新增預設的按鈕將被禁用。
Color color = Color(1, 1, 1, 1) 🔗
目前選擇的顏色。
ColorModeType color_mode = 0 🔗
void set_color_mode(value: ColorModeType)
ColorModeType get_color_mode()
The currently selected color mode.
bool color_modes_visible = true 🔗
如果為 true,則顏色模式按鈕可見。
如果為 true,只有在使用者鬆開滑鼠按鈕後才會套用顏色,否則即使在鼠標移動事件中也會立即套用(會造成性能問題)。
如果為 true,則顯示 Alpha 通道滑動條(不透明度)。
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.
如果為 true,則十六進位顏色程式碼輸入框可見。
PickerShapeType picker_shape = 0 🔗
void set_picker_shape(value: PickerShapeType)
PickerShapeType get_picker_shape()
The shape of the color space view.
如果為 true,則色板和近期顏色預設可見。
如果為 true,則顏色取樣器和顏色預覽可見。
如果為 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 主題屬性。
色相選擇滑桿的寬度。
滑桿旁顏色標籤的最小寬度。
ColorPicker 周圍的邊距。
飽和值選擇框的高度。
飽和度選擇框的寬度。
“新增預設”按鈕的圖示。
箭頭抓取器的紋理。
The icon for the button that copies the color in text format to the clipboard.
右側的色相選擇滑桿的自訂紋理。
The icon for the button that switches color text to hexadecimal.
顏色預設下拉式功能表展開時使用的圖示。
顏色預設下拉式功能表折疊時使用的圖示。
The icon for color preset option menu.
Texture2D overbright_indicator 🔗
該指示器用於指示顏色值在 0-1 範圍之外。
顯示在色塊/圓(取決於 picker_shape)上的圖像,標記目前選擇的顏色。
The fill image displayed behind the picker cursor.
顏色預覽框的背景面板(顏色為半透明時可見)。
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.
螢幕取色器按鈕的圖示。
圓形拾取器形狀的圖示。
矩形拾取器形狀的圖示。
矩形輪拾取器形狀的圖示。
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.
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.