diff options
author | jsjtxietian <jsjtxietian@outlook.com> | 2024-03-18 12:51:32 +0800 |
---|---|---|
committer | jsjtxietian <jsjtxietian@outlook.com> | 2024-04-15 19:48:41 +0800 |
commit | be0dc5271833ae19b30f60e65b8dc1e6f0f49bea (patch) | |
tree | 818e9aa972d0b4443c8cebc9389c0147db27a442 | |
parent | d00734053f9cda8ade5e6c3afd86266e6df571c6 (diff) | |
download | redot-engine-be0dc5271833ae19b30f60e65b8dc1e6f0f49bea.tar.gz |
Make "Pick Color"'s result less precise, keep only 3 decimals
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 0a6eacf11d..fb91792fd7 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -2122,10 +2122,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); |