Browse Source

[+] Add reference for default brightness

Azalea (on HyDEV-Daisy) 3 years ago
parent
commit
b68e0ccf52
3 changed files with 10 additions and 5 deletions
  1. 6 0
      hyfetch/constants.py
  2. 2 2
      hyfetch/main.py
  3. 2 3
      hyfetch/presets.py

+ 6 - 0
hyfetch/constants.py

@@ -30,6 +30,7 @@ _/\_\_   _/_/\_
 |##|  (_(  |##|""".strip('\n')
 |##|  (_(  |##|""".strip('\n')
 
 
 TEST_ASCII_WIDTH = max(len(line) for line in TEST_ASCII.split('\n'))
 TEST_ASCII_WIDTH = max(len(line) for line in TEST_ASCII.split('\n'))
+DEFAULT_DARK_L = 0.
 
 
 @dataclass
 @dataclass
 class GlobalConfig:
 class GlobalConfig:
@@ -42,5 +43,10 @@ class GlobalConfig:
     def light_dark(self) -> Literal['light', 'dark']:
     def light_dark(self) -> Literal['light', 'dark']:
         return 'light' if self.is_light else 'dark'
         return 'light' if self.is_light else 'dark'
 
 
+    def default_lightness(self, term: Literal['light', 'dark'] | None = None) -> float:
+        if term is None:
+            term = self.light_dark()
+        return 0.65 if term.lower() == 'dark' else 0.4
+
 
 
 GLOBAL_CFG = GlobalConfig(color_mode='8bit', override_distro=None, debug=False, is_light=False)
 GLOBAL_CFG = GlobalConfig(color_mode='8bit', override_distro=None, debug=False, is_light=False)

+ 2 - 2
hyfetch/main.py

@@ -146,14 +146,14 @@ def create_config() -> Config:
     # Print cats
     # Print cats
     num_cols = TERM_LEN // (TEST_ASCII_WIDTH + 2)
     num_cols = TERM_LEN // (TEST_ASCII_WIDTH + 2)
     ratios = [col / (num_cols - 1) for col in range(num_cols)]
     ratios = [col / (num_cols - 1) for col in range(num_cols)]
-    ratios = [r * 0.6 + 0.2 for r in ratios]
+    ratios = [(r * 0.4 + 0.1) if is_light else (r * 0.4 + 0.5) for r in ratios]
     lines = [ColorAlignment('horizontal').recolor_ascii(TEST_ASCII.replace(
     lines = [ColorAlignment('horizontal').recolor_ascii(TEST_ASCII.replace(
         '{txt}', f'{r * 100:.0f}%'.center(5)), _prs.set_light_dl(r, light_dark)).split('\n') for r in ratios]
         '{txt}', f'{r * 100:.0f}%'.center(5)), _prs.set_light_dl(r, light_dark)).split('\n') for r in ratios]
     [printc('  '.join(line)) for line in zip(*lines)]
     [printc('  '.join(line)) for line in zip(*lines)]
 
 
     while True:
     while True:
         print()
         print()
-        printc('Which brightness level look the best? (Default: unset)')
+        printc(f'Which brightness level look the best? (Default: left blank = {GLOBAL_CFG.default_lightness(light_dark):.2f} for {light_dark} mode)')
         lightness = input('> ').strip().lower() or None
         lightness = input('> ').strip().lower() or None
 
 
         # Parse lightness
         # Parse lightness

+ 2 - 3
hyfetch/presets.py

@@ -124,15 +124,14 @@ class ColorProfile:
         at_least, at_most = (True, None) if term.lower() == 'dark' else (None, True)
         at_least, at_most = (True, None) if term.lower() == 'dark' else (None, True)
         return self.set_light_raw(light, at_least, at_most)
         return self.set_light_raw(light, at_least, at_most)
 
 
-    def set_light_dl_def(self, term: LightDark = GLOBAL_CFG.light_dark()):
+    def set_light_dl_def(self, term: LightDark | None = None):
         """
         """
         Set default lightness with respect to dark/light terminals
         Set default lightness with respect to dark/light terminals
 
 
         :param term: Terminal color (can be "dark" or "light")
         :param term: Terminal color (can be "dark" or "light")
         :return: New color profile (original isn't modified)
         :return: New color profile (original isn't modified)
         """
         """
-        light = 0.65 if term.lower() == 'dark' else 0.4
-        return self.set_light_dl(light, term)
+        return self.set_light_dl(GLOBAL_CFG.default_lightness(term), term)
 
 
     def unique_colors(self) -> ColorProfile:
     def unique_colors(self) -> ColorProfile:
         """
         """