Skip to content

Instantly share code, notes, and snippets.

@bfu4
Last active June 1, 2021 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bfu4/8ac7058fbcc69d33acfd04133f35e136 to your computer and use it in GitHub Desktop.
Save bfu4/8ac7058fbcc69d33acfd04133f35e136 to your computer and use it in GitHub Desktop.
Colors
class Colors:
@staticmethod
def red() -> str:
"""
The color red
:return: red
"""
return Colors.__fmt(124)
@staticmethod
def orange() -> str:
"""
The color orange
:return: orange
"""
return Colors.__fmt(214)
@staticmethod
def yellow() -> str:
"""
The color yellow
:return: yellow
"""
return Colors.__fmt(226)
@staticmethod
def green() -> str:
"""
The color green
:return: green
"""
return Colors.__fmt(82)
@staticmethod
def blue() -> str:
"""
The color blue
:return: blue
"""
return Colors.__fmt(63)
@staticmethod
def aqua() -> str:
"""
The color aqua
:return: aqua
"""
return Colors.__fmt(81)
@staticmethod
def purple() -> str:
"""
The color purple
:return: purple
"""
return Colors.__fmt(129)
@staticmethod
def white() -> str:
"""
The color white
:return: white
"""
return Colors.__fmt(231)
@staticmethod
def gray() -> str:
"""
The color gray
:return: gray
"""
return Colors.__fmt(250)
@staticmethod
def light_pink() -> str:
"""
The color light pink
:return: light pink
"""
return Colors.custom_shift(39, 4)
@staticmethod
def black() -> str:
"""
The color black
:return: black
"""
return Colors.__fmt(0)
@staticmethod
def reset() -> str:
"""
Reset entirely
:return:
"""
return "\u001b[0m"
@staticmethod
def custom_shift(initial: int, index: int = 0) -> str:
"""
Shift a color
https://i.stack.imgur.com/KTSQa.png
:return: shifted color of index
"""
colors = []
for i in range(52, 232):
if (initial - i) % 36 == 0:
colors.append(i)
return Colors.__fmt(colors[index])
@staticmethod
def __fmt(color: int):
return f"\u001b[38;5;{color}m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment