summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-05-22 09:26:37 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-05-22 09:26:37 +0200
commite34b97312e91606dae2e26064dcd628dc360dc88 (patch)
treed8075d15ec36d841d6c888a8c907fefed5a49a1d
parent214968243c442c0fdcbdfef23943c1547aeafdbc (diff)
parentbe0dc5271833ae19b30f60e65b8dc1e6f0f49bea (diff)
downloadredot-engine-e34b97312e91606dae2e26064dcd628dc360dc88.tar.gz
Merge pull request #89630 from jsjtxietian/pick-color
Make "Pick Color"'s result less precise, keep only 3 decimals
-rw-r--r--editor/plugins/script_text_editor.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 191d58228b..f3f6fc91a9 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -2133,10 +2133,11 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
void ScriptTextEditor::_color_changed(const Color &p_color) {
String new_args;
+ const int decimals = 3;
if (p_color.a == 1.0f) {
- new_args = String("(" + rtos(p_color.r) + ", " + rtos(p_color.g) + ", " + rtos(p_color.b) + ")");
+ new_args = String("(" + String::num(p_color.r, decimals) + ", " + String::num(p_color.g, decimals) + ", " + String::num(p_color.b, decimals) + ")");
} else {
- new_args = String("(" + rtos(p_color.r) + ", " + rtos(p_color.g) + ", " + rtos(p_color.b) + ", " + rtos(p_color.a) + ")");
+ new_args = String("(" + String::num(p_color.r, decimals) + ", " + String::num(p_color.g, decimals) + ", " + String::num(p_color.b, decimals) + ", " + String::num(p_color.a, decimals) + ")");
}
String line = code_editor->get_text_editor()->get_line(color_position.x);