Ver código fonte

[F] Fix preset length calculation

Azalea (on HyDEV-Daisy) 3 anos atrás
pai
commit
4ba359a161
2 arquivos alterados com 16 adições e 1 exclusões
  1. 1 1
      hyfetch/presets.py
  2. 15 0
      test.py

+ 1 - 1
hyfetch/presets.py

@@ -54,7 +54,7 @@ class ColorProfile:
         while extras > 0:
             extras -= 2
             weights[border_i] += 1
-            weights[-border_i] += 1
+            weights[-(border_i + 1)] += 1
             border_i += 1
 
         return self.with_weights(weights)

+ 15 - 0
test.py

@@ -0,0 +1,15 @@
+from hyfetch.color_util import RGB
+from hyfetch.presets import PRESETS
+
+
+def print_colors_test(colors: list[RGB]):
+    print(''.join(f'{c.to_ansi_rgb()}#' for c in colors))
+
+
+if __name__ == '__main__':
+    p = PRESETS.get('transgender')
+    print_colors_test(p.with_length(9))
+    print_colors_test(p.with_length(6))
+    p = PRESETS.get('nonbinary')
+    print_colors_test(p.with_length(7))
+    print_colors_test(p.with_length(6))