colors.py 990 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. """
  2. The following constants are defined to change TEXT colors:
  3. * :const:`RED`
  4. * :const:`GREEN`
  5. * :const:`AMBER`
  6. * :const:`DIM_RED`
  7. * :const:`DIM_GREEN`
  8. * :const:`BROWN`
  9. * :const:`ORANGE`
  10. * :const:`YELLOW`
  11. * :const:`RAINBOW_1`
  12. * :const:`RAINBOW_2`
  13. * :const:`COLOR_MIX`
  14. * :const:`AUTOCOLOR`
  15. """
  16. # Colors
  17. RED = "\x1C1"
  18. GREEN = "\x1C2"
  19. AMBER = "\x1C3"
  20. DIM_RED = "\x1C4"
  21. DIM_GREEN = "\x1C5"
  22. BROWN = "\x1C6"
  23. ORANGE = "\x1C7"
  24. YELLOW = "\x1C8"
  25. RAINBOW_1 = "\x1C9"
  26. RAINBOW_2 = "\x1CA"
  27. COLOR_MIX = "\x1CB"
  28. AUTOCOLOR = "\x1CC"
  29. def rgb(rgb):
  30. """
  31. Create color constant for use in TEXT and STRING files.
  32. :param rgb: 6-character hex string in form RRGGBB.
  33. """
  34. if len(rgb) and rgb[0] == "#":
  35. rgb = rgb[1:]
  36. return "\x1CZ%s" % rgb
  37. def shadow_rgb(rgb):
  38. """
  39. Create shadow color constant for use in TEXT and STRING files.
  40. :param rgb: 6-character hex string in form RRGGBB.
  41. """
  42. if len(rgb) and rgb[0] == "#":
  43. rgb = rgb[1:]
  44. return "\x1CY%s" % rgb