From 413d90f8e6af3012fa0dd6841c34b822e43ff7ae Mon Sep 17 00:00:00 2001 From: Griatch Date: Sun, 29 Sep 2024 14:14:52 +0200 Subject: [PATCH] Made true color display more flexible, but decided to still keep it at one line since multiple could be mis-interpreted --- evennia/commands/default/account.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/evennia/commands/default/account.py b/evennia/commands/default/account.py index 51f3978de9..55cca35525 100644 --- a/evennia/commands/default/account.py +++ b/evennia/commands/default/account.py @@ -838,10 +838,10 @@ class CmdColorTest(COMMAND_DEFAULT_CLASS): ) return ftable - def make_hex_color_from_column(self, column_number): - r = 255 - column_number * 255 / 76 - g = column_number * 510 / 76 - b = column_number * 255 / 76 + def make_hex_color_from_column(self, column_number, count): + r = 255 - column_number * 255 / count + g = column_number * 510 / count + b = column_number * 255 / count if g > 255: g = 510 - g @@ -936,8 +936,16 @@ class CmdColorTest(COMMAND_DEFAULT_CLASS): "True Colors (if this is not a smooth rainbow transition, your client might not " "report that it can handle truecolor): \n" ) - for i in range(76): - string += f"|[{self.make_hex_color_from_column(i)} |n" + display_width = self.client_width() + num_colors = display_width * 1 + color_block = [ + f"|[{self.make_hex_color_from_column(i, num_colors)} " for i in range(num_colors) + ] + color_block = [ + "".join(color_block[iline : iline + display_width]) + for iline in range(0, num_colors, display_width) + ] + string += "\n".join(color_block) string += ( "\n|nfg: |#FF0000||#FF0000|n (|#F00||#F00|n) to |#0000FF||#0000FF|n (|#00F||#00F|n)"