Skip to content

Commit

Permalink
Merge pull request #89630 from jsjtxietian/pick-color
Browse files Browse the repository at this point in the history
Make "Pick Color"'s result less precise, keep only 3 decimals
  • Loading branch information
akien-mga committed May 22, 2024
2 parents 2149682 + be0dc52 commit e34b973
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions editor/plugins/script_text_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e34b973

Please sign in to comment.