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 |
主题属性¶
|
||
|
||
|
||
|
||
|
||
|
||
信号¶
color_changed ( Color color )
更改颜色时发出。
preset_added ( Color color )
添加预设时发出。
preset_removed ( Color color )
移除预设时发出。
枚举¶
enum ColorModeType:
ColorModeType MODE_RGB = 0
允许使用红、绿、蓝滑块编辑颜色。
ColorModeType MODE_HSV = 1
允许使用色相、饱和度、明度滑块编辑颜色。
ColorModeType MODE_RAW = 2
允许颜色 R、G、B 分量值超过 1.0,这可用于某些需要它的特殊操作(例如在 HDR 中,着色而不变暗或渲染精灵)。
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
色彩空间形状和形状选择按钮被隐藏。不能从形状弹出窗口中选择。
属性说明¶
bool can_add_swatches = true
如果为 true
,则可以在色板下添加预设。如果为 false
,添加预设的按钮将被禁用。
Color color = Color(1, 1, 1, 1)
当前选择的颜色。
ColorModeType color_mode = 0
void set_color_mode ( ColorModeType value )
ColorModeType get_color_mode ( )
当前选择的颜色模式。见 ColorModeType。
bool color_modes_visible = true
如果为 true
,则颜色模式按钮可见。
bool deferred_mode = false
如果为 true
,只有在用户松开鼠标按钮后才会应用颜色,否则即使在鼠标移动事件中也会立即应用(会造成性能问题)。
bool edit_alpha = true
如果为 true
,则显示 Alpha 通道滑动条(不透明度)。
bool hex_visible = true
如果为 true
,则十六进制颜色代码输入框可见。
PickerShapeType picker_shape = 0
void set_picker_shape ( PickerShapeType value )
PickerShapeType get_picker_shape ( )
色彩空间视图的形状。见 PickerShapeType。
bool presets_visible = true
如果为 true
,则色板和近期颜色预设可见。
bool sampler_visible = true
如果为 true
,则颜色采样器和颜色预览可见。
bool sliders_visible = 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
返回取色器的近期预设中的颜色列表。
主题属性说明¶
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_hue
右侧的色相选择滑块的自定义纹理。
Texture2D color_okhsl_hue
OKHSL 颜色模式的 H 滑块的自定义纹理。
Texture2D expanded_arrow
颜色预设下拉菜单展开时使用的图标。
Texture2D folded_arrow
颜色预设下拉菜单折叠时使用的图标。
Texture2D overbright_indicator
该指示器用于指示颜色值在 0-1 范围之外。
Texture2D picker_cursor
显示在颜色框/圆(取决于 picker_shape)上的图像,标记当前选择的颜色。
Texture2D sample_bg
颜色预览框的背景面板(颜色为半透明时可见)。
Texture2D screen_picker
屏幕取色器按钮的图标。
Texture2D shape_circle
圆形拾取器形状的图标。
Texture2D shape_rect
矩形拾取器形状的图标。
Texture2D shape_rect_wheel
矩形轮拾取器形状的图标。