greet.py 871 B

123456789101112131415161718192021222324252627282930313233343536
  1. def grad(n):
  2. s = 0x08
  3. r = 0xff
  4. g = 0x00
  5. b = 0x00
  6. for i in range(n):
  7. if r >= s and b < s:
  8. r -= s
  9. g += s
  10. elif g >= s and r < s:
  11. g -= s
  12. b += s
  13. elif b >= s and g < s:
  14. b -= s
  15. r += s
  16. return f'#{r:02x}{g:02x}{b:02x}'
  17. def fancy_greet(version):
  18. from rich.console import Console
  19. from rich.text import Text
  20. zc_msg = fr'''
  21. ||| . . _ _._|_ _. . . _ .__ _.. _. . __.. _ __. .
  22. ||| //\|/ |/_| | == / / \|/ |( /_||/ | | __||/ |/ \_|
  23. ||| \_/| |\_ |. \__\_/| |_) \_ | \/ |__|| |\__ _/
  24. |||
  25. ||| v{version}
  26. '''
  27. lns = zc_msg.split('\n')
  28. console = Console()
  29. for l in lns:
  30. txt = Text(l)
  31. txt.stylize('bold')
  32. for i in range(len(l)):
  33. txt.stylize(grad(i), i, i+1)
  34. console.print(txt)