colors.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. """
  2. The following constants are defined to change TEXT
  3. (:class:`alphasign.text.Text`) colors:
  4. * :const:`RED`
  5. * :const:`GREEN`
  6. * :const:`AMBER`
  7. * :const:`DIM_RED`
  8. * :const:`DIM_GREEN`
  9. * :const:`BROWN`
  10. * :const:`ORANGE`
  11. * :const:`YELLOW`
  12. * :const:`RAINBOW_1`
  13. * :const:`RAINBOW_2`
  14. * :const:`COLOR_MIX`
  15. * :const:`AUTOCOLOR`
  16. .. autofunction:: rgb
  17. .. autofunction:: shadow_rgb
  18. --------
  19. Examples
  20. --------
  21. Make a text file with red text::
  22. msg = alphasign.Text("%sthis text is red" % alphasign.colors.RED, label="A")
  23. Make a text file with purple text (#CC66FF)::
  24. msg = alphasign.Text("%sthis text should be in purple" %
  25. alphasign.colors.rgb("CC66FF"), label="A")
  26. Make a bi-color text file (red primary with a green shadow)::
  27. msg = alphasign.Text("%s%sred and green" %
  28. (alphasign.colors.rgb("FF0000"),
  29. alphasign.colors.rgb("00FF00")), label="A")
  30. """
  31. # Colors
  32. RED = "\x1C1"
  33. GREEN = "\x1C2"
  34. AMBER = "\x1C3"
  35. DIM_RED = "\x1C4"
  36. DIM_GREEN = "\x1C5"
  37. BROWN = "\x1C6"
  38. ORANGE = "\x1C7"
  39. YELLOW = "\x1C8"
  40. RAINBOW_1 = "\x1C9"
  41. RAINBOW_2 = "\x1CA"
  42. COLOR_MIX = "\x1CB"
  43. AUTOCOLOR = "\x1CC"
  44. def rgb(rgb):
  45. """
  46. Create color constant for use in TEXT and STRING files.
  47. :param rgb: 6-character hex string in form RRGGBB.
  48. """
  49. if len(rgb) and rgb[0] == "#":
  50. rgb = rgb[1:]
  51. return "\x1CZ%s" % rgb
  52. def shadow_rgb(rgb):
  53. """
  54. Create shadow color constant for use in TEXT and STRING files.
  55. :param rgb: 6-character hex string in form RRGGBB.
  56. """
  57. if len(rgb) and rgb[0] == "#":
  58. rgb = rgb[1:]
  59. return "\x1CY%s" % rgb