ColorPicker
Inherits: VBoxContainer < BoxContainer < Container < Control < CanvasItem < Entity < Object
Description
Section titled “Description”A widget that provides an interface for selecting or modifying a color.
A widget that provides an interface for selecting or modifying a color. It can optionally provide functionalities like a color sampler (eyedropper), color modes, and presets.
Note: This control is the color picker widget itself. You can use a ColorPickerButton instead if you need a button that brings up a ColorPicker in a popup.
Properties
Section titled “Properties”| Type | Name | Default |
|---|---|---|
| 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 |
Methods
Section titled “Methods”| Returns | Method |
|---|---|
| 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 |
Signals
Section titled “Signals”color_changed
color_changed(color: Color)
Emitted when the color is changed.
preset_added
preset_added(color: Color)
Emitted when a preset is added.
preset_removed
preset_removed(color: Color)
Emitted when a preset is removed.
Enumerations
Section titled “Enumerations”ColorModeType
enum ColorModeType
MODE_RGB = 0
Allows editing the color with Red/Green/Blue sliders in sRGB color space.
MODE_HSV = 1
Allows editing the color with Hue/Saturation/Value sliders.
MODE_LINEAR = 2
Allows editing the color with Red/Green/Blue sliders in linear color space.
MODE_OKHSL = 3
Allows editing the color with Hue/Saturation/Lightness sliders.
OKHSL is a new color space similar to HSL but that better match perception by leveraging the Oklab color space which is designed to be simple to use, while doing a good job at predicting perceived lightness, chroma and hue.
PickerShapeType
enum PickerShapeType
SHAPE_HSV_RECTANGLE = 0
HSV Color Model rectangle color space.
SHAPE_HSV_WHEEL = 1
HSV Color Model rectangle color space with a wheel.
SHAPE_VHS_CIRCLE = 2
HSV Color Model circle color space. Use Saturation as a radius.
SHAPE_OKHSL_CIRCLE = 3
HSL OK Color Model circle color space.
SHAPE_NONE = 4
The color space shape and the shape select button are hidden. Can’t be selected from the shapes popup.
SHAPE_OK_HS_RECTANGLE = 5
OKHSL Color Model rectangle with constant lightness.
SHAPE_OK_HL_RECTANGLE = 6
OKHSL Color Model rectangle with constant saturation.
Theme items
Section titled “Theme items”focused_not_editing_cursor_color
Color focused_not_editing_cursor_color (color) = Color(1, 1, 1, 0.275)
center_slider_grabbers
int center_slider_grabbers (constant) = 1
h_width
int h_width (constant) = 30
label_width
int label_width (constant) = 10
margin
int margin (constant) = 4
sv_height
int sv_height (constant) = 256
sv_width
int sv_width (constant) = 256
add_preset
Texture2D add_preset (icon)
bar_arrow
Texture2D bar_arrow (icon)
color_copy
Texture2D color_copy (icon)
color_hue
Texture2D color_hue (icon)
color_script
Texture2D color_script (icon)
expanded_arrow
Texture2D expanded_arrow (icon)
folded_arrow
Texture2D folded_arrow (icon)
menu_option
Texture2D menu_option (icon)
overbright_indicator
Texture2D overbright_indicator (icon)
picker_cursor
Texture2D picker_cursor (icon)
picker_cursor_bg
Texture2D picker_cursor_bg (icon)
sample_bg
Texture2D sample_bg (icon)
sample_revert
Texture2D sample_revert (icon)
screen_picker
Texture2D screen_picker (icon)
shape_circle
Texture2D shape_circle (icon)
shape_rect
Texture2D shape_rect (icon)
shape_rect_wheel
Texture2D shape_rect_wheel (icon)
picker_focus_circle
StyleBox picker_focus_circle (style)
picker_focus_rectangle
StyleBox picker_focus_rectangle (style)
sample_focus
StyleBox sample_focus (style)
Property descriptions
Section titled “Property descriptions”can_add_swatches
bool can_add_swatches = true
If true, it’s possible to add presets under Swatches. If false, the button to add presets is disabled.
color
Color color = Color(1, 1, 1, 1)
The currently selected color.
color_mode
ColorModeType color_mode = 0
The currently selected color mode.
color_modes_visible
bool color_modes_visible = true
If true, the color mode buttons are visible.
deferred_mode
bool deferred_mode = false
If true, the color will apply only after the user releases the mouse button, otherwise it will apply immediately even in mouse motion event (which can cause performance issues).
edit_alpha
bool edit_alpha = true
If true, shows an alpha channel slider (opacity).
edit_intensity
bool edit_intensity = true
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.
hex_visible
bool hex_visible = true
If true, the hex color code input field is visible.
picker_shape
PickerShapeType picker_shape = 0
The shape of the color space view.
presets_visible
bool presets_visible = true
If true, the Swatches and Recent Colors presets are visible.
sampler_visible
bool sampler_visible = true
If true, the color sampler and color preview are visible.
sliders_visible
bool sliders_visible = true
If true, the color sliders are visible.
Method descriptions
Section titled “Method descriptions”add_preset
void add_preset(color: Color)
Adds the given color to a list of color presets. The presets are displayed in the color picker and the user will be able to select them.
Note: The presets list is only for this color picker.
add_recent_preset
void add_recent_preset(color: Color)
Adds the given color to a list of color recent presets so that it can be picked later. Recent presets are the colors that were picked recently, a new preset is automatically created and added to recent presets when you pick a new color.
Note: The recent presets list is only for this color picker.
erase_preset
void erase_preset(color: Color)
Removes the given color from the list of color presets of this color picker.
erase_recent_preset
void erase_recent_preset(color: Color)
Removes the given color from the list of color recent presets of this color picker.
get_presets
PackedColorArray get_presets() const
Returns the list of colors in the presets of the color picker.
get_recent_presets
PackedColorArray get_recent_presets() const
Returns the list of colors in the recent presets of the color picker.
